Skip to content

Commit

Permalink
Merge pull request #290 from DataDog/fix-non-zero-exit-code
Browse files Browse the repository at this point in the history
Fix non-working status code option on guarddog verify
  • Loading branch information
christophetd authored Nov 13, 2023
2 parents 7f47374 + db6419b commit c9006b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Metadata heuristics:
| potentially_compromised_email_domain | Identify when a package maintainer e-mail domain (and therefore package manager account) might have been compromised |
| typosquatting | Identify packages that are named closely to an highly popular package |
| direct_url_dependency | Identify packages with direct URL dependencies. Dependencies fetched this way are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install. |
| npm_confusion | Identify package versions which have meaningful differences between the content of their package.json and the package version metadata as returned by the NPM API. Specifically identifies differences between dependencies, scripts, and documentation locations. |
| npm_metadata_mismatch | Identify packages which have mismatches between the npm pacakge manifest and the package info |


<!-- END_RULE_LIST -->
Expand Down
10 changes: 5 additions & 5 deletions guarddog/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ def _scan(identifier, version, rules, exclude_rules, output_format, exit_non_zer
print_scan_results(result, result['package'])

if exit_non_zero_on_finding:
for result in results:
exit_with_status_code(result)
exit_with_status_code(results)


def _list_rules(ecosystem):
Expand Down Expand Up @@ -376,6 +375,7 @@ def format_code_line_for_output(code):

# Given the results, exit with the appropriate status code
def exit_with_status_code(results):
num_issues = results.get('issues', 0)
if num_issues > 0:
exit(EXIT_CODE_ISSUES_FOUND)
for result in results:
num_issues = result.get('issues', 0)
if num_issues > 0:
exit(EXIT_CODE_ISSUES_FOUND)

0 comments on commit c9006b8

Please sign in to comment.