-
Notifications
You must be signed in to change notification settings - Fork 4
68 lines (57 loc) · 2.3 KB
/
brakeman.yml
File metadata and controls
68 lines (57 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Ensure Brakeman Passes
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
brakeman:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby & install gems (cached)
uses: ./.github/actions/setup-ruby-deps
- name: Print tool versions
run: |
echo "Ruby version: $(ruby -v)"
echo "Gem version: $(gem -v)"
echo "Bundler version: $(bundle -v)"
echo "Brakeman version: $(bundle exec brakeman --version || echo 'not installed')"
- name: Check if Brakeman is up-to-date (warn only)
run: |
set +e
bundle exec brakeman -q --no-progress --ensure-latest >/dev/null
CODE=$?
set -e
if [ "$CODE" -eq 5 ]; then
echo "::warning title=Brakeman::Installed version is not the latest. Run 'bundle update brakeman' to update."
elif [ "$CODE" -ne 0 ]; then
echo "::error title=Brakeman::Version check failed::Exit code $CODE"
exit $CODE
fi
- name: Run Brakeman (JSON)
run: |
mkdir -p tmp
bundle exec brakeman -q --no-progress --no-exit-on-warn \
-f json -o tmp/brakeman-output.json
- name: Run Brakeman (plain text for humans)
run: |
bundle exec brakeman -q --no-progress --no-exit-on-warn \
-f plain -o tmp/brakeman-output.txt || true
- name: Show Brakeman JSON summary
run: |
echo "Warnings count: $(jq '.warnings | length' tmp/brakeman-output.json)"
echo "High-confidence count: $(jq '[.warnings[] | select(.confidence == "High")] | length' tmp/brakeman-output.json)"
- name: Upload Brakeman Reports
uses: actions/upload-artifact@v4
with:
name: brakeman-report
path: |
tmp/brakeman-output.json
tmp/brakeman-output.txt
- name: Fail on High-confidence warnings
run: |
HIGH_CONF_COUNT=$(jq '[.warnings[] | select(.confidence == "High")] | length' tmp/brakeman-output.json)
echo "High-confidence warnings: $HIGH_CONF_COUNT"
if [ "$HIGH_CONF_COUNT" -gt 0 ]; then
echo "Brakeman detected high-confidence warnings. Failing the job."
exit 1
fi