|
| 1 | +#!/bin/bash |
| 2 | +# Script yarn_audit.sh |
| 3 | +# Runs a yarn audit, but ignores accepted yarn warnings, and pretty-prints errors in JSON |
| 4 | + |
| 5 | +# YARN_IGNROE is a list of accepted yarn warnings, space separated: |
| 6 | +# Path traversal in webpack-dev-middleware |
| 7 | +YARN_IGNORE="GHSA-wr3j-pwj9-hqq6" |
| 8 | +# Uncontrolled resource consumption in braces |
| 9 | +YARN_IGNORE="$YARN_IGNORE GHSA-grv7-fg5c-xmjg" |
| 10 | +# Denial of service in http-proxy-middleware |
| 11 | +YARN_IGNORE="$YARN_IGNORE GHSA-c7qv-q95q-8v27" |
| 12 | +# Improper Verification of Cryptographic Signature in node-forge |
| 13 | +YARN_IGNORE="$YARN_IGNORE GHSA-x4jg-mjrx-434g GHSA-cfm4-qjh2-4765" |
| 14 | +# node-forge has ASN.1 Unbounded Recursion |
| 15 | +YARN_IGNORE="$YARN_IGNORE GHSA-554w-wpv2-vw27" |
| 16 | +# node-forge has an Interpretation Conflict vulnerability via its ASN.1 Validator Desynchronization |
| 17 | +YARN_IGNORE="$YARN_IGNORE GHSA-5gfm-wpxj-wjgq" |
| 18 | +# Inefficient Regular Expression Complexity in nth-check" |
| 19 | +YARN_IGNORE="$YARN_IGNORE GHSA-rp65-9cf3-cjxr" |
| 20 | +# ip SSRF improper categorization in isPublic |
| 21 | +YARN_IGNORE="$YARN_IGNORE GHSA-2p57-rm9w-gvfp" |
| 22 | + |
| 23 | +YARN_IGNORE_JSON="`echo $YARN_IGNORE | sed -e 's/^/"/' -e 's/$/"/' -e 's/ /", "/g'`" |
| 24 | +echo "yarn audit --no-progress --level high --json" |
| 25 | +yarn audit --no-progress --level high --json > yarn_audit.json || true |
| 26 | +echo |
| 27 | +echo "Summary counts of vulnerabilities found, before filtering accepted warnings:" |
| 28 | +cat yarn_audit.json | jq -c 'select ( .type == "auditSummary" )' | jq -M |
| 29 | + |
| 30 | +echo |
| 31 | +echo "Filtering for new high or critical severity warnings:" |
| 32 | +for IGNORE in $YARN_IGNORE; do |
| 33 | + cat yarn_audit.json | \ |
| 34 | + jq -cMe 'select ( .type == "auditAdvisory" and (.data.advisory.github_advisory_id == "'"$IGNORE"'") )' > /dev/null || \ |
| 35 | + echo "Warning: yarn audit no longer flags github_advisory_id $IGNORE" |
| 36 | +done |
| 37 | + |
| 38 | +if cat yarn_audit.json | jq -c 'select ( .type == "auditAdvisory" and (.data.advisory.github_advisory_id | IN ('"$YARN_IGNORE_JSON"') | not) )' | jq -Me; then |
| 39 | + echo |
| 40 | + echo Warning: New yarn audit vulnerabilities found in yarn.lock, listed above. |
| 41 | + echo Run yarn upgrade, or update YARN_IGNORE in script/yarn_audit.sh |
| 42 | + echo with accepted github_advisory_id values. |
| 43 | + exit 1 |
| 44 | +else |
| 45 | + rm -f yarn_audit.json |
| 46 | + echo No new yarn audit vulnerabilities found |
| 47 | +fi |
0 commit comments