Skip to content

Commit 2216e08

Browse files
authored
Merge pull request diffblue#204 from diffblue/feature/include_tomcat_classes
SEC-63 : Introduced option --use-tomcat-library.
2 parents 264f2e2 + 1a19559 commit 2216e08

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

security-scanner/run.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
def __get_my_dir(): return os.path.dirname(os.path.realpath(__file__))
1313

14+
def __get_benchmark_library_dir(): return os.path.join(__get_my_dir(), "../benchmarks/LIBRARIES")
15+
def __get_diffblue_models_library_dir(): return os.path.join(__get_benchmark_library_dir(), "models/model/target/classes")
16+
def __get_tomcat_library_dir(): return os.path.join(__get_benchmark_library_dir(), "apache-tomcat-9/lib")
17+
1418

1519
def __parse_cmd_line():
1620
parser = argparse.ArgumentParser(
@@ -50,14 +54,17 @@ def __parse_cmd_line():
5054
help="If specified, then the analyser will save statistics in HTML format together "
5155
"with in JSON format (which is always saved).")
5256
parser.add_argument("--dump-html-slice", action="store_true",
53-
help="If specified, then the analyser will save the sliced GOTO program in HTML format together "
54-
"with in JSON format (which is always saved).")
57+
help="If specified, then the analyser will save the sliced GOTO program in HTML format "
58+
"together with in JSON format (which is always saved).")
5559
parser.add_argument("--dump-html-program", action="store_true",
5660
help="If specified, then the analysed program is dumped in HTML format.")
5761
parser.add_argument("--verbosity", type=int, default=9,
5862
help="It specifies how many debugging messages will be printed to the standard output stream "
5963
"during the analysis.")
60-
parser.add_argument("--use-models-library", action="store_true", help="Add the Diffblue models library to the application JAR")
64+
parser.add_argument("--use-models-library", action="store_true",
65+
help="Add the Diffblue models library to the application JAR.")
66+
parser.add_argument("--use-tomcat-library", action="store_true",
67+
help="Add the Tomcat 9 library to the application JAR.")
6168
parser.add_argument("--data-flow-insensitive-instrumentation", action="store_true",
6269
help="If specified, then the tool 'security-analyser' will use the data-flow insensitive "
6370
"instrumentation of the checked properties into the output GOTO programs. In that case"
@@ -85,10 +92,9 @@ def evaluate(cmdline):
8592

8693
input_search_dirs = [cmdline.install_dir]
8794
if cmdline.use_models_library:
88-
input_search_dirs.append(os.path.join(__get_my_dir(), "../benchmarks/LIBRARIES/models/model/target/classes"))
89-
if not os.path.exists(input_search_dirs[-1]):
90-
repo_root = os.path.realpath(os.path.join(__get_my_dir(), ".."))
91-
raise Exception("Models library not found at %s; consider running 'make' in %s" % (input_search_dirs[-1], repo_root))
95+
input_search_dirs.append(__get_diffblue_models_library_dir())
96+
if cmdline.use_tomcat_library:
97+
input_search_dirs.append(__get_tomcat_library_dir())
9298

9399
prof["install_classes"] = mkbench.build_classes_configuration(
94100
input_search_dirs,
@@ -218,6 +224,14 @@ def __main():
218224
analyser.get_symex_pathname() + "'.")
219225
return
220226

227+
if cmdline.use_models_library and not os.path.isdir(__get_diffblue_models_library_dir()):
228+
print("ERROR: Models library not found at %s; consider running 'make' in %s" % (
229+
__get_diffblue_models_library_dir(), os.path.realpath(os.path.join(__get_my_dir(), ".."))))
230+
return
231+
if cmdline.use_tomcat_library and not os.path.isdir(__get_tomcat_library_dir()):
232+
print("ERROR: Tomcat 9 library was not found at " + __get_tomcat_library_dir() + "")
233+
return
234+
221235
if not os.path.exists(cmdline.results_dir):
222236
os.makedirs(cmdline.results_dir)
223237
if not os.path.exists(cmdline.temp_dir):

0 commit comments

Comments
 (0)