Skip to content

Commit

Permalink
csmock: do not apply results limits twice
Browse files Browse the repository at this point in the history
If the `--embed-context` feature is enabled, available and successful,
there should be no reason to apply results limits again.  This is an
optimization that should not affect the results.

Related: https://issues.redhat.com/browse/OSH-67
kdudka committed Oct 10, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 801cec2 commit a108242
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion py/csmock
Original file line number Diff line number Diff line change
@@ -434,6 +434,7 @@ class ScanProps:
self.cswrap_timeout = DEFAULT_CSWRAP_TIMEOUT
self.embed_context = 0
self.results_limits_opts = []
self.results_limits_applied = False
self.no_scan = False
self.print_defects = False
self.need_rpm_bi = False
@@ -1248,17 +1249,19 @@ cd %%s*/ || cd *\n\
cmd += f" <'{all_file}' >'{tmp_file}'"
if results.exec_cmd(cmd, shell=True) == 0:
shutil.move(tmp_file, all_file)
props.results_limits_applied = True

# we are done with mock

# make sure to apply results limits because `csgrep --embed-context` might not be available in chroot
if props.results_limits_opts:
if props.results_limits_opts and not props.results_limits_applied:
tmp_file = f"{all_file}.tmp"
csgrep_cmd = "csgrep --mode=json " + strlist_to_shell_cmd(props.results_limits_opts)
csgrep_cmd += f" '{all_file}' >'{tmp_file}'"
ec = results.exec_cmd(csgrep_cmd, shell=True)
if 0 == ec:
shutil.move(tmp_file, all_file)
props.results_limits_applied = True
else:
results.error("failed to apply results limits", ec=ec)

0 comments on commit a108242

Please sign in to comment.