Skip to content

Commit d99b5bf

Browse files
committed
Reuse previous tests from experimental
1 parent c705031 commit d99b5bf

17 files changed

+387
-243
lines changed

java/ql/test/experimental/query-tests/security/CWE-749/AndroidManifest.xml

Lines changed: 0 additions & 51 deletions
This file was deleted.

java/ql/test/experimental/query-tests/security/CWE-749/UnsafeAndroidAccess.expected

Lines changed: 0 additions & 31 deletions
This file was deleted.

java/ql/test/experimental/query-tests/security/CWE-749/UnsafeAndroidAccess.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.

java/ql/test/experimental/query-tests/security/CWE-749/options

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app" android:versionCode="1" android:versionName="1.0">
3-
<application>
4-
<activity android:name=".UnsafeAndroidAccess">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.example.app"
3+
android:installLocation="auto"
4+
android:versionCode="1"
5+
android:versionName="0.1" >
6+
7+
<uses-permission android:name="android.permission.INTERNET" />
8+
9+
<application
10+
android:icon="@drawable/ic_launcher"
11+
android:label="@string/app_name"
12+
android:theme="@style/AppTheme" >
13+
<activity
14+
android:name=".UnsafeAndroidAccess"
15+
android:icon="@drawable/ic_launcher"
16+
android:label="@string/app_name">
517
<intent-filter>
618
<action android:name="android.intent.action.MAIN" />
719
<category android:name="android.intent.category.LAUNCHER" />
820
</intent-filter>
921
</activity>
22+
23+
<activity android:name=".UnsafeActivity1" android:exported="true">
24+
<intent-filter>
25+
<action android:name="android.intent.action.VIEW"/>
26+
</intent-filter>
27+
</activity>
28+
29+
<activity android:name=".UnsafeActivity2">
30+
<intent-filter>
31+
<action android:name="android.intent.action.VIEW"/>
32+
</intent-filter>
33+
</activity>
34+
35+
<activity android:name=".SafeActivity1" android:exported="false">
36+
<intent-filter>
37+
<action android:name="android.intent.action.VIEW"/>
38+
</intent-filter>
39+
</activity>
40+
41+
<activity android:name=".SafeActivity2" android:exported="false" />
42+
43+
<activity android:name=".SafeActivity3" />
44+
45+
<activity android:name=".UnsafeActivity3" android:exported="true" />
46+
<activity android:name=".UnsafeActivity4" android:exported="true" />
47+
48+
<receiver android:name=".UnsafeAndroidBroadcastReceiver" android:exported="true" />
1049
</application>
11-
</manifest>
50+
51+
</manifest>

java/ql/test/experimental/query-tests/security/CWE-749/SafeActivity1.java renamed to java/ql/test/query-tests/security/CWE-749/SafeActivity1.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import android.webkit.WebViewClient;
1010

1111
public class SafeActivity1 extends Activity {
12-
//Test onCreate with both JavaScript and cross-origin resource access enabled while taking remote user inputs from bundle extras
12+
// Test onCreate with both JavaScript and cross-origin resource access enabled while taking
13+
// remote user inputs from bundle extras.
14+
// The Activity is explicitly not exported, even though it has an intent-filter.
1315
public void onCreate(Bundle savedInstanceState) {
1416
super.onCreate(savedInstanceState);
1517
setContentView(-1);
@@ -29,6 +31,6 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
2931
});
3032

3133
String thisUrl = getIntent().getExtras().getString("url");
32-
wv.loadUrl(thisUrl);
34+
wv.loadUrl(thisUrl); // Safe
3335
}
34-
}
36+
}

java/ql/test/experimental/query-tests/security/CWE-749/SafeActivity2.java renamed to java/ql/test/query-tests/security/CWE-749/SafeActivity2.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import android.webkit.WebViewClient;
1010

1111
public class SafeActivity2 extends Activity {
12-
//Test onCreate with both JavaScript and cross-origin resource access enabled while taking remote user inputs from bundle extras
12+
// Test onCreate with both JavaScript and cross-origin resource access enabled while taking
13+
// remote user inputs from bundle extras.
14+
// The Activity is explicitly not exported.
1315
public void onCreate(Bundle savedInstanceState) {
1416
super.onCreate(savedInstanceState);
1517
setContentView(-1);
@@ -29,6 +31,6 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
2931
});
3032

3133
String thisUrl = getIntent().getExtras().getString("url");
32-
wv.loadUrl(thisUrl);
34+
wv.loadUrl(thisUrl); // Safe
3335
}
34-
}
36+
}

java/ql/test/experimental/query-tests/security/CWE-749/SafeActivity3.java renamed to java/ql/test/query-tests/security/CWE-749/SafeActivity3.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import android.webkit.WebViewClient;
1010

1111
public class SafeActivity3 extends Activity {
12-
//Test onCreate with both JavaScript and cross-origin resource access enabled while taking remote user inputs from bundle extras
12+
// Test onCreate with both JavaScript and cross-origin resource access enabled while taking
13+
// remote user inputs from bundle extras.
14+
// The Activity is implicitly not exported.
1315
public void onCreate(Bundle savedInstanceState) {
1416
super.onCreate(savedInstanceState);
1517
setContentView(-1);
@@ -29,6 +31,6 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
2931
});
3032

3133
String thisUrl = getIntent().getExtras().getString("url");
32-
wv.loadUrl(thisUrl);
34+
wv.loadUrl(thisUrl); // Safe
3335
}
34-
}
36+
}

java/ql/test/experimental/query-tests/security/CWE-749/UnsafeActivity1.java renamed to java/ql/test/query-tests/security/CWE-749/UnsafeActivity1.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import android.webkit.WebViewClient;
1010

1111
public class UnsafeActivity1 extends Activity {
12-
//Test onCreate with both JavaScript and cross-origin resource access enabled while taking remote user inputs from bundle extras
12+
// Test onCreate with both JavaScript and cross-origin resource access enabled while taking
13+
// remote user inputs from bundle extras.
14+
// The Activity is exported and has an intent-filter.
1315
public void onCreate(Bundle savedInstanceState) {
1416
super.onCreate(savedInstanceState);
1517
setContentView(-1);
@@ -29,6 +31,6 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
2931
});
3032

3133
String thisUrl = getIntent().getExtras().getString("url");
32-
wv.loadUrl(thisUrl);
34+
wv.loadUrl(thisUrl); // $hasUnsafeAndroidAccess
3335
}
34-
}
36+
}

0 commit comments

Comments
 (0)