diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-10-04 02:11:56 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 02:11:56 -0700 |
commit | 1fe955600979f54ada204afa6c357fd094d6f549 (patch) | |
tree | d22ee28ccf664986109f61c52a041aa803e2e505 /cmd/podman/network_create.go | |
parent | 7af4074c6f96d0fabd2ab5dd6c5773053f80aa08 (diff) | |
parent | c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba (diff) | |
download | podman-1fe955600979f54ada204afa6c357fd094d6f549.tar.gz podman-1fe955600979f54ada204afa6c357fd094d6f549.tar.bz2 podman-1fe955600979f54ada204afa6c357fd094d6f549.zip |
Merge pull request #4188 from Mrigank11/validate_network_name
podman network create: validate user input
Diffstat (limited to 'cmd/podman/network_create.go')
-rw-r--r-- | cmd/podman/network_create.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/podman/network_create.go b/cmd/podman/network_create.go index 378a92568..11f13faad 100644 --- a/cmd/podman/network_create.go +++ b/cmd/podman/network_create.go @@ -4,11 +4,12 @@ package main import ( "fmt" - "github.com/containers/libpod/pkg/network" "net" "github.com/containers/libpod/cmd/podman/cliconfig" + "github.com/containers/libpod/libpod" "github.com/containers/libpod/pkg/adapter" + "github.com/containers/libpod/pkg/network" "github.com/containers/libpod/pkg/rootless" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -58,6 +59,9 @@ func networkcreateCmd(c *cliconfig.NetworkCreateValues) error { if len(c.InputArgs) > 1 { return errors.Errorf("only one network can be created at a time") } + if len(c.InputArgs) > 0 && !libpod.NameRegex.MatchString(c.InputArgs[0]) { + return libpod.RegexError + } runtime, err := adapter.GetRuntimeNoStore(getContext(), &c.PodmanCommand) if err != nil { return err |