Skip to content

Commit

Permalink
Merge pull request #235 from knqyf263/fix/repository_url
Browse files Browse the repository at this point in the history
Fix OCI repository URL resolution
  • Loading branch information
puerco authored Aug 30, 2024
2 parents 0502b40 + 32d37a1 commit a7af197
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/ctl/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ func (impl *defaultVexCtlImplementation) NormalizeProducts(subjects []productRef
ref := ""
qs := p.Qualifiers.Map()
if r, ok := qs["repository_url"]; ok {
ref = fmt.Sprintf("%s/%s", strings.TrimSuffix(r, "/"), p.Name)
ref = strings.TrimSuffix(r, "/")
} else {
// digest or image
ref = p.Name
Expand Down
4 changes: 2 additions & 2 deletions pkg/ctl/implementation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestNormalizeProducts(t *testing.T) {
},
{
name: "purl, custom registry",
products: []productRef{{Name: "pkg:oci/kube-apiserver?repository_url=registry.k8s.io&tag=v1.26.0"}},
products: []productRef{{Name: "pkg:oci/kube-apiserver?repository_url=registry.k8s.io/kube-apiserver/&tag=v1.26.0"}},
expectedImage: []productRef{{Name: "registry.k8s.io/kube-apiserver:v1.26.0", Hashes: make(map[vex.Algorithm]vex.Hash)}},
expectedOther: []productRef{},
expectedUnattestable: []productRef{},
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestVerifyImageSubjects(t *testing.T) {
[]intoto.Subject{
{Name: "ghcr.io/test/image@sha256:74634d9736a45ca9f6e1187e783492199e020f4a5c19d0b1abc2b604f894ac99"},
},
[]string{"pkg:oci/image@sha256:74634d9736a45ca9f6e1187e783492199e020f4a5c19d0b1abc2b604f894ac99?repository_url=ghcr.io/test"},
[]string{"pkg:oci/image@sha256:74634d9736a45ca9f6e1187e783492199e020f4a5c19d0b1abc2b604f894ac99?repository_url=ghcr.io/test/image"},
false,
},
} {
Expand Down

0 comments on commit a7af197

Please sign in to comment.