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 12, 2023
1 parent 70f7903 commit 51145d3
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)

Check warning on line 50 in src/codemodder/semgrep.py

View check run for this annotation

Codecov / codecov/patch

src/codemodder/semgrep.py#L48-L50

Added lines #L48 - L50 were not covered by tests
results = SarifResultSet.from_sarif(temp_sarif_file.name)
return results

0 comments on commit 51145d3

Please sign in to comment.