diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2018-01-23 12:16:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-23 12:16:42 +0100 |
commit | 478a26e7b0da84c9911ba3b616d244633245698f (patch) | |
tree | 9f05e8bddff6a950c33585fac561d5ac09677a7e /controller-api/src/main | |
parent | 3859cc47b9abfb6b8236dfe5ad81397573e058dd (diff) | |
parent | 53740801d5a99e0516de55dc47a6ec1689345934 (diff) |
Merge pull request #4732 from vespa-engine/jvenstad/tls-enforce-name-constraints
Restrict tenant and application names to not have double dashes, upon…
Diffstat (limited to 'controller-api/src/main')
3 files changed, 7 insertions, 3 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/ApplicationId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/ApplicationId.java index 0a5f2809780..fceecedb9fe 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/ApplicationId.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/ApplicationId.java @@ -22,7 +22,7 @@ public class ApplicationId extends NonDefaultIdentifier { public static void validate(String id) { if (!isLegal(id)) { - throwInvalidId(id, "Must match pattern " + strictPattern, "application"); + throwInvalidId(id, strictPatternExplanation); } } diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Identifier.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Identifier.java index 70ebc8712d5..2fd75e25498 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Identifier.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/Identifier.java @@ -12,7 +12,11 @@ import java.util.regex.Pattern; */ public abstract class Identifier { - protected static final Pattern strictPattern = Pattern.compile("[a-z0-9][a-z0-9-]{0,26}[a-z0-9]"); + protected static final String strictPatternExplanation = + "New tenant or application names must start with a letter, may contain no more than 20 " + + "characters, and may only contain lowercase letters, digits or dashes, but no double-dashes."; + // TODO: Use this also for instances, if they ever get proper support. + protected static final Pattern strictPattern = Pattern.compile("^(?=.{1,20}$)[a-z](-?[a-z0-9]+)*$"); private static final Pattern serializedIdentifierPattern = Pattern.compile("[a-zA-Z0-9_-]+"); private static final Pattern serializedPattern = Pattern.compile("[a-zA-Z0-9_.-]+"); diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/TenantId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/TenantId.java index 82cd6d80ec8..2c619fb58ef 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/TenantId.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/identifiers/TenantId.java @@ -22,7 +22,7 @@ public class TenantId extends NonDefaultIdentifier { public static void validate(String id) { if (!strictPattern.matcher(id).matches()) { - throwInvalidId(id, "Must match pattern " + strictPattern, "tenant"); + throwInvalidId(id, strictPatternExplanation); } } |