Skip to content

Refactor DockerReference to ContainerImageReference#1768

Open
Copilot wants to merge 6 commits intomainfrom
copilot/refactor-docker-reference-to-container-image-refer
Open

Refactor DockerReference to ContainerImageReference#1768
Copilot wants to merge 6 commits intomainfrom
copilot/refactor-docker-reference-to-container-image-refer

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

Renames ComponentType.DockerReferenceComponentType.ContainerImageReference and all related types, files, and directories. This type will be shared by Helm and Kubernetes detectors, so the naming should not be Docker-specific.

Renamed types

  • ComponentType.DockerReferenceContainerImageReference
  • DetectorClass.DockerReferenceContainerImageReference
  • DockerReference class hierarchy → ContainerImageReference (incl. DockerReferenceKindContainerImageReferenceKind)
  • DockerReferenceComponentContainerImageReferenceComponent
  • DockerReferenceUtilityContainerImageReferenceUtility
  • DockerReferenceExceptionContainerImageReferenceException
  • DockerRegexContainerImageRegex

Renamed files/directories

  • Common/DockerReference/Common/ContainerImageReference/ (all 4 files within)
  • Contracts/DockerReference.csContainerImageReference.cs
  • TypedComponent/DockerReferenceComponent.csContainerImageReferenceComponent.cs
  • Test file renamed accordingly

Updated references

  • TypedComponentMapping, DockerfileComponentDetector, DigestUtility, schema docs

Backward compatibility

  • Added DockerReference = ContainerImageReference enum alias (marked [Obsolete]) in ComponentType so old JSON manifests containing "DockerReference" still deserialize correctly
  • Added "DockerReference"ContainerImageReferenceComponent entry in TypedComponentMapping so old component type discriminators in manifests resolve correctly
  • Updated manifest.schema.json to include both ContainerImageReference and DockerReference enum values
  • Updated TypedComponentMapping_AllMappedTypes_AreUnique test to account for the backward-compat alias

Not changed

Workflow files and VerificationTest.ps1 use --DetectorArgs DockerReference=EnableIfDefaultOff — this keys on the detector's Id string, not the ComponentType, so it remains unchanged.

New Detector Checklist

  • I have gone through the docs for creating a new detector here
  • My new detector implements IDefaultOffComponentDetector
  • I have created a PR to the verification repo with components that my new detector can find
  • (If necessary) I have updated the Feature Overview table in the README

Copilot AI review requested due to automatic review settings April 7, 2026 16:44
@jpinz jpinz marked this pull request as ready for review April 7, 2026 16:47
@jpinz jpinz requested a review from a team as a code owner April 7, 2026 16:47
@jpinz jpinz requested a review from JamieMagee April 7, 2026 16:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Renames the Docker-specific “DockerReference” component type and related utilities/models to a registry-agnostic “ContainerImageReference”, enabling reuse across multiple detectors (e.g., Dockerfile, Helm, Kubernetes) without Docker-centric naming.

Changes:

  • Renamed ComponentType.DockerReference / DetectorClass.DockerReference to ContainerImageReference equivalents and updated all references.
  • Moved/renamed Docker-reference parsing utilities/exceptions/regex to ContainerImageReference*.
  • Updated Dockerfile detector registration to emit ContainerImageReference typed components; updated tests and schema/docs to match.
Show a summary per file
File Description
test/Microsoft.ComponentDetection.Common.Tests/ContainerImageReferenceUtilityTests.cs Updates tests to use ContainerImageReferenceUtility and renamed test class.
src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs Updates detector category/component type and emits ContainerImageReferenceComponent.
src/Microsoft.ComponentDetection.Contracts/TypedComponent/ContainerImageReferenceComponent.cs Renamed typed component for container image references.
src/Microsoft.ComponentDetection.Contracts/TypedComponent/ComponentType.cs Renames enum value to ContainerImageReference.
src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs Renames detector class enum to ContainerImageReference.
src/Microsoft.ComponentDetection.Contracts/ContainerImageReference.cs Renames reference model hierarchy and conversion to typed component.
src/Microsoft.ComponentDetection.Contracts/BcdeModels/TypedComponentMapping.cs Updates polymorphic type discriminator mapping for the renamed typed component.
src/Microsoft.ComponentDetection.Common/ContainerImageReference/DigestUtility.cs Updates digest validation to use ContainerImageRegex.
src/Microsoft.ComponentDetection.Common/ContainerImageReference/ContainerImageRegex.cs Renames regex helper class to container-image terminology.
src/Microsoft.ComponentDetection.Common/ContainerImageReference/ContainerImageReferenceUtility.cs Renames parsing utility class and updates regex usage.
src/Microsoft.ComponentDetection.Common/ContainerImageReference/ContainerImageReferenceException.cs Renames exception base type/messages to container-image terminology.
docs/schema/manifest.schema.json Updates schema enums from DockerReference to ContainerImageReference.
docs/detectors/dockerfile.md Updates docs to reference ContainerImageReferenceUtility.

Copilot's findings

Comments suppressed due to low confidence (6)

src/Microsoft.ComponentDetection.Contracts/ContainerImageReference.cs:127

  • CanonicalReference.ToString() formats the digest as @${Digest} (includes a literal $), producing an invalid container image reference string (e.g., repo@$sha256:...). This should be formatted as @{Digest} without the $.

