Skip to content

Commit 1b54bf0

Browse files
committed
[jimple2cpg] bump soot 4.6.0 > 4.7.1
1 parent b48167c commit 1b54bf0

24 files changed

Lines changed: 115 additions & 121 deletions

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ ThisBuild / resolvers ++= Seq(
9898
Resolver.mavenLocal,
9999
"Sonatype OSS" at "https://oss.sonatype.org/content/repositories/public",
100100
"Atlassian" at "https://packages.atlassian.com/mvn/maven-atlassian-external",
101-
"Gradle Releases" at "https://repo.gradle.org/gradle/libs-releases/"
101+
"Gradle Releases" at "https://repo.gradle.org/gradle/libs-releases/",
102+
"Google Maven" at "https://maven.google.com/"
102103
)
103104

104105
ThisBuild / Test / fork := true

joern-cli/frontends/jimple2cpg/build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ libraryDependencies ++= Seq(
1313
"org.scalatest" %% "scalatest" % Versions.scalatest % Test,
1414
"org.benf" % "cfr" % Versions.cfr
1515
)
16+
dependencyOverrides += "com.google.guava" % "guava" % "33.5.0-jre" // required currently because of the dependencies of soot 4.7.1
1617

1718
enablePlugins(JavaAppPackaging, LauncherJarPlugin)
1819
trapExit := false

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/Jimple2Cpg.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class Jimple2Cpg extends X2CpgFrontend {
4141
case _ =>
4242
Options.v().set_src_prec(Options.src_prec_apk_c_j)
4343
}
44-
Options.v().set_process_multiple_dex(true)
4544
// workaround for Soot's bug while parsing large apk.
4645
// see: https://github.com/soot-oss/soot/issues/1256
4746
Options.v().setPhaseOption("jb", "use-original-names:false")

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/astcreation/AstCreator.scala

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class AstCreator(
4141
typeName
4242
}
4343

