-
Notifications
You must be signed in to change notification settings - Fork 210
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
[erchef] Fix ACL updates when actor names includes '.' #1275
Conversation
Unlike users and groups, client names can contain the `.` character. In fact, this character this likely since the client name is often based on the node name which is based on the FQDN of the node. In #1159, we added the ability to add name-spaced actors and groups to ACLs. However, that changed validated the actor names against the more restrictive user/group regular expression. This change uses the standard NAME_REGEX for validation which includes `.`. It does mean that some invalid user and group names will pass validation; however, presumably such users and groups will fail to be found in the database since they can't be created. Fixes #1274 Signed-off-by: Steven Danna <[email protected]>
Signed-off-by: Steven Danna <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This continues to look good after a few passes through it. Minor comments, optionally actionable. +1 on moving regex to the regex module.
end | ||
|
||
it "returns 200", :acl do | ||
put("#{request_url}/#{permission}", platform.admin_user, :payload => update_body).should look_like({:status => 200}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also verify through a get
that the name isn't munged in any way,
@@ -58,7 +58,8 @@ | |||
%% http://wiki.chef.io/display/chef/Roles#Roles-name. Judging | |||
%% from the cookbook names and recipes in the opscode/cookbooks | |||
%% repository, this regular expression applies to them as well. | |||
-define(NAME_REGEX, "[.[:alnum:]_-]+"). | |||
-define(NAME_CHAR_CLASS, "[.[:alnum:]_-]"). | |||
-define(NAME_REGEX, ?NAME_CHAR_CLASS ++ "+"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's minor, but I don't know if the precompile will resolve this - the append might be done inline on each call. Same for the others. May not be significant enough to matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I wonder if we avoid the ++ and just use the feature where you can put two string literals next to each other: "foo" "bar"
if that happens at compile time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty confident that's the case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed it does:
-module(test).
-export([foo/0]).
foo() ->
"bar" " " "baz".
> erl
Erlang/OTP 18 [erts-7.3.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V7.3.1 (abort with ^G)
1> compile:file("test.erl", S).
* 1: variable 'S' is unbound
2> compile:file("test.erl", 'S').
{ok,test}
3>
User switch command
--> q
> head -15 test.S
{module, test}. %% version = 0
{exports, [{foo,0},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 7}.
{function, foo, 0, 2}.
{label,1}.
{line,[{location,"test.erl",3}]}.
{func_info,{atom,test},{atom,foo},0}.
{label,2}.
{move,{literal,"bar baz"},{x,0}}.
Signed-off-by: Steven Danna <[email protected]>
Signed-off-by: Steven Danna <[email protected]>
You may ask "why not remove pivotal from the list" and the answer is that I'm being paranoid about platform.admin_user being something other than pivotal. Signed-off-by: Steven Danna <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm +1 for moving this forward.
We probably should revisit what our name validation should look like in general. I'd like to see us expand what we accept, but reserve some patterns for our internal usage if at all possible.
@@ -58,7 +58,8 @@ | |||
%% http://wiki.chef.io/display/chef/Roles#Roles-name. Judging | |||
%% from the cookbook names and recipes in the opscode/cookbooks | |||
%% repository, this regular expression applies to them as well. | |||
-define(NAME_REGEX, "[.[:alnum:]_-]+"). | |||
-define(NAME_CHAR_CLASS, "[.[:alnum:]_-]"). | |||
-define(NAME_REGEX, ?NAME_CHAR_CLASS ++ "+"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty confident that's the case.
Unlike users and groups, client names can contain the
.
character.In fact, this character this likely since the client name is often
based on the node name which is based on the FQDN of the node.
In #1159, we added the ability to add name-spaced
actors and groups to ACLs. However, that changed validated the actor
names against the more restrictive user/group regular expression.
This change uses the standard NAME_REGEX for validation which includes
.
. It does mean that some invalid user and group names will passvalidation; however, presumably such users and groups will fail to be
found in the database since they can't be created.
Fixes #1274
Signed-off-by: Steven Danna [email protected]