Skip to content

Commit 5c57b20

Browse files
committed
ci: fix exclusions updater
1 parent e09319f commit 5c57b20

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

.github/workflows/exclusions.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,35 @@ jobs:
3434
deactivate
3535
3636
- name: Parse false positive detections by desired categories
37-
id: parse_detections
3837
run: |
3938
grep -oP '(?<=test_false_pos\[)[^\]]+(?=\].*result was Claimed)' fp_test_results.txt \
4039
| sort -u > false_positive_exclusions.txt
4140
grep -oP '(?<=test_false_pos\[)[^\]]+(?=\].*result was WAF)' fp_test_results.txt \
4241
| sort -u > waf_hits.txt
4342
43+
- name: Detect if exclusions list changed
44+
id: detect_changes
45+
run: |
46+
git fetch origin exclusions || true
47+
48+
if git show origin/exclusions:exclusions.txt >/dev/null 2>&1; then
49+
# If the exclusions branch and file exist, compare
50+
if git diff --quiet origin/exclusions -- exclusions.txt; then
51+
echo "changed=false" >> "$GITHUB_OUTPUT"
52+
else
53+
echo "changed=true" >> "$GITHUB_OUTPUT"
54+
fi
55+
else
56+
# If the exclusions branch or file do not exist, treat as changed
57+
echo "changed=true" >> "$GITHUB_OUTPUT"
58+
fi
59+
60+
if git diff --quiet false_positive_exclusions.txt; then
61+
echo "exclusions_changed=false" >> $GITHUB_OUTPUT
62+
else
63+
echo "exclusions_changed=true" >> $GITHUB_OUTPUT
64+
fi
65+
4466
- name: Quantify and display results
4567
run: |
4668
FP_COUNT=$(wc -l < false_positive_exclusions.txt | xargs)
@@ -50,7 +72,7 @@ jobs:
5072
echo ">>> WAF hits:" && cat waf_hits.txt
5173
5274
- name: Commit and push exclusions list
53-
if: steps.parse_detections.outputs.changed == 'true' || steps.parse_detections.outputs.changed == 'true'
75+
if: steps.detect_changes.outputs.exclusions_changed == 'true'
5476
run: |
5577
git config user.name "Paul Pfeister (automation)"
5678
git config user.email "[email protected]"

0 commit comments

Comments
 (0)