Skip to content

Commit 879ddf8

Browse files
feat: scan vampi using openapi.json
1 parent 4b76e67 commit 879ddf8

2 files changed

Lines changed: 147 additions & 13 deletions

File tree

.github/workflows/scans.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
workflow_dispatch:
78

89
env:
910
GO_VERSION: "1.27"
@@ -66,7 +67,7 @@ jobs:
6667
id: vulnapi
6768
run: |
6869
chmod +x vulnapi
69-
./vulnapi discover api http://localhost:8080 --rate 500/s --sqa-opt-out
70+
./vulnapi discover api http://localhost:8080 --rate 500/s --no-progress --sqa-opt-out
7071
7172
- name: Stop Server
7273
if: ${{ always() }}
@@ -90,7 +91,7 @@ jobs:
9091
continue-on-error: true
9192
run: |
9293
chmod +x vulnapi
93-
./vulnapi scan curl http://localhost:8080 --sqa-opt-out
94+
./vulnapi scan curl http://localhost:8080 --no-progress --sqa-opt-out
9495
9596
- name: Check for vulnerabilities
9697
if: ${{ steps.vulnapi.outcome == 'failure' }}
@@ -127,7 +128,7 @@ jobs:
127128
continue-on-error: true
128129
run: |
129130
chmod +x vulnapi
130-
./vulnapi scan curl ${{ matrix.challenge.url }} --sqa-opt-out
131+
./vulnapi scan curl ${{ matrix.challenge.url }} --no-progress --sqa-opt-out
131132
132133
- name: Check for vulnerabilities
133134
if: ${{ steps.vulnapi.outcome == 'failure' }}
@@ -190,7 +191,7 @@ jobs:
190191
continue-on-error: true
191192
run: |
192193
chmod +x vulnapi
193-
./vulnapi scan curl http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}" --scans "${{ matrix.checkID }}" --sqa-opt-out
194+
./vulnapi scan curl http://localhost:8080 -H "Authorization: Bearer ${{ steps.get-jwt.outputs.jwt }}" --scans "${{ matrix.checkID }}" --no-progress --sqa-opt-out
194195
195196
- name: Check for vulnerabilities
196197
if: ${{ steps.vulnapi.outcome != 'failure' }}
@@ -229,7 +230,7 @@ jobs:
229230
id: vulnapi
230231
run: |
231232
chmod +x vulnapi
232-
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --scans "generic.accept_unauthenticated_operation" --sqa-opt-out
233+
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --scans "generic.accept_unauthenticated_operation" --no-progress --sqa-opt-out
233234
234235
- name: Stop Server
235236
if: ${{ always() }}
@@ -263,7 +264,7 @@ jobs:
263264
continue-on-error: true
264265
run: |
265266
chmod +x vulnapi
266-
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --scans "generic.accept_unauthenticated_operation" --sqa-opt-out
267+
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --scans "generic.accept_unauthenticated_operation" --no-progress --sqa-opt-out
267268
268269
- name: Check for vulnerabilities
269270
if: ${{ steps.vulnapi.outcome != 'failure' }}
@@ -303,7 +304,7 @@ jobs:
303304
continue-on-error: true
304305
run: |
305306
chmod +x vulnapi
306-
./vulnapi scan curl http://localhost:8080 -H "Authorization: Bearer abcdef1234" --scans "generic.accept_unauthenticated_operation" --sqa-opt-out
307+
./vulnapi scan curl http://localhost:8080 -H "Authorization: Bearer abcdef1234" --scans "generic.accept_unauthenticated_operation" --no-progress --sqa-opt-out
307308
308309
- name: Check for vulnerabilities
309310
if: ${{ steps.vulnapi.outcome != 'failure' }}
@@ -342,7 +343,7 @@ jobs:
342343
id: vulnapi
343344
run: |
344345
chmod +x vulnapi
345-
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --sqa-opt-out
346+
./vulnapi scan curl http://localhost:8080 -H "X-API-Key: abcdef1234" --no-progress --sqa-opt-out
346347
347348
- name: Stop Server
348349
if: ${{ always() }}
@@ -448,9 +449,9 @@ jobs:
448449
run: |
449450
chmod +x vulnapi
450451
if [ "${{ matrix.challenge }}" = "misconfiguration.http_method_override" ]; then
451-
./vulnapi scan curl ${{ matrix.url }} -H "Authorization: Bearer valid-token" ${{ matrix.scans }} --sqa-opt-out
452+
./vulnapi scan curl ${{ matrix.url }} -H "Authorization: Bearer valid-token" ${{ matrix.scans }} --no-progress --sqa-opt-out
452453
else
453-
./vulnapi scan curl ${{ matrix.url }} ${{ matrix.scans }} --sqa-opt-out
454+
./vulnapi scan curl ${{ matrix.url }} ${{ matrix.scans }} --no-progress --sqa-opt-out
454455
fi
455456
456457
- name: Check for vulnerabilities
@@ -498,7 +499,7 @@ jobs:
498499
continue-on-error: true
499500
run: |
500501
chmod +x vulnapi
501-
./vulnapi scan graphql ${{ matrix.url }} --scans "${{ matrix.challenge }}" --sqa-opt-out
502+
./vulnapi scan graphql ${{ matrix.url }} --scans "${{ matrix.challenge }}" --no-progress --sqa-opt-out
502503
503504
- name: Check for vulnerabilities
504505
if: ${{ steps.vulnapi.outcome != 'failure' }}
@@ -556,9 +557,9 @@ jobs:
556557
run: |
557558
chmod +x vulnapi
558559
if [ "${{ matrix.openapi }}" = "simple_no_scheme.openapi.json" ]; then
559-
./vulnapi scan openapi ./test/stub/${{ matrix.openapi }} --severity-threshold 0 --sqa-opt-out
560+
./vulnapi scan openapi ./test/stub/${{ matrix.openapi }} --severity-threshold 0 --rate 500/s --no-progress --sqa-opt-out
560561
else
561-
./vulnapi scan openapi ./test/stub/${{ matrix.openapi }} --sqa-opt-out
562+
./vulnapi scan openapi ./test/stub/${{ matrix.openapi }} --rate 500/s --no-progress --sqa-opt-out
562563
fi
563564
564565
- name: Check for vulnerabilities

