Merge pull request #10128 from vieux/filters_image

Server-side restriction of allowed image filters
This commit is contained in:
Arnaud Porterie 2015-01-19 13:24:03 -08:00
commit cb9db04fd7
2 changed files with 8 additions and 10 deletions

View File

@ -50,10 +50,6 @@ const (
tarHeaderSize = 512
)
var (
acceptedImageFilterTags = map[string]struct{}{"dangling": {}}
)
func (cli *DockerCli) CmdHelp(args ...string) error {
if len(args) > 1 {
method, exists := cli.getMethod(args[:2]...)
@ -1352,12 +1348,6 @@ func (cli *DockerCli) CmdImages(args ...string) error {
}
}
for name := range imageFilterArgs {
if _, ok := acceptedImageFilterTags[name]; !ok {
return fmt.Errorf("Invalid filter '%s'", name)
}
}
matchName := cmd.Arg(0)
// FIXME: --viz and --tree are deprecated. Remove them in a future version.
if *flViz || *flTree {

View File

@ -11,6 +11,8 @@ import (
"github.com/docker/docker/pkg/parsers/filters"
)
var acceptedImageFilterTags = map[string]struct{}{"dangling": {}}
func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
var (
allImages map[string]*image.Image
@ -22,6 +24,12 @@ func (s *TagStore) CmdImages(job *engine.Job) engine.Status {
if err != nil {
return job.Error(err)
}
for name := range imageFilters {
if _, ok := acceptedImageFilterTags[name]; !ok {
return job.Errorf("Invalid filter '%s'", name)
}
}
if i, ok := imageFilters["dangling"]; ok {
for _, value := range i {
if strings.ToLower(value) == "true" {