1111
1212def printHelp ():
1313 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]
1515
1616This generates summary, source and sink models for the code in the database.
1717The files will be placed in `java/ql/lib/semmle/code/java/frameworks/<outputQll>` where
@@ -24,6 +24,8 @@ def printHelp():
2424 --with-summaries
2525If none of these flags are specified, all models are generated.
2626
27+ --dry-run: Only run the queries, but don't write to file.
28+
2729Example invocations:
2830$ python3 GenerateFlowModel.py /tmp/dbs/apache_commons-codec_45649c8 "apache/Codec.qll"
2931$ python3 GenerateFlowModel.py /tmp/dbs/jdk15_db "javase/jdk_sinks.qll" --with-sinks
@@ -39,6 +41,8 @@ def printHelp():
3941generateSinks = False
4042generateSources = False
4143generateSummaries = False
44+ dryRun = False
45+
4246if "--with-sinks" in sys .argv :
4347 sys .argv .remove ("--with-sinks" )
4448 generateSinks = True
@@ -51,6 +55,10 @@ def printHelp():
5155 sys .argv .remove ("--with-summaries" )
5256 generateSummaries = True
5357
58+ if "--dry-run" in sys .argv :
59+ sys .argv .remove ("--dry-run" )
60+ dryRun = True
61+
5462if not generateSinks and not generateSources and not generateSummaries :
5563 generateSinks = generateSources = generateSummaries = True
5664
@@ -165,6 +173,10 @@ def asCsvModel(superclass, kind, rows):
165173qllContents = qllTemplate .format (shortname , sinkCsv , sourceCsv , summaryCsv )
166174
167175
176+ if dryRun :
177+ print ("CSV Models generated, but not written to file." )
178+ sys .exit (0 )
179+
168180with open (frameworkTarget , "w" ) as frameworkQll :
169181 frameworkQll .write (qllContents )
170182
0 commit comments