-
-
Notifications
You must be signed in to change notification settings - Fork 525
Migrate Fuzz tests tool to Schemathesis and add REST Fuzz tests #3122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
856882d
95fa30b
ab17c1a
ee2db6a
53680ff
ad9f80f
f499fe3
bf36420
9a2469d
62cf309
90229b3
32e8cf0
55f9c93
72f1455
76317b6
15a5338
8e94807
e7c2a83
9bfc020
35a7953
b5dff77
09c6df6
7f8dce6
45745d2
4cdc0ec
2cb8575
d8f48e4
b2889f5
b04a1bb
7f8472f
7a58f68
888d69c
049a62e
37d6ef9
b926648
65ab732
04212fc
2f3e878
0e86350
b1dd271
7e6a053
8cbcdf2
b5a1cae
30a2d91
dec17df
24dbe5b
d497542
0019c04
5e107aa
b09badb
d2b477b
8788ef1
a8af00d
0908be1
ad8b748
9df950a
42114d3
446e362
1182cc3
1fc8d64
76e0360
607fc50
5d516a8
bc1c8ef
076d6c9
40a68cb
34c5e41
8b3c80b
8e7aa32
7ebf238
1a2080e
b240fc9
92e5a48
e8304e1
349b72d
1b0d920
2b1551f
5d9bf41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| name: Run fuzz tests | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| test-file: | ||
| description: 'The test file to run fuzz tests on' | ||
| required: true | ||
| type: string | ||
| rest-url: | ||
| description: 'The REST API URL to test against' | ||
| required: false | ||
| type: string | ||
| default: 'http://localhost:9500/api/v0' | ||
|
|
||
| jobs: | ||
| run-fuzz-tests: | ||
| name: Run Fuzz Tests | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 20 | ||
| services: | ||
| db: | ||
| image: pgvector/pgvector:pg16 | ||
| env: | ||
| POSTGRES_DB: nest_db_fuzz | ||
| POSTGRES_PASSWORD: nest_user_fuzz_password | ||
| POSTGRES_USER: nest_user_fuzz | ||
| options: >- | ||
| --health-cmd="pg_isready -U nest_user_fuzz -d nest_db_fuzz -h localhost -p 5432" | ||
| --health-interval=5s | ||
| --health-retries=5 | ||
| --health-timeout=5s | ||
| ports: | ||
| - 5432:5432 | ||
| cache: | ||
| image: redis:8.0.5-alpine3.21 | ||
| options: >- | ||
| --health-cmd="redis-cli ping" | ||
| --health-interval=5s | ||
| --health-retries=5 | ||
| --health-timeout=5s | ||
| ports: | ||
| - 6379:6379 | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | ||
|
|
||
| - name: Set up Docker buildx | ||
| uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f | ||
|
|
||
| - name: Setup Backend environment | ||
| uses: ./.github/workflows/setup-backend-environment | ||
| with: | ||
| db_username: nest_user_fuzz | ||
| db_name: nest_db_fuzz | ||
|
|
||
| - name: Run backend with fuzz environment variables | ||
| run: | | ||
| docker run -d --rm --name fuzz-nest-backend \ | ||
| --env-file backend/.env.fuzz.example \ | ||
| --network host \ | ||
| -e DJANGO_DB_HOST=localhost \ | ||
| -e DJANGO_REDIS_AUTH_ENABLED=False \ | ||
| -e DJANGO_REDIS_HOST=localhost \ | ||
| -p 9500:9500 \ | ||
| owasp/nest:test-backend-latest \ | ||
| sh -c ' | ||
| python manage.py migrate && | ||
| gunicorn wsgi:application --bind 0.0.0.0:9500 | ||
| ' | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - name: Waiting for the backend to be ready | ||
| run: | | ||
| timeout 5m bash -c ' | ||
| until wget --spider http://localhost:9500/a; do | ||
| echo "Waiting for backend..." | ||
| sleep 5 | ||
| done | ||
| ' | ||
| echo "Backend is up!" | ||
|
|
||
| - name: Load Postgres data | ||
| env: | ||
| PGPASSWORD: nest_user_fuzz_password | ||
| run: | | ||
| set -euo pipefail | ||
| if ! pg_restore -h localhost -U nest_user_fuzz -d nest_db_fuzz < backend/data/nest.dump; then | ||
| echo "Data loading failed" | ||
| exit 1 | ||
| fi | ||
| echo "Data loading completed." | ||
|
|
||
| - name: Build Fuzz-testing image | ||
| uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 | ||
| with: | ||
| cache-from: | | ||
| type=gha | ||
| type=registry,ref=owasp/nest:test-fuzz-backend-cache | ||
| cache-to: | | ||
| type=gha,compression=zstd | ||
| context: backend | ||
| file: docker/backend/Dockerfile.fuzz | ||
| load: true | ||
| platforms: linux/amd64 | ||
| tags: owasp/nest:test-fuzz-backend-latest | ||
|
|
||
|
Comment on lines
93
to
106
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find fuzz-related files and directories
echo "=== Searching for Dockerfile in fuzz directories ==="
fd -t f "Dockerfile" | grep -i fuzz
echo -e "\n=== Searching for entrypoint.sh in fuzz directories ==="
fd -t f "entrypoint.sh" | grep -i fuzz
echo -e "\n=== Searching for test_rest.py or similar fuzz test files ==="
fd -t f "test_rest.py"
echo -e "\n=== Checking all fuzz directories ==="
fd -t d "fuzz"
echo -e "\n=== Listing contents of backend directory ==="
ls -la backend/ 2>/dev/null || echo "backend/ not found"
echo -e "\n=== Listing contents of docker directory ==="
ls -la docker/ 2>/dev/null || echo "docker/ not found"
echo -e "\n=== Repository root structure ==="
ls -la | grep -E "^d"Repository: OWASP/Nest Length of output: 2685 Critical: Docker build file path must be relative to context. When
This causes Docker to look for Fix by making the file path relative to the context directory: Proposed fix - name: Build Fuzz-testing image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83
with:
cache-from: |
type=gha
type=registry,ref=owasp/nest:test-fuzz-backend-cache
cache-to: |
type=gha,compression=zstd
context: docker/backend/fuzz
- file: docker/backend/fuzz/Dockerfile
+ file: Dockerfile
load: true
platforms: linux/amd64
tags: owasp/nest:test-fuzz-backend-latest🤖 Prompt for AI Agents
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure it works after file location refactoring.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: Length of output: 1213 @arkid15r, I've verified the file structure after the refactoring and can confirm everything is in place correctly: ✅ Verified file locations:
The CodeRabbit fix is correct and necessary. With the current configuration:
Docker will look for Apply the fix: context: docker/backend/fuzz
file: Dockerfile # ✅ relative to contextThis matches the pattern used in your 🧠 Learnings used |
||
| - name: Run fuzz tests | ||
| env: | ||
| TEST_FILE: ${{ inputs.test-file }} | ||
| REST_URL: ${{ inputs.rest-url }} | ||
| run: | | ||
| docker run \ | ||
| --network host \ | ||
| -e BASE_URL=http://localhost:9500 \ | ||
| -e CI=true \ | ||
| -e REST_URL="$REST_URL" \ | ||
| -e TEST_FILE="$TEST_FILE" \ | ||
| owasp/nest:test-fuzz-backend-latest | ||
Uh oh!
There was an error while loading. Please reload this page.