-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adde DYNAMIC_TYPE_HINT_FULL_NAME on literal nodes. (#3832)
* Adde DYNAMIC_TYPE_HINT_FULL_NAME on literal nodes. This is required as type anchor for type resolution. * Add support for bytes literals.
- Loading branch information
Showing
7 changed files
with
75 additions
and
33 deletions.
There are no files selected for viewing
9 changes: 7 additions & 2 deletions
9
joern-cli/frontends/pysrc2cpg/src/main/scala/io/joern/pysrc2cpg/Constants.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package io.joern.pysrc2cpg | ||
|
||
object Constants { | ||
val ANY = "ANY" | ||
val GLOBAL_NAMESPACE = "<global>" | ||
val ANY = "ANY" | ||
val GLOBAL_NAMESPACE = "<global>" | ||
val builtinStrType = "builtin.str" | ||
val builtinBytesType = "builtin.bytes" | ||
val builtinIntType = "builtin.int" | ||
val builtinFloatType = "builtin.float" | ||
val builtinComplexType = "builtin.complex" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...-cli/frontends/pysrc2cpg/src/test/scala/io/joern/pysrc2cpg/cpg/BytesLiteralCpgTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.joern.pysrc2cpg.cpg | ||
|
||
import io.joern.pysrc2cpg.{Constants, Py2CpgTestContext} | ||
import io.shiftleft.semanticcpg.language.* | ||
import org.scalatest.freespec.AnyFreeSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class BytesLiteralCpgTests extends AnyFreeSpec with Matchers { | ||
lazy val cpg = Py2CpgTestContext.buildCpg("""b"123"""".stripMargin) | ||
|
||
"test num literal node properties" in { | ||
val literal = cpg.literal.head | ||
literal.code shouldBe "b\"123\"" | ||
literal.typeFullName shouldBe Constants.ANY | ||
literal.dynamicTypeHintFullName should contain only (Constants.builtinBytesType) | ||
literal.lineNumber shouldBe Some(1) | ||
literal.columnNumber shouldBe Some(1) | ||
} | ||
} |
10 changes: 6 additions & 4 deletions
10
.../io/joern/pysrc2cpg/cpg/NumCpgTests.scala → ...rn/pysrc2cpg/cpg/IntLiteralCpgTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 5 additions & 3 deletions
8
.../io/joern/pysrc2cpg/cpg/StrCpgTests.scala → ...rn/pysrc2cpg/cpg/StrLiteralCpgTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters