Skip to content

Commit b6a59f0

Browse files
committed
Java: Add support and tests for implicitly exported activity aliases
1 parent 1472335 commit b6a59f0

File tree

8 files changed

+60
-0
lines changed

8 files changed

+60
-0
lines changed

java/ql/lib/semmle/code/java/frameworks/android/Android.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class ExportableAndroidComponent extends AndroidComponent {
5757
or
5858
this.hasIntentFilter() and
5959
not this.getAndroidComponentXmlElement().isNotExported()
60+
or
61+
exists(AndroidActivityAliasXmlElement e |
62+
e = this.getAndroidComponentXmlElement() and
63+
not e.isNotExported() and
64+
e.hasAnIntentFilterElement()
65+
)
6066
}
6167
}
6268

java/ql/test/library-tests/frameworks/android/activity-alias/AndroidManifest.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,34 @@
5252
android:exported="true"
5353
android:label="@string/app_name"
5454
android:targetActivity="com.example.myapplication.AnotherActivity"></activity-alias>
55+
<activity
56+
android:name=".ExampleActivity"
57+
android:exported="false"
58+
android:label="@string/app_name"
59+
></activity>
5560

61+
<activity-alias
62+
android:name=".ExampleAlias"
63+
android:exported="true"
64+
android:label="@string/app_name"
65+
android:targetActivity=".ExampleActivity">
66+
</activity-alias>
67+
68+
<activity
69+
android:name=".Example2Activity"
70+
android:exported="false"
71+
android:label="@string/app_name">
72+
</activity>
73+
74+
<activity-alias
75+
android:name=".Example2Alias"
76+
android:label="@string/app_name"
77+
android:targetActivity=".Example2Activity">
78+
<intent-filter>
79+
<action android:name="android.intent.action.MAIN"></action>
80+
<action android:name="android.intent.category.LAUNCHER"></action>
81+
</intent-filter>
82+
</activity-alias>
5683
</application>
5784

5885
</manifest>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.myapplication;
2+
3+
import android.app.Activity;
4+
5+
public class Example2Activity extends Activity {
6+
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.myapplication;
2+
3+
import android.app.Activity;
4+
5+
public class ExampleActivity extends Activity {
6+
7+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
| .AnotherAlias | .AnotherActivity |
2+
| .Example2Alias | .Example2Activity |
3+
| .ExampleAlias | .ExampleActivity |
24
| .MainAlias | .MainActivity |
35
| .SecondAlias | .MainActivity |
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| Example2Activity.java:5:14:5:29 | Example2Activity | AndroidManifest.xml:68:9:72:20 | activity |
2+
| Example2Activity.java:5:14:5:29 | Example2Activity | AndroidManifest.xml:74:9:82:26 | activity-alias |
3+
| ExampleActivity.java:5:14:5:28 | ExampleActivity | AndroidManifest.xml:55:9:59:25 | activity |
4+
| ExampleActivity.java:5:14:5:28 | ExampleActivity | AndroidManifest.xml:61:9:66:26 | activity-alias |
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import java
2+
import semmle.code.java.frameworks.android.Android
3+
4+
from ExportableAndroidComponent component
5+
where component.isExported()
6+
select component, component.getAndroidComponentXmlElement()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0/

0 commit comments

Comments
 (0)