class ChunkStartTool(CmdLineTool): def __init__(self, DESCRIPTION): CmdLineTool.__init__(self, DESCRIPTION) # @Override def _constructIdQuery(self): pass # @Override def _constructQueryForChunk(self, chunk): pass # @Override def handleChunkResult(self, res, chunk): pass # @Override def _start(self): pass def _stop(self): pass def _runImpl(self): self.dbInterface = DBInterface() self.dbInterface.connectToDatabase() self._start() query = self._constructIdQuery() ids = self.dbInterface.runGremlinQuery(query) for chunk in self.dbInterface.chunks(ids, CHUNK_SIZE): query = self._constructQueryForChunk(chunk) res = self.dbInterface.runGremlinQuery(query) self._handleChunkResult(res, chunk) self._stop()
#!/usr/bin/env python3 from octopus.server.DBInterface import DBInterface projectName = 'android.tar.gz' query = "queryNodeIndex('type:Function').id" db = DBInterface() db.connectToDatabase(projectName) ids = db.runGremlinQuery(query) CHUNK_SIZE = 256 LOCATION = '/home/sid/RABBIT_HOLE/CODE_ANALYSIS/joern/projects/octopus/data/projects/' for chunk in db.chunks(ids, CHUNK_SIZE): query = """ getCallsToRegex(".*read(Int|Uint)(32|64)") .statements() .out("REACHES") .has("code",textRegex(".*(malloc|memcpy).*")) .functions() .functionToLocationStr() """ query2 = """ getNodesWithTypeAndName(TYPE_FUNCTION, '*onTransact*') .out(FUNCTION_TO_AST_EDGE) .getArguments('(memcpy OR malloc)', '2') .out(USES_EDGE) .filter{