Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee81091

Browse files
authored
update chen (#219)
* update chen Signed-off-by: Prabhu Subramanian <[email protected]> * Tweaks Signed-off-by: Prabhu Subramanian <[email protected]> * Tweaks Signed-off-by: Prabhu Subramanian <[email protected]> --------- Signed-off-by: Prabhu Subramanian <[email protected]>
1 parent 81c8c31 commit ee81091

11 files changed

Lines changed: 53 additions & 36 deletions

File tree

build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name := "atom"
22
ThisBuild / organization := "io.appthreat"
3-
ThisBuild / version := "2.4.2"
3+
ThisBuild / version := "2.4.3"
44
ThisBuild / scalaVersion := "3.7.3"
55

6-
val chenVersion = "2.5.4"
6+
val chenVersion = "2.5.5"
77

88
lazy val atom = Projects.atom
99

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"downloadUrl": "https://github.com/AppThreat/atom",
88
"issueTracker": "https://github.com/AppThreat/atom/issues",
99
"name": "atom",
10-
"version": "2.4.2",
10+
"version": "2.4.3",
1111
"description": "Atom is a novel intermediate representation for next-generation code analysis.",
1212
"applicationCategory": "code-analysis",
1313
"keywords": [

src/main/scala/io/appthreat/atom/Atom.scala

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -791,18 +791,29 @@ object Atom:
791791
ag
792792
}
793793

794-
private def enhanceCpg(config: AtomConfig, cpg: Cpg): Either[String, Unit] =
794+
private def enhanceCpg(config: AtomConfig, atom: Cpg): Either[String, Unit] =
795795
config match
796796
case x: AtomConfig if needsDataFlowEnhancement(x) =>
797797
println("Generating data-flow dependencies from atom. Please wait ...")
798-
new CdxPass(cpg).createAndApply()
799-
new EasyTagsPass(cpg).createAndApply()
800-
new ChennaiTagsPass(cpg).createAndApply()
801-
new OssDataFlow(new OssDataFlowOptions(maxNumberOfDefinitions = x.maxNumDef))
802-
.run(new LayerCreatorContext(cpg))
803-
Right(())
798+
try
799+
new OssDataFlow(new OssDataFlowOptions(maxNumberOfDefinitions = x.maxNumDef))
800+
.run(new LayerCreatorContext(atom))
801+
new CdxPass(atom).createAndApply()
802+
new EasyTagsPass(atom).createAndApply()
803+
new ChennaiTagsPass(atom).createAndApply()
804+
Right(())
805+
catch
806+
case npe: NullPointerException
807+
if npe.getMessage != null &&
808+
npe.getMessage.contains("AdjacentNodes") =>
809+
Left(s"CPG appears to be corrupted with broken references. " +
810+
s"Try removing the atom file and regenerating it. Error: ${npe.getMessage}")
811+
case ex: Exception =>
812+
Left(
813+
s"Failed to enhance CPG: ${ex.getMessage} ${ex.getStackTrace.take(40).mkString("\n")}"
814+
)
804815
case _ =>
805-
new EasyTagsPass(cpg).createAndApply()
816+
new EasyTagsPass(atom).createAndApply()
806817
Right(())
807818

808819
private def needsDataFlowEnhancement(config: AtomConfig): Boolean =

src/main/scala/io/appthreat/atom/frontends/clike/C2Atom.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import scala.util.Try
1313
class C2Atom extends X2CpgFrontend[Config]:
1414

1515
def createCpg(config: Config): Try[Cpg] =
16-
withNewEmptyCpg(config.outputPath, config) { (cpg, config) =>
17-
new MetaDataPass(cpg, Languages.NEWC, config.inputPath).createAndApply()
18-
new AstCreationPass(cpg, config).createAndApply()
16+
withNewEmptyCpg(config.outputPath, config) { (atom, config) =>
17+
new MetaDataPass(atom, Languages.NEWC, config.inputPath).createAndApply()
18+
new AstCreationPass(atom, config).createAndApply()
1919
}

src/main/scala/io/appthreat/atom/passes/DataDepsPass.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import scala.collection.mutable
1010

1111
/** A pass that calculates reaching definitions ("data dependencies") based on ReachingDefPass
1212
*/
13-
class DataDepsPass(cpg: Cpg, maxNumberOfDefinitions: Int = 2000)(implicit s: Semantics)
14-
extends ConcurrentWriterCpgPass[Method](cpg):
13+
class DataDepsPass(atom: Cpg, maxNumberOfDefinitions: Int = 2000)(implicit s: Semantics)
14+
extends ConcurrentWriterCpgPass[Method](atom):
1515

1616
// If there are any regex method full names, load them early
17-
s.loadRegexSemantics(cpg)
17+
s.loadRegexSemantics(atom)
1818

19-
override def generateParts(): Array[Method] = cpg.method.toArray
19+
override def generateParts(): Array[Method] = atom.method.toArray
2020

2121
override def runOnPart(dstGraph: DiffGraphBuilder, method: Method): Unit =
2222
val problem = ReachingDefProblem.create(method)

src/main/scala/io/appthreat/atom/passes/TypeHintPass.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import io.shiftleft.codepropertygraph.generated.nodes.Call
66
import io.shiftleft.semanticcpg.language.*
77
import overflowdb.traversal.Traversal
88

9-
class TypeHintPass(cpg: Cpg) extends XTypeHintCallLinker(cpg):
9+
class TypeHintPass(atom: Cpg) extends XTypeHintCallLinker(atom):
1010

1111
override protected val pathSep = ':'
1212

13-
override protected def calls: Traversal[Call] = cpg.call
13+
override protected def calls: Traversal[Call] = atom.call
1414
.or(_.nameNot("<operator>.*", "<operators>.*"), _.name("<operator>.new"))
1515
.filterNot(c =>
1616
c.code.startsWith("$(") || c.code.startsWith("_tmp_") || c.code.startsWith("{")

wrapper/nodejs/package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wrapper/nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@appthreat/atom",
3-
"version": "2.4.2",
3+
"version": "2.4.3",
44
"description": "Create atom (⚛) representation for your application, packages and libraries",
55
"exports": "./index.js",
66
"type": "module",

wrapper/nodejs/packages/atom-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@appthreat/atom-common",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Common library for the @appthreat/atom project.",
55
"main": "index.js",
66
"type": "module",

wrapper/nodejs/packages/atom-common/utils.mjs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,31 @@ const IGNORE_DIRS = process.env.ASTGEN_IGNORE_DIRS
1515
"eslint-rules",
1616
"codemods",
1717
"flow-typed",
18-
"i18n",
18+
"i18n"
1919
];
2020

2121
const IGNORE_FILE_PATTERN = new RegExp(
22-
process.env.ASTGEN_IGNORE_FILE_PATTERN ||
23-
"(three|\\.d)\\.(js|ts|jsx|tsx)$",
22+
process.env.ASTGEN_IGNORE_FILE_PATTERN || "(three|\\.d)\\.(js|ts|jsx|tsx)$",
2423
"i"
2524
);
2625

27-
export const getAllFiles = (dir, extn, files, result, regex, ignore_node_modules=true) => {
26+
export const getAllFiles = (
27+
dir,
28+
extn,
29+
files,
30+
result,
31+
regex,
32+
ignore_node_modules = true
33+
) => {
2834
files = files || readdirSync(dir);
2935
result = result || [];
3036
regex = regex || new RegExp(`\\${extn}$`);
3137

3238
for (let i = 0; i < files.length; i++) {
3339
const file = files[i];
3440
if (
35-
file.startsWith(".") ||
36-
IGNORE_FILE_PATTERN.test(file)
41+
(ignore_node_modules && file.startsWith(".")) ||
42+
IGNORE_FILE_PATTERN.test(file)
3743
) {
3844
continue;
3945
}
@@ -42,7 +48,7 @@ export const getAllFiles = (dir, extn, files, result, regex, ignore_node_modules
4248
// Ignore directories
4349
const dirName = basename(fileWithDir);
4450
if (
45-
dirName.startsWith(".") ||
51+
(ignore_node_modules && dirName.startsWith(".")) ||
4652
IGNORE_DIRS.includes(dirName.toLowerCase()) ||
4753
(ignore_node_modules && dirName.toLowerCase() === "node_modules")
4854
) {

0 commit comments

Comments
 (0)