facebook / mariana-trench

A security focused static analysis tool for Android and Java applications.
https://mariana-tren.ch/
MIT License
1.06k stars 137 forks source link

Example code does not work #124

Open tosiara opened 1 year ago

tosiara commented 1 year ago

Bug

Bug description The example code provided in README does not work

Reproduction steps

  1. Run the example mariana-trench command line from README
  2. Command fails: CRITICAL Analysis binary exited with exit code 7.

Expected behavior According to README the command should succeed and find 9 issues

Logs

(mariana-trench) user@vm:~/git/mariana-trench/mariana-trench$ mariana-trench   --system-jar-configuration-path=$ANDROID_SDK/platforms/android-32/android.jar   --model-generator-configuration-paths=configuration/default_generator_config.json   --lifecycles-paths=configuration/lifecycles.json   --rules-paths=configuration/rules.json   --apk-path=documentation/sample-app/app/build/outputs/apk/debug/app-debug.apk   --source-root-directory=documentation/sample-app/app/src/main/java   --model-generator-search-paths=configuration/model-generators/
INFO Extracting `/home/user/git/mariana-trench/mariana-trench/documentation/sample-app/app/build/outputs/apk/debug/app-debug.apk`...
INFO Extracted APK into `/tmp/tmprsfzgljt_apk` and DEX into `/tmp/tmpg0nviq4u_dex`
INFO Running Mariana Trench: /home/user/.venvs/mariana-trench/bin/mariana-trench-binary --system-jar-paths /home/user/Android/Sdk/platforms/android-32/android.jar --apk-directory /tmp/tmprsfzgljt_apk --dex-directory /tmp/tmpg0nviq4u_dex --rules-paths configuration/rules.json --repository-root-directory /home/user/git/mariana-trench/mariana-trench/ --source-root-directory /home/user/git/mariana-trench/mariana-trench/documentation/sample-app/app/src/main/java/ --apk-path /home/user/git/mariana-trench/mariana-trench/documentation/sample-app/app/build/outputs/apk/debug/app-debug.apk --output-directory /home/user/git/mariana-trench/mariana-trench/ --maximum-source-sink-distance 7 --model-generator-configuration-paths /home/user/git/mariana-trench/mariana-trench/configuration/default_generator_config.json --model-generator-search-paths /home/user/git/mariana-trench/mariana-trench/configuration/model-generators --lifecycles-paths /home/user/git/mariana-trench/mariana-trench/configuration/lifecycles.json
Trace settings:
TRACEFILE=
SHOW_TIMESTAMPS=
SHOW_TRACEMODULE=
TRACE_METHOD_FILTER=
2023-03-24 11:47:11 INFO Initializing Redex...
2023-03-24 11:47:11 INFO Redex initialized in 0.31s.
2023-03-24 11:47:11 INFO Storing methods...
2023-03-24 11:47:11 INFO Stored all methods in 0.02s. Memory used, RSS: 0.13GB
2023-03-24 11:47:11 INFO Storing fields...
2023-03-24 11:47:11 INFO Stored all fields in 0.01s. Memory used, RSS: 0.14GB
2023-03-24 11:47:11 INFO Building source index...
abort: no repository found in '/home/user/git/mariana-trench/mariana-trench/documentation/sample-app/app/src/main/java' (.hg not found)
2023-03-24 11:47:11 WARNING Source directory is not a mercurial repository. Trying `find` to discover files.
2023-03-24 11:47:11 INFO Built source index in 0.10s. Memory used, RSS: 0.14GB
2023-03-24 11:47:11 INFO Building control flow graphs...
2023-03-24 11:47:11 INFO Built control flow graphs in 0.02s. Memory used, RSS: 0.16GB
2023-03-24 11:47:11 INFO Inferring types...
2023-03-24 11:47:11 INFO Reflection analysis 0.01s. Memory used, RSS: 0.17GB
2023-03-24 11:47:12 INFO Global analysis 1.02s. Memory used, RSS: 0.21GB
2023-03-24 11:47:12 INFO Inferred types in 1.03s. Memory used, RSS: 0.21GB
2023-03-24 11:47:12 INFO Building class hierarchies...
2023-03-24 11:47:12 INFO Built class hierarchies in 0.01s. Memory used, RSS: 0.21GB
2023-03-24 11:47:12 INFO Building fields cache...
2023-03-24 11:47:12 INFO Built fields cache in 0.02s. Memory used, RSS: 0.24GB
2023-03-24 11:47:12 INFO Creating life-cycle wrapper methods...
2023-03-24 11:47:12 INFO Created 7 life-cycle methods for classes inheriting from `Landroid/app/Activity;`
2023-03-24 11:47:12 INFO Created 5 life-cycle methods for classes inheriting from `Landroid/app/Fragment;`
2023-03-24 11:47:12 INFO Created 6 life-cycle methods for classes inheriting from `Landroidx/fragment/app/Fragment;`
2023-03-24 11:47:12 INFO Created 22 life-cycle methods for classes inheriting from `Landroid/app/Service;`
2023-03-24 11:47:12 INFO Created 1 life-cycle methods for classes inheriting from `Landroidx/fragment/app/FragmentActivity;`
2023-03-24 11:47:12 INFO Created lifecycle methods in 0.00s. Memory used, RSS: 0.24GB
2023-03-24 11:47:12 INFO Building override graph...
2023-03-24 11:47:12 INFO Built override graph in 0.05s. Memory used, RSS: 0.25GB
2023-03-24 11:47:12 INFO Building method mappings for shim/model generation over 71218 methods
2023-03-24 11:47:12 INFO Generated method mappings in 0.11s. Memory used, RSS: 0.29GB
2023-03-24 11:47:12 INFO Building call graph...
2023-03-24 11:47:12 INFO Processed 10000/71218 methods.
2023-03-24 11:47:13 INFO Processed 20000/71218 methods.
2023-03-24 11:47:13 INFO Processed 30000/71218 methods.
2023-03-24 11:47:13 INFO Processed 40000/71218 methods.
2023-03-24 11:47:13 INFO Processed 50000/71218 methods.
2023-03-24 11:47:13 INFO Processed 60000/71218 methods.
2023-03-24 11:47:13 INFO Processed 70000/71218 methods.
2023-03-24 11:47:13 INFO Built call graph in 0.24s. Memory used, RSS: 0.33GB
2023-03-24 11:47:13 INFO Generating models...
MarianaTrench invalid_argument_error: Model generator(s) ActivitySourceGenerator, AndroidBroadcastSourceGenerator, CastUriFeatureGenerator, ContextFeature, DataCastFeatureGenerator, FileSinkGenerator, ImplicitIntentSourceGenerator, IntentDataFeatureGenerator, SensitiveCookieDataGenerator, SQLiteDatabaseSinksGenerator either do not exist or couldn't be parsed.
CRITICAL Analysis binary exited with exit code 7.

Additional context Ubuntu 22.04

antnks commented 1 year ago

Example code still works in this commit: 423e2ca2ef36ac216686bef4ae1fa4d03cfe91ea

mlucchini commented 1 year ago

Introduced in commit 84f62c4. Essentially, the current code understands both signature and signature_pattern constraint types (example within ActivitySourceGenerator.json), however the released version of mariana_trench installed with npm doesn't know how to parse signature_pattern, which is present in the committed models.

This error should disappear with the next npm release, will look into whether it's worth reverting that change and re-apply it later.

fishso commented 1 year ago

Introduced in commit 84f62c4. Essentially, the current code understands both signature and signature_pattern constraint types (example within ActivitySourceGenerator.json), however the released version of mariana_trench installed with npm doesn't know how to parse signature_pattern, which is present in the committed models.

This error should disappear with the next npm release, will look into whether it's worth reverting that change and re-apply it later.

the master version parse signature_match failed also.