Merge pull request #1211 from tt/remove-name-verification
Remove name verification
This commit is contained in:
commit
0a71df72a1
2 changed files with 19 additions and 3 deletions
|
@ -169,6 +169,8 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
|
||||||
switch verificationError := verificationError.(type) {
|
switch verificationError := verificationError.(type) {
|
||||||
case distribution.ErrManifestBlobUnknown:
|
case distribution.ErrManifestBlobUnknown:
|
||||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestBlobUnknown.WithDetail(verificationError.Digest))
|
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestBlobUnknown.WithDetail(verificationError.Digest))
|
||||||
|
case distribution.ErrManifestNameInvalid:
|
||||||
|
imh.Errors = append(imh.Errors, v2.ErrorCodeNameInvalid.WithDetail(err))
|
||||||
case distribution.ErrManifestUnverified:
|
case distribution.ErrManifestUnverified:
|
||||||
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnverified)
|
imh.Errors = append(imh.Errors, v2.ErrorCodeManifestUnverified)
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/docker/distribution/context"
|
"github.com/docker/distribution/context"
|
||||||
"github.com/docker/distribution/digest"
|
"github.com/docker/distribution/digest"
|
||||||
"github.com/docker/distribution/manifest/schema1"
|
"github.com/docker/distribution/manifest/schema1"
|
||||||
|
"github.com/docker/distribution/reference"
|
||||||
"github.com/docker/libtrust"
|
"github.com/docker/libtrust"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ func SkipLayerVerification(ms distribution.ManifestService) error {
|
||||||
ms.skipDependencyVerification = true
|
ms.skipDependencyVerification = true
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("skip layer verification only valid for manifeststore")
|
return fmt.Errorf("skip layer verification only valid for manifestStore")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *manifestStore) Put(manifest *schema1.SignedManifest) error {
|
func (ms *manifestStore) Put(manifest *schema1.SignedManifest) error {
|
||||||
|
@ -106,8 +107,21 @@ func (ms *manifestStore) GetByTag(tag string, options ...distribution.ManifestSe
|
||||||
// content, leaving trust policies of that content up to consumers.
|
// content, leaving trust policies of that content up to consumers.
|
||||||
func (ms *manifestStore) verifyManifest(ctx context.Context, mnfst *schema1.SignedManifest) error {
|
func (ms *manifestStore) verifyManifest(ctx context.Context, mnfst *schema1.SignedManifest) error {
|
||||||
var errs distribution.ErrManifestVerification
|
var errs distribution.ErrManifestVerification
|
||||||
if mnfst.Name != ms.repository.Name() {
|
|
||||||
errs = append(errs, fmt.Errorf("repository name does not match manifest name"))
|
if len(mnfst.Name) > reference.NameTotalLengthMax {
|
||||||
|
errs = append(errs,
|
||||||
|
distribution.ErrManifestNameInvalid{
|
||||||
|
Name: mnfst.Name,
|
||||||
|
Reason: fmt.Errorf("manifest name must not be more than %v characters", reference.NameTotalLengthMax),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if !reference.NameRegexp.MatchString(mnfst.Name) {
|
||||||
|
errs = append(errs,
|
||||||
|
distribution.ErrManifestNameInvalid{
|
||||||
|
Name: mnfst.Name,
|
||||||
|
Reason: fmt.Errorf("invalid manifest name format"),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(mnfst.History) != len(mnfst.FSLayers) {
|
if len(mnfst.History) != len(mnfst.FSLayers) {
|
||||||
|
|
Loading…
Reference in a new issue