Skip to content

Instantly share code, notes, and snippets.

@neatshell
Forked from cromwellryan/yarn-audit-csv.sh
Last active November 13, 2024 14:34
Show Gist options
  • Save neatshell/f2212038aebcc5c1150708b07004df62 to your computer and use it in GitHub Desktop.
Save neatshell/f2212038aebcc5c1150708b07004df62 to your computer and use it in GitHub Desktop.
level=${1-critical}
# Generate an audit report of Level or Critical advisories
yarn audit --json --level "${level}" > audit.lines
# Transform from JSON-lines to JSON format
jq -s '.' audit.lines > audit.json
# Extract advisories
jq -r '.[] |
select(.type == "auditAdvisory") |
{ severity: .data.advisory.severity, path: .data.resolution.path, cves: (.data.advisory.cves | @csv), module_name: .data.advisory.module_name } |
select(.severity == "critical" or .severity == "high") |
[.severity, .module_name, .path, .cves] |
@csv' \
audit.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment