Skip to content

Commit c876ddf

Browse files
authored
ci: audit-dependencies workflow (#13090)
Add weekly check for dependency vulnerabilities. Asana: https://app.asana.com/1/10497086658021/project/1210456585958356/task/1210561338171143
1 parent 855a320 commit c876ddf

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
severity=${1:-"critical"}
4+
audit_json=$(pnpm audit --prod --json)
5+
output_file="audit_output.json"
6+
7+
echo "Auditing for ${severity} vulnerabilities..."
8+
9+
echo "${audit_json}" | jq --arg severity "${severity}" '
10+
.advisories | to_entries |
11+
map(select(.value.patched_versions != "<0.0.0" and .value.severity == $severity) |
12+
{
13+
package: .value.module_name,
14+
vulnerable: .value.vulnerable_versions,
15+
fixed_in: .value.patched_versions
16+
}
17+
)
18+
' >$output_file
19+
20+
audit_length=$(jq 'length' $output_file)
21+
22+
if [[ "${audit_length}" -gt "0" ]]; then
23+
echo "Actionable vulnerabilities found in the following packages:"
24+
jq -r '.[] | "\u001b[1m\(.package)\u001b[0m vulnerable in \u001b[31m\(.vulnerable)\u001b[0m fixed in \u001b[32m\(.fixed_in)\u001b[0m"' $output_file | while read -r line; do echo -e "$line"; done
25+
echo "Output written to ${output_file}"
26+
exit 1
27+
else
28+
echo "No actionable vulnerabilities"
29+
exit 0
30+
fi
Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,58 @@
11
name: audit-dependencies
22

33
on:
4+
# Sundays at 2am EST
5+
schedule:
6+
- cron: '0 7 * * 0'
47
workflow_dispatch:
8+
inputs:
9+
audit-level:
10+
description: The level of audit to run (low, moderate, high, critical)
11+
required: false
12+
default: critical
13+
debug:
14+
description: Enable debug logging
15+
required: false
16+
default: false
17+
18+
env:
19+
NODE_VERSION: 23.11.0
20+
PNPM_VERSION: 9.7.1
21+
DO_NOT_TRACK: 1 # Disable Turbopack telemetry
22+
NEXT_TELEMETRY_DISABLED: 1 # Disable Next telemetry
523

624
jobs:
7-
dummy:
25+
audit:
826
runs-on: ubuntu-24.04
927
steps:
10-
- name: Dummy step
11-
run: echo "This is a dummy step"
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Setup
31+
uses: ./.github/actions/setup
32+
with:
33+
node-version: ${{ env.NODE_VERSION }}
34+
pnpm-version: ${{ env.PNPM_VERSION }}
35+
36+
- name: Run audit dependencies script
37+
id: audit_dependencies
38+
run: ./.github/workflows/audit-dependencies.sh ${{ inputs.audit-level }}
39+
40+
- name: Slack notification on failure
41+
if: failure()
42+
uses: slackapi/slack-github-action@v2.1.0
43+
with:
44+
webhook: ${{ inputs.debug == 'true' && secrets.SLACK_TEST_WEBHOOK_URL || secrets.SLACK_WEBHOOK_URL }}
45+
webhook-type: incoming-webhook
46+
payload: |
47+
{
48+
"username": "GitHub Actions Bot",
49+
"blocks": [
50+
{
51+
"type": "section",
52+
"text": {
53+
"type": "mrkdwn",
54+
"text": "🚨 Actionable vulnerabilities found: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Details>"
55+
}
56+
},
57+
]
58+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ packages/ui/esbuild
2727
packages/next/esbuild
2828
packages/richtext-lexical/esbuild
2929

30+
audit_output.json
31+
3032
.turbo
3133

3234
# Ignore test directory media folder/files

0 commit comments

Comments
 (0)