Skip to content

Commit

Permalink
Merge pull request #12 from Privado-Inc/masterTmp1
Browse files Browse the repository at this point in the history
Master sync : 23 Dec
  • Loading branch information
pandurangpatil authored Feb 5, 2025
2 parents 314bec9 + 342b505 commit b1edf95
Show file tree
Hide file tree
Showing 19 changed files with 63 additions and 36 deletions.
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name := "codepropertygraph"

// parsed by project/Versions.scala, updated by updateDependencies.sh
val flatgraphVersion = "0.0.89"
val flatgraphVersion = "0.1.2"

inThisBuild(
List(
organization := "io.shiftleft",
scalaVersion := "3.4.2",
scalaVersion := "3.5.2",
resolvers ++= Seq(
"Github Package Registry" at "https://maven.pkg.github.com/Privado-Inc/flatgraph",
Resolver.mavenLocal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ abstract class ForkJoinParallelCpgPassWithTimeout[T <: AnyRef](
nanosBuilt = System.nanoTime()
nDiff = diffGraph.size

// TODO how about `nDiffT` which seems to count the number of modifications..
// nDiffT = overflowdb.BatchedUpdate
// .applyDiff(cpg.graph, diffGraph, null)
// .transitiveModifications()

flatgraph.DiffGraphApplier.applyDiff(cpg.graph, diffGraph)
nDiffT = flatgraph.DiffGraphApplier.applyDiff(cpg.graph, diffGraph)
} catch {
case exc: Exception =>
baseLogger.error(s"Pass ${name} failed", exc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ final class AccessNeighborsForBinding(val node: nodes.Binding) extends AnyVal {
try { refOut.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label REF to an adjacent METHOD is mandatory, but not defined for this BINDING node with seq=" + node.seq,
"OUT edge with label REF to an adjacent METHOD is mandatory, but not defined for this BINDING node with " + nodeInfo,
e
)
}
Expand All @@ -34,8 +35,9 @@ final class AccessNeighborsForBinding(val node: nodes.Binding) extends AnyVal {
try { bindsIn.collectAll[nodes.TypeDecl].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label BINDS to an adjacent TYPE_DECL is mandatory, but not defined for this BINDING node with seq=" + node.seq,
"IN edge with label BINDS to an adjacent TYPE_DECL is mandatory, but not defined for this BINDING node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ final class AccessNeighborsForBlock(val node: nodes.Block) extends AnyVal {
try { astIn.collectAll[nodes.Block].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent BLOCK is mandatory, but not defined for this BLOCK node with seq=" + node.seq,
"IN edge with label AST to an adjacent BLOCK is mandatory, but not defined for this BLOCK node with " + nodeInfo,
e
)
}
Expand Down Expand Up @@ -268,8 +269,9 @@ final class AccessNeighborsForBlock(val node: nodes.Block) extends AnyVal {
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this BLOCK node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this BLOCK node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ final class AccessNeighborsForCall(val node: nodes.Call) extends AnyVal {
try { astIn.collectAll[nodes.ControlStructure].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this CALL node with seq=" + node.seq,
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this CALL node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ final class AccessNeighborsForFieldIdentifier(val node: nodes.FieldIdentifier) e
try { argumentIn.collectAll[nodes.Call].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label ARGUMENT to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with seq=" + node.seq,
"IN edge with label ARGUMENT to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with " + nodeInfo,
e
)
}
Expand All @@ -48,8 +49,9 @@ final class AccessNeighborsForFieldIdentifier(val node: nodes.FieldIdentifier) e
try { astIn.collectAll[nodes.Call].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with seq=" + node.seq,
"IN edge with label AST to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with " + nodeInfo,
e
)
}
Expand All @@ -69,8 +71,9 @@ final class AccessNeighborsForFieldIdentifier(val node: nodes.FieldIdentifier) e
try { cfgOut.collectAll[nodes.Call].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label CFG to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with seq=" + node.seq,
"OUT edge with label CFG to an adjacent CALL is mandatory, but not defined for this FIELD_IDENTIFIER node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ final class AccessNeighborsForLiteral(val node: nodes.Literal) extends AnyVal {
try { astIn.collectAll[nodes.ControlStructure].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this LITERAL node with seq=" + node.seq,
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this LITERAL node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ final class AccessNeighborsForMember(val node: nodes.Member) extends AnyVal {
try { astIn.collectAll[nodes.TypeDecl].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent TYPE_DECL is mandatory, but not defined for this MEMBER node with seq=" + node.seq,
"IN edge with label AST to an adjacent TYPE_DECL is mandatory, but not defined for this MEMBER node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ final class AccessNeighborsForMethod(val node: nodes.Method) extends AnyVal {
try { astOut.collectAll[nodes.MethodReturn].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label AST to an adjacent METHOD_RETURN is mandatory, but not defined for this METHOD node with seq=" + node.seq,
"OUT edge with label AST to an adjacent METHOD_RETURN is mandatory, but not defined for this METHOD node with " + nodeInfo,
e
)
}
Expand Down Expand Up @@ -293,8 +294,9 @@ final class AccessNeighborsForMethod(val node: nodes.Method) extends AnyVal {
try { astOut.collectAll[nodes.Block].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label AST to an adjacent BLOCK is mandatory, but not defined for this METHOD node with seq=" + node.seq,
"OUT edge with label AST to an adjacent BLOCK is mandatory, but not defined for this METHOD node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ final class AccessNeighborsForMethodParameterIn(val node: nodes.MethodParameterI
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_PARAMETER_IN node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_PARAMETER_IN node with " + nodeInfo,
e
)
}
Expand All @@ -105,8 +106,9 @@ final class AccessNeighborsForMethodParameterIn(val node: nodes.MethodParameterI
try { evalTypeOut.collectAll[nodes.Type].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label EVAL_TYPE to an adjacent TYPE is mandatory, but not defined for this METHOD_PARAMETER_IN node with seq=" + node.seq,
"OUT edge with label EVAL_TYPE to an adjacent TYPE is mandatory, but not defined for this METHOD_PARAMETER_IN node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ final class AccessNeighborsForMethodParameterOut(val node: nodes.MethodParameter
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_PARAMETER_OUT node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_PARAMETER_OUT node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ final class AccessNeighborsForMethodRef(val node: nodes.MethodRef) extends AnyVa
try { astIn.collectAll[nodes.ControlStructure].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this METHOD_REF node with seq=" + node.seq,
"IN edge with label AST to an adjacent CONTROL_STRUCTURE is mandatory, but not defined for this METHOD_REF node with " + nodeInfo,
e
)
}
Expand Down Expand Up @@ -449,8 +450,9 @@ final class AccessNeighborsForMethodRef(val node: nodes.MethodRef) extends AnyVa
try { refOut.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label REF to an adjacent METHOD is mandatory, but not defined for this METHOD_REF node with seq=" + node.seq,
"OUT edge with label REF to an adjacent METHOD is mandatory, but not defined for this METHOD_REF node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ final class AccessNeighborsForMethodReturn(val node: nodes.MethodReturn) extends
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_RETURN node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this METHOD_RETURN node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ final class AccessNeighborsForModifier(val node: nodes.Modifier) extends AnyVal
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this MODIFIER node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this MODIFIER node with " + nodeInfo,
e
)
}
Expand All @@ -32,8 +33,9 @@ final class AccessNeighborsForModifier(val node: nodes.Modifier) extends AnyVal
try { astIn.collectAll[nodes.TypeDecl].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent TYPE_DECL is mandatory, but not defined for this MODIFIER node with seq=" + node.seq,
"IN edge with label AST to an adjacent TYPE_DECL is mandatory, but not defined for this MODIFIER node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ final class AccessNeighborsForReturn(val node: nodes.Return) extends AnyVal {
try { cfgOut.collectAll[nodes.MethodReturn].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"OUT edge with label CFG to an adjacent METHOD_RETURN is mandatory, but not defined for this RETURN node with seq=" + node.seq,
"OUT edge with label CFG to an adjacent METHOD_RETURN is mandatory, but not defined for this RETURN node with " + nodeInfo,
e
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ final class AccessNeighborsForTypeParameter(val node: nodes.TypeParameter) exten
try { astIn.collectAll[nodes.Method].next() }
catch {
case e: java.util.NoSuchElementException =>
val nodeInfo = String.format("id=%d, (seq=%d)", node.id, node.seq)
throw new flatgraph.SchemaViolationException(
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this TYPE_PARAMETER node with seq=" + node.seq,
"IN edge with label AST to an adjacent METHOD is mandatory, but not defined for this TYPE_PARAMETER node with " + nodeInfo,
e
)
}
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.1
sbt.version=1.10.6
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
addSbtPlugin("com.github.sbt" % "sbt-protobuf" % "0.7.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-findbugs" % "2.0.0")
addSbtPlugin("io.shiftleft" % "sbt-ci-release-early" % "2.0.18")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.5")
addSbtPlugin("io.shiftleft" % "sbt-ci-release-early" % "2.0.48")
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.1.0")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.4")
addSbtPlugin("io.joern" % "sbt-flatgraph" % Versions.flatgraph)
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3")
14 changes: 12 additions & 2 deletions updateDependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ check_installed() {
fi
}

function sedi() {
if sed --version 2> /dev/null | grep -q 'GNU' ; then
# GNU sed does not like a second argument for -i
sed -i "$@"
else
# but macOS (FreeBSD) sed needs it
sed -i '' "$@"
fi
}

check_installed curl

# check if xmllint is installed
Expand Down Expand Up @@ -57,13 +67,13 @@ function update {
if [ "$NON_INTERACTIVE_OPTION" == "--non-interactive" ]
then
echo "non-interactive mode, auto-updating $NAME: $OLD_VERSION -> $VERSION"
sed -i "s/$SEARCH/$REPLACE/" build.sbt
sedi "s/$SEARCH/$REPLACE/" build.sbt
else
echo "update $NAME: $OLD_VERSION -> $VERSION? [Y/n]"
read ANSWER
if [ -z $ANSWER ] || [ "y" == $ANSWER ] || [ "Y" == $ANSWER ]
then
sed -i "s/$SEARCH/$REPLACE/" build.sbt
sedi "s/$SEARCH/$REPLACE/" build.sbt
fi
fi
fi
Expand Down

0 comments on commit b1edf95

Please sign in to comment.