Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support sarif output for scan #259

Closed
wants to merge 2 commits into from
Closed

Conversation

H4dr1en
Copy link
Contributor

@H4dr1en H4dr1en commented Jun 29, 2023

Fix #197

Tested successfully in combination with #257

PS: I think there is a bug in the output format SARIF for the verify command, it does not log all the errors

@@ -188,3 +188,50 @@ def report_verify_sarif(package_path: str, rule_names: list[str], scan_results:
runs = get_run(results, driver)
log = get_sarif_log([runs])
return json.dumps(log, indent=2)


def report_scan_sarif(rule_names: list[str], scan_results: list[dict],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a unit test for it? it seems to be failing for a sample package I tried it on:

$ guarddog pypi scan first-exercise --output-format sarif
File "/Users/christophetd/workspace/guarddog/guarddog/cli.py", line 191, in _scan
    return_value = report_scan_sarif(list(ALL_RULES), results, ecosystem)
  File "/Users/christophetd/workspace/guarddog/guarddog/reporters/sarif.py", line 211, in report_scan_sarif
    "startLine": record["start"]["line"],
TypeError: string indices must be integers

@christophetd
Copy link
Contributor

Closing following inactivity, feel free to reopen or ask for help if appropriate, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support SARIF output in "scan" commands
2 participants