Joern:无需​​ neo4j-server 直接访问图数据库

Joern: access graph database directly without neo4j-server

joern documentation 说:

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

你怎么做到的?

运行之后 java -jar $JOERN/bin/joern.jar $CodeDirectory 在我的代码中,使用所有这些 .id 和 .db 文件创建了一个 Neo4J 数据库目录 (.joernIndex)。 是否有可能to access my code(有python-joern)没有 运行一个neo4j服务器? (需要服务器吗?)

此处记录了使用 Joern 数据库的 Web 界面方式:

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

python-joern 接口记录在此处:

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

和程序:

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

基本上 URL-way 与 Neo4J 服务器通信,这称为 Joern 的 "REST API"。

现在如果您想访问数据库 "directly",您可以使用一些 Java 程序,如下所示:

Loading all Neo4J db to RAM

或一些 python,如下所示:

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

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

但最重要的是,您仍将启动 Neo4J 数据库服务器,并且您的程序(通过 neo4j 驱动程序,启用基于网络的通信成为可能)与数据库服务器通信。

但是如果你想直接加载"database"文件,自己解析,然后提取数据,那就很难了。