Skip to content

Commit

Permalink
Capture and log semgrep process errors
Browse files Browse the repository at this point in the history
  • Loading branch information
drdavella committed Nov 13, 2023
1 parent 638dc87 commit d12990b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/codemodder/semgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ def run(
)
command.extend(map(str, files_to_analyze or [execution_context.directory]))
logger.debug("semgrep command: `%s`", " ".join(command))
subprocess.run(
call = subprocess.run(
command,
shell=False,
check=True,
check=False,
stdout=None if execution_context.verbose else subprocess.PIPE,
stderr=None if execution_context.verbose else subprocess.PIPE,
)
if call.returncode != 0:
if not execution_context.verbose:
logger.error("captured semgrep stderr: %s", call.stderr)
raise subprocess.CalledProcessError(call.returncode, command)
results = SarifResultSet.from_sarif(temp_sarif_file.name)
return results

0 comments on commit d12990b

Please sign in to comment.