Skip to content

Commit

Permalink
Update chen. Brings minor tweaks
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Oct 13, 2023
1 parent bf26340 commit 240404a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ThisBuild / organization := "io.appthreat"
ThisBuild / version := "1.5.0"
ThisBuild / scalaVersion := "3.3.1"

val chenVersion = "0.0.14"
val chenVersion = "0.0.16"

lazy val atom = Projects.atom

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package io.appthreat.atom.slicing

import io.appthreat.dataflowengineoss.language.*
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.PropertyNames
import io.shiftleft.codepropertygraph.generated.nodes.*
import io.shiftleft.codepropertygraph.generated.{EdgeTypes, PropertyNames}
import io.shiftleft.semanticcpg.language.*

import java.util.concurrent.*
Expand Down
26 changes: 16 additions & 10 deletions src/main/scala/io/appthreat/atom/slicing/ReachableSlicing.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package io.appthreat.atom.slicing

import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.nodes.*
import io.appthreat.dataflowengineoss.language.*
import io.appthreat.dataflowengineoss.DefaultSemantics
import io.appthreat.dataflowengineoss.language.Path.{maxTrackedWidth, tagAsString}
import io.appthreat.dataflowengineoss.language.*
import io.appthreat.dataflowengineoss.queryengine.{EngineConfig, EngineContext}
import io.appthreat.dataflowengineoss.semanticsloader.Semantics
import io.shiftleft.codepropertygraph.Cpg
import io.shiftleft.codepropertygraph.generated.nodes.*
import io.shiftleft.semanticcpg.language.*
import io.shiftleft.semanticcpg.language.{DefaultNodeExtensionFinder, ICallResolver, NoResolve, NodeExtensionFinder}

import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer}
import scala.collection.mutable.ArrayBuffer

object ReachableSlicing {

Expand All @@ -35,7 +33,6 @@ object ReachableSlicing {
val addedPaths = mutable.Set[String]()
var purls = mutable.Set[String]()
path.elements.foreach { astNode =>
val nodeType = astNode.getClass.getSimpleName
val lineNumber = astNode.lineNumber.getOrElse("").toString
val fileName = astNode.file.name.headOption.getOrElse("").replace("<unknown>", "")
var fileLocation = s"${fileName}#${lineNumber}"
Expand Down Expand Up @@ -65,13 +62,15 @@ object ReachableSlicing {
}
sliceNode = sliceNode.copy(
name = methodParameterIn.name,
code = methodParameterIn.method.fullName,
code = methodParameterIn.code,
typeFullName = methodParameterIn.typeFullName,
parentMethodName = methodName,
parentMethodSignature = methodParameterIn.method.signature,
parentPackageName = methodParameterIn.method.location.packageName,
parentClassName = methodParameterIn.method.location.className,
isExternal = methodParameterIn.method.isExternal,
lineNumber = methodParameterIn.lineNumber,
columnNumber = methodParameterIn.columnNumber,
tags = tags
)
tableRows += sliceNode
Expand All @@ -83,7 +82,9 @@ object ReachableSlicing {
parentMethodName = methodName,
parentMethodSignature = ret.method.signature,
parentPackageName = ret.method.location.packageName,
parentClassName = ret.method.location.className
parentClassName = ret.method.location.className,
lineNumber = ret.lineNumber,
columnNumber = ret.columnNumber
)
tableRows += sliceNode
case identifier: Identifier =>
Expand All @@ -100,6 +101,8 @@ object ReachableSlicing {
parentMethodSignature = identifier.method.signature,
parentPackageName = identifier.method.location.packageName,
parentClassName = identifier.method.location.className,
lineNumber = identifier.lineNumber,
columnNumber = identifier.columnNumber,
tags = tags
)
tableRows += sliceNode
Expand Down Expand Up @@ -127,13 +130,16 @@ object ReachableSlicing {
else false
if (call.methodFullName.startsWith("<operator")) isExternal = false
sliceNode = sliceNode.copy(
name = call.method.name,
name = call.name,
fullName = call.callee(NoResolve).head.fullName,
code = call.code,
isExternal = isExternal,
parentMethodName = call.method.name,
parentMethodSignature = call.method.signature,
parentPackageName = call.method.location.packageName,
parentClassName = call.method.location.className,
lineNumber = call.lineNumber,
columnNumber = call.columnNumber,
tags = tags
)
tableRows += sliceNode
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/io/appthreat/atom/slicing/UsageSlicing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import io.shiftleft.codepropertygraph.generated.nodes.*
import io.shiftleft.codepropertygraph.generated.{Languages, Operators, PropertyNames}
import io.shiftleft.semanticcpg.language.*

import java.util.concurrent.*
import java.util.concurrent.atomic.AtomicBoolean
import java.util.regex.Pattern
import scala.annotation.unused
import scala.collection.concurrent.TrieMap
import scala.util.Try

import java.util.concurrent.*

/** A utility for slicing based off of usage references for identifiers and parameters. This is mainly tested around
* JavaScript CPGs.
*/
Expand Down

0 comments on commit 240404a

Please sign in to comment.