Skip to content

Commit

Permalink
Export individual representations (#44)
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu authored Dec 21, 2023
1 parent 2489e1a commit 370aa44
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 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 := "1.1.0"
ThisBuild / version := "1.1.1"
ThisBuild / scalaVersion := "3.3.1"

val cpgVersion = "1.4.22"
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": "1.1.0",
"version": "1.1.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 = "1.1.0" %}
{% set version = "1.1.1" %}

package:
name: chen
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 = "1.1.0"
version = "1.1.1"
description = "Code Hierarchy Exploration Net (chen)"
authors = ["Team AppThreat <[email protected]>"]
license = "Apache-2.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.shiftleft.semanticcpg.language.types.structure

import better.files.File
import io.shiftleft.codepropertygraph.generated.*
import io.shiftleft.codepropertygraph.generated.nodes.*
import io.shiftleft.semanticcpg.language.*
Expand Down Expand Up @@ -264,4 +265,30 @@ class MethodTraversal(val traversal: Iterator[Method]) extends AnyVal:
end dot

def dot: ExportResult = dot(null)

def exportAllRepr(dotCfgDir: String = null): Unit =
var pathToUse = getOrCreateExportPath(dotCfgDir)
traversal
.foreach { method =>
val methodName = method.name
val methodFullName = method.fullName
val filename = method.location.filename
val methodHash = Fingerprinting.calculate_hash(methodFullName)
File(
pathToUse,
s"${methodName}-${sanitizeFilename(filename)}-${methodHash.slice(0, 8)}-ast.dot"
).write(method.dotAst.head)
File(
pathToUse,
s"${methodName}-${sanitizeFilename(filename)}-${methodHash.slice(0, 8)}-cdg.dot"
).write(method.dotCdg.head)
File(
pathToUse,
s"${methodName}-${sanitizeFilename(filename)}-${methodHash.slice(0, 8)}-cfg.dot"
).write(method.dotCfg.head)
}
end exportAllRepr

def exportAllRepr: Unit = exportAllRepr(null)

end MethodTraversal

0 comments on commit 370aa44

Please sign in to comment.