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

Support wider range of application names #31752

Merged

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Jul 3, 2018

This extends the validation for application names to allow an optional
suffix of "-" (or "_") followed by any number of "filename safe characters"
(other than '*').

The purpose of this is to support multiple kibana instances against a
single ES cluster where the name of each kibana application is
"kibana-${kibana-index}", assuming some reasonable limits on the
Kibana index name.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
This extends the validation for application names to allow an optional
suffix of "-" (or "_") followed by any number of printable, visible
ascii characters.

The purpose of this is to support multiple kibana instances against a
single ES cluster where the name of each kibana application is
"kibana-${kibana-index}", assuming some reasonable limits on the
Kibana index name.
@tvernum tvernum added >enhancement review :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC labels Jul 3, 2018
@tvernum tvernum requested a review from albertzaharovits July 3, 2018 06:31
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@tvernum
Copy link
Contributor Author

tvernum commented Jul 3, 2018

CC: @kobelb

* - Then any number of printable, visible ASCII characters (letter, numbers, symbols) other than '*'
*/
private static final Pattern VALID_APPLICATION = Pattern.compile("^[a-z][A-Za-z0-9]{2,}([_-][\\p{Graph}&&[^*]]*)?$");
private static final Pattern VALID_APPLICATION_OR_WILDCARD = Pattern.compile("^[a-z*][A-Za-z0-9*]*([_-]\\p{Graph}*)?$");
Copy link
Contributor

@albertzaharovits albertzaharovits Jul 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The \p{Graph} thing is probably too broad for indices names

public static final Set<Character> INVALID_FILENAME_CHARS = unmodifiableSet(
. I would leave it as it is though, treading on regex is long haul.

VALID_APPLICATION_OR_WILDCARD is again too broad, it accepts multiple * intertwined with text, so more like a regex than an wildcard.
This one I would change. I would use the same regex as VALID_APPLICATION but ending with [*]?$ instead of $. Also, a test for this would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting that we only support wildcards that end in *?
That wasn't my intent, but it solves all the use cases for which wildcards are required, so it sounds like a reasonable approach, although I do need to work out an appropriate regex for it.

I do wonder whether trying to do all this with a regex is becoming a little futile...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I meant the * to only be allowed at the end, and the test will check that * is not allowed anywhere else. It was a reflex, I haven't considered the implication of it, though...

Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left one change request, OTT LGTM.

The Pattern based validation was overly permissive and gave bad error
messages. It has been rewritten to be a combination of Patterns and
explicit logic
@tvernum
Copy link
Contributor Author

tvernum commented Jul 3, 2018

Thanks @albertzaharovits
I re-wrote the implementation so that it doesn't try to do everything in a single regex. Can you have another look when you're free.

tvernum added 3 commits July 3, 2018 22:58
I had used "astrix" to match Strings.validFileNameExcludingAstrix
but since this method doesn't call that utility method, it seemed
silly to keep the misspelling.
Copy link
Contributor

@albertzaharovits albertzaharovits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tvernum tvernum merged commit 4e1031b into elastic:security-app-privs Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Security/Authorization Roles, Privileges, DLS/FLS, RBAC/ABAC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants