Skip to content

Commit 74c3a2e

Browse files
Update Joern version to remove CLOSURE_ORIGINAL_NAME (#366)
We are using x2cpg VariableScopeManager which does not set the CLOSURE_ORIGINAL_NAME from version 4.0.384 onwards. For: ShiftLeftSecurity/codescience#8347
1 parent 995c47d commit 74c3a2e

File tree

2 files changed

+22
-34
lines changed

2 files changed

+22
-34
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
val cpgVersion = "1.7.37"
2-
val joernVersion = "4.0.383"
2+
val joernVersion = "4.0.384"
33

44
val gitCommitString = SettingKey[String]("gitSha")
55

src/test/scala/io/shiftleft/js2cpg/passes/MixedAstCreationPassTest.scala

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,17 @@ class MixedAstCreationPassTest extends AbstractPassTest {
188188
val List(barRef) = fooBlock.astChildren.isCall.astChildren.isMethodRef.l
189189
val List(closureBinding) = barRef.captureOut.l
190190
closureBinding.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
191-
closureBinding.closureOriginalName shouldBe Option("x")
192191
closureBinding.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
193192

194-
closureBinding.refOut.head shouldBe fooLocalX
193+
closureBinding.refOut.l shouldBe List(fooLocalX)
195194

196195
val List(barMethod) = cpg.method.nameExact("bar").l
197196
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
198197
val List(barLocals) = barMethodBlock.astChildren.isLocal.l
199198
barLocals.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
200199

201200
val List(identifierX) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
202-
identifierX.refOut.head shouldBe barLocals
201+
identifierX.refOut.l shouldBe List(barLocals)
203202
}
204203

205204
"have correct closure binding (two variables)" in AstFixture("""
@@ -219,15 +218,13 @@ class MixedAstCreationPassTest extends AbstractPassTest {
219218

220219
val List(closureBindForY, closureBindForX) = barRef.captureOut.l
221220

222-
closureBindForX.closureOriginalName shouldBe Option("x")
223221
closureBindForX.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
224222
closureBindForX.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
225-
closureBindForX.refOut.head shouldBe fooLocalX
223+
closureBindForX.refOut.l shouldBe List(fooLocalX)
226224

227-
closureBindForY.closureOriginalName shouldBe Option("y")
228225
closureBindForY.closureBindingId shouldBe Option("code.js::program:foo:bar:y")
229226
closureBindForY.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
230-
closureBindForY.refOut.head shouldBe fooLocalY
227+
closureBindForY.refOut.l shouldBe List(fooLocalY)
231228

232229
val List(barMethod) = cpg.method.nameExact("bar").l
233230
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
@@ -237,13 +234,13 @@ class MixedAstCreationPassTest extends AbstractPassTest {
237234
barLocalsForX.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
238235

239236
val List(identifierX) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
240-
identifierX.refOut.head shouldBe barLocalsForX
237+
identifierX.refOut.l shouldBe List(barLocalsForX)
241238

242239
barLocalsForY.name shouldBe "y"
243240
barLocalsForY.closureBindingId shouldBe Option("code.js::program:foo:bar:y")
244241

245242
val List(identifierY) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("y").l
246-
identifierY.refOut.head shouldBe barLocalsForY
243+
identifierY.refOut.l shouldBe List(barLocalsForY)
247244
}
248245

249246
"have correct closure binding for capturing over 2 levels" in AstFixture("""
@@ -263,9 +260,8 @@ class MixedAstCreationPassTest extends AbstractPassTest {
263260

264261
val List(closureBindingXInFoo) = barRef.captureOut.l
265262
closureBindingXInFoo.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
266-
closureBindingXInFoo.closureOriginalName shouldBe Option("x")
267263
closureBindingXInFoo.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
268-
closureBindingXInFoo.refOut.head shouldBe fooLocalX
264+
closureBindingXInFoo.refOut.l shouldBe List(fooLocalX)
269265

270266
val List(barMethod) = cpg.method.nameExact("bar").l
271267
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
@@ -274,22 +270,21 @@ class MixedAstCreationPassTest extends AbstractPassTest {
274270
barLocalX.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
275271

276272
val List(barIdentifierX) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
277-
barIdentifierX.refOut.head shouldBe barLocalX
273+
barIdentifierX.refOut.l shouldBe List(barLocalX)
278274

279275
val List(bazRef) = barMethodBlock.astChildren.isCall.astChildren.isMethodRef.l
280276
val List(closureBindingXInBar) = bazRef.captureOut.l
281277
closureBindingXInBar.closureBindingId shouldBe Option("code.js::program:foo:bar:baz:x")
282-
closureBindingXInBar.closureOriginalName shouldBe Option("x")
283278
closureBindingXInBar.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
284-
closureBindingXInBar.refOut.head shouldBe barLocalX
279+
closureBindingXInBar.refOut.l shouldBe List(barLocalX)
285280

286281
val List(bazMethod) = cpg.method.nameExact("baz").l
287282
val List(bazMethodBlock) = bazMethod.astChildren.isBlock.l
288283
val List(bazLocalX) = bazMethodBlock.astChildren.isLocal.nameExact("x").l
289284
bazLocalX.closureBindingId shouldBe Option("code.js::program:foo:bar:baz:x")
290285

291286
val List(bazIdentifierX) = bazMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
292-
bazIdentifierX.refOut.head shouldBe bazLocalX
287+
bazIdentifierX.refOut.l shouldBe List(bazLocalX)
293288
}
294289

295290
"have correct closure binding for capturing over 2 levels with intermediate blocks" in AstFixture("""
@@ -312,9 +307,8 @@ class MixedAstCreationPassTest extends AbstractPassTest {
312307
val List(barRef) = fooBlock.astChildren.isCall.astChildren.isMethodRef.l
313308
val List(closureBindingXInFoo) = barRef.captureOut.l
314309
closureBindingXInFoo.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
315-
closureBindingXInFoo.closureOriginalName shouldBe Option("x")
316310
closureBindingXInFoo.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
317-
closureBindingXInFoo.refOut.head shouldBe fooLocalX
311+
closureBindingXInFoo.refOut.l shouldBe List(fooLocalX)
318312

319313
val List(barMethod) = cpg.method.nameExact("bar").l
320314
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
@@ -323,15 +317,14 @@ class MixedAstCreationPassTest extends AbstractPassTest {
323317
barLocalX.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
324318

325319
val List(barIdentifierX) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
326-
barIdentifierX.refOut.head shouldBe barLocalX
320+
barIdentifierX.refOut.l shouldBe List(barLocalX)
327321

328322
val List(barMethodInnerBlock) = barMethodBlock.astChildren.isBlock.l
329323
val List(bazRef) = barMethodInnerBlock.astChildren.isCall.astChildren.isMethodRef.l
330324
val List(closureBindingXInBar) = bazRef.captureOut.l
331325
closureBindingXInBar.closureBindingId shouldBe Option("code.js::program:foo:bar:baz:x")
332-
closureBindingXInBar.closureOriginalName shouldBe Option("x")
333326
closureBindingXInBar.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
334-
closureBindingXInBar.refOut.head shouldBe barLocalX
327+
closureBindingXInBar.refOut.l shouldBe List(barLocalX)
335328

336329
val List(bazMethod) = cpg.method.nameExact("baz").l
337330
val List(bazMethodBlock) = bazMethod.astChildren.isBlock.l
@@ -341,7 +334,7 @@ class MixedAstCreationPassTest extends AbstractPassTest {
341334

342335
val List(bazMethodInnerBlock) = bazMethodBlock.astChildren.isBlock.l
343336
val List(bazIdentifierX) = bazMethodInnerBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
344-
bazIdentifierX.refOut.head shouldBe bazLocalX
337+
bazIdentifierX.refOut.l shouldBe List(bazLocalX)
345338
}
346339

347340
"have correct closure binding for capturing over 2 levels with no intermediate use" in AstFixture("""
@@ -359,9 +352,8 @@ class MixedAstCreationPassTest extends AbstractPassTest {
359352
val List(barRef) = fooBlock.astChildren.isCall.astChildren.isMethodRef.l
360353
val List(closureBindingXInFoo) = barRef.captureOut.l
361354
closureBindingXInFoo.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
362-
closureBindingXInFoo.closureOriginalName shouldBe Option("x")
363355
closureBindingXInFoo.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
364-
closureBindingXInFoo.refOut.head shouldBe fooLocalX
356+
closureBindingXInFoo.refOut.l shouldBe List(fooLocalX)
365357

366358
val List(barMethod) = cpg.method.nameExact("bar").l
367359
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
@@ -372,9 +364,8 @@ class MixedAstCreationPassTest extends AbstractPassTest {
372364
val List(bazRef) = barMethodBlock.astChildren.isCall.astChildren.isMethodRef.l
373365
val List(closureBindingXInBar) = bazRef.captureOut.l
374366
closureBindingXInBar.closureBindingId shouldBe Option("code.js::program:foo:bar:baz:x")
375-
closureBindingXInBar.closureOriginalName shouldBe Option("x")
376367
closureBindingXInBar.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
377-
closureBindingXInBar.refOut.head shouldBe barLocalX
368+
closureBindingXInBar.refOut.l shouldBe List(barLocalX)
378369

379370
val List(bazMethod) = cpg.method.nameExact("baz").l
380371
val List(bazMethodBlock) = bazMethod.astChildren.isBlock.l
@@ -383,7 +374,7 @@ class MixedAstCreationPassTest extends AbstractPassTest {
383374
bazLocalX.closureBindingId shouldBe Option("code.js::program:foo:bar:baz:x")
384375

385376
val List(bazIdentifierX) = bazMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
386-
bazIdentifierX.refOut.head shouldBe bazLocalX
377+
bazIdentifierX.refOut.l shouldBe List(bazLocalX)
387378
}
388379

389380
"have correct closure binding for capturing the same variable into 2 different anonymous methods" in AstFixture("""
@@ -401,17 +392,15 @@ class MixedAstCreationPassTest extends AbstractPassTest {
401392

402393
val List(closureBindingXAnon1) = anon1Ref.captureOut.l
403394
closureBindingXAnon1.closureBindingId shouldBe Option("code.js::program:foo:anonymous:x")
404-
closureBindingXAnon1.closureOriginalName shouldBe Option("x")
405395
closureBindingXAnon1.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
406-
closureBindingXAnon1.refOut.head shouldBe fooLocalX
396+
closureBindingXAnon1.refOut.l shouldBe List(fooLocalX)
407397

408398
val List(anon2Ref) =
409399
fooBlock.astChildren.isCall.astChildren.isMethodRef.methodFullNameExact("code.js::program:foo:anonymous1").l
410400
val List(closureBindingXAnon2) = anon2Ref.captureOut.l
411401
closureBindingXAnon2.closureBindingId shouldBe Option("code.js::program:foo:anonymous1:x")
412-
closureBindingXAnon2.closureOriginalName shouldBe Option("x")
413402
closureBindingXAnon2.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
414-
closureBindingXAnon2.refOut.head shouldBe fooLocalX
403+
closureBindingXAnon2.refOut.l shouldBe List(fooLocalX)
415404
}
416405

417406
"have correct closure bindings" in AstFixture("""
@@ -427,17 +416,16 @@ class MixedAstCreationPassTest extends AbstractPassTest {
427416
val List(barRef) = fooBlock.astChildren.isCall.astChildren.isMethodRef.l
428417
val List(closureBinding) = barRef.captureOut.l
429418
closureBinding.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
430-
closureBinding.closureOriginalName shouldBe Option("x")
431419
closureBinding.evaluationStrategy shouldBe EvaluationStrategies.BY_REFERENCE
432-
closureBinding.refOut.head shouldBe fooLocalX
420+
closureBinding.refOut.l shouldBe List(fooLocalX)
433421

434422
val List(barMethod) = cpg.method.nameExact("bar").l
435423
val List(barMethodBlock) = barMethod.astChildren.isBlock.l
436424
val List(barLocals) = barMethodBlock.astChildren.isLocal.l
437425
barLocals.closureBindingId shouldBe Option("code.js::program:foo:bar:x")
438426

439427
val List(identifierX) = barMethodBlock.astChildren.isCall.astChildren.isIdentifier.nameExact("x").l
440-
identifierX.refOut.head shouldBe barLocals
428+
identifierX.refOut.l shouldBe List(barLocals)
441429
}
442430

443431
"have correct method full names for scoped anonymous functions" in AstFixture("""

0 commit comments

Comments
 (0)