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

Commit

Permalink
Tweaks (#43)
Browse files Browse the repository at this point in the history
* Tweaks

Signed-off-by: Prabhu Subramanian <[email protected]>

* Update atom bin dir for windows

Signed-off-by: Prabhu Subramanian <[email protected]>

---------

Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu authored Jun 23, 2023
1 parent 6eb2ad5 commit 5ab9b8c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 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.8.1" \
org.opencontainers.image.version="1.8.2" \
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 ci/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.8.1" \
org.opencontainers.image.version="1.8.2" \
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 ci/Dockerfile-atom
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.8.1" \
org.opencontainers.image.version="1.8.2" \
org.opencontainers.image.vendor="AppThreat" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cpggen" \
Expand Down
25 changes: 21 additions & 4 deletions cpggen/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
import tempfile
import zipfile
from pathlib import Path
from pathlib import Path, PureWindowsPath

import psutil
from psutil._common import bytes2human
Expand Down Expand Up @@ -483,7 +483,19 @@ def exec_tool(
if atom_home:
atom_bin_dir = os.path.join(atom_home, "bin", "")
else:
atom_bin_dir = "/usr/local/bin/"
# Handle the case where the user might have installed atom npm package on windows
# but not set the PATH environment variable
atom_bin_dir = (
str(Path.home() / "AppData" / "Roaming" / "npm")
if sys.platform == "win32"
else "/usr/local/bin"
)
atom_bin_dir = os.path.join(atom_bin_dir, "")
if sys.platform == "win32" and os.path.exists(atom_bin_dir):
os.environ["ATOM_BIN_DIR"] = atom_bin_dir
os.environ["PATH"] = (
os.environ["PATH"] + os.pathsep + atom_bin_dir + os.pathsep
)
# Set joern_home from environment variable
# This is required to handle bundled exe mode
if (
Expand Down Expand Up @@ -583,6 +595,9 @@ def exec_tool(
if go_mods:
modules = [os.path.dirname(gmod) for gmod in go_mods]
for amodule in modules:
# Expand . directory names
if amodule == ".":
amodule = os.path.abspath(amodule)
cmd_with_args = cpg_tools_map.get(cpg_cmd_lang)
# Fallback to atom if the command doesn't exist
if (
Expand Down Expand Up @@ -906,11 +921,13 @@ def exec_tool(
)
else:
LOG.info(
"""%s for %s is %s. You can import this in joern using importCpg("%s")""",
"""%s for %s is %s.\nTo import this in joern, use importCpg(%r)""",
whats_built,
tool_lang_simple,
cpg_out,
cpg_out,
str(PureWindowsPath(cpg_out))
if sys.platform == "win32"
else cpg_out,
)
with open(manifest_out, mode="w", encoding="utf-8") as mfp:
# In case of github action, we need to convert this to relative path
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.8.1"
version = "1.8.2"
description = "Generate CPG for multiple languages for code and threat analysis"
authors = ["Team AppThreat <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 5ab9b8c

Please sign in to comment.