Skip to content

Commit

Permalink
Standalone EXT template
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Jun 11, 2023
1 parent 821938d commit e0c33c6
Show file tree
Hide file tree
Showing 163 changed files with 47,271 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cpg.bin
target/
.idea/
/.bsp
/joern-inst
/workspace
5 changes: 5 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version = 3.5.1
runner.dialect = scala213
preset = IntelliJ
maxColumn = 120
align.preset = true
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Sample standalone application on top of joern
=============================================

A program that makes use of Joern to create a CPG and list all method
names:

```
sbt stage
./standalone -Dlog4j.configurationFile=log4j2.xml
```
49 changes: 49 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name := "standalone"
ThisBuild/organization := "org.codeminers"
ThisBuild/scalaVersion := "2.13.8"

// parsed by project/Versions.scala, updated by updateDependencies.sh
val cpgVersion = "1.3.612"
val joernVersion = "1.2.3"
val overflowdbVersion = "1.179"

lazy val schema = Projects.schema
lazy val domainClasses = Projects.domainClasses
lazy val schemaExtender = Projects.schemaExtender

dependsOn(domainClasses)

libraryDependencies ++= Seq(
"com.github.pathikrit" %% "better-files" % "3.9.2",
"com.github.scopt" %% "scopt" % "4.1.0",
"org.apache.logging.log4j" % "log4j-slf4j2-impl" % "2.20.0" % Optional,
"io.joern" %% "x2cpg" % Versions.joern,
"io.joern" %% "javasrc2cpg" % Versions.joern,
"io.joern" %% "joern-cli" % Versions.joern,
"io.joern" %% "semanticcpg" % Versions.joern,
"io.joern" %% "semanticcpg" % Versions.joern % Test classifier "tests",
"org.scalatest" %% "scalatest" % "3.2.15" % Test
)


ThisBuild/Compile/scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-language:implicitConversions",
)

enablePlugins(JavaAppPackaging)

ThisBuild/licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0"))

Global/onChangedBuildSource := ReloadOnSourceChanges

ThisBuild / resolvers ++= Seq(
Resolver.mavenLocal,
"Sonatype OSS" at "https://oss.sonatype.org/content/repositories/public",
"Atlassian" at "https://packages.atlassian.com/mvn/maven-atlassian-external",
"Gradle Releases" at "https://repo.gradle.org/gradle/libs-releases/"
)

Compile/doc/sources := Seq.empty
Compile/packageDoc/publishArtifact := false
11 changes: 11 additions & 0 deletions domain-classes/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name := "joern-standalone-domain-classes"

libraryDependencies += "io.shiftleft" %% "overflowdb-traversal" % Versions.overflowdb

lazy val generatedSrcDir = settingKey[File]("root for generated sources - we want to check those in")
generatedSrcDir := (Compile/sourceDirectory).value / "generated"

Compile/unmanagedSourceDirectories += generatedSrcDir.value
Compile/compile := (Compile/compile).dependsOn(Projects.schema/Compile/generateDomainClasses).value

Compile / scalacOptions --= Seq("-Xfatal-warnings", "-Wunused", "-Ywarn-unused")
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package io.shiftleft.codepropertygraph.generated;

import overflowdb.*;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class ControlStructureTypes {

/** Represents a break statement. Labeled breaks are expected to have a JUMP_LABEL
node AST child with ORDER 1 */
public static final String BREAK = "BREAK";

/** Represents a continue statement. Labeled continues are expected to have a JUMP_LABEL
node AST child with ORDER 1 */
public static final String CONTINUE = "CONTINUE";

/** Represents a while statement */
public static final String WHILE = "WHILE";

/** Represents a do statement */
public static final String DO = "DO";

/** Represents a for statement */
public static final String FOR = "FOR";

/** Represents a goto statement */
public static final String GOTO = "GOTO";

/** Represents an if statement */
public static final String IF = "IF";

/** Represents an else statement */
public static final String ELSE = "ELSE";

/** Represents a switch statement */
public static final String SWITCH = "SWITCH";

/** Represents a try statement */
public static final String TRY = "TRY";

/** Represents a throw statement */
public static final String THROW = "THROW";

/** Represents a match expression */
public static final String MATCH = "MATCH";

/** Represents a yield expression */
public static final String YIELD = "YIELD";


public static Set<String> ALL = new HashSet<String>() {{
add(BREAK);
add(CONTINUE);
add(WHILE);
add(DO);
add(FOR);
add(GOTO);
add(IF);
add(ELSE);
add(SWITCH);
add(TRY);
add(THROW);
add(MATCH);
add(YIELD);
}};

}
Loading

0 comments on commit e0c33c6

Please sign in to comment.