octopus-platform / joern

A robust parser for C/C++ storing abstract syntax trees, control flow graphs and program dependence graphs in a neo4j graph database.
http://mlsec.org/joern
GNU Lesser General Public License v3.0
546 stars 140 forks source link

joern-plot-proggraph giving back empty dot files #149

Open rmmilewi opened 7 years ago

rmmilewi commented 7 years ago

Hello! I'll preface this by saying that I'm not quite sure if this is an issue or me not fully understanding how to make best use of joern. So let's say that I have a vertex like this:

{'id': 243204216, 'label': 'vertex', 'type': 'vertex', 'properties': {'code': [{'id': '35cu1b-40spko-3yd', 'value': 'main'}], 'location': [{'id': '35cufj-40spko-27t1', 'value': '131:0:5973:6992'}], '_key': [{'id': '35ct8v-40spko-sl', 'value': '297308'}], 'type': [{'id': '35ctn3-40spko-1l1', 'value': 'Function'}]}}

And I'm interested in plotting any edges that flow out from that node, of which there are many. I've noticed that when I pass joern-plot-proggraph the id, I always get back an empty graph.

echo 243204216 | joern-plot-proggraph mycode.tar.gz -all -P //243204216 digraph "" { } //###

On the other hand, I can use Gremlin queries to trace my way from that starting vertex to all its descendants, so I would expect the dot file to be... not empty. Maybe I'm just using the tool in the wrong way.

Thanks!

P.S. (Bonus question): If I use joern in an academic paper, and I wanted to heap glowing praise on the tool and its authors, are there any works that I should cite?

LPhD commented 6 years ago

It seems there is a problem in the documentation: When you use the the id (not the _key value), you should not pass the -P flag. Without the flag, there occurs another issue: File "...local/lib/python3.5/site-packages/octopus/shelltool/ResultProcessor.py", line 16, in properties return self.result['properties'] KeyError: 'properties'

To fix this, just remove the ['properties'] in line 16 of ResultProcessor.py. Rebuild your project and it will work.