Skip to content

Commit

Permalink
[dataflowengineoss] - Graceful Error Handling for AccessPathUsage (jo…
Browse files Browse the repository at this point in the history
…ernio#3893)

Added WARN log for missing node handling and continued with further processing. Added respective unit tests for the same. Note: This is not the fix, this will just unblock the further processing of the CPG.
  • Loading branch information
pandurangpatil authored Dec 5, 2023
1 parent 864026a commit a8e84b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ object AccessPathUsage {
val (base, tail) = toTrackedBaseAndAccessPathInternal(argOne.get)
val path = AccessPathHandling.memberAccessToPath(memberAccess, tail)
(base, path)
case _ =>
logger.warn(s"Missing handling for node type ${node.getClass}.")
(TrackedUnknown, Nil)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,4 +695,17 @@ class DataflowTest extends DataFlowCodeToCpgSuite {
sink.reachableBy(identifierSource).size shouldBe 1
}
}

"Field access on TemplatedDom directly" should {
val cpg = code("""
|import { useRouter } from "next/router";
|
|const tabComponentType = (<Tab title={"typeComponent"} />).type;
|
|""".stripMargin)
"Not throw error and get handled it gracefully" in {
val List(x) = cpg.identifier("tabComponentType").l
x.lineNumber shouldBe Some(4)
}
}
}

0 comments on commit a8e84b3

Please sign in to comment.