Skip to content

Commit 2b3b4ca

Browse files
MichakrawSBclaude
andcommitted
ci: auto-dismiss Dependabot and Wiz security alerts in samples/
samples/ contains generated integration-test fixtures (not production code) so security alerts from that directory are noise. This daily workflow dismisses any open alerts whose path starts with samples/ automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c7dd2fc commit 2b3b4ca

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Auto-dismiss security alerts in samples/
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * *' # daily at 06:00 UTC
6+
workflow_dispatch:
7+
8+
permissions:
9+
security-events: write
10+
11+
jobs:
12+
dismiss:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Dismiss Dependabot alerts in samples/
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
run: |
19+
page=1
20+
dismissed=0
21+
while : ; do
22+
response=$(gh api "repos/$GITHUB_REPOSITORY/dependabot/alerts?state=open&per_page=100&page=$page")
23+
count=$(echo "$response" | jq 'length')
24+
[ "$count" -eq 0 ] && break
25+
26+
while IFS= read -r number; do
27+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/dependabot/alerts/$number" \
28+
-f state=dismissed \
29+
-f dismissed_reason=tolerable_risk \
30+
-f dismissed_comment="samples/ contains generated integration-test fixtures, not production code" \
31+
--silent
32+
echo "Dismissed Dependabot alert #$number"
33+
((dismissed++))
34+
done < <(echo "$response" | jq -r '.[] | select(.dependency.manifest_path | startswith("samples/")) | .number | tostring')
35+
36+
((page++))
37+
done
38+
echo "Total Dependabot alerts dismissed: $dismissed"
39+
40+
- name: Dismiss code scanning alerts in samples/
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
page=1
45+
dismissed=0
46+
while : ; do
47+
response=$(gh api "repos/$GITHUB_REPOSITORY/code-scanning/alerts?state=open&per_page=100&page=$page")
48+
count=$(echo "$response" | jq 'length')
49+
[ "$count" -eq 0 ] && break
50+
51+
while IFS= read -r number; do
52+
gh api --method PATCH "repos/$GITHUB_REPOSITORY/code-scanning/alerts/$number" \
53+
-f state=dismissed \
54+
-f dismissed_reason="used in tests" \
55+
-f dismissed_comment="samples/ contains generated integration-test fixtures, not production code" \
56+
--silent
57+
echo "Dismissed code scanning alert #$number"
58+
((dismissed++))
59+
done < <(echo "$response" | jq -r '.[] | select(.most_recent_instance.location.path | startswith("samples/")) | .number | tostring')
60+
61+
((page++))
62+
done
63+
echo "Total code scanning alerts dismissed: $dismissed"

0 commit comments

Comments
 (0)