From 84d67b98eb88ebf4fa2e3559d94ac07b005425e1 Mon Sep 17 00:00:00 2001 From: Jono Yang Date: Mon, 9 Sep 2024 15:38:16 -0700 Subject: [PATCH] Map checksums and paths in android d2d pipeline #1366 Signed-off-by: Jono Yang --- scanpipe/pipelines/android_d2d.py | 9 ++------- scanpipe/pipes/d2d.py | 11 +++++------ setup.cfg | 1 + 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/scanpipe/pipelines/android_d2d.py b/scanpipe/pipelines/android_d2d.py index 9de85b96b..64a2d9995 100644 --- a/scanpipe/pipelines/android_d2d.py +++ b/scanpipe/pipelines/android_d2d.py @@ -58,13 +58,8 @@ def steps(cls): cls.collect_and_create_codebase_resources, cls.map_checksum, cls.find_java_packages, - cls.map_java_to_class, - cls.map_jar_to_source, - cls.flag_mapped_resources_archives_and_ignored_directories, - cls.remove_packages_without_resources, - cls.flag_deployed_from_resources_with_missing_license, - cls.create_local_files_packages, + cls.map_path, ) def convert_dex_to_java(self): - d2d.convert_dex_to_java(self.project) + d2d.convert_dex_to_java(self.project, to_only=True) diff --git a/scanpipe/pipes/d2d.py b/scanpipe/pipes/d2d.py index 356b1b2c2..ac064eb0c 100644 --- a/scanpipe/pipes/d2d.py +++ b/scanpipe/pipes/d2d.py @@ -1894,13 +1894,15 @@ def map_go_paths(project, logger=None): ) -def convert_dex_to_java(project): +def convert_dex_to_java(project, to_only=False): location = project.codebase_path abs_location = abspath(expanduser(location)) for top, _, files in fileutils.walk(abs_location): for f in files: if not f.endswith('.dex'): continue + if to_only and FROM in top: + continue loc = join(top, f) run_jadx(location=loc) @@ -1911,15 +1913,12 @@ def run_jadx(location): This will decompile the classes.dex file into Java source files. """ - rc, result, err = command.execute( + command.execute( cmd_loc="jadx", args=[ "-d", - f"{file_name(location)}-java", + f"{location}-out", location, ], to_files=False, ) - - if rc != 0: - raise Exception(err) diff --git a/setup.cfg b/setup.cfg index 63bc86982..ba536e1b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -130,6 +130,7 @@ scancodeio_pipelines = analyze_docker_image = scanpipe.pipelines.docker:Docker analyze_root_filesystem_or_vm_image = scanpipe.pipelines.root_filesystem:RootFS analyze_windows_docker_image = scanpipe.pipelines.docker_windows:DockerWindows + android_d2d = scanpipe.pipelines.android_d2d:AndroidAPKDeployToDevelop collect_strings_gettext = scanpipe.pipelines.collect_strings_gettext:CollectStringsGettext collect_symbols_ctags = scanpipe.pipelines.collect_symbols_ctags:CollectSymbolsCtags collect_symbols_pygments = scanpipe.pipelines.collect_symbols_pygments:CollectSymbolsPygments