44+
protected def sootTypeToString(t: soot.Type): String = {
45+
t.toString.replace("\'", "")
46+
}
47+
4448
/** Entry point of AST creation. Translates a compilation unit created by JavaParser into a DiffGraph containing the
4549
* corresponding CPG AST.
4650
*/
@@ -119,7 +123,7 @@ class AstCreator(
119123
.code(arrRef.toString())
120124
.lineNumber(line(parentUnit))
121125
.columnNumber(column(parentUnit))
122-
.typeFullName(registerType(arrRef.getType.toQuotedString))
126+
.typeFullName(registerType(sootTypeToString(arrRef.getType)))
123127

124128
val astChildren = astsForValue(arrRef.getBase, parentUnit) ++ astsForValue(arrRef.getIndex, parentUnit)
125129
Ast(indexAccess)
@@ -129,7 +133,7 @@ class AstCreator(
129133

130134
protected def astForLocal(local: soot.Local, parentUnit: SUnit): Ast = {
131135
val name = local.getName
132-
val typeFullName = registerType(local.getType.toQuotedString)
136+
val typeFullName = registerType(sootTypeToString(local.getType))
133137
Ast(
134138
NewIdentifier()
135139
.name(name)
@@ -145,7 +149,7 @@ class AstCreator(
145149
NewIdentifier()
146150
.code(x.toString())
147151
.name(x.toString())
148-
.typeFullName(registerType(x.getType.toQuotedString))
152+
.typeFullName(registerType(sootTypeToString(x.getType)))
149153
.lineNumber(line(parentUnit))
150154
.columnNumber(column(parentUnit))
151155
)
@@ -156,16 +160,16 @@ class AstCreator(
156160
NewIdentifier()
157161
.name("this")
158162
.code("this")
159-
.typeFullName(registerType(method.getType.toQuotedString))
160-
.dynamicTypeHintFullName(Seq(registerType(method.getType.toQuotedString)))
163+
.typeFullName(registerType(sootTypeToString(method.getType)))
164+
.dynamicTypeHintFullName(Seq(registerType(sootTypeToString(method.getType))))
161165
)
162166
}
163167

164168
protected def createThisNode(method: SootMethod, builder: NewNode): Ast = createThisNode(method.makeRef(), builder)
165169

166170
protected def createThisNode(method: SootMethodRef, builder: NewNode): Ast = {
167171
if (!method.isStatic || method.isConstructor) {
168-
val parentType = registerType(Try(method.getDeclaringClass.getType.toQuotedString).getOrElse("ANY"))
172+
val parentType = registerType(Try(sootTypeToString(method.getDeclaringClass.getType)).getOrElse("ANY"))
169173
Ast(builder match {
170174
case x: NewIdentifier =>
171175
x.name("this")
@@ -205,7 +209,7 @@ class AstCreator(
205209
val fieldAccessBlock = NewCall()
206210
.name(Operators.fieldAccess)
207211
.code(s"$leftOpString.${fieldRef.getFieldRef.name()}")
208-
.typeFullName(registerType(fieldRef.getType.toQuotedString))
212+
.typeFullName(registerType(sootTypeToString(fieldRef.getType)))
209213
.methodFullName(Operators.fieldAccess)
210214
.dispatchType(DispatchTypes.STATIC_DISPATCH)
211215
.lineNumber(line(parentUnit))
@@ -219,7 +223,7 @@ class AstCreator(
219223
.columnNumber(column(parentUnit))
220224
.name(leftOpString)
221225
.code(leftOpString)
222-
.typeFullName(registerType(leftOpType.toQuotedString)),
226+
.typeFullName(registerType(sootTypeToString(leftOpType))),
223227
NewFieldIdentifier()
224228
.order(2)
225229
.argumentIndex(2)
@@ -241,7 +245,7 @@ class AstCreator(
241245
.columnNumber(column(parentUnit))
242246
.name(caughtException.toString())
243247
.code(caughtException.toString())
244-
.typeFullName(registerType(caughtException.getType.toQuotedString))
248+
.typeFullName(registerType(sootTypeToString(caughtException.getType)))
245249
)
246250
}
247251

@@ -251,7 +255,7 @@ class AstCreator(
251255
Ast(
252256
NewLiteral()
253257
.code(s"${x.value.parseAsJavaType}.class")
254-
.typeFullName(registerType(x.getType.toQuotedString))
258+
.typeFullName(registerType(sootTypeToString(x.getType)))
255259
)
256260
case _: NullConstant =>
257261
Ast(
@@ -263,7 +267,7 @@ class AstCreator(
263267
Ast(
264268
NewLiteral()
265269
.code(constant.toString)
266-
.typeFullName(registerType(constant.getType.toQuotedString))
270+
.typeFullName(registerType(sootTypeToString(constant.getType)))
267271
)
268272
}
269273
}

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/astcreation/declarations/AstForMethodsCreator.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
6868
methodAstWithAnnotations(
6969
methodNode
7070
.lineNumberEnd(methodBody.toString.split('\n').filterNot(_.isBlank).length)
71-
.code(methodBody.toString),
71+
.code(methodBody.toString.replace("\'", "")),
7272
parameterAsts,
7373
astForMethodBody(methodBody, bodyStatementsInfo),
7474
astForMethodReturn(methodDeclaration),
@@ -146,14 +146,14 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
146146
}
147147

148148
private def astForMethodReturn(methodDeclaration: SootMethod): NewMethodReturn = {
149-
val typeFullName = registerType(methodDeclaration.getReturnType.toQuotedString)
149+
val typeFullName = registerType(sootTypeToString(methodDeclaration.getReturnType))
150150
methodReturnNode(methodDeclaration, typeFullName)
151151
}
152152

153153
private def createMethodNode(methodDeclaration: SootMethod, typeDecl: RefType) = {
154154
val name = methodDeclaration.getName
155155
val fullName = methodFullName(typeDecl, methodDeclaration)
156-
val methodDeclType = registerType(methodDeclaration.getReturnType.toQuotedString)
156+
val methodDeclType = registerType(sootTypeToString(methodDeclaration.getReturnType))
157157
val code = if (!methodDeclaration.isConstructor) {
158158
s"$methodDeclType $name${paramListSignature(methodDeclaration, withParams = true)}"
159159
} else {
@@ -168,19 +168,19 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
168168
Option(signature),
169169
filename,
170170
Option(NodeTypes.TYPE_DECL),
171-
Option(typeDecl.toQuotedString)
171+
Option(sootTypeToString(typeDecl))
172172
)
173173
}
174174

175175
private def methodFullName(typeDecl: RefType, methodDeclaration: SootMethod): String = {
176-
val typeName = registerType(typeDecl.toQuotedString)
177-
val returnType = registerType(methodDeclaration.getReturnType.toQuotedString)
176+
val typeName = registerType(sootTypeToString(typeDecl))
177+
val returnType = registerType(sootTypeToString(methodDeclaration.getReturnType))
178178
val methodName = methodDeclaration.getName
179179
s"$typeName.$methodName:$returnType${paramListSignature(methodDeclaration)}"
180180
}
181181

182182
private def paramListSignature(methodDeclaration: SootMethod, withParams: Boolean = false) = {
183-
val paramTypes = methodDeclaration.getParameterTypes.asScala.map(x => registerType(x.toQuotedString))
183+
val paramTypes = methodDeclaration.getParameterTypes.asScala.map(x => registerType(sootTypeToString(x)))
184184

185185
val paramNames =
186186
if (!methodDeclaration.isPhantom && Try(methodDeclaration.retrieveActiveBody()).isSuccess)
@@ -198,7 +198,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
198198

199199
protected def astForParameterRef(parameterRef: ParameterRef, parentUnit: SUnit): Ast = {
200200
val name = s"@parameter${parameterRef.getIndex}"
201-
Ast(identifierNode(parentUnit, name, name, registerType(parameterRef.getType.toQuotedString)))
201+
Ast(identifierNode(parentUnit, name, name, registerType(sootTypeToString(parameterRef.getType))))
202202
}
203203

204204
private def astForParameter(
@@ -207,7 +207,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
207207
methodDeclaration: SootMethod,
208208
parameterAnnotations: Map[String, VisibilityAnnotationTag]
209209
): Ast = {
210-
val typeFullName = registerType(parameter.getType.toQuotedString)
210+
val typeFullName = registerType(sootTypeToString(parameter.getType))
211211

212212
val paramAst = Ast(
213213
parameterInNode(
@@ -236,7 +236,7 @@ trait AstForMethodsCreator(implicit withSchemaValidation: ValidationMode) { this
236236
val jimpleLocals = body.getLocals.asScala.filterNot(l => jimpleParams.contains(l) || l.getName == "this").toList
237237
val locals = jimpleLocals.map { local =>
238238
val name = local.getName
239-
val typeFullName = registerType(local.getType.toQuotedString)
239+
val typeFullName = registerType(sootTypeToString(local.getType))
240240
val code = s"$typeFullName $name"
241241
Ast(localNode(body, name, code, typeFullName))
242242
}

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/astcreation/declarations/AstForTypeDeclsCreator.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ trait AstForTypeDeclsCreator(implicit withSchemaValidation: ValidationMode) { th
1515
/** Creates the AST root for type declarations and acts as the entry point for method generation.
1616
*/
1717
protected def astForTypeDecl(typ: RefType, namespaceBlockFullName: String): Ast = {
18-
val fullName = registerType(typ.toQuotedString)
18+
val fullName = registerType(sootTypeToString(typ))
1919
val shortName = typ.getSootClass.getShortJavaStyleName
2020
val clz = typ.getSootClass
2121
val code = new mutable.StringBuilder()
@@ -59,7 +59,7 @@ trait AstForTypeDeclsCreator(implicit withSchemaValidation: ValidationMode) { th
5959
}
6060

6161
private def astForField(field: SootField): Ast = {
62-
val typeFullName = registerType(field.getType.toQuotedString)
62+
val typeFullName = registerType(sootTypeToString(field.getType))
6363
val name = field.getName
6464
val annotations = field.getTags.asScala
6565
.collect { case x: VisibilityAnnotationTag => x }
@@ -69,7 +69,7 @@ trait AstForTypeDeclsCreator(implicit withSchemaValidation: ValidationMode) { th
6969
tag.getConstant.toString
7070
}
7171
val code =
72-
if (field.getDeclaration.contains("enum")) name
72+
if (field.getQuotedDeclaration.contains("enum")) name
7373
else {
7474
constantValue match {
7575
case Some(value) => s"$typeFullName $name = $value"
@@ -87,11 +87,11 @@ trait AstForTypeDeclsCreator(implicit withSchemaValidation: ValidationMode) { th
8787
*/
8888
private def inheritedAndImplementedClasses(clazz: SootClass): (List[String], List[String]) = {
8989
val implementsTypeFullName = clazz.getInterfaces.asScala.map { (i: SootClass) =>
90-
registerType(i.getType.toQuotedString)
90+
registerType(sootTypeToString(i.getType))
9191
}.toList
9292
val inheritsFromTypeFullName =
93-
if (clazz.hasSuperclass && clazz.getSuperclass.getType.toQuotedString != "java.lang.Object") {
94-
List(registerType(clazz.getSuperclass.getType.toQuotedString))
93+
if (clazz.hasSuperclass && sootTypeToString(clazz.getSuperclass.getType) != "java.lang.Object") {
94+
List(registerType(sootTypeToString(clazz.getSuperclass.getType)))
9595
} else if (implementsTypeFullName.isEmpty) {
9696
List(registerType("java.lang.Object"))
9797
} else List()

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/astcreation/expressions/AstForExpressionsCreator.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
7676
}
7777

7878
val signature =
79-
s"${registerType(callee.getReturnType.toQuotedString)}(${(for (i <- 0 until callee.getParameterTypes.size())
80-
yield registerType(callee.getParameterType(i).toQuotedString)).mkString(",")})"
79+
s"${registerType(sootTypeToString(callee.getReturnType))}(${(for (i <- 0 until callee.getParameterTypes.size())
80+
yield registerType(sootTypeToString(callee.getParameterType(i)))).mkString(",")})"
8181
val thisAsts = invokeExpr match {
8282
case expr: InstanceInvokeExpr => astsForValue(expr.getBase, parentUnit)
8383
case _ => Seq(createThisNode(callee, NewIdentifier()))
@@ -89,7 +89,7 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
8989
else
9090
callee.getName
9191

92-
val calleeType = registerType(callee.getDeclaringClass.getType.toQuotedString)
92+
val calleeType = registerType(sootTypeToString(callee.getDeclaringClass.getType))
9393
val callType =
9494
if (callee.isConstructor) "void"
9595
else calleeType
@@ -134,7 +134,7 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
134134
case u: NewMultiArrayExpr =>
135135
astForArrayCreateExpr(x, u.getSizes.asScala, parentUnit)
136136
case _ =>
137-
val parentType = registerType(x.getType.toQuotedString)
137+
val parentType = registerType(sootTypeToString(x.getType))
138138
Ast(
139139
NewCall()
140140
.name(Operators.alloc)
@@ -151,7 +151,7 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
151151
private def astForArrayCreateExpr(arrayInitExpr: Expr, sizes: Iterable[Value], parentUnit: soot.Unit): Ast = {
152152
// Jimple does not have Operators.arrayInitializer
153153
// to enforce 3 address code form
154-
val arrayBaseType = registerType(arrayInitExpr.getType.toQuotedString)
154+
val arrayBaseType = registerType(sootTypeToString(arrayInitExpr.getType))
155155
val code = s"new ${arrayBaseType.substring(0, arrayBaseType.indexOf('['))}${sizes.map(s => s"[$s]").mkString}"
156156
val callBlock = NewCall()
157157
.name(Operators.alloc)
@@ -172,7 +172,7 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
172172
.methodFullName(methodName)
173173
.code(unaryExpr.toString())
174174
.dispatchType(DispatchTypes.STATIC_DISPATCH)
175-
.typeFullName(registerType(unaryExpr.getType.toQuotedString))
175+
.typeFullName(registerType(sootTypeToString(unaryExpr.getType)))
176176
.lineNumber(line(parentUnit))
177177
.columnNumber(column(parentUnit))
178178

@@ -190,10 +190,10 @@ trait AstForExpressionsCreator(implicit withSchemaValidation: ValidationMode) {
190190

191191
val valueAsts = unaryExpr match {
192192
case instanceOfExpr: InstanceOfExpr =>
193-
val t = registerType(instanceOfExpr.getCheckType.toQuotedString)
193+
val t = registerType(sootTypeToString(instanceOfExpr.getCheckType))
194194
astsForValue(op, parentUnit) ++ astForTypeRef(t)
195195
case castExpr: CastExpr =>
196-
val t = registerType(castExpr.getCastType.toQuotedString)
196+
val t = registerType(sootTypeToString(castExpr.getCastType))
197197
astForTypeRef(t) ++ astsForValue(op, parentUnit)
198198
case _ => astsForValue(op, parentUnit)
199199
}

joern-cli/frontends/jimple2cpg/src/main/scala/io/joern/jimple2cpg/astcreation/statements/AstForStatementsCreator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ trait AstForStatementsCreator(implicit withSchemaValidation: ValidationMode) { t
7777
assignStmt,
7878
Operators.assignment,
7979
s"$lhsCode = $rhsCode",
80-
Option(registerType(leftOp.getType.toQuotedString))
80+
Option(registerType(leftOp.getType.toString))
8181
)
8282
Seq(callAst(assignment, identifier ++ initAsts))
8383
}

0 commit comments

Comments
 (0)