Skip to content

Commit

Permalink
Merge pull request #1956 from blacklanternsecurity/fix-jadx
Browse files Browse the repository at this point in the history
Fix Tests, Java Deps
  • Loading branch information
TheTechromancer authored Nov 13, 2024
2 parents 154c354 + 9d8d7a1 commit 09f7ec3
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/distro_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ jobs:
export BBOT_DISTRO_TESTS=true
poetry env use python3.11
poetry install
poetry run pytest --reruns 2 -o timeout_func_only=true --timeout 1200 --disable-warnings --log-cli-level=INFO -k gowitness .
poetry run pytest --reruns 2 -o timeout_func_only=true --timeout 1200 --disable-warnings --log-cli-level=INFO .
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
poetry install
- name: Run tests
run: |
poetry run pytest --exitfirst --reruns 2 -o timeout_func_only=true --timeout 1200 --disable-warnings --log-cli-level=INFO --cov-config=bbot/test/coverage.cfg --cov-report xml:cov.xml --cov=bbot -k gowitness .
poetry run pytest --exitfirst --reruns 2 -o timeout_func_only=true --timeout 1200 --disable-warnings --log-cli-level=INFO --cov-config=bbot/test/coverage.cfg --cov-report xml:cov.xml --cov=bbot .
- name: Upload Debug Logs
uses: actions/upload-artifact@v3
with:
Expand Down
1 change: 1 addition & 0 deletions bbot/core/helpers/depsinstaller/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ def install_core_deps(self):
"make": "make",
"gcc": "gcc",
"bash": "bash",
"which": "which",
}
for command, package_name in core_deps.items():
if not self.parent_helper.which(command):
Expand Down
33 changes: 33 additions & 0 deletions bbot/core/shared_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,39 @@
},
]

DEP_JAVA = [
{
"name": "Check if Java is installed",
"command": "which java",
"register": "java_installed",
"ignore_errors": True,
},
{
"name": "Install latest JRE (Debian)",
"package": {"name": ["default-jre"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Debian' and java_installed.rc != 0",
},
{
"name": "Install latest JRE (Arch)",
"package": {"name": ["jre-openjdk"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Archlinux' and java_installed.rc != 0",
},
{
"name": "Install latest JRE (Fedora)",
"package": {"name": ["which", "java-latest-openjdk-headless"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'RedHat' and java_installed.rc != 0",
},
{
"name": "Install latest JRE (Alpine)",
"package": {"name": ["openjdk11"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Alpine' and java_installed.rc != 0",
},
]

# shared module dependencies -- ffuf, massdns, chromium, etc.
SHARED_DEPS = {}
for var, val in list(locals().items()):
Expand Down
32 changes: 4 additions & 28 deletions bbot/modules/jadx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,8 @@ class jadx(BaseModule):
options_desc = {
"threads": "Maximum jadx threads for extracting apk's, default: 4",
}
deps_common = ["java"]
deps_ansible = [
{
"name": "Install latest JRE (Debian)",
"package": {"name": ["default-jre"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Debian'",
},
{
"name": "Install latest JRE (Arch)",
"package": {"name": ["jre-openjdk"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Archlinux'",
},
{
"name": "Install latest JRE (Fedora)",
"package": {"name": ["which", "java-latest-openjdk-headless"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'RedHat'",
},
{
"name": "Install latest JRE (Alpine)",
"package": {"name": ["openjdk11"], "state": "present"},
"become": True,
"when": "ansible_facts['os_family'] == 'Alpine'",
},
{
"name": "Create jadx directory",
"file": {"path": "#{BBOT_TOOLS}/jadx", "state": "directory", "mode": "0755"},
Expand Down Expand Up @@ -102,10 +79,9 @@ async def decompile_apk(self, path, output_dir):
try:
output = await self.run_process(command, check=True)
except CalledProcessError as e:
self.warning(f"Error decompiling {path}. STDERR: {repr(e.stderr)}")
self.warning(f"Error decompiling {path}. STDOUT: {e.stdout} STDERR: {repr(e.stderr)}")
return False
if not Path(output_dir / "resources").exists() and not Path(output_dir / "sources").exists():
self.warning(f"JADX was unable to decompile {path}.")
self.warning(output)
if not (output_dir / "resources").exists() and not (output_dir / "sources").exists():
self.warning(f"JADX was unable to decompile {path}: (STDOUT: {output.stdout} STDERR: {output.stderr})")
return False
return True

0 comments on commit 09f7ec3

Please sign in to comment.