@@ -24,16 +24,26 @@ def get_diffblue_models_library_props():
24
24
props ["diffblue_models_library" ]["paths" ].append (pathname )
25
25
else :
26
26
props ["diffblue_models_library" ]["error" ] = "Cannot access Diffblue Models Library's file " + pathname
27
- return props
28
- pathname = os .path .join (get_benchmark_library_dir (), "oracle-jdk-8" )
29
- if os .path .isdir (pathname ):
30
- props ["diffblue_models_library" ]["paths" ].append (pathname )
31
- else :
32
- pathname = os .path .join (get_benchmark_library_dir (), "openjdk-8" )
33
- if os .path .isdir (pathname ):
34
- props ["diffblue_models_library" ]["paths" ].append (pathname )
35
- else :
36
- print ("Warning: cannot access JDK install directory " + pathname )
27
+ return props
28
+
29
+ def get_java_runtime_library ():
30
+ props = {"java_runtime_library" : {"paths" : [], "error" : None }}
31
+ pathname = os .path .join (get_benchmark_library_dir (), "openjdk-8" )
32
+ if not os .path .isdir (pathname ):
33
+ pathname = os .path .join (get_benchmark_library_dir (), "oracle-jdk-8" )
34
+ if not os .path .isdir (pathname ):
35
+ props ["java_runtime_library" ]["error" ] = (
36
+ "Cannot find Java standard library on neither of the paths: " +
37
+ os .path .join (get_benchmark_library_dir (), "openjdk-8" ) + ", " + pathname
38
+ )
39
+ return props
40
+ jars_selection = ["rt.jar" , "jce.jar" ]
41
+ for jar in jars_selection :
42
+ jar_full_path = os .path .join (pathname , jar )
43
+ if os .path .isfile (jar_full_path ):
44
+ props ["java_runtime_library" ]["paths" ].append (jar_full_path )
45
+ if os .path .join (pathname , "rt.jar" ) not in props ["java_runtime_library" ]["paths" ]:
46
+ props ["java_runtime_library" ]["error" ] = "Cannot find 'rt.jar' Java standard library package in the directory " + pathname
37
47
return props
38
48
39
49
def get_apache_tomcat_props ():
@@ -58,6 +68,7 @@ def get_spring_framework_props():
58
68
59
69
result = {}
60
70
result .update (get_diffblue_models_library_props ())
71
+ result .update (get_java_runtime_library ())
61
72
result .update (get_apache_tomcat_props ())
62
73
result .update (get_spring_framework_props ())
63
74
return result
@@ -119,6 +130,10 @@ def __parse_cmd_line():
119
130
"during the analysis." )
120
131
parser .add_argument ("--use-models-library" , action = "store_true" ,
121
132
help = "Add the Diffblue Models Library's JAR file to the classpath of the security-scanner." )
133
+ parser .add_argument ("--use-java-runtime-library" , action = "store_true" ,
134
+ help = "Add the Java standard library to the classpath. First, there will be attempt to add "
135
+ "OpenJDK version of the library. If it is not found (e.g. not installed), then the "
136
+ "Oracle's version of the library is searched for." )
122
137
parser .add_argument ("--use-apache-tomcat" , action = "store_true" ,
123
138
help = "Add the Apache Tomcat's JAR files to the classpath of the security-scanner." )
124
139
parser .add_argument ("--use-spring-framework" , action = "store_true" ,
@@ -161,6 +176,7 @@ def evaluate(cmdline, common_libraries):
161
176
cmdline .input_path ,
162
177
cmdline .libraries
163
178
+ (common_libraries ["diffblue_models_library" ]["paths" ] if cmdline .use_models_library else [])
179
+ + (common_libraries ["java_runtime_library" ]["paths" ] if cmdline .use_java_runtime_library else [])
164
180
+ (common_libraries ["apache_tomcat" ]["paths" ] if cmdline .use_apache_tomcat else [])
165
181
+ (common_libraries ["spring_framework" ]["paths" ] if cmdline .use_spring_framework else []),
166
182
cmdline .entry_point ,
@@ -313,6 +329,9 @@ def __main():
313
329
if cmdline .use_models_library and common_libraries ["diffblue_models_library" ]["error" ] is not None :
314
330
print ("ERROR: " + common_libraries ["diffblue_models_library" ]["error" ])
315
331
return
332
+ if cmdline .use_java_runtime_library and common_libraries ["java_runtime_library" ]["error" ] is not None :
333
+ print ("ERROR: " + common_libraries ["java_runtime_library" ]["error" ])
334
+ return
316
335
if cmdline .use_apache_tomcat and common_libraries ["apache_tomcat" ]["error" ] is not None :
317
336
print ("ERROR: " + common_libraries ["apache_tomcat" ]["error" ])
318
337
return
0 commit comments