mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 12:28:01 +08:00
Merge pull request from GHSA-55r9-5mx9-qq7r
when a client pushes an image zot's inline dedupe will try to find the blob path corresponding with the blob digest that it's currently pushed and if it's found in the cache then zot will make a symbolic link to that cache entry and report to the client that the blob already exists on the location. Before this patch authorization was not applied on this process meaning that a user could copy blobs without having permissions on the source repo. Added a rule which says that the client should have read permissions on the source repo before deduping, otherwise just Stat() the blob and return the corresponding status code. Signed-off-by: Petu Eusebiu <peusebiu@cisco.com> Co-authored-by: Petu Eusebiu <peusebiu@cisco.com>
This commit is contained in:
committed by
GitHub
parent
002ff05f6e
commit
aaee0220e4
Vendored
+36
@@ -141,6 +141,42 @@ func (d *DynamoDBDriver) GetBlob(digest godigest.Digest) (string, error) {
|
||||
return out.OriginalBlobPath, nil
|
||||
}
|
||||
|
||||
func (d *DynamoDBDriver) GetAllBlobs(digest godigest.Digest) ([]string, error) {
|
||||
blobPaths := []string{}
|
||||
|
||||
resp, err := d.client.GetItem(context.TODO(), &dynamodb.GetItemInput{
|
||||
TableName: aws.String(d.tableName),
|
||||
Key: map[string]types.AttributeValue{
|
||||
"Digest": &types.AttributeValueMemberS{Value: digest.String()},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
d.log.Error().Err(err).Str("tableName", d.tableName).Msg("failed to get blob")
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
out := Blob{}
|
||||
|
||||
if resp.Item == nil {
|
||||
d.log.Debug().Err(zerr.ErrCacheMiss).Str("digest", string(digest)).Msg("failed to find blob in cache")
|
||||
|
||||
return nil, zerr.ErrCacheMiss
|
||||
}
|
||||
|
||||
_ = attributevalue.UnmarshalMap(resp.Item, &out)
|
||||
|
||||
blobPaths = append(blobPaths, out.OriginalBlobPath)
|
||||
|
||||
for _, item := range out.DuplicateBlobPath {
|
||||
if item != out.OriginalBlobPath {
|
||||
blobPaths = append(blobPaths, item)
|
||||
}
|
||||
}
|
||||
|
||||
return blobPaths, nil
|
||||
}
|
||||
|
||||
func (d *DynamoDBDriver) PutBlob(digest godigest.Digest, path string) error {
|
||||
if path == "" {
|
||||
d.log.Error().Err(zerr.ErrEmptyValue).Str("digest", digest.String()).
|
||||
|
||||
Reference in New Issue
Block a user