Skip to content

Commit 894d5bb

Browse files
authored
Feature/july pkg updates (#80)
* Update packages Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Some data flow fixes with tests Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * passes and passesNot Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Update maven and gradle in container image Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> --------- Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
1 parent 565ae85 commit 894d5bb

File tree

38 files changed

+2877
-2225
lines changed

38 files changed

+2877
-2225
lines changed

.sbtopts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-J-Xms3G
2-
-J-Xmx4G
2+
-J-Xmx16G

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for you
66

77
- Java >= 21
88
- Python >= 3.10
9-
- Node.js >= 18 (To run [atom](https://github.com/AppThreat/atom))
9+
- Node.js >= 20 (To run [atom](https://github.com/AppThreat/atom))
1010
- Minimum 16GB RAM
1111

1212
## Getting started
@@ -147,9 +147,9 @@ Refer to the documentation site to learn more about the commands.
147147
148148
## Languages supported
149149
150-
- C/C++ (Requires Java 21 or above)
150+
- C/C++
151151
- H (C/C++ Header files alone)
152-
- Java (Requires compilation) - 8 to 17
152+
- Java (Requires compilation) - 8 to 21
153153
- Jar
154154
- Android APK (Requires Android SDK. Set the environment variable `ANDROID_HOME`)
155155
- JavaScript

build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name := "chen"
22
ThisBuild / organization := "io.appthreat"
3-
ThisBuild / version := "2.1.0"
4-
ThisBuild / scalaVersion := "3.4.1"
3+
ThisBuild / version := "2.1.1"
4+
ThisBuild / scalaVersion := "3.4.2"
55

66
val cpgVersion = "1.0.0"
77

ci/Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ LABEL maintainer="appthreat" \
1212
org.opencontainers.docker.cmd="docker run --rm -v /tmp:/tmp -v $HOME:$HOME -v $(pwd):/app:rw -it ghcr.io/appthreat/chen chennai"
1313

1414
ARG JAVA_VERSION=22.0.1-graalce
15-
ARG MAVEN_VERSION=3.9.6
16-
ARG GRADLE_VERSION=8.7
15+
ARG MAVEN_VERSION=3.9.8
16+
ARG GRADLE_VERSION=8.8
1717

1818
ENV JAVA_VERSION=$JAVA_VERSION \
1919
MAVEN_VERSION=$MAVEN_VERSION \

codemeta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"downloadUrl": "https://github.com/AppThreat/chen",
88
"issueTracker": "https://github.com/AppThreat/chen/issues",
99
"name": "chen",
10-
"version": "2.1.0",
10+
"version": "2.1.1",
1111
"description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
1212
"applicationCategory": "code-analysis",
1313
"keywords": [

console/build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ enablePlugins(JavaAppPackaging)
44

55
val ScoptVersion = "4.1.0"
66
val CaskVersion = "0.9.2"
7-
val CirceVersion = "0.14.6"
7+
val CirceVersion = "0.14.9"
88
val ZeroturnaroundVersion = "1.17"
99

1010
dependsOn(
@@ -24,7 +24,7 @@ libraryDependencies ++= Seq(
2424
"io.circe" %% "circe-generic" % CirceVersion,
2525
"io.circe" %% "circe-parser" % CirceVersion,
2626
"org.zeroturnaround" % "zt-zip" % ZeroturnaroundVersion,
27-
"com.lihaoyi" %% "os-lib" % "0.10.0",
27+
"com.lihaoyi" %% "os-lib" % "0.10.2",
2828
"com.lihaoyi" %% "pprint" % "0.9.0",
2929
"com.lihaoyi" %% "cask" % CaskVersion,
3030
"dev.scalapy" %% "scalapy-core" % "0.5.3",

dataflowengineoss/src/main/scala/io/appthreat/dataflowengineoss/language/package.scala

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import io.appthreat.dataflowengineoss.language.nodemethods.{
66
ExtendedCfgNodeMethods
77
}
88
import io.shiftleft.codepropertygraph.generated.nodes.*
9+
import io.shiftleft.semanticcpg.language.*
10+
import scala.language.implicitConversions
911

1012
package object language:
1113

@@ -26,4 +28,17 @@ package object language:
2628

2729
implicit def toDdgNodeDotSingle(method: Method): DdgNodeDot =
2830
new DdgNodeDot(Iterator.single(method))
31+
32+
implicit def toExtendedPathsTrav[NodeType <: Path](traversal: IterableOnce[NodeType])
33+
: PassesExt =
34+
new PassesExt(traversal.iterator)
35+
36+
class PassesExt(traversal: Iterator[Path]):
37+
38+
def passes(trav: Iterator[AstNode] => Iterator[?]): Iterator[Path] =
39+
traversal.filter(_.elements.exists(_.start.where(trav).nonEmpty))
40+
41+
def passesNot(trav: Iterator[AstNode] => Iterator[?]): Iterator[Path] =
42+
traversal.filter(_.elements.forall(_.start.where(trav).isEmpty))
43+
2944
end language

dataflowengineoss/src/main/scala/io/appthreat/dataflowengineoss/passes/reachingdef/EdgeValidator.scala

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ object EdgeValidator:
2424
case (childNode: Expression, parentNode)
2525
if isCallRetval(parentNode) || !isValidEdgeToExpression(parentNode, childNode) =>
2626
false
27+
case (childNode: Call, parentNode: Expression)
28+
if isCallRetval(childNode) && childNode.argument.contains(parentNode) =>
29+
// e.g. foo(x), but there are semantics for `foo` that don't taint its return value
30+
// in which case we don't want `x` to taint `foo(x)`.
31+
false
2732
case (childNode: Expression, parentNode: Expression)
2833
if parentNode.isArgToSameCallWith(
2934
childNode

dataflowengineoss/src/main/scala/io/appthreat/dataflowengineoss/passes/reachingdef/ReachingDefProblem.scala

+16-15
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class ReachingDefTransferFunction(flowGraph: ReachingDefFlowGraph)
165165
val gen: Map[StoredNode, mutable.BitSet] =
166166
initGen(method).withDefaultValue(mutable.BitSet())
167167

168-
val kill: Map[StoredNode, Set[Definition]] =
168+
val kill: Map[StoredNode, mutable.BitSet] =
169169
initKill(method, gen).withDefaultValue(mutable.BitSet())
170170

171171
/** For a given flow graph node `n` and set of definitions, apply the transfer function to
@@ -226,8 +226,8 @@ class ReachingDefTransferFunction(flowGraph: ReachingDefFlowGraph)
226226
*/
227227
private def initKill(
228228
method: Method,
229-
gen: Map[StoredNode, Set[Definition]]
230-
): Map[StoredNode, Set[Definition]] =
229+
gen: Map[StoredNode, mutable.BitSet]
230+
): Map[StoredNode, mutable.BitSet] =
231231

232232
val allIdentifiers: Map[String, List[CfgNode]] =
233233
val results = mutable.Map.empty[String, List[CfgNode]]
@@ -266,44 +266,45 @@ class ReachingDefTransferFunction(flowGraph: ReachingDefFlowGraph)
266266
* gen(call).
267267
*/
268268
private def killsForGens(
269-
genOfCall: Set[Definition],
269+
genOfCall: mutable.BitSet,
270270
allIdentifiers: Map[String, List[CfgNode]],
271271
allCalls: Map[String, List[Call]]
272-
): Set[Definition] =
272+
): mutable.BitSet =
273273

274-
def definitionsOfSameVariable(definition: Definition): Set[Definition] =
274+
def definitionsOfSameVariable(definition: Definition): Iterator[Definition] =
275275
val definedNodes = flowGraph.numberToNode(definition) match
276276
case param: MethodParameterIn =>
277-
allIdentifiers(param.name)
277+
allIdentifiers(param.name).iterator
278278
.filter(x => x.id != param.id)
279279
case identifier: Identifier =>
280-
val sameIdentifiers = allIdentifiers(identifier.name)
280+
val sameIdentifiers = allIdentifiers(identifier.name).iterator
281281
.filter(x => x.id != identifier.id)
282282

283283
/** Killing an identifier should also kill field accesses on that identifier.
284284
* For example, a reassignment `x = new Box()` should kill any previous calls
285285
* to `x.value`, `x.length()`, etc.
286286
*/
287-
val sameObjects: Iterable[Call] = allCalls.values.flatten
287+
val sameObjects: Iterator[Call] = allCalls.valuesIterator.flatten
288288
.filter(_.name == Operators.fieldAccess)
289289
.filter(_.ast.isIdentifier.nameExact(identifier.name).nonEmpty)
290290

291291
sameIdentifiers ++ sameObjects
292292
case call: Call =>
293-
allCalls(call.code)
293+
allCalls(call.code).iterator
294294
.filter(x => x.id != call.id)
295-
case _ => Set()
295+
case _ => Iterator.empty
296296
definedNodes
297297
// It can happen that the CFG is broken and contains isolated nodes,
298298
// in which case they are not in `nodeToNumber`. Let's filter those.
299299
.collect {
300300
case x if nodeToNumber.contains(x) => Definition.fromNode(x, nodeToNumber)
301-
}.toSet
301+
}
302302
end definitionsOfSameVariable
303303

304-
genOfCall.flatMap { definition =>
305-
definitionsOfSameVariable(definition)
306-
}
304+
val res = mutable.BitSet()
305+
for definition <- genOfCall do
306+
res.addAll(definitionsOfSameVariable(definition))
307+
res
307308
end killsForGens
308309
end ReachingDefTransferFunction
309310

meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% set version = "2.1.0" %}
1+
{% set version = "2.1.1" %}
22

33
package:
44
name: chen

platform/frontends/c2cpg/build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ dependsOn(Projects.semanticcpg, Projects.dataflowengineoss % Test, Projects.x2cp
44

55
libraryDependencies ++= Seq(
66
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4",
7-
"org.eclipse.platform" % "org.eclipse.equinox.common" % "3.19.0",
8-
"org.eclipse.platform" % "org.eclipse.core.resources" % "3.20.100" excludeAll(
7+
"org.eclipse.platform" % "org.eclipse.equinox.common" % "3.19.100",
8+
"org.eclipse.platform" % "org.eclipse.core.resources" % "3.20.200" excludeAll(
99
ExclusionRule(organization = "com.ibm.icu", name = "icu4j"),
1010
ExclusionRule(organization = "org.eclipse.platform", name = "org.eclipse.jface"),
1111
ExclusionRule(organization = "org.eclipse.platform", name = "org.eclipse.jface.text")

0 commit comments

Comments
 (0)