By now you can scan images, dependencies, code and running apps. Each tool prints its own report, in its own format, and every run starts from scratch. That does not scale: ten tools across fifty services is five hundred reports a week, and no human reads them. Worse, the same CVE shows up in every report, so you cannot tell what is new, what you already triaged, and what someone decided to accept last month.
DefectDojo is where findings go to live. It ingests the output of your scanners, deduplicates findings across runs and tools, tracks their state (active, false positive, risk accepted, mitigated), and gives you one dashboard instead of five hundred reports. It is the aggregation layer that makes all the scanning you have done actually usable.
Why this lab matters
Scanning produces findings; it does not manage them. Without an aggregation layer every scan is a fresh wall of CVEs with no memory of what you already decided. DefectDojo is the system of record: it remembers, deduplicates, and tracks state, so a finding you triaged once stays triaged.
After this lab you will be able to:
- run DefectDojo and understand its product / engagement / test / finding model
- import a scanner's output through the REST API
- see how re-importing the same scan deduplicates instead of piling up
- triage a finding so a known issue stops being noise on every run
How this lab works
Read this once - every lab in this track follows the same rules.
Where you type the commands. Open a terminal and go to the folder where you cloned this repository. On Windows use PowerShell (search for it in the Start menu), on macOS or Linux use Terminal. Every path in this lab is written from the repository root, so stay there unless a step says otherwise.
Lines starting with > are explanations, not commands. Don't paste them.
Only the text inside grey code boxes gets typed.
The 📋 sign means it's your turn. When you see it, try the step yourself first. Underneath it there is a collapsed "Not sure how?" arrow with the answer - open it after you have tried, not before. The labs are written this way on purpose: you remember what you worked out, not what you pasted.
If a command fails, that is normal. Some steps fail deliberately to show you what the error looks like. Read the sentence above the command before you assume something is broken.
When you get stuck, in this order:
- Re-read the paragraph above the command - the answer is usually there.
- Open the "Not sure how?" arrow.
- Open
hints.mdfor a nudge. - Open
solution.mdfor the full answer. Using it is fine; copying it without reading is not.
When you finish, run the Cleanup section at the bottom. Labs share ports and container names, so leftovers from one lab break the next one.
Before you start
Takes about 60 minutes.
Docker Desktop must be running. Check it:
docker version
A Server: section in the output means you are ready. If you get an error
instead, start Docker Desktop and wait until the whale icon stops animating.
DefectDojo runs seven containers and needs a few GB of RAM - give Docker Desktop at least 4GB (Settings → Resources) or the app will be very slow to start.
Run every command from the root of this repository - the paths in this lab are written relative to it.
References
Starting DefectDojo
This Docker Compose file runs the whole platform: the Django app in four roles (web, scheduler, worker, one-time initializer), an nginx front end, a Postgres database and a Valkey (Redis) queue.
Start it in the background:
docker compose -f labs/defectdojo/docker-compose.yml up -d
The initializer container sets up the database and the admin user, then exits - the first start takes a few minutes while it pulls images and migrates the schema. Watch it finish:
docker compose -f labs/defectdojo/docker-compose.yml logs -f initializer
When the initializer logs stop and the container exits, DefectDojo is ready at http://localhost:8080. The admin user is admin and the password is set in the compose file to Lab-DevSecOps-2026!.
That password is hard-coded for the lab only. A real install generates a random one on first boot and prints it in the initializer logs.
📋 Open the UI and log in to confirm the platform is up.
Not sure how?
Browse to http://localhost:8080, enter admin / Lab-DevSecOps-2026!, and you land on the dashboard. It is empty - no findings yet. If the page does not load, the app may still be migrating; give it another minute and check docker compose -f labs/defectdojo/docker-compose.yml ps to confirm every service is running.
Getting an API token
We will drive DefectDojo through its REST API, the same way a pipeline would. First authenticate as admin to get a token:
curl -s -X POST http://localhost:8080/api/v2/api-token-auth/ -H "Content-Type: application/json" -d "{\"username\": \"admin\", \"password\": \"Lab-DevSecOps-2026!\"}"
The response is {"token":"..."}. Copy the token value - every call below sends it in an Authorization: Token <your-token> header.
Scanning an image and importing the results
Produce a scan to import. We will scan the decade-old python:3.4-alpine image you met in the scanning lab, writing Trivy's JSON output into this lab's folder:
docker run --rm -v "${PWD}:/repo" aquasec/trivy:0.76.0 image --format json --output /repo/labs/defectdojo/reports/trivy.json python:3.4-alpine
Now import that report. The auto_create_context flag tells DefectDojo to create the product and engagement for you if they do not exist:
curl -s -X POST http://localhost:8080/api/v2/import-scan/ -H "Authorization: Token YOUR_TOKEN" -F "scan_type=Trivy Scan" -F "product_type_name=DevSecOps Lab" -F "product_name=python-app" -F "engagement_name=Image scan" -F "auto_create_context=true" -F "file=@labs/defectdojo/reports/trivy.json"
The response summarises the import - how many findings were created. In the UI, Products → python-app now shows the findings grouped under an engagement and a test.
📋 Use the API to find out how many active findings DefectDojo is now tracking.
Not sure how?
The findings endpoint returns a count field for any filter. Ask for active findings only:
curl -s -H "Authorization: Token YOUR_TOKEN" "http://localhost:8080/api/v2/findings/?active=true&limit=1"
Read the count at the top of the JSON - that is the total number of active findings, regardless of the limit. It is a big number; that is the point of needing a tool to manage them.
Deduplication: importing the same scan again
A pipeline runs the same scan on every build. If every run created fresh findings, your dashboard would double every day. DefectDojo deduplicates. Re-import the exact same report with the reimport-scan endpoint:
curl -s -X POST http://localhost:8080/api/v2/reimport-scan/ -H "Authorization: Token YOUR_TOKEN" -F "scan_type=Trivy Scan" -F "product_name=python-app" -F "engagement_name=Image scan" -F "auto_create_context=true" -F "file=@labs/defectdojo/reports/trivy.json"
The response reports something like new_findings: 0, reactivated_findings: 0, closed_findings: 0. Nothing changed, because DefectDojo recognised every finding from the first import. That is the behaviour that makes continuous scanning usable: only genuinely new problems show up as new.
Lab
Aggregation only pays off when more than one scan feeds in. Scan a second image - the old Nginx web image from the scanning lab is a good noisy example - and import it into the same product under a new engagement. Then do the thing scanning alone never let you do: pick one finding and triage it through the API, marking it as a false positive or risk-accepted, so it drops out of the active count and stays out on the next import.
If something goes wrong
Cannot connect to the Docker daemon - Docker Desktop is not running.
Start it and wait until the whale icon stops animating.
port is already allocated - a container from an earlier lab is still
holding that port. See what is running with docker ps, then remove the old
container with docker rm -f <name>.
The UI returns 502 or will not load - the app is still starting. DefectDojo
is heavy; wait a minute, then check every service is up with
docker compose -f labs/defectdojo/docker-compose.yml ps. The uwsgi service
is the web app - if it keeps restarting, read its logs.
401 Unauthorized from the API - the token is wrong or expired. Re-run the
api-token-auth call and copy the new token, with no spaces around it.
The import returns 0 findings - check the Trivy report was actually
written (labs/defectdojo/reports/trivy.json should be a large file) and that
scan_type is exactly Trivy Scan.
Still stuck? The Cleanup section below resets everything, so you can start the lab again from a clean machine.
Cleanup
Remove this lab's containers and its volumes - DefectDojo stores data in
volumes, so a plain down would leave the database behind:
docker compose -f labs/defectdojo/docker-compose.yml down -v
This removes only the containers this lab started. If you want a clean slate,
docker pswill show anything still running.