Skip to content

Commit b3e1d03

Browse files
authored
Merge pull request diffblue#604 from diffblue/jd/feature/pipeline_stop_on_exception
[SEC-677] Turning DI off by default and making errors fail pipeline
2 parents 20c6bf1 + d678065 commit b3e1d03

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

driver/mkbench.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ def run_di_model_generation(configuration, cmdline):
8282
will drive generation.
8383
"""
8484

85+
if not cmdline.di_generation:
86+
print("DI generation disabled. Skipping.", file=sys.stderr)
87+
return None
88+
8589
# If we don't have anything vaguely looking like a spring library being used, just skip generation.
86-
if not next((lib for lib in cmdline.libraries if re.search("spring-[a-zA-Z]*-[0-9]*\.[0-9]*", lib)), None) \
87-
or cmdline.skip_di_generation:
90+
if not any((re.search("spring-[a-zA-Z]*-[0-9]*\.[0-9]*", lib) for lib in cmdline.libraries)):
8891
print("No Spring Framework libraries passed in, cannot generate any DI-related code.", file=sys.stderr)
8992
return None
9093

@@ -114,9 +117,7 @@ def run_di_model_generation(configuration, cmdline):
114117
if additional_spring_files:
115118
di_generation_commandline.extend(["--input-file"] + additional_spring_files)
116119

117-
di_generation_result = utility.call(di_generation_commandline, "DI model generator", cmdline.verbosity, stderr=subprocess.STDOUT)
118-
if di_generation_result != 0:
119-
return None
120+
utility.check_call(di_generation_commandline, "DI model generator", cmdline.verbosity, stderr=subprocess.STDOUT)
120121

121122
# Quick check to see if we have any output files.
122123
if not next((file for root, dirs, files in os.walk(generated_source_file_path) for file in files), None):
@@ -159,10 +160,7 @@ def run_di_model_generation(configuration, cmdline):
159160
with open(ant_build_path, 'x') as ant_xml_file:
160161
ant_xml_file.write(ant_build_statement)
161162

162-
javac_result = utility.call(["ant", "-file", ant_build_path], "Java Compiler for DI model overlays", cmdline.verbosity, stderr=subprocess.STDOUT)
163-
if javac_result != 0:
164-
print("Java compilation of DI-generated source failed.")
165-
return None
163+
utility.check_call(["ant", "-file", ant_build_path], "Java Compiler for DI model overlays", cmdline.verbosity, stderr=subprocess.STDOUT)
166164

167165
return generated_jar_path
168166

driver/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ def create_parser():
197197
parser.add_argument("--run-scan", type=str, const='', nargs="?",
198198
help="Flag for whether a security scan should be run. If left empty, will run on all folders in results-dir."
199199
"If passed a path to a command_line.json file, it will only run on that folder.")
200-
parser.add_argument("--skip-di-generation", action='store_true',
201-
help="Turns off DI overlay generation. This overrides the automatic detection of DI usage.")
200+
parser.add_argument("--di-generation", action="store_true",
201+
help="Turns on DI overlay generation. This overrides the automatic detection of DI usage.")
202202

203203
return parser
204204

0 commit comments

Comments
 (0)