Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ func testing() {
nonvariadicDeclaredFunction([]int{})
}

func variadicDeclaredFunction(x ...int) int { // $ isVariadic
func variadicDeclaredFunction(x ...int) int {
a := make([]int, 0, 10)
y := append(x, a...)
print(x[0], x[1])
println(x[0], x[1])
fmt.Fprint(nil, nil, nil)
variadicFunctionLiteral := func(z ...int) int { return z[1] } // $ isVariadic
return variadicFunctionLiteral(y...)
}
} // $ isVariadic

func nonvariadicDeclaredFunction(x []int) int {
return 0
Expand Down
4 changes: 2 additions & 2 deletions go/ql/test/library-tests/semmle/go/concepts/HTTP/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func main() {

http.HandleFunc("/foo", handler) // $ handler="/foo"

http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) { // $ handler="/bar"
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
}) // $ handler="/bar"
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void test() throws Exception {

// Test all fluent methods are passing taint through to their result:
StrBuilder fluentAllMethodsTest = new StrBuilder(taint());
sink(fluentAllMethodsTest // $hasTaintFlow
sink(fluentAllMethodsTest
.append("text")
.appendAll("text")
.appendFixedWidthPadLeft("text", 4, ' ')
Expand All @@ -171,7 +171,7 @@ void test() throws Exception {
.setLength(500)
.setNewLineText("newline")
.setNullText("NULL")
.trim());
.trim()); // $hasTaintFlow

// Test all fluent methods are passing taint back to their qualifier:
StrBuilder fluentAllMethodsTest2 = new StrBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void test() throws Exception {

// Test all fluent methods are passing taint through to their result:
StrBuilder fluentAllMethodsTest = new StrBuilder(taint());
sink(fluentAllMethodsTest // $hasTaintFlow
sink(fluentAllMethodsTest
.append("text")
.appendAll("text")
.appendFixedWidthPadLeft("text", 4, ' ')
Expand All @@ -171,7 +171,7 @@ void test() throws Exception {
.setLength(500)
.setNewLineText("newline")
.setNullText("NULL")
.trim());
.trim()); // $hasTaintFlow

// Test all fluent methods are passing taint back to their qualifier:
StrBuilder fluentAllMethodsTest2 = new StrBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void test() throws Exception {

// Test all fluent methods are passing taint through to their result:
TextStringBuilder fluentAllMethodsTest = new TextStringBuilder(taint());
sink(fluentAllMethodsTest // $hasTaintFlow
sink(fluentAllMethodsTest
.append("text")
.appendAll("text")
.appendFixedWidthPadLeft("text", 4, ' ')
Expand All @@ -172,7 +172,7 @@ void test() throws Exception {
.setLength(500)
.setNewLineText("newline")
.setNullText("NULL")
.trim());
.trim()); // $hasTaintFlow

// Test all fluent methods are passing taint back to their qualifier:
TextStringBuilder fluentAllMethodsTest2 = new TextStringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public void encodeBegin(FacesContext facesContext, UIComponent component) throws
ResponseWriter writer = facesContext.getResponseWriter();
writer.write("<script type=\"text/javascript\">");
writer.write("(function(){");
writer.write("dswh.init('" + windowId + "','" // $xss
writer.write("dswh.init('" + windowId + "','"
+ "......" + "',"
+ -1 + ",{");
+ -1 + ",{"); // $xss
writer.write("});");
writer.write("})();");
writer.write("</script>");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.happybirthday">

<!-- $ hasDebuggableAttributeEnabled --> <application
<application
android:debuggable="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -13,7 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31">
tools:targetApi="31"> <!-- $ hasDebuggableAttributeEnabled -->
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.happybirthday">

<!-- Safe: manifest file located in build directory --> <application
<application
android:debuggable="true"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
Expand All @@ -13,7 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31">
tools:targetApi="31"> <!-- Safe: manifest file located in build directory -->
<activity
android:name=".MainActivity"
android:exported="true">
Expand Down
12 changes: 6 additions & 6 deletions java/ql/test/query-tests/security/CWE-524/res/layout/Test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto">


<!-- $hasResult --> <EditText
<EditText
android:id="@+id/test1_password"
android:inputType="text"/>
android:inputType="text"/> <!-- $hasResult -->

<EditText
android:id="@+id/test2_safe"
Expand All @@ -20,12 +20,12 @@
android:id="@+id/test4_password"
android:inputType="textPassword"/>

<!-- $hasResult --> <EditText
<EditText
android:id="@+id/test5_bank_account_name"
android:inputType="textMultiLine"/>
android:inputType="textMultiLine"/> <!-- $hasResult -->

<!-- $hasResult --> <EditText
android:id="@+id/test6_password"/>
<EditText
android:id="@+id/test6_password"/> <!-- $hasResult -->

<EditText
android:id="@+id/test7_password"/>
Expand Down
48 changes: 24 additions & 24 deletions java/ql/test/query-tests/security/CWE-926/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,100 +14,100 @@
android:theme="@style/Theme.HappyBirthday"
tools:targetApi="31">

<!-- $ hasImplicitExport --> <activity
<activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</activity> <!-- $ hasImplicitExport -->

<!-- $ hasImplicitExport --> <receiver
<receiver
android:name=".CheckInstall">
<intent-filter>
<action android:name="android.intent.action.PACKAGE_INSTALL"/>

</intent-filter>
</receiver>
</receiver> <!-- $ hasImplicitExport -->

<!-- $ hasImplicitExport --> <service
<service
android:name=".backgroundService">
<intent-filter>
<action android:name="android.intent.action.START_BACKGROUND"/>

</intent-filter>
</service>
</service> <!-- $ hasImplicitExport -->

<!-- $ hasImplicitExport --> <provider
<provider
android:name=".MyCloudProvider">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>

</intent-filter>
</provider>
</provider> <!-- $ hasImplicitExport -->

<!-- Safe: 'android:exported' explicitly set --> <activity
<activity
android:name=".Activity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</activity> <!-- Safe: 'android:exported' explicitly set -->

<!-- Safe: no intent filter --> <activity
<activity
android:name=".Activity">
</activity>
</activity> <!-- Safe: no intent filter -->

<!-- Safe: has 'permission' attribute --> <activity
<activity
android:name=".Activity"
android:permission=".Test">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
</activity> <!-- Safe: has 'permission' attribute -->

<!-- Safe: 'provider' with read and write permissions set --> <provider
<provider
android:name=".MyCloudProvider"
android:readPermission=".TestRead"
android:writePermission=".TestWrite">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>

</intent-filter>
</provider>
</provider> <!-- Safe: 'provider' with read and write permissions set -->

<!-- $ hasImplicitExport --> <provider
<provider
android:name=".MyCloudProvider"
android:readPermission=".TestRead">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>

</intent-filter>
</provider>
</provider> <!-- $ hasImplicitExport -->

<!-- $ hasImplicitExport --> <provider
<provider
android:name=".MyCloudProvider"
android:writePermission=".TestWrite">
<intent-filter>
<action android:name="android.intent.action.DOCUMENTS_PROVIDER"/>

</intent-filter>
</provider>
</provider> <!-- $ hasImplicitExport -->

<!-- Safe: has category 'android.intent.category.LAUNCHER' --> <activity
<activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</activity> <!-- Safe: has category 'android.intent.category.LAUNCHER' -->

<!-- Safe: has action 'android.intent.category.MAIN' --> <activity
<activity
android:name=".Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</activity> <!-- Safe: has action 'android.intent.category.MAIN' -->

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@

<!-- Read Only -->

<!-- $ hasIncompletePermissions --><provider
<provider
android:name=".MyContentProviderRO"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:readPermission="android.permission.MANAGE_DOCUMENTS"></provider>
android:readPermission="android.permission.MANAGE_DOCUMENTS"></provider><!-- $ hasIncompletePermissions -->


<!-- Write Only -->

<!-- $ hasIncompletePermissions --> <provider
<provider
android:name=".MyContentProviderWO"
android:authorities="table"
android:enabled="true"
android:exported="true"
android:writePermission="android.permission.MANAGE_DOCUMENTS"></provider>
android:writePermission="android.permission.MANAGE_DOCUMENTS"></provider><!-- $ hasIncompletePermissions -->

<!-- Full -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
'django.contrib.staticfiles',
]

MIDDLEWARE = [ # $CsrfProtectionSetting=false
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
# 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
] # $CsrfProtectionSetting=false

ROOT_URLCONF = 'testproj.urls'

Expand Down
4 changes: 2 additions & 2 deletions python/ql/test/library-tests/frameworks/flask/old_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def get(self, user_id): # $ requestHandler

the_view = MyView.as_view('my_view')

app.add_url_rule('/the/', defaults={'user_id': None}, # $routeSetup="/the/"
view_func=the_view, methods=['GET',])
app.add_url_rule('/the/', defaults={'user_id': None},
view_func=the_view, methods=['GET',]) # $routeSetup="/the/"

@app.route("/dangerous") # $routeSetup="/dangerous"
def dangerous(): # $requestHandler
Expand Down
28 changes: 14 additions & 14 deletions ruby/ql/test/library-tests/dataflow/api-graphs/callbacks.rb
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
Something.foo.withCallback do |a, b| #$ use=getMember("Something").getMethod("foo").getReturn().getMethod("withCallback").getReturn()
Something.foo.withCallback do |a, b| #$ use=getMember("Something").getMethod("foo").getReturn()
a.something #$ use=getMember("Something").getMethod("foo").getReturn().getMethod("withCallback").getBlock().getParameter(0).getMethod("something").getReturn()
b.somethingElse #$ use=getMember("Something").getMethod("foo").getReturn().getMethod("withCallback").getBlock().getParameter(1).getMethod("somethingElse").getReturn()
end
end #$ use=getMember("Something").getMethod("foo").getReturn().getMethod("withCallback").getReturn()

Something.withNamedArg do |a:, b: nil| #$ use=getMember("Something").getMethod("withNamedArg").getReturn()
Something.withNamedArg do |a:, b: nil| #$ use=getMember("Something")
a.something #$ use=getMember("Something").getMethod("withNamedArg").getBlock().getKeywordParameter("a").getMethod("something").getReturn()
b.somethingElse #$ use=getMember("Something").getMethod("withNamedArg").getBlock().getKeywordParameter("b").getMethod("somethingElse").getReturn()
end
end #$ use=getMember("Something").getMethod("withNamedArg").getReturn()

Something.withLambda ->(a, b) { #$ use=getMember("Something").getMethod("withLambda").getReturn()
Something.withLambda ->(a, b) { #$ use=getMember("Something")
a.something #$ use=getMember("Something").getMethod("withLambda").getParameter(0).getParameter(0).getMethod("something").getReturn()
b.something #$ use=getMember("Something").getMethod("withLambda").getParameter(0).getParameter(1).getMethod("something").getReturn()
}
} #$ use=getMember("Something").getMethod("withLambda").getReturn()

Something.namedCallback( #$ use=getMember("Something").getMethod("namedCallback").getReturn()
Something.namedCallback( #$ use=getMember("Something")
onEvent: ->(a, b) {
a.something #$ use=getMember("Something").getMethod("namedCallback").getKeywordParameter("onEvent").getParameter(0).getMethod("something").getReturn()
b.something #$ use=getMember("Something").getMethod("namedCallback").getKeywordParameter("onEvent").getParameter(1).getMethod("something").getReturn()
}
)
) #$ use=getMember("Something").getMethod("namedCallback").getReturn()

Something.nestedCall1 do |a| #$ use=getMember("Something").getMethod("nestedCall1").getReturn()
a.nestedCall2 do |b:| #$ use=getMember("Something").getMethod("nestedCall1").getBlock().getParameter(0).getMethod("nestedCall2").getReturn()
Something.nestedCall1 do |a| #$ use=getMember("Something")
a.nestedCall2 do |b:| #$ use=getMember("Something").getMethod("nestedCall1").getBlock().getParameter(0)
b.something #$ use=getMember("Something").getMethod("nestedCall1").getBlock().getParameter(0).getMethod("nestedCall2").getBlock().getKeywordParameter("b").getMethod("something").getReturn()
end
end
end #$ use=getMember("Something").getMethod("nestedCall1").getBlock().getParameter(0).getMethod("nestedCall2").getReturn()
end #$ use=getMember("Something").getMethod("nestedCall1").getReturn()

def getCallback()
->(x) {
Expand All @@ -33,7 +33,7 @@ def getCallback()
end
Something.indirectCallback(getCallback()) #$ use=getMember("Something").getMethod("indirectCallback").getReturn()

Something.withMixed do |a, *args, b| #$ use=getMember("Something").getMethod("withMixed").getReturn()
Something.withMixed do |a, *args, b| #$ use=getMember("Something")
a.something #$ use=getMember("Something").getMethod("withMixed").getBlock().getParameter(0).getMethod("something").getReturn()
# b.something # not currently handled correctly
end
end #$ use=getMember("Something").getMethod("withMixed").getReturn()
Loading