-
Notifications
You must be signed in to change notification settings - Fork 10
/
cndToQueries.py
58 lines (39 loc) · 1.8 KB
/
cndToQueries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from DBContentsProvider import DBContentsProvider
from PatchAnalysis.CheckToSinks import CheckToSinks
from PatchAnalysis.CheckToSubChecks import CheckToSubChecks
from DataFlowModeling.DataFlowModelCreator import DataFlowModelCreator
from CheckModeling.CheckOverlayCreator import CheckOverlayCreator
from QueryGeneration.ModelToQuery import ModelToQuery
from Debug.ModelPrinter import ModelPrinter
class APIFuncToQueries:
def run(self, checkId):
contentProvider = DBContentsProvider()
check2SubChecks = CheckToSubChecks(contentProvider)
subChecks = check2SubChecks.checkToSubChecks(checkId)
check2Sinks = CheckToSinks(contentProvider)
sinks = check2Sinks.checkToSink(checkId)
print sinks
if not sinks:
print 'No sinks.'
sys.exit()
modelCreator = DataFlowModelCreator(contentProvider)
overlayCreator = CheckOverlayCreator(contentProvider)
for sink in sinks:
sinkSymbol, callSiteId = sink
if 'log' in sinkSymbol: continue
print sinkSymbol
modelCreator.createDataFlowModels(sinkSymbol, callSiteId)
models = modelCreator.getModels()
overlayCreator.createForModels(models, subChecks)
models = overlayCreator.getModels()
converter = ModelToQuery()
for query in [converter.convert(model) for model in models]:
print query
# modelPrinter = ModelPrinter()
# modelPrinter.printSummary(models)
# modelPrinter.printAll(models)
if __name__ == '__main__':
import sys
checkId = sys.argv[1]
tool = APIFuncToQueries()
tool.run(checkId)