From dddd430ce5b71062c20a9a30f6be49d7d13d4714 Mon Sep 17 00:00:00 2001 From: Umnik Date: Fri, 17 Feb 2023 19:01:50 +0300 Subject: [PATCH 1/4] no exit code as counter --- exodus_analyze.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/exodus_analyze.py b/exodus_analyze.py index bf7ccc2..c3f1be4 100755 --- a/exodus_analyze.py +++ b/exodus_analyze.py @@ -58,7 +58,7 @@ def get_ignore_list(ignore_arg): return ignored, '' -def analyze_apk(apk, json_mode, output_file, ignore_list): +def analyze_apk(apk, json_mode, output_file, no_counter, ignore_list): analysis = AnalysisHelper(apk) analysis.load_trackers_signatures() if json_mode: @@ -72,6 +72,8 @@ def analyze_apk(apk, json_mode, output_file, ignore_list): analysis.print_apk_infos() analysis.print_embedded_trackers() + if no_counter: + return trackers_not_ignored = [t for t in analysis.detect_trackers() if t.id not in ignore_list] sys.exit(len(trackers_not_ignored)) @@ -105,6 +107,13 @@ def main(): default=None, help='comma-separated ids of trackers to ignore' ) + parser.add_argument( + '--no-exit-counter', + dest='no_counter', + action='store_true', + default=False, + help='do not use exit code as trackers counter' + ) args = parser.parse_args() args_error = validate_arguments(args) @@ -117,7 +126,7 @@ def main(): if ignore_error: raise_error(parser, ignore_error) - analyze_apk(args.apk, args.json_mode, args.output_file, ignore_list) + analyze_apk(args.apk, args.json_mode, args.output_file, args.no_counter, ignore_list) if __name__ == '__main__': From 87f6a9aec989af935e8531c06aea39b6fed882e8 Mon Sep 17 00:00:00 2001 From: Umnik Date: Tue, 21 Feb 2023 15:49:27 +0300 Subject: [PATCH 2/4] exit code instead of --no-exit-counter --- exodus_analyze.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exodus_analyze.py b/exodus_analyze.py index c3f1be4..c8e8fc4 100755 --- a/exodus_analyze.py +++ b/exodus_analyze.py @@ -108,7 +108,7 @@ def main(): help='comma-separated ids of trackers to ignore' ) parser.add_argument( - '--no-exit-counter', + '-e', '--exit-code', dest='no_counter', action='store_true', default=False, From 6d6176fe6e4985f5da78bdc1157bc9bed964de3e Mon Sep 17 00:00:00 2001 From: umnik Date: Mon, 1 May 2023 15:02:55 +0300 Subject: [PATCH 3/4] fix forced exit code --- README.md | 4 +++- exodus_analyze.py | 20 +++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 8a37e5e..c872f9d 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ pip install -r requirements.txt ```bash $ ./exodus_analyze.py --help -usage: exodus_analyze.py [-h] [-t] [-j] [-o OUTPUT_FILE] [-i IGNORE] apk +usage: exodus_analyze.py [-h] [-t] [-j] [-o OUTPUT_FILE] [-i IGNORE] [-e CODE] apk positional arguments: apk the apk file to analyse @@ -75,6 +75,8 @@ optional arguments: store JSON report in file (requires -j option) -i IGNORE, --ignore IGNORE comma-separated ids of trackers to ignore + -e CODE, --exit-code CODE + use the CODE instead of trackers counter as exit code if trackers was detected ``` #### Text output diff --git a/exodus_analyze.py b/exodus_analyze.py index c8e8fc4..a78f868 100755 --- a/exodus_analyze.py +++ b/exodus_analyze.py @@ -58,7 +58,7 @@ def get_ignore_list(ignore_arg): return ignored, '' -def analyze_apk(apk, json_mode, output_file, no_counter, ignore_list): +def analyze_apk(apk, json_mode, output_file, forced_code, ignore_list): analysis = AnalysisHelper(apk) analysis.load_trackers_signatures() if json_mode: @@ -72,10 +72,11 @@ def analyze_apk(apk, json_mode, output_file, no_counter, ignore_list): analysis.print_apk_infos() analysis.print_embedded_trackers() - if no_counter: - return trackers_not_ignored = [t for t in analysis.detect_trackers() if t.id not in ignore_list] - sys.exit(len(trackers_not_ignored)) + counter = len(trackers_not_ignored) + if all([counter, forced_code is not None]): + sys.exit(forced_code) + sys.exit(counter) def main(): @@ -109,10 +110,10 @@ def main(): ) parser.add_argument( '-e', '--exit-code', - dest='no_counter', - action='store_true', - default=False, - help='do not use exit code as trackers counter' + metavar='CODE', + dest='override_code', + type=int, + help='use the CODE instead of trackers counter as exit code if trackers was detected' ) args = parser.parse_args() @@ -126,7 +127,8 @@ def main(): if ignore_error: raise_error(parser, ignore_error) - analyze_apk(args.apk, args.json_mode, args.output_file, args.no_counter, ignore_list) + + analyze_apk(args.apk, args.json_mode, args.output_file, args.override_code, ignore_list) if __name__ == '__main__': From e542df7ce18ba13d703d4b58fd1974df12d68dc8 Mon Sep 17 00:00:00 2001 From: umnik Date: Mon, 1 May 2023 15:22:29 +0300 Subject: [PATCH 4/4] extra line removed --- exodus_analyze.py | 1 - 1 file changed, 1 deletion(-) diff --git a/exodus_analyze.py b/exodus_analyze.py index a78f868..687dd3d 100755 --- a/exodus_analyze.py +++ b/exodus_analyze.py @@ -127,7 +127,6 @@ def main(): if ignore_error: raise_error(parser, ignore_error) - analyze_apk(args.apk, args.json_mode, args.output_file, args.override_code, ignore_list)