aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMrigank Krishan <mrigankkrishan@gmail.com>2019-10-04 02:00:29 +0530
committerMrigank Krishan <mrigankkrishan@gmail.com>2019-10-04 02:34:01 +0530
commitc5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba (patch)
tree22b35a2055f803e811eb12666460f7627889b53a /libpod
parent86c8650c2328a4a611e614c7220627feae4d4eae (diff)
downloadpodman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.tar.gz
podman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.tar.bz2
podman-c5e26f8e40f3bc51ee7cdfce8eb4207105e4c4ba.zip
podman network create: validate user input
Disallow invalid/confusing names such as '../bar' or 'foo ' Closes #4184 Signed-off-by: Mrigank Krishan <mrigankkrishan@gmail.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/options.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/libpod/options.go b/libpod/options.go
index d28cb3d8c..22ab22a95 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -20,8 +20,8 @@ import (
)
var (
- nameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
- regexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
+ NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$")
+ RegexError = errors.Wrapf(define.ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*")
)
// Runtime Creation Options
@@ -648,8 +648,8 @@ func WithName(name string) CtrCreateOption {
}
// Check the name against a regex
- if !nameRegex.MatchString(name) {
- return regexError
+ if !NameRegex.MatchString(name) {
+ return RegexError
}
ctr.config.Name = name
@@ -1426,8 +1426,8 @@ func WithVolumeName(name string) VolumeCreateOption {
}
// Check the name against a regex
- if !nameRegex.MatchString(name) {
- return regexError
+ if !NameRegex.MatchString(name) {
+ return RegexError
}
volume.config.Name = name
@@ -1532,8 +1532,8 @@ func WithPodName(name string) PodCreateOption {
}
// Check the name against a regex
- if !nameRegex.MatchString(name) {
- return regexError
+ if !NameRegex.MatchString(name) {
+ return RegexError
}
pod.config.Name = name
@@ -1550,8 +1550,8 @@ func WithPodHostname(hostname string) PodCreateOption {
}
// Check the hostname against a regex
- if !nameRegex.MatchString(hostname) {
- return regexError
+ if !NameRegex.MatchString(hostname) {
+ return RegexError
}
pod.config.Hostname = hostname