Skip to content

Commit 5ddc924

Browse files
committed
NV-4462 Scope the demo DAST scan and make it reliable
The "Test Case - Java Spring App" workflow scanned on every push to main. With a NIGHTVISION_TOKEN secret configured (the javaspringvulny target and auth are seeded in every account) the scan runs for real, so it should run only when a push can actually affect it, should not silently mask spec extraction failures, and should not race the app's startup. - Add a paths-ignore filter so a push touching only docs, other-platform CI glue, or the manual-only sibling notification workflows does not trigger a scan. App source, specs, Dockerfile/compose, build files, scan config, and this workflow still trigger one. - Make spec extraction assert a non-empty spec: extract to a local file and drop the `|| true` mask and backup-spec fallback, so a real API Discovery regression turns the run red instead of silently scanning with a stale spec. - Replace the fixed `sleep 10` after `docker compose up` with a readiness poll: curl the app until it accepts connections (compose's depends_on waits only for container start, and a Spring Boot + Postgres cold start routinely exceeds 10s). On timeout, dump compose logs and fail loudly instead of letting the auth replay and scan flake.
1 parent f50e51c commit 5ddc924

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

.github/workflows/nightvision.yml

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ on:
1515
push:
1616
branches:
1717
- main
18+
# Do not run the DAST scan when a push touches only files that cannot affect the
19+
# scanned app or the scan itself: docs, other-platform CI glue, and the manual-only
20+
# sibling notification workflows. App source, specs, Dockerfile/compose, build files,
21+
# scan config, and this workflow still trigger a scan. (NV-4462.)
22+
paths-ignore:
23+
- '**/*.md'
24+
- '.gitignore'
25+
- '.gitlab-ci.yml'
26+
- 'convert_sarif_to_gitlab.py'
27+
- 'azure-pipelines.yml'
28+
- 'sarif_to_azure_devops.py'
29+
- 'bitbucket-pipelines.yml'
30+
- 'Jenkinsfile'
31+
- '.github/workflows/nightvision-email.yml'
32+
- '.github/workflows/nightvision-slack.yml'
33+
- '.github/workflows/nightvision-teams.yml'
1834
workflow_dispatch:
1935

2036
env:
@@ -36,15 +52,29 @@ jobs:
3652
wget -c https://downloads.nightvision.net/binaries/latest/nightvision_latest_linux_amd64.tar.gz -O - | tar -xz; sudo mv nightvision /usr/local/bin/
3753
python -m pip install semgrep --user
3854
55+
# Extract the spec to a local file and assert it is non-empty. The '|| true' mask
56+
# and the backup-spec fallback are dropped so a real API Discovery regression turns
57+
# the run red instead of silently scanning with a stale spec. (NV-4462.)
3958
- name: (3) Extract API documentation from code
4059
run: |
41-
nightvision swagger extract ./ -t ${NIGHTVISION_TARGET} --lang spring || true
42-
if [ ! -e openapi-spec.yml ]; then
43-
cp backup-openapi-spec.yml openapi-spec.yml
44-
fi
60+
nightvision swagger extract ./ --lang spring -o openapi-spec.yml --no-upload
61+
test -s openapi-spec.yml
4562
46-
- name: (4) Start the app
47-
run: docker compose up -d; sleep 10
63+
# Spring Boot + Postgres cold start (after the Gradle image build) routinely
64+
# exceeds a fixed sleep, and compose's depends_on waits only for container start,
65+
# not for the app to accept connections. Poll until it responds (any HTTP status
66+
# means it is listening) instead of sleeping a flat 10s; on timeout, dump logs and
67+
# fail loudly rather than letting the scan flake later. --retry-max-time caps the
68+
# whole loop (~150s) so a listening-but-hung port fails fast instead of burning
69+
# --max-time on every one of --retry attempts. (NV-4462.)
70+
- name: (4) Start the app and wait until it is ready
71+
run: |
72+
docker compose up -d
73+
if ! curl -sk --retry 60 --retry-delay 2 --retry-max-time 150 --retry-all-errors --max-time 5 -o /dev/null https://127.0.0.1:9000/; then
74+
echo "App did not become ready in time; recent compose logs:"
75+
docker compose logs --no-color --tail 200
76+
exit 1
77+
fi
4878
4979
- name: (5) Scan the API
5080
run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ bin/
77
.project
88
.settings/
99
.env
10-
.DS_Store
10+
.DS_Store
11+
__pycache__

0 commit comments

Comments
 (0)