mirror of
https://github.com/containers/podman.git
synced 2025-10-19 04:03:23 +08:00
Do not crash on invalid filters
Vendor in latest containers/common Fixes #23120 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
2
go.mod
2
go.mod
@ -13,7 +13,7 @@ require (
|
||||
github.com/checkpoint-restore/go-criu/v7 v7.1.0
|
||||
github.com/containernetworking/plugins v1.5.1
|
||||
github.com/containers/buildah v1.36.1-0.20240715114330-4a82e0a3f382
|
||||
github.com/containers/common v0.59.1-0.20240715151621-fdf625dfee0e
|
||||
github.com/containers/common v0.59.1-0.20240717135212-fdbae3a180cb
|
||||
github.com/containers/conmon v2.0.20+incompatible
|
||||
github.com/containers/gvisor-tap-vsock v0.7.4-0.20240515153903-01a1a0cd3f70
|
||||
github.com/containers/image/v5 v5.31.1-0.20240711123249-1dbd8fbbe516
|
||||
|
4
go.sum
4
go.sum
@ -79,8 +79,8 @@ github.com/containernetworking/plugins v1.5.1 h1:T5ji+LPYjjgW0QM+KyrigZbLsZ8jaX+
|
||||
github.com/containernetworking/plugins v1.5.1/go.mod h1:MIQfgMayGuHYs0XdNudf31cLLAC+i242hNm6KuDGqCM=
|
||||
github.com/containers/buildah v1.36.1-0.20240715114330-4a82e0a3f382 h1:NUScZGjAC6Cd1KuPcnCac10Q/gz01PULzh7Em/VXZOc=
|
||||
github.com/containers/buildah v1.36.1-0.20240715114330-4a82e0a3f382/go.mod h1:HlwJHYRlP5j8siiPY46I8py00hlGxWPC/vCZZ/01EEU=
|
||||
github.com/containers/common v0.59.1-0.20240715151621-fdf625dfee0e h1:x6PiZObWn9XD9lcvC6ShqDvvoTsRBktY8ycuwhlWWug=
|
||||
github.com/containers/common v0.59.1-0.20240715151621-fdf625dfee0e/go.mod h1:KrQ9y5qa7TBVzp7qs7I1MVi6Uxntu0hM5wjd5bmvMnM=
|
||||
github.com/containers/common v0.59.1-0.20240717135212-fdbae3a180cb h1:9OgHqOACzWRzPFewtx/lOSKnPvWAMMlW3ruvXQL4fP4=
|
||||
github.com/containers/common v0.59.1-0.20240717135212-fdbae3a180cb/go.mod h1:KrQ9y5qa7TBVzp7qs7I1MVi6Uxntu0hM5wjd5bmvMnM=
|
||||
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
|
||||
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
|
||||
github.com/containers/gvisor-tap-vsock v0.7.4-0.20240515153903-01a1a0cd3f70 h1:aACcXSIgcuPq5QdNZZ8B53BCdhqYvw33/8QmZWJATvg=
|
||||
|
@ -38,7 +38,11 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions)
|
||||
filters := make(map[string][]string, len(opts.Filter))
|
||||
for _, filter := range opts.Filter {
|
||||
f := strings.SplitN(filter, "=", 2)
|
||||
filters[f[0]] = append(filters[f[0]], f[1])
|
||||
if len(f) > 1 {
|
||||
filters[f[0]] = append(filters[f[0]], f[1])
|
||||
} else {
|
||||
filters[f[0]] = append(filters[f[0]], "")
|
||||
}
|
||||
}
|
||||
options := new(images.ListOptions).WithAll(opts.All).WithFilters(filters)
|
||||
psImages, err := images.List(ir.ClientCtx, options)
|
||||
|
@ -123,6 +123,9 @@ Labels.created_at | 20[0-9-]\\\+T[0-9:]\\\+Z
|
||||
run_podman images ${opts} --filter=before=$iname
|
||||
is "$output" "sha256:$iid--$IMAGE" "filter: before"
|
||||
|
||||
run_podman 125 image list -f json
|
||||
is "$output" 'Error: invalid image filter "json": must be in the format "filter=value or filter!=value"' "Invalid filter"
|
||||
|
||||
# Clean up
|
||||
run_podman rmi $iname
|
||||
run_podman rm $cname
|
||||
|
6
vendor/github.com/containers/common/libimage/filters.go
generated
vendored
6
vendor/github.com/containers/common/libimage/filters.go
generated
vendored
@ -88,6 +88,8 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
||||
return tree, nil
|
||||
}
|
||||
|
||||
filterInvalidValue := `invalid image filter %q: must be in the format "filter=value or filter!=value"`
|
||||
|
||||
var wantedReferenceMatches, unwantedReferenceMatches []string
|
||||
filters := map[string][]filterFunc{}
|
||||
duplicate := map[string]string{}
|
||||
@ -101,7 +103,7 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
||||
} else {
|
||||
split = strings.SplitN(f, "=", 2)
|
||||
if len(split) != 2 {
|
||||
return nil, fmt.Errorf("invalid image filter %q: must be in the format %q", f, "filter=value or filter!=value")
|
||||
return nil, fmt.Errorf(filterInvalidValue, f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,7 +197,7 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
||||
filter = filterBefore(until)
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported image filter %q", key)
|
||||
return nil, fmt.Errorf(filterInvalidValue, key)
|
||||
}
|
||||
if negate {
|
||||
filter = negateFilter(filter)
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -169,7 +169,7 @@ github.com/containers/buildah/pkg/sshagent
|
||||
github.com/containers/buildah/pkg/util
|
||||
github.com/containers/buildah/pkg/volumes
|
||||
github.com/containers/buildah/util
|
||||
# github.com/containers/common v0.59.1-0.20240715151621-fdf625dfee0e
|
||||
# github.com/containers/common v0.59.1-0.20240717135212-fdbae3a180cb
|
||||
## explicit; go 1.21.0
|
||||
github.com/containers/common/internal
|
||||
github.com/containers/common/internal/attributedstring
|
||||
|
Reference in New Issue
Block a user