Skip to content

feat(locations): container scanners emit the scanned image as an Image location - #15999

Merged
Maffooch merged 2 commits into
bugfixfrom
parsers/container-image-locations
Sep 18, 2026
Merged

Maffooch merged 2 commits into
bugfixfrom
parsers/container-image-locations

Conversation

@blakeaowens

Copy link
Copy Markdown
Contributor

Container scanners emit the scanned image as an Image location

Open-source half of the Pro code-to-cloud work (Container Image Locations). The documentation for the feature merged separately in #15979; this PR is the parser contract only. Text-only description.

What changes

  • dojo/tools/locations.py: LocationData.image(...) with exactly six keys (registry, repository, digest, tag, oci_source, oci_revision), always present, and split_image_reference(reference) which splits [registry/]repository[:tag][@digest] into raw parts without normalising them. The first path segment counts as a registry only when it contains a dot or a colon or is localhost, so nginx:1.25 has no registry and the consumer decides the default.
  • Five parsers attach the scanned image to every finding of a container scan, inside locations_enabled(), one location per digest the image is known by, else one tag-only location:
    • Trivy: ArtifactType == "container_image", Metadata.RepoDigests and RepoTags, ArtifactName as the fallback. Filesystem, repository and SBOM scans add nothing.
    • Grype: source.type == "image"; repoDigests when present, else manifestDigest with the user's reference.
    • Anchore Enterprise: the manifest digest that keys each image in the report, plus the repository:tag in the policy row.
    • Trivy Operator: report.artifact and report.registry.server on vulnerability and exposed-secret reports.
    • Snyk Container: projectName starting with docker-image|, tag read from path; Snyk reports no digest.

Behaviour without a consumer

Open-source imports are unchanged: LocationManager.make_abstract_locations drops types it does not know with a debug log, so the new items are inert until an installation registers the image type.

Tests

  • Exact data dict assertions on existing fixtures for all five parsers, guarded with skip_unless_v3.
  • One small fabricated Trivy report (unittests/scans/trivy/image_multi_digest.json) with two repo digests, asserting two locations that share the tag.
  • A negative case: a Trivy filesystem scan adds no image location.
  • A table test for split_image_reference and the six-key shape.
  • Fixtures and examples use placeholder names only.

Pairs with the DefectDojo Pro pull request for the same story (base bugfix, milestone 3.3.200).

🤖 Generated with Claude Code

…d hierarchy edges

Documents the Pro code-to-cloud work: the Container Image location type (registry,
repository, digest and tag, tag-only rows kept distinct), where images appear (All
Images, the asset location map region, the finding's Runs in tile), the image to
repository link and its manual override, the suggested deploys-to edges on the
hierarchy page, and the Container Image root cause type.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@blakeaowens blakeaowens added this to the 3.3.200 milestone Sep 18, 2026
@blakeaowens
blakeaowens force-pushed the parsers/container-image-locations branch from eb44f1b to cedeed0 Compare September 18, 2026 01:46
…e location

Adds LocationData.image, a six-key contract (registry, repository, digest, tag,
oci_source, oci_revision) that Pro's Container Image location type consumes, and
split_image_reference, which splits a raw image reference without normalising it.
Open-source imports are unchanged: LocationManager already drops location types it
does not know, so the new items only take effect where a consumer registers the
image type.

Five parsers attach the scanned image to every finding of a container scan, one
location per digest the image is known by and a tag-only location when the scanner
reports no digest: Trivy (ArtifactType container_image, Metadata.RepoDigests and
RepoTags), Grype (source.target repo digests, else the manifest digest with the
user's reference), Anchore Enterprise (the evaluated image id and tag), Trivy
Operator (report.artifact and report.registry, on vulnerability and secret
reports), and Snyk Container (docker-image projects, tag from path, no digest).

Tests assert the exact data dicts on existing fixtures and one small fabricated
Trivy report with two repo digests; a table test covers the splitter.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Maffooch
Maffooch added this pull request to the merge queue Sep 18, 2026
Merged via the queue into bugfix with commit e51ac1e Sep 18, 2026
50 checks passed
@Maffooch
Maffooch deleted the parsers/container-image-locations branch September 18, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants