Loading tools/lint/test/files/tor-browser-checks/bad/AndroidManifest.xml 0 → 100644 +53 −0 Changes for tools/lint/test/files/tor-browser-checks/bad/AndroidManifest.xml: 53 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <activity android:name=".IntentReceiverActivity" android:exported="false"> </activity> <!-- No intent-filter at all. Mirrors the original tor-browser#45145 regression (org.mozilla.gecko.BrowserApp). --> <activity-alias android:name="org.mozilla.gecko.BrowserApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> </activity-alias> <!-- Has its own "open this link" intent-filter, but that's VIEW, not MAIN+LAUNCHER, so it still doesn't need to be exported. --> <activity-alias android:name="org.mozilla.gecko.PermissiveApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> </intent-filter> </activity-alias> <!-- Has LAUNCHER without MAIN: still not a real launcher entry point, so this should be flagged too since both are required. --> <activity-alias android:name="org.mozilla.gecko.LauncherCategoryOnlyApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity-alias> <!-- Not an activity at all: the check covers every exportable component type, not just activities/aliases. --> <receiver android:name="com.example.evil.UnlistedReceiver" android:exported="true"> <intent-filter> <action android:name="com.example.evil.SOME_ACTION" /> </intent-filter> </receiver> </application> </manifest> tools/lint/test/files/tor-browser-checks/good/AndroidManifest.xml 0 → 100644 +37 −0 Changes for tools/lint/test/files/tor-browser-checks/good/AndroidManifest.xml: 37 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <activity android:name=".IntentReceiverActivity" android:exported="false"> </activity> <activity-alias android:name="org.mozilla.gecko.BrowserApp" android:targetActivity=".IntentReceiverActivity" android:exported="false"> </activity-alias> <!-- Exported, but has a MAIN+LAUNCHER intent-filter: the one case Android itself requires exported="true" for. --> <activity-alias android:name="${applicationId}.App" android:exported="true" android:targetActivity="HomeActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity-alias> <!-- Exported and not a MAIN+LAUNCHER entry point, but it doesn't matter since exported="false" is always fine to flag as good. --> <receiver android:name="onboarding.WidgetPinnedReceiver" android:exported="false"> <intent-filter> <action android:name="org.mozilla.fenix.onboarding.WidgetPinnedReceiver.widgetPinned" /> </intent-filter> </receiver> </application> </manifest> tools/lint/test/python.toml +4 −0 Changes for tools/lint/test/python.toml: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ skip-if = ["os == 'win'"] ["test_shellcheck.py"] ["test_stylelint.py"] ["test_tor_browser_checks.py"] tags = "base-browser" skip-if = ["os == 'win'"] # busts the tree for subsequent tasks on the same worker (bug 1708591) # Setup conflicts with eslint setup so this should run sequentially. sequential = true Loading tools/lint/test/test_tor_browser_checks.py 0 → 100644 +29 −0 Changes for tools/lint/test/test_tor_browser_checks.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line import mozunit LINTER = "tor-browser-checks" def test_flags_exported_non_launcher_components(lint, paths): results = lint(paths("bad/AndroidManifest.xml")) assert len(results) == 4 flagged_names = { "org.mozilla.gecko.BrowserApp", "org.mozilla.gecko.PermissiveApp", "org.mozilla.gecko.LauncherCategoryOnlyApp", "com.example.evil.UnlistedReceiver", } for expected_name in flagged_names: assert any(expected_name in r.message for r in results) for r in results: assert r.rule == "unnecessary-exported-component" def test_allows_launcher_entries_and_unexported_components(lint, paths): results = lint(paths("good/AndroidManifest.xml")) assert len(results) == 0 if __name__ == "__main__": mozunit.main() tools/lint/tor-browser-checks.yml 0 → 100644 +16 −0 Changes for tools/lint/tor-browser-checks.yml: 16 added lines, 0 removed lines. Original line number Diff line number Diff line --- tor-browser-checks: description: >- Tor Browser specific static checks (one linter, several independent checks -- see tools/lint/tor-browser-checks/__init__.py) include: - 'mobile/android/fenix/app/src/main/AndroidManifest.xml' - 'mobile/android/fenix/app/src/debug/AndroidManifest.xml' - 'mobile/android/fenix/app/src/beta/AndroidManifest.xml' - 'mobile/android/fenix/app/src/release/AndroidManifest.xml' - 'mobile/android/fenix/app/src/nightly/AndroidManifest.xml' - 'mobile/android/fenix/app/src/benchmark/AndroidManifest.xml' support-files: - 'tools/lint/tor-browser-checks/**' type: external payload: tor-browser-checks:lint Loading
tools/lint/test/files/tor-browser-checks/bad/AndroidManifest.xml 0 → 100644 +53 −0 Changes for tools/lint/test/files/tor-browser-checks/bad/AndroidManifest.xml: 53 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <activity android:name=".IntentReceiverActivity" android:exported="false"> </activity> <!-- No intent-filter at all. Mirrors the original tor-browser#45145 regression (org.mozilla.gecko.BrowserApp). --> <activity-alias android:name="org.mozilla.gecko.BrowserApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> </activity-alias> <!-- Has its own "open this link" intent-filter, but that's VIEW, not MAIN+LAUNCHER, so it still doesn't need to be exported. --> <activity-alias android:name="org.mozilla.gecko.PermissiveApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="http" /> <data android:scheme="https" /> </intent-filter> </activity-alias> <!-- Has LAUNCHER without MAIN: still not a real launcher entry point, so this should be flagged too since both are required. --> <activity-alias android:name="org.mozilla.gecko.LauncherCategoryOnlyApp" android:targetActivity=".IntentReceiverActivity" android:exported="true"> <intent-filter> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity-alias> <!-- Not an activity at all: the check covers every exportable component type, not just activities/aliases. --> <receiver android:name="com.example.evil.UnlistedReceiver" android:exported="true"> <intent-filter> <action android:name="com.example.evil.SOME_ACTION" /> </intent-filter> </receiver> </application> </manifest>
tools/lint/test/files/tor-browser-checks/good/AndroidManifest.xml 0 → 100644 +37 −0 Changes for tools/lint/test/files/tor-browser-checks/good/AndroidManifest.xml: 37 added lines, 0 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android"> <application> <activity android:name=".IntentReceiverActivity" android:exported="false"> </activity> <activity-alias android:name="org.mozilla.gecko.BrowserApp" android:targetActivity=".IntentReceiverActivity" android:exported="false"> </activity-alias> <!-- Exported, but has a MAIN+LAUNCHER intent-filter: the one case Android itself requires exported="true" for. --> <activity-alias android:name="${applicationId}.App" android:exported="true" android:targetActivity="HomeActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity-alias> <!-- Exported and not a MAIN+LAUNCHER entry point, but it doesn't matter since exported="false" is always fine to flag as good. --> <receiver android:name="onboarding.WidgetPinnedReceiver" android:exported="false"> <intent-filter> <action android:name="org.mozilla.fenix.onboarding.WidgetPinnedReceiver.widgetPinned" /> </intent-filter> </receiver> </application> </manifest>
tools/lint/test/python.toml +4 −0 Changes for tools/lint/test/python.toml: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -69,6 +69,10 @@ skip-if = ["os == 'win'"] ["test_shellcheck.py"] ["test_stylelint.py"] ["test_tor_browser_checks.py"] tags = "base-browser" skip-if = ["os == 'win'"] # busts the tree for subsequent tasks on the same worker (bug 1708591) # Setup conflicts with eslint setup so this should run sequentially. sequential = true Loading
tools/lint/test/test_tor_browser_checks.py 0 → 100644 +29 −0 Changes for tools/lint/test/test_tor_browser_checks.py: 29 added lines, 0 removed lines. Original line number Diff line number Diff line import mozunit LINTER = "tor-browser-checks" def test_flags_exported_non_launcher_components(lint, paths): results = lint(paths("bad/AndroidManifest.xml")) assert len(results) == 4 flagged_names = { "org.mozilla.gecko.BrowserApp", "org.mozilla.gecko.PermissiveApp", "org.mozilla.gecko.LauncherCategoryOnlyApp", "com.example.evil.UnlistedReceiver", } for expected_name in flagged_names: assert any(expected_name in r.message for r in results) for r in results: assert r.rule == "unnecessary-exported-component" def test_allows_launcher_entries_and_unexported_components(lint, paths): results = lint(paths("good/AndroidManifest.xml")) assert len(results) == 0 if __name__ == "__main__": mozunit.main()
tools/lint/tor-browser-checks.yml 0 → 100644 +16 −0 Changes for tools/lint/tor-browser-checks.yml: 16 added lines, 0 removed lines. Original line number Diff line number Diff line --- tor-browser-checks: description: >- Tor Browser specific static checks (one linter, several independent checks -- see tools/lint/tor-browser-checks/__init__.py) include: - 'mobile/android/fenix/app/src/main/AndroidManifest.xml' - 'mobile/android/fenix/app/src/debug/AndroidManifest.xml' - 'mobile/android/fenix/app/src/beta/AndroidManifest.xml' - 'mobile/android/fenix/app/src/release/AndroidManifest.xml' - 'mobile/android/fenix/app/src/nightly/AndroidManifest.xml' - 'mobile/android/fenix/app/src/benchmark/AndroidManifest.xml' support-files: - 'tools/lint/tor-browser-checks/**' type: external payload: tor-browser-checks:lint