1
0
mirror of https://github.com/containers/image.git synced 2025-04-18 19:44:05 +03:00

Validate the tags returned by a registry

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2024-04-18 19:10:39 +02:00 committed by Krzysztof Wilczyński
parent 1b9415b7eb
commit 4b2d28a409
No known key found for this signature in database
GPG Key ID: 7C64768D3DE334E7

View File

@ -88,7 +88,12 @@ func GetRepositoryTags(ctx context.Context, sys *types.SystemContext, ref types.
if err = json.NewDecoder(res.Body).Decode(&tagsHolder); err != nil {
return nil, err
}
tags = append(tags, tagsHolder.Tags...)
for _, tag := range tagsHolder.Tags {
if _, err := reference.WithTag(dr.ref, tag); err != nil { // Ensure the tag does not contain unexpected values
return nil, fmt.Errorf("registry returned invalid tag %q: %w", tag, err)
}
tags = append(tags, tag)
}
link := res.Header.Get("Link")
if link == "" {