Joern:访问图直接数据库而不Neo4j的服务器
问题描述:
的joern documentation说:Joern:访问图直接数据库而不Neo4j的服务器
它可以从你的脚本 由数据库加载到内存中的脚本启动直接访问图形数据库。
你怎么能这样做?
在我的代码上运行 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
而蟒蛇-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
基本上是与Neo4J服务器交谈的URL方式,这被称为Joern的“REST API”。
现在如果你想访问 “直接” 的数据库,你可以使用一些Java程序如下所示:
或者一些Python如下所示:
https://neo4j.com/developer/python/
https://marcobonzanini.com/2015/04/06/getting-started-with-neo4j-and-python/
但底线你还是要开始Neo 4J数据库服务器,并且您的程序(通过neo4j驱动程序,使基于网络的通信成为可能)与数据库服务器交谈。
但是,如果你想直接加载“数据库”文件,自己解析它,并提取出数据,那么它将很难。