Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Support for jimple
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed May 9, 2023
1 parent ca62dd7 commit 7b2331c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL maintainer="appthreat" \
org.opencontainers.image.authors="Team AppThreat <[email protected]>" \
org.opencontainers.image.source="https://github.com/appthreat/cpggen" \
org.opencontainers.image.url="https://github.com/appthreat/cpggen" \
org.opencontainers.image.version="1.0.9" \
org.opencontainers.image.version="1.0.10" \
org.opencontainers.image.vendor="AppThreat" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cpggen" \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-alma8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL maintainer="appthreat" \
org.opencontainers.image.authors="Team AppThreat <[email protected]>" \
org.opencontainers.image.source="https://github.com/appthreat/cpggen" \
org.opencontainers.image.url="https://github.com/appthreat/cpggen" \
org.opencontainers.image.version="1.0.9" \
org.opencontainers.image.version="1.0.10" \
org.opencontainers.image.vendor="AppThreat" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cpggen" \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile-oss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL maintainer="appthreat" \
org.opencontainers.image.authors="Team AppThreat <[email protected]>" \
org.opencontainers.image.source="https://github.com/appthreat/cpggen" \
org.opencontainers.image.url="https://github.com/appthreat/cpggen" \
org.opencontainers.image.version="1.0.9" \
org.opencontainers.image.version="1.0.10" \
org.opencontainers.image.vendor="AppThreat" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cpggen" \
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ Download the executable binary for your operating system from the [releases page
- cdxgen with Node.js 18 - Generates SBoM

```bash
curl -LO https://github.com/AppThreat/cpggen/releases/download/v1.0.9/cpggen-linux-amd64
curl -LO https://github.com/AppThreat/cpggen/releases/download/v1.0.10/cpggen-linux-amd64
chmod +x cpggen-linux-amd64
./cpggen-linux-amd64 --help
```

On Windows,

```powershell
curl -LO https://github.com/appthreat/cpggen/releases/download/v1.0.9/cpggen.exe
curl -LO https://github.com/appthreat/cpggen/releases/download/v1.0.10/cpggen.exe
.\cpggen.exe --help
```

Expand Down
2 changes: 2 additions & 0 deletions cpggen/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def get(configName, default_value=None):
"java": "%(joern_home)sjavasrc2cpg%(only_bat_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s",
"java-with-deps": "%(joern_home)sjavasrc2cpg%(only_bat_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s --fetch-dependencies --inference-jar-paths %(home_dir)s/.m2",
"java-with-gradle-deps": "%(joern_home)sjavasrc2cpg%(only_bat_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s --fetch-dependencies --inference-jar-paths %(home_dir)s/.gradle/caches/modules-2/files-2.1",
"jimple": "%(joern_home)sjimple2cpg%(only_bat_ext)s%(android_jar)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s",
"binary": "%(joern_home)sghidra2cpg%(only_bat_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s",
"js": "%(joern_home)sjssrc2cpg%(bin_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s",
"ts": "%(joern_home)sjssrc2cpg%(bin_ext)s -J-Xmx%(memory)s -o %(cpg_out)s %(src)s",
Expand Down Expand Up @@ -578,6 +579,7 @@ def exec_tool(
bin_ext=bin_ext,
exe_ext=exe_ext,
only_bat_ext=only_bat_ext,
android_jar=os.getenv("JIMPLE_ANDROID_JAR", ""),
os_path_sep=os.path.sep,
**extra_args,
)
Expand Down
8 changes: 8 additions & 0 deletions cpggen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def detect_project_type(src_dir):
:param src_dir: Source directory
:return List of detected types
"""
is_java_like = False
home_dir = str(Path.home())
maven_cache = os.path.join(home_dir, ".m2")
gradle_cache = os.path.join(home_dir, ".gradle", "caches", "modules-2", "files-2.1")
Expand All @@ -344,6 +345,7 @@ def detect_project_type(src_dir):
or find_files(src_dir, ".gradle", False, True)
or find_files(src_dir, ".java", False, True)
):
is_java_like = True
if os.getenv("SHIFTLEFT_ACCESS_TOKEN"):
project_types.append("jar")
else:
Expand Down Expand Up @@ -395,6 +397,12 @@ def detect_project_type(src_dir):
project_types.append("llvm")
if is_exe(src_dir):
project_types.append("binary")
# Directory contains just a bunch of jar then try jimple
if not is_java_like and find_files(src_dir, ".jar", False, True):
if os.getenv("SHIFTLEFT_ACCESS_TOKEN"):
project_types.append("jar")
else:
project_types.append("jimple")
return project_types


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cpggen"
version = "1.0.9"
version = "1.0.10"
description = "Generate CPG for multiple languages for use with joern"
authors = ["Team AppThreat <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 7b2331c

Please sign in to comment.