Skip to content

Commit

Permalink
Support for .cdx.json
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Oct 11, 2023
1 parent d281cbf commit f8f3f69
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := "chen"
ThisBuild / organization := "io.appthreat"
ThisBuild / version := "0.0.13"
ThisBuild / version := "0.0.14"
ThisBuild / scalaVersion := "3.3.1"

val cpgVersion = "1.4.22"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg) {
extensionFilter(".build"),
pathEndFilter("CMakeLists.txt"),
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json"),
pathEndFilter("setup.cfg"),
pathEndFilter("setup.py")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg) {
pathEndFilter("AndroidManifest.xml"),
// Bom
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg) {
pathEndFilter("AndroidManifest.xml"),
// Bom
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json")
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import better.files.File
import io.appthreat.x2cpg.passes.frontend.XConfigFileCreationPass
import io.shiftleft.codepropertygraph.Cpg

class ConfigFileCreationPass(cpg: Cpg, requirementsTxt: String = "requirement.txt")
class ConfigFileCreationPass(cpg: Cpg, requirementsTxt: String = "requirements.txt")
extends XConfigFileCreationPass(cpg) {

override val configFileFilters: List[File => Boolean] = List(
Expand All @@ -16,6 +16,7 @@ class ConfigFileCreationPass(cpg: Cpg, requirementsTxt: String = "requirement.tx
extensionFilter(".yaml"),
extensionFilter(".lock"),
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json"),
pathEndFilter("setup.cfg"),
// Requirements.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class CdxPass(cpg: Cpg) extends CpgPass(cpg) {

private def containsRegex(str: String) = Pattern.quote(str) == str

private val BOM_JSON_FILE = "bom.json"
private val BOM_JSON_FILE = ".*(bom|cdx).json"

override def run(dstGraph: DiffGraphBuilder): Unit = {
cpg.configFile(BOM_JSON_FILE).content.foreach { cdxData =>
cpg.configFile.name(BOM_JSON_FILE).content.foreach { cdxData =>
val cdxJson = parse(cdxData).getOrElse(Json.Null)
val cursor: HCursor = cdxJson.hcursor
val components = cursor.downField("components").focus.flatMap(_.asArray).getOrElse(Vector.empty)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "appthreat-chen"
version = "0.0.13"
version = "0.0.14"
description = "Code Hierarchy Exploration Net (chen)"
authors = ["Team AppThreat <cloud@appthreat.com>"]
license = "Apache-2.0"
Expand Down

0 comments on commit f8f3f69

Please sign in to comment.