Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Jul 14, 2023
1 parent aba4beb commit 459b495
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
10 changes: 6 additions & 4 deletions src/main/scala/io/appthreat/atom/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import io.joern.c2cpg.{C2Cpg, Config as CConfig}
import io.appthreat.atom.slicing.{UsageSlicing, *}
import io.joern.javasrc2cpg.{JavaSrc2Cpg, Config as JavaConfig}
import io.joern.jimple2cpg.{Jimple2Cpg, Config as JimpleConfig}
import io.joern.jssrc2cpg.passes.{ConstClosurePass, JavaScriptInheritanceNamePass}
import io.joern.jssrc2cpg.passes.{ConstClosurePass, JavaScriptInheritanceNamePass, ImportResolverPass}
import io.joern.jssrc2cpg.{JsSrc2Cpg, Config as JSConfig}
import io.joern.pysrc2cpg.{
DynamicTypeHintFullNamePass,
Py2CpgOnFileSystem,
PythonInheritanceNamePass,
PythonTypeHintCallLinker,
PythonTypeRecoveryPass,
ImportsPass as PythonImportsPass,
ImportResolverPass as PyImportResolverPass,
Py2CpgOnFileSystemConfig as PyConfig
}
import io.joern.x2cpg.passes.base.AstLinkerPass
Expand Down Expand Up @@ -223,7 +222,7 @@ object Atom {
.map { cpg =>
new JavaScriptInheritanceNamePass(cpg).createAndApply()
new ConstClosurePass(cpg).createAndApply()
new NaiveCallLinker(cpg).createAndApply()
new ImportResolverPass(cpg).createAndApply()
cpg
}
case Languages.PYTHONSRC | Languages.PYTHON | "PY" =>
Expand All @@ -239,6 +238,9 @@ object Atom {
)
.map { cpg =>
new PythonImportsPass(cpg).createAndApply()
new PyImportResolverPass(cpg).createAndApply()
new DynamicTypeHintFullNamePass(cpg).createAndApply()
new PythonInheritanceNamePass(cpg).createAndApply()
cpg
}
case _ => Failure(new RuntimeException(s"No language frontend supported for language '$language'"))
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/appthreat/atom/parsedeps/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ package object parsedeps {
cpg.metaData.language.map(_.toUpperCase).headOption match
case Some(language) if Set(Languages.PYTHONSRC, Languages.PYTHON, "PY").contains(language) =>
Right(PythonDependencyParser.parse(cpg))
case Some(language) => Left(s"'$language' is not yet supported for the `depscan` command")
case _ => Left("Unable to extract CPG language")
case Some(language) => Left(s"'$language' is not yet supported for the `parsedeps` command")
case _ => Left("Unable to extract atom language")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ object DataFlowSlicing {
sliceNode.copy(
name = n.name,
fullName = n.methodFullName,
isExternal = n.callee.isExternal.l(0),
signature = n.callee.signature.l(0),
isExternal = if (n.callee.isExternal.isEmpty) false else n.callee.isExternal.l(0),
signature = if (n.callee.signature.isEmpty) "" else n.callee.signature.l(0),
typeFullName = n.typeFullName
)
case n: Method =>
Expand Down
4 changes: 2 additions & 2 deletions wrapper/nodejs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const dirName = import.meta ? dirname(fileURLToPath(url)) : __dirname;
const LOG4J_CONFIG = join(dirName, "plugins", "log4j2.xml");
const ATOM_HOME = join(dirName, "plugins", "atom-1.0.0");
const APP_LIB_DIR = join(ATOM_HOME, "lib");
const freeMemoryGB = Math.floor(freemem() / 1024 / 1024 / 1024);
const freeMemoryGB = Math.max(Math.floor(freemem() / 1024 / 1024 / 1024), 4);
const JVM_ARGS =
"-XX:+UseG1GC -XX:+ExplicitGCInvokesConcurrent -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:+UnlockDiagnosticVMOptions -XX:G1SummarizeRSetStatsPeriod=1";
const JAVA_OPTS = `${process.env.JAVA_OPTS || ""} -Xms${Math.round(
Math.floor(freeMemoryGB / 2)
)}G -Xmx${freeMemoryGB}G ${JVM_ARGS}`;
const APP_MAIN_CLASS = "io.appthreat.atom.Atom";
let APP_CLASSPATH = join(APP_LIB_DIR, "io.appthreat.atom-1.0.0-classpath.jar");
const APP_CLASSPATH = join(APP_LIB_DIR, "io.appthreat.atom-1.0.0-classpath.jar");
let JAVACMD = "java";
if (process.env.JAVA_HOME) {
JAVACMD = join(process.env.JAVA_HOME, "bin", "java" + (isWin ? ".exe" : ""));
Expand Down
4 changes: 2 additions & 2 deletions wrapper/nodejs/package-lock.json

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

2 changes: 1 addition & 1 deletion wrapper/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appthreat/atom",
"version": "0.15.1",
"version": "0.16.0",
"description": "Create atom (⚛) representation for your application, packages and libraries",
"exports": "./index.js",
"type": "module",
Expand Down

0 comments on commit 459b495

Please sign in to comment.