0

The joern documentation says:

It is possible to access the graph database directly from your scripts by loading the database into memory on script startup.

How can you do that?

After running java -jar $JOERN/bin/joern.jar $CodeDirectory over my code, a Neo4J database directory (.joernIndex) is created with all these .id- and .db-files. Is it possible to access my code (with python-joern) without running a neo4j server? (Is the server necessary?)

user1511417
  • 1,880
  • 3
  • 20
  • 41

1 Answers1

0

The web interface way to use the Joern database is documented here:

http://joern.readthedocs.io/en/latest/import.html

And the python-joern interface is documented here:

http://joern.readthedocs.io/en/latest/access.html#python-joern-api

And the program:

from joern.all import JoernSteps

j = JoernSteps()

j.setGraphDbURL('http://localhost:7474/db/data/')

# j.addStepsDir('Use this to inject utility traversals')

j.connectToDatabase()

res =  j.runGremlinQuery('getFunctionsByName("main")')
res =  j.runCypherQuery('...')

for r in res: print r

basically the URL-way to talk to the Neo4J server, and this is called Joern's "REST API".

Now if you want to access the database "directly", you can using some Java program as shown here:

Loading all Neo4J db to RAM

Or some python as shown here:

https://neo4j.com/developer/python/

https://marcobonzanini.com/2015/04/06/getting-started-with-neo4j-and-python/

But bottomline you are still going to start the Neo4J database server, and your program (via neo4j driver, which enable network based communication possible) talk to the database server.

But if you want to load the "database" files directly, parsed it yourself, and extract out the data then it is going to be hard.

Community
  • 1
  • 1
Peter Teoh
  • 6,337
  • 4
  • 42
  • 58