diff --git a/rasta_exp/grunt-worker.py b/rasta_exp/grunt-worker.py index 82e7b6a..4d3542d 100755 --- a/rasta_exp/grunt-worker.py +++ b/rasta_exp/grunt-worker.py @@ -203,9 +203,17 @@ if __name__ == "__main__": parser.add_argument( "--task", help="[debug] Name of the task to perform", type=str, action="store" ) - parser.add_argument( + app_group = parser.add_mutually_exclusive_group() + app_group.add_argument( "--sha", help="[debug] sha to make the --task on", type=str, action="store" ) + app_group.add_argument( + "--apk-path", + help="[debug] apk to make the --task on", + type=Path, + action="store", + ) + group = parser.add_mutually_exclusive_group(required=True) group.add_argument("--docker", action="store_true") group.add_argument("--singularity", action="store_true") @@ -224,7 +232,7 @@ if __name__ == "__main__": result_dir = args.result_dir if result_dir is None: result_dir = base_dir - + # base_dir = os.path.join(base_dir, str(uuid.uuid4())) if not os.path.isdir(base_dir): os.makedirs(base_dir) @@ -303,20 +311,26 @@ if __name__ == "__main__": raise Exception("Debug mode must be used with BOTH --task and --sha") task = args.task # sha = str(args.sha).upper() # TMP patch - sha = str(args.sha) - if len(sha) != 64: + # sha = str(args.sha) + if args.sha is not None and len(args.sha) != 64: # raise Exception("invalid --sha value") print("invalid --sha value, exception disabled for tests") - apk_blob = get_apk_from_androzoo( - sha256=sha, - apikey=androzoo_apikey, - base_url=androzoo_base_url, - reraise=False, - local_cache=androzoo_local_cache, - ) - if apk_blob is None: - print(f"Unable to obtain apk for sha={sha}") + if args.sha is not None: + apk_blob = get_apk_from_androzoo( + sha256=args.sha, + apikey=androzoo_apikey, + base_url=androzoo_base_url, + reraise=False, + local_cache=androzoo_local_cache, + ) + sha = args.sha + if apk_blob is None: + print(f"Unable to obtain apk for sha={sha}") else: + with args.apk_path.open("rb") as fp: + apk_blob = fp.read() + sha = args.apk_path.name.removesuffix(".apk") # no a sha, but good enough + if apk_blob is not None: # do_one_job(sha256: str, tool_name: str, base_dir: str, apk_blob, container_mode, container_image, keep_tmp_dir=False): res = do_one_job( sha256=sha,