Accept wildcard mandatory signature repositories

This commit is contained in:
copilot-swe-agent[bot]
2026-05-29 15:58:51 +00:00
committed by GitHub
parent 3b8813be6e
commit c024d0e04e
3 changed files with 35 additions and 1 deletions
+1 -1
View File
@@ -135,7 +135,7 @@ func (linter *Linter) CheckMandatorySignatures(repo string, manifestDigest godig
mandatory := false
for _, mandatoryRepo := range linter.config.MandatorySignatures {
if repo == mandatoryRepo {
if mandatoryRepo == "*" || mandatoryRepo == "**" || repo == mandatoryRepo {
mandatory = true
break
@@ -81,6 +81,40 @@ func TestMandatorySignaturesFunction(t *testing.T) {
So(err, ShouldNotBeNil)
So(pass, ShouldBeFalse)
})
for _, wildcard := range []string{"*", "**"} {
wildcard := wildcard
Convey("mandatory signatures check rejects unsigned images for wildcard repository list "+wildcard, t, func() {
enable := true
lintConfig := &extconf.LintConfig{
BaseConfig: extconf.BaseConfig{Enable: &enable},
MandatorySignatures: []string{wildcard},
}
dir := t.TempDir()
testStoreCtlr := ociutils.GetDefaultStoreController(dir, log.NewTestLogger())
err := WriteImageToFileSystem(CreateRandomImage(), "zot-test", "0.0.1", testStoreCtlr)
So(err, ShouldBeNil)
indexContent, err := os.ReadFile(path.Join(dir, "zot-test", "index.json"))
So(err, ShouldBeNil)
var index ispec.Index
err = json.Unmarshal(indexContent, &index)
So(err, ShouldBeNil)
linter := lint.NewLinter(lintConfig, log.NewTestLogger())
linter.SetSignatureVerifier(mockImageTrustStore{trusted: true}, true)
imgStore := local.NewImageStore(dir, false, false,
log.NewTestLogger(), monitoring.NewMetricsServer(false, log.NewTestLogger()), linter, nil, nil, nil)
pass, err := linter.CheckMandatorySignatures("zot-test", index.Manifests[0].Digest, imgStore)
So(err, ShouldNotBeNil)
So(pass, ShouldBeFalse)
})
}
}
type mockImageTrustStore struct {
BIN
View File
Binary file not shown.