Joern can be enhanced via plugins. Plugins can...
- ... access the code property graph using the query language and create new nodes, edges and properties via the DiffGraph API.
- ... interface with arbitrary Java libraries to e.g., access the filesystem or network, or data analysis capabilities.
- ... add new node and edge types to the schema, or extend definitions of existing node and edge types
In the simplest case, plugins add queries to Joern, as for example the
query-database plugin does.
Plugins are distributed as zip files containing Java archives. They can be written in any JVM-based language, e.g., in Java, Scala, or Kotlin.
Joern comes with a few plugins pre-installed. You can list installed plugins using
New plugins can be added:
You can download an example plugin here for testing:
We provide a sample plugin written in Scala that you can use as a template. In order to build it yourself, make sure you have the following dependencies installed:
- OpenJDK 8 or higher
- The scala built tool (any version)
You can then install and test the sample plugin by running
This will install
joern in the sub directory
joern-inst and create
symbolic links in the working directory. Finally, it will add the sample
plugin to the aforementioned joern installation via
Now start joern:
and on the
joern shell, type
You should see the sample plugin named
gitextension in the overview
You can inspect and modify the options of the example plugin via
To run the extension on the shell, type
run.gitextension. This should
throw an exception, indicating that no projects are loaded.
Joern plugins can be developed in an IDE and the process of importing a plugin may differ slightly from IDE to IDE. The following instructions are for IntelliJ 2020.1.1.
Choose "Open or Import" to import the project.
Next, select the directory from the file selector. Assuming that your
IntelliJ installation has support for
sbt installed, the import is
Finally, navigate to
GitextentionTests. You can right-click on the class or the
individual tests to run them.
You can create a plugin ready for installation via
./joern --add-plugin by
You can add dependencies by modifying the variable
In order to extend the Code Property Graph schema specification in your
plugin, use the
in your build files, together with an extension of the original schema which
defines what will be extended. The
sample-plugin contains a working example
of the usage of the aforementioned packages in
schema/build.sbt, and an example
of the schema definition at
The example schema extension only adds a new node type
EXAMPLE_NODE and a new property
EXAMPLE_PROPERTY. The new property is added to both the new node type as well as an existing node type from the base schema.
The schema is defined in overflowdb-schema, which is a Scala DSL. I.e. you can open
sample-plugin in your favorite IDE (we recommend Intellij Idea) and get autocompletion, compiler feedback etc., which should help with creating your schema extension. For more inspiration you could explore the base cpg schema definition which is split across multiple files for modularity: https://github.com/ShiftLeftSecurity/codepropertygraph/tree/master/schema/src/main/scala/io/shiftleft/codepropertygraph/schema
To generate the domain classes and install the schema extension in your joern distribution (must be installed first), simply run
./install.sh in the sample-plugin.