This issue also appears on line 204 of the same file.
src/Microsoft.ComponentDetection.Contracts/ContainerImageReference.cs:207

  • DualReference.ToString() formats the digest as @${Digest} (includes a literal $), producing an invalid container image reference string. Remove the $ so the string matches standard name:tag@digest syntax.
    src/Microsoft.ComponentDetection.Contracts/TypedComponent/ContainerImageReferenceComponent.cs:47
  • ContainerImageReferenceComponent.ComputeBaseId() excludes Domain, so references to the same repository/tag/digest from different registries (e.g., docker.io/library/nginx vs ghcr.io/library/nginx) will collide and be treated as the same component. Include Domain (and consider normalizing nulls) in the base identity to keep component IDs unique across registries.
    docs/schema/manifest.schema.json:158
  • The manifest schema enum now only allows ContainerImageReference. Any older manifests that still contain DockerReference in supportedComponentTypes will fail schema validation. If backward compatibility is desired, consider allowing both values (or versioning the schema) while the rename is rolling out.
            "type": "string",
            "enum": [
              "Other",
              "NuGet",
              "Npm",
              "Maven",
              "Git",
              "RubyGems",
              "Cargo",
              "Pip",
              "Go",
              "DockerImage",
              "Pod",
              "Linux",
              "Conda",
              "Spdx",
              "Vcpkg",
              "ContainerImageReference",
              "Conan",
              "Swift",
              "DotNet",
              "CppSdk"
            ]

src/Microsoft.ComponentDetection.Common/ContainerImageReference/ContainerImageReferenceUtility.cs:93

  • The utility is now container-image generic, but the public API still exposes SplitDockerDomain(...). Consider renaming this to a container-image/registry-neutral name (and optionally keeping SplitDockerDomain as an [Obsolete] wrapper) to align with the refactor and avoid reintroducing Docker-specific terminology into shared code.
    src/Microsoft.ComponentDetection.Contracts/ContainerImageReference.cs:152
  • The comment for RepositoryReference says it represents docker.io/library/ubuntu, but RepositoryReference.ToString() currently returns only Repository (no domain). Either update ToString() to include the domain or adjust the comment so it accurately describes the string representation.
  • Files reviewed: 13/13 changed files
  • Comments generated: 1

@jpinz
Copy link
Copy Markdown
Member

jpinz commented Apr 7, 2026

@copilot fix the failing verification tests

Copilot AI requested review from Copilot and removed request for Copilot April 7, 2026 17:06
Copilot AI requested review from Copilot and removed request for Copilot April 7, 2026 17:07
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 7, 2026

@copilot fix the failing verification tests

Fixed in 8f9bb09. The verification tests were failing because old scan manifests contain "DockerReference" as the component type discriminator, which wasn't recognized after the rename. Added:

  1. A backward-compat DockerReference = ContainerImageReference enum alias (marked [Obsolete]) so old JSON with "DockerReference" still deserializes to the correct ComponentType value
  2. A "DockerReference"ContainerImageReferenceComponent entry in TypedComponentMapping so old component type discriminators in manifests resolve correctly
  3. Updated the docs schema to include both enum values
  4. Updated the TypedComponentMapping_AllMappedTypes_AreUnique test to account for the backward-compat alias

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 4myvsblobprodcus32.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/D47EE5A44C32F70BEBA9A6371300F374/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/7D18E16D43FB596DC4D44D5C4D606078/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/86123D718A0A7D5E3D8DDB87D50A845A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • 5rqvsblobprodcus385.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/2D3586D8C912F6D195254B43F0F0042B/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/4EB20032E82B2584A5C53CFFE5CD470A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • azuresdkartifacts.blob.core.windows.net
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp /opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/csharp/tools/linux64/Semmle.Autobuild.CSharp (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/4EB20032E82B2584A5C53CFFE5CD470A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/2D3586D8C912F6D195254B43F0F0042B/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/86123D718A0A7D5E3D8DDB87D50A845A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • k4kvsblobprodcus344.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/2D3586D8C912F6D195254B43F0F0042B/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/86123D718A0A7D5E3D8DDB87D50A845A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/D93C69A3F90DACDB68555AD6306FA9CB/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • pdfvsblobprodcus380.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/4EB20032E82B2584A5C53CFFE5CD470A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/2D3586D8C912F6D195254B43F0F0042B/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/86123D718A0A7D5E3D8DDB87D50A845A/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)
  • ytvvsblobprodcus310.vsblob.vsassets.io
    • Triggering command: /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/.dotnet/dotnet restore --no-dependencies /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/A57A5A89CDBA36A2878C8A42DA58182C/missingpackages_workingdir --packages /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/missingpackages /p:DisableImplicitNuGetFallbackFolder=true --verbosity normal --configfile /tmp/codeql-scratch-fe72422a9cf5c763/dbs/csharp/working/nugetconfig/nuget.config --force (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of jpinz April 7, 2026 17:08
Copilot AI requested a review from jpinz April 7, 2026 17:08

# Dev nupkgs
dev-source
.nuget/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for some reason copilot kept trying to check in .nuget/nuget.exe so this removes that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants