Skip to content

Commit

Permalink
Ruby reachables
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu committed Jan 13, 2025
1 parent 00ce822 commit af028e1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 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 := "2.3.0"
ThisBuild / version := "2.3.1"
ThisBuild / scalaVersion := "3.6.2"

val cpgVersion = "1.0.1"
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"downloadUrl": "https://github.com/AppThreat/chen",
"issueTracker": "https://github.com/AppThreat/chen/issues",
"name": "chen",
"version": "2.3.0",
"version": "2.3.1",
"description": "Code Hierarchy Exploration Net (chen) is an advanced exploration toolkit for your application source code and its dependency hierarchy.",
"applicationCategory": "code-analysis",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "2.3.0" %}
{% set version = "2.3.1" %}

package:
name: chen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ class ConfigFileCreationPass(cpg: Cpg) extends XConfigFileCreationPass(cpg):
// XML files
extensionFilter(".xml"),
// ERB files
extensionFilter(".erb")
extensionFilter(".erb"),
pathEndFilter("bom.json"),
pathEndFilter(".cdx.json"),
pathEndFilter("chennai.json")
)
end ConfigFileCreationPass
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ class CdxPass(atom: Cpg) extends CpgPass(atom):
else
str

private def toRubyModuleForm(str: String) =
if str.nonEmpty then
s".*(::)?${str.split("::").head}(::).*"
else
str

override def run(dstGraph: DiffGraphBuilder): Unit =
atom.configFile.name(BOM_JSON_FILE).content.foreach { cdxData =>
val cdxJson = parse(cdxData).getOrElse(Json.Null)
Expand Down Expand Up @@ -161,14 +167,28 @@ class CdxPass(atom: Cpg) extends CpgPass(atom):
bpkg.replace(File.separator, Pattern.quote(File.separator))
if language == Languages.PYTHON || language == Languages.PYTHONSRC
then bpkg = toPyModuleForm(bpkg)
if language == Languages.RUBYSRC
then bpkg = toRubyModuleForm(bpkg)
if language == Languages.PHP
then
bpkg = bpkg.replaceAll("""\\""", """\\\\""")
bpkg = s"""$bpkg.*"""
if bpkg.nonEmpty && !donePkgs.contains(bpkg) then
donePkgs.put(bpkg, true)
// Ruby
if language == Languages.RUBYSRC
then
atom.call.code(bpkg).argument.newTagNode(
compPurl
).store()(dstGraph)
atom.call.code(bpkg).receiver.newTagNode(
s"$compType-value"
).store()(dstGraph)
atom.call.code(bpkg).callee(NoResolve).isMethod.parameter.newTagNode(
s"$compType-input"
).store()(dstGraph)
// C/C++
if language == Languages.NEWC || language == Languages.C
else if language == Languages.NEWC || language == Languages.C
then
atom.method.fullNameExact(bpkg).callIn(
NoResolve
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 = "2.3.0"
version = "2.3.1"
description = "Code Hierarchy Exploration Net (chen)"
authors = ["Team AppThreat <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit af028e1

Please sign in to comment.