Skip to content

feat(cosign): Support Cosign v3 Bundle signature format#22628

Merged
wy65701436 merged 4 commits intogoharbor:mainfrom
Aloui-Ikram:feat/support-cosign-v3-bundle
Dec 15, 2025
Merged

feat(cosign): Support Cosign v3 Bundle signature format#22628
wy65701436 merged 4 commits intogoharbor:mainfrom
Aloui-Ikram:feat/support-cosign-v3-bundle

Conversation

@Aloui-Ikram
Copy link
Contributor

@Aloui-Ikram Aloui-Ikram commented Dec 8, 2025

This PR adds support for the new Cosign signature format introduced in v2.6+ (and made default in v3.0+).

The Problem:
Cosign changed its default signature format to the OCI 1.1 Bundle format with the media type:
application/vnd.dev.sigstore.bundle.v0.3+json

Harbor's Subject Middleware currently only recognizes the legacy Cosign media type. As a result, new signatures are classified as generic subject.accessory artifacts. This causes the UI to show the artifact as "Not Signed" (Red X) and missing the Cosign icon.
The Fix:
I updated src/server/middleware/subject/subject.go to:

  1. Define the new bundle media type constant.
  2. Update the switch logic to map this new media type to model.TypeCosignSignature.

This change maintains backward compatibility (legacy signatures are still supported).

Verification:
Tested locally with Harbor Dev Environment (harbor-next) and Cosign v3.0.2.

  • Validated that cosign sign (defaults) creates the new bundle format.
  • Validated that Harbor API now returns type: "signature.cosign".
  • Validated that Harbor UI displays the "Signed" status correctly.

Screenshots

Before (The Issue)

Harbor fails to recognize the signature (Red X, generic accessory type):
2

After (The Fix)

Harbor correctly identifies the signature (Green Checkmark, Cosign icon):
4ee
image

Issue being fixed

Fixes #22401

Please indicate you've done the following:

  • Well Written Title and Summary of the PR
  • Label the PR as needed. "release-note/new-feature"
  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Made sure tests are passing and test coverage is added if needed.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed in website repository.

Signed-off-by: Aloui-Ikram <ikram@container-registry.com>
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 65.85%. Comparing base (c8c11b4) to head (9c6c757).
⚠️ Report is 607 commits behind head on main.

Files with missing lines Patch % Lines
src/server/middleware/subject/subject.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main   #22628       +/-   ##
===========================================
+ Coverage   45.36%   65.85%   +20.48%     
===========================================
  Files         244     1073      +829     
  Lines       13333   116095   +102762     
  Branches     2719     2931      +212     
===========================================
+ Hits         6049    76452    +70403     
- Misses       6983    35405    +28422     
- Partials      301     4238     +3937     
Flag Coverage Δ
unittests 65.85% <0.00%> (+20.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/server/middleware/subject/subject.go 47.61% <0.00%> (ø)

... and 986 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@bupd bupd left a comment

Choose a reason for hiding this comment

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

/lgtm

@Aloui-Ikram Aloui-Ikram changed the title [WIP] feat(cosign): Support Cosign v3 Bundle signature format feat(cosign): Support Cosign v3 Bundle signature format Dec 8, 2025
Signed-off-by: Aloui-Ikram <ikram@container-registry.com>
@Aloui-Ikram Aloui-Ikram force-pushed the feat/support-cosign-v3-bundle branch from d89420d to 3f05013 Compare December 8, 2025 15:02
@bupd
Copy link
Contributor

bupd commented Dec 8, 2025

@Aloui-Ikram Once again, thanks for clearing up my backlog.

@wy65701436
Copy link
Contributor

@Aloui-Ikram thanks for your contribution, can you ensure all the CI pipelines pass?

@MinerYang please have a review and validate the changes at our end, thanks.

@Aloui-Ikram
Copy link
Contributor Author

@wy65701436 You’re welcome , i reviewed the CI failure ,they are coming from unrelated UT tests ,they don’t seem related to my changes in middleware/subject

@MinerYang MinerYang added release-note/update Update or Fix and removed release-note/new-feature New Harbor Feature labels Dec 11, 2025
Signed-off-by: Aloui-Ikram <ikram@container-registry.com>
Copy link
Contributor

@MinerYang MinerYang left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@wy65701436 wy65701436 left a comment

Choose a reason for hiding this comment

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

lgtm

@wy65701436 wy65701436 enabled auto-merge (squash) December 12, 2025 07:00
@bupd
Copy link
Contributor

bupd commented Dec 12, 2025

looks like the UTTEST is flaking again.

@wy65701436 wy65701436 merged commit fbb45d8 into goharbor:main Dec 15, 2025
17 of 18 checks passed
intojhanurag pushed a commit to intojhanurag/harbor that referenced this pull request Jan 22, 2026
* feat(cosign): support Cosign v3 bundle format

Signed-off-by: Aloui-Ikram <ikram@container-registry.com>

* fix: format code with gofmt

Signed-off-by: Aloui-Ikram <ikram@container-registry.com>

* refactor: rename variable to mediaTypeCosignArtifactType

Signed-off-by: Aloui-Ikram <ikram@container-registry.com>

---------

Signed-off-by: Aloui-Ikram <ikram@container-registry.com>
Co-authored-by: Aloui-Ikram <ikram@container-registry.com>
Co-authored-by: miner <miner.yang@broadcom.com>
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.

New cosign 2.6 signature format is not recognized by Harbor

7 participants