11
11
12
12
def printHelp ():
13
13
print ("""Usage:
14
- python3 GenerateFlowModel.py <library-database> <outputQll> [--with-sinks] [--with-sources] [--with-summaries]
14
+ python3 GenerateFlowModel.py <library-database> <outputQll> [--with-sinks] [--with-sources] [--with-summaries] [--dry-run]
15
15
16
16
This generates summary, source and sink models for the code in the database.
17
17
The files will be placed in `java/ql/lib/semmle/code/java/frameworks/<outputQll>` where
@@ -24,6 +24,8 @@ def printHelp():
24
24
--with-summaries
25
25
If none of these flags are specified, all models are generated.
26
26
27
+ --dry-run: Only run the queries, but don't write to file.
28
+
27
29
Example invocations:
28
30
$ python3 GenerateFlowModel.py /tmp/dbs/apache_commons-codec_45649c8 "apache/Codec.qll"
29
31
$ python3 GenerateFlowModel.py /tmp/dbs/jdk15_db "javase/jdk_sinks.qll" --with-sinks
@@ -39,6 +41,8 @@ def printHelp():
39
41
generateSinks = False
40
42
generateSources = False
41
43
generateSummaries = False
44
+ dryRun = False
45
+
42
46
if "--with-sinks" in sys .argv :
43
47
sys .argv .remove ("--with-sinks" )
44
48
generateSinks = True
@@ -51,6 +55,10 @@ def printHelp():
51
55
sys .argv .remove ("--with-summaries" )
52
56
generateSummaries = True
53
57
58
+ if "--dry-run" in sys .argv :
59
+ sys .argv .remove ("--dry-run" )
60
+ dryRun = True
61
+
54
62
if not generateSinks and not generateSources and not generateSummaries :
55
63
generateSinks = generateSources = generateSummaries = True
56
64
@@ -165,6 +173,10 @@ def asCsvModel(superclass, kind, rows):
165
173
qllContents = qllTemplate .format (shortname , sinkCsv , sourceCsv , summaryCsv )
166
174
167
175
176
+ if dryRun :
177
+ print ("CSV Models generated, but not written to file." )
178
+ sys .exit (0 )
179
+
168
180
with open (frameworkTarget , "w" ) as frameworkQll :
169
181
frameworkQll .write (qllContents )
170
182
0 commit comments