Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 0ab7022

Browse files
authored
Normalize paths stored in FILE nodes (#147)
* Normalize path. * scalafmt.
1 parent 167eb2c commit 0ab7022

File tree

3 files changed

+2
-2
lines changed

3 files changed

+2
-2
lines changed

src/main/scala/io/shiftleft/fuzzyc2cpg/FuzzyC2Cpg.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class FuzzyC2Cpg(outputModuleFactory: CpgOutputModuleFactory) {
117117

118118
def createFileNode(pathToFile: Path): Node = {
119119
newNode(NodeType.FILE)
120-
.addStringProperty(NodePropertyName.NAME, pathToFile.toAbsolutePath.toString)
120+
.addStringProperty(NodePropertyName.NAME, pathToFile.toAbsolutePath.normalize.toString)
121121
.build()
122122
}
123123

src/test/scala/io/shiftleft/fuzzyc2cpg/ProgramStructureTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ProgramStructureTests extends WordSpec with Matchers {
2525
.value(NodeKeys.NAME)
2626
.headOption
2727
fileName.isDefined shouldBe true
28+
fileName.head should not contain ".."
2829
fileName.head should not be "src/test/resources/testcode/structure/structure.c"
2930
fileName.head should endWith("src/test/resources/testcode/structure/structure.c")
3031
}

src/test/scala/io/shiftleft/fuzzyc2cpg/cfg/AstToCfgTests.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class AstToCfgTests extends WordSpec with Matchers {
4747
override def addNodeProperty(nodeBuilder: CfgNode, property: NodeProperty, value: Boolean): Unit = ???
4848
override def addNodeProperty(nodeBuilder: CfgNode, property: NodeProperty, value: List[String]): Unit = ???
4949

50-
5150
override def createEdgeBuilder(dst: CfgNode, src: CfgNode, edgeKind: EdgeKind): CfgNodeEdgePairBuilder = {
5251
if (src.successors.exists(_.cfgNode == dst)) {
5352
throw new RuntimeException("Found duplicate edge.")

0 commit comments

Comments
 (0)