.github/workflows/vampi.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: VAmPI Scan
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- vampi-scan
8+
workflow_dispatch:
9+
10+
env:
11+
GO_VERSION: "1.27"
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
permissions:
18+
contents: read
19+
20+
jobs:
21+
build:
22+
name: Build VulnAPI
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v7
27+
28+
- name: Setup Go environment
29+
uses: actions/setup-go@v7
30+
with:
31+
go-version: ${{ env.GO_VERSION }}
32+
33+
- name: Build
34+
run: go build -o vulnapi main.go
35+
36+
- name: Upload binary
37+
uses: actions/upload-artifact@v7
38+
with:
39+
name: vulnapi
40+
path: vulnapi
41+
retention-days: 1
42+
43+
scan-vulnerable:
44+
name: Scan VAmPI (vulnerable)
45+
runs-on: ubuntu-latest
46+
needs: build
47+
48+
steps:
49+
- name: Run VAmPI
50+
run: docker run -d -p 5000:5000 -e vulnerable=1 erev0s/vampi:latest
51+
52+
- name: Wait for VAmPI
53+
run: |
54+
for i in $(seq 1 30); do
55+
if curl -sf http://127.0.0.1:5000/openapi.json -o /dev/null; then
56+
echo "VAmPI is up"
57+
exit 0
58+
fi
59+
sleep 2
60+
done
61+
echo "VAmPI did not become ready"
62+
exit 1
63+
64+
- name: Populate database
65+
run: curl -sf http://127.0.0.1:5000/createdb
66+
67+
- name: Download binary
68+
uses: actions/download-artifact@v8
69+
with:
70+
name: vulnapi
71+
72+
- name: VulnAPI
73+
id: vulnapi
74+
continue-on-error: true
75+
run: |
76+
chmod +x vulnapi
77+
./vulnapi scan openapi http://127.0.0.1:5000/openapi.json --rate 500/s --no-progress --sqa-opt-out
78+
79+
- name: Fail if no vulnerabilities found
80+
if: ${{ steps.vulnapi.outcome != 'failure' }}
81+
run: |
82+
echo "Expected vulnerabilities not found"
83+
exit 1
84+
85+
- name: Stop VAmPI
86+
if: ${{ always() }}
87+
run: docker stop $(docker ps -q --filter ancestor=erev0s/vampi:latest)
88+
89+
scan-secure:
90+
name: Scan VAmPI (secure)
91+
runs-on: ubuntu-latest
92+
needs: build
93+
94+
steps:
95+
- name: Run VAmPI
96+
run: docker run -d -p 5000:5000 -e vulnerable=0 erev0s/vampi:latest
97+
98+
- name: Wait for VAmPI
99+
run: |
100+
for i in $(seq 1 30); do
101+
if curl -sf http://127.0.0.1:5000/openapi.json -o /dev/null; then
102+
echo "VAmPI is up"
103+
exit 0
104+
fi
105+
sleep 2
106+
done
107+
echo "VAmPI did not become ready"
108+
exit 1
109+
110+
- name: Populate database
111+
run: curl -sf http://127.0.0.1:5000/createdb
112+
113+
- name: Download binary
114+
uses: actions/download-artifact@v8
115+
with:
116+
name: vulnapi
117+
118+
- name: VulnAPI
119+
id: vulnapi
120+
continue-on-error: true
121+
run: |
122+
chmod +x vulnapi
123+
./vulnapi scan openapi http://127.0.0.1:5000/openapi.json --rate 500/s --no-progress --sqa-opt-out
124+
125+
- name: Fail if vulnerabilities found
126+
if: ${{ steps.vulnapi.outcome == 'failure' }}
127+
run: |
128+
echo "Unexpected vulnerabilities found in secure mode"
129+
exit 1
130+
131+
- name: Stop VAmPI
132+
if: ${{ always() }}
133+
run: docker stop $(docker ps -q --filter ancestor=erev0s/vampi:latest)

0 commit comments

Comments
 (0)