Java: Add support and tests for implicitly exported activity aliases

This commit is contained in:
Ed Minnix
2022-11-17 13:09:38 -05:00
parent 1472335c2e
commit b6a59f0885
8 changed files with 60 additions and 0 deletions

View File

@@ -57,6 +57,12 @@ class ExportableAndroidComponent extends AndroidComponent {
or
this.hasIntentFilter() and
not this.getAndroidComponentXmlElement().isNotExported()
or
exists(AndroidActivityAliasXmlElement e |
e = this.getAndroidComponentXmlElement() and
not e.isNotExported() and
e.hasAnIntentFilterElement()
)
}
}

View File

@@ -52,7 +52,34 @@
android:exported="true"
android:label="@string/app_name"
android:targetActivity="com.example.myapplication.AnotherActivity"></activity-alias>
<activity
android:name=".ExampleActivity"
android:exported="false"
android:label="@string/app_name"
></activity>
<activity-alias
android:name=".ExampleAlias"
android:exported="true"
android:label="@string/app_name"
android:targetActivity=".ExampleActivity">
</activity-alias>
<activity
android:name=".Example2Activity"
android:exported="false"
android:label="@string/app_name">
</activity>
<activity-alias
android:name=".Example2Alias"
android:label="@string/app_name"
android:targetActivity=".Example2Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN"></action>
<action android:name="android.intent.category.LAUNCHER"></action>
</intent-filter>
</activity-alias>
</application>
</manifest>

View File

@@ -0,0 +1,7 @@
package com.example.myapplication;
import android.app.Activity;
public class Example2Activity extends Activity {
}

View File

@@ -0,0 +1,7 @@
package com.example.myapplication;
import android.app.Activity;
public class ExampleActivity extends Activity {
}

View File

@@ -1,3 +1,5 @@
| .AnotherAlias | .AnotherActivity |
| .Example2Alias | .Example2Activity |
| .ExampleAlias | .ExampleActivity |
| .MainAlias | .MainActivity |
| .SecondAlias | .MainActivity |

View File

@@ -0,0 +1,4 @@
| Example2Activity.java:5:14:5:29 | Example2Activity | AndroidManifest.xml:68:9:72:20 | activity |
| Example2Activity.java:5:14:5:29 | Example2Activity | AndroidManifest.xml:74:9:82:26 | activity-alias |
| ExampleActivity.java:5:14:5:28 | ExampleActivity | AndroidManifest.xml:55:9:59:25 | activity |
| ExampleActivity.java:5:14:5:28 | ExampleActivity | AndroidManifest.xml:61:9:66:26 | activity-alias |

View File

@@ -0,0 +1,6 @@
import java
import semmle.code.java.frameworks.android.Android
from ExportableAndroidComponent component
where component.isExported()
select component, component.getAndroidComponentXmlElement()

View File

@@ -0,0 +1 @@
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../../stubs/google-android-9.0.0/