Skip to content

Commit

Permalink
Export individual representations
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Dec 21, 2023
1 parent 09f40bd commit e6fa116
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 20 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/repotests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
./atom.sh usages --remove-atom -o /tmp/py4.atom -l python $GITHUB_WORKSPACE/repotests/django-DefectDojo -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/py4.usages.json
./atom.sh usages --remove-atom -o /tmp/c3.atom -l c $GITHUB_WORKSPACE/repotests/libexpat -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/c.usages.json
./atom.sh --remove-atom -o /tmp/java-sec-code.atom -l java $GITHUB_WORKSPACE/repotests/java-sec-code -Dlog4j.configurationFile=log4j2.xml --export-atom --export-dir gml_exports
./atom.sh --remove-atom -o /tmp/java-sec-code.atom -l java $GITHUB_WORKSPACE/repotests/java-sec-code -Dlog4j.configurationFile=log4j2.xml -x --export-dir gml_exports
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8"
Expand All @@ -150,9 +150,3 @@ jobs:
if: runner.os != 'Windows'
env:
JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8"
- run: |
cdxgen -t js -o $GITHUB_WORKSPACE/repotests/juice-shop/bom.json $GITHUB_WORKSPACE/repotests/juice-shop
./atom.sh reachables --remove-atom -o /tmp/juice-shop.atom -l js $GITHUB_WORKSPACE/repotests/juice-shop -Dlog4j.configurationFile=log4j2.xml --slice-outfile /tmp/juice-shop.reachables.json
env:
JAVA_TOOL_OPTIONS: "-Dfile.encoding=UTF-8"
if: runner.os != 'Windows'
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Usage: atom [parsedeps|data-flow|usages|reachables] [options] [input]
-l, --language <value> source language
--with-data-deps generate the atom with data-dependencies - defaults to `false`
--remove-atom do not persist the atom file - defaults to `false`
--export-atom export the atom file with data-dependencies to graphml - defaults to `false`
-x, --export-atom export the atom file with data-dependencies to graphml - defaults to `false`
--export-dir <value> export directory. Default: atom-exports
--file-filter <value> the name of the source file to generate slices from. Uses regex.
--method-name-filter <value>
Expand Down Expand Up @@ -140,6 +140,8 @@ The resulting graphml files could be imported into [Neo4j](https://neo4j.com/lab
atom -o app.atom -l java --export-atom --export-format dot --export-dir <export dir> <path to application>
```

In dot format, individual representations such as ast, cdg, and cfg would also get exported.

To also compute and include data-dependency graph (DDG) information in the exported files, pass `--with-data-deps`

```shell
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name := "atom"
ThisBuild / organization := "io.appthreat"
ThisBuild / version := "1.7.5"
ThisBuild / version := "1.8.0"
ThisBuild / scalaVersion := "3.3.1"

val chenVersion = "1.0.10"
val chenVersion = "1.1.1"

lazy val atom = Projects.atom

Expand Down
45 changes: 45 additions & 0 deletions codemeta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"@context": "https://doi.org/10.5063/schema/codemeta-2.0",
"@type": "SoftwareSourceCode",
"license": "https://spdx.org/licenses/Apache-2.0",
"codeRepository": "git+https://github.com/AppThreat/atom.git",
"contIntegration": "https://github.com/AppThreat/atom/actions",
"downloadUrl": "https://github.com/AppThreat/atom",
"issueTracker": "https://github.com/AppThreat/atom/issues",
"name": "atom",
"version": "1.8.0",
"description": ".",
"applicationCategory": "code-analysis",
"keywords": [
"static-analysis",
"code-analysis",
"dependency-analysis",
"code-hierarchy-analysis",
"static-slicer",
"reachability-analysis"
],
"programmingLanguage": [
"Scala 3",
"Node.js"
],
"runtimePlatform": [
"JVM"
],
"operatingSystem": [
"Linux",
"Windows",
"MacOS"
],
"softwareRequirements": [
"Java >= 21",
"Node.js >= 16"
],
"author": [
{
"@type": "Person",
"givenName": "Team",
"familyName": "AppThreat",
"email": "cloud@appthreat.com"
}
]
}
20 changes: 13 additions & 7 deletions src/main/scala/io/appthreat/atom/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ object Atom:
val DEFAULT_ATOM_OUT_FILE: String =
if Properties.isWin || Charset.defaultCharset() != Charset.forName("UTF-8") then "app.atom"
else "app.⚛"
val DEFAULT_SLICE_OUT_FILE = "slices.json"
val DEFAULT_SLICE_DEPTH = 7
val DEFAULT_MAX_DEFS: Int = 2000
val FRAMEWORK_INPUT_TAG: String = "framework-input"
val FRAMEWORK_OUTPUT_TAG: String = "framework-output"
val DEFAULT_EXPORT_DIR: String = "atom-exports"
val DEFAULT_SLICE_OUT_FILE = "slices.json"
val DEFAULT_SLICE_DEPTH = 7
val DEFAULT_MAX_DEFS: Int = 2000
val FRAMEWORK_INPUT_TAG: String = "framework-input"
val FRAMEWORK_OUTPUT_TAG: String = "framework-output"
val DEFAULT_EXPORT_DIR: String = "atom-exports"
// Possible values: graphml, dot
val DEFAULT_EXPORT_FORMAT: String = "graphml"
// Possible values: no-delombok, default, types-only, run-delombok
private val DEFAULT_DELOMBOK_MODE: String =
Expand Down Expand Up @@ -126,7 +127,7 @@ object Atom:
case config: AtomConfig => config.withRemoveAtom(true)
case _ => c
)
opt[Unit]("export-atom")
opt[Unit]('x', "export-atom")
.text("export the atom file with data-dependencies to graphml - defaults to `false`")
.action((_, c) =>
c match
Expand Down Expand Up @@ -323,9 +324,14 @@ object Atom:
_.name.startsWith("lambda")
).gml(x.exportDir)
case _ =>
// Export all representations
ag.method.internal.filterNot(_.name.startsWith("<")).filterNot(
_.name.startsWith("lambda")
).dot(x.exportDir)
// Export individual representations
ag.method.internal.filterNot(_.name.startsWith("<")).filterNot(
_.name.startsWith("lambda")
).exportAllRepr(x.exportDir)
case _: DataFlowConfig =>
val dataFlowSlice = sliceCpg(ag).collect { case x: DataFlowSlice => x }
val atomDataFlowSliceJson =
Expand Down
4 changes: 2 additions & 2 deletions wrapper/nodejs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wrapper/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appthreat/atom",
"version": "1.7.5",
"version": "1.8.0",
"description": "Create atom (⚛) representation for your application, packages and libraries",
"exports": "./index.js",
"type": "module",
Expand Down

0 comments on commit e6fa116

Please sign in to comment.