Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate SLM policy ids strictly (#45998) #46145

Merged
merged 1 commit into from
Sep 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,9 @@ public ActionRequestValidationException validate() {
ActionRequestValidationException err = new ActionRequestValidationException();

// ID validation
if (id.contains(",")) {
err.addValidationError("invalid policy id [" + id + "]: must not contain ','");
}
if (id.contains(" ")) {
err.addValidationError("invalid policy id [" + id + "]: must not contain spaces");
if (Strings.validFileName(id) == false) {
err.addValidationError("invalid policy id [" + id + "]: must not contain the following characters " +
Strings.INVALID_FILENAME_CHARS);
}
if (id.charAt(0) == '_') {
err.addValidationError("invalid policy id [" + id + "]: must not start with '_'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public void testValidation() {

ValidationException e = policy.validate();
assertThat(e.validationErrors(),
containsInAnyOrder("invalid policy id [a,b]: must not contain ','",
containsInAnyOrder(
"invalid policy id [a,b]: must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?]",
"invalid snapshot name [<my, snapshot-{now/M}>]: must not contain contain" +
" the following characters [ , \", *, \\, <, |, ,, >, /, ?]",
"invalid repository name [ ]: cannot be empty",
Expand Down