-
Notifications
You must be signed in to change notification settings - Fork 292
CA-252876: AD group name with parenthesis not work as expect in Xense… #3031
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
Conversation
|
For example, https://github.com/fillzero/xen-api/blob/535d72b81cc878f9d19e1e78a12ec3b6c1e16eaa/ocaml/xapi/extauth_plugin_ADpbis.ml#L489 After the change, log output: |
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 fine with this for now but strongly believe this should be refactored to use regular expression-matching or scanf-matching to extract the desired identifiers from the string directly without rewriting the string. I'd like to see a comment from @jonludlam.
I'm not that bothered about using regexps, but I do want to see unit tests for this module. This PR definitely shouldn't be merged without a unit test for at least the function being changed (and the functions it in turn calls). |
@lindig @jonludlam |
("", "Group[2 of 2] name = testdomain\\domain+users (gid = 580911617, sid = S-1-5-21-791009147-1041474540-2433379237-513)")], | ||
["S-1-5-21-791009147-1041474540-2433379237-1102"; "S-1-5-21-791009147-1041474540-2433379237-513"]; | ||
] | ||
end) |
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.
Can you add a test for a couple of malformed entries as well?
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.
@mseri
Thanks for your comment.
Updated. Are you happy to review again?
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.
Actually, can you add a test over [("blah", "1"); ("", "0 | 1 | 2 | 3")]
as well?
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.
Is it supposed to get '1'
really? I would imagine that that should be considered broken input... and get []
or an error.
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.
@mseri , here is the output using utop:
utop # extract_sid_from_group_list [("blah", "1"); ("", "0 | 1 | 2 | 3")];;
- : bytes list = ["1"]
And log from make test
2017-05-19T14:57:55+00:00 607ae1f1e5f0#00 I: Test base_suite:0:test_extauth_ADpbis:1:test_pbis_extract_sid:1:[("blah", "1"); ("", "0 | 1 | 2 | 3")] -> ["1"] is successful.
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.
Yes, that is exactly my point. It should not. You should extract the sid
, and there is no sid
in that string. Also I believe you would get something like:
(*Note: I did not test the following, I might be wrong *)
extract_sid_from_group_list [("Number of groups found for user 'cnk3@UN'", "1");
("", "Group[1 of 1] name = a|b|c|d\\UN\\KnmOJ (gid = 492513842, sid = S-1-5-31-5921451325-154521381-3135732118-4527)")];;
["b"];
as well, which would be clearly wrong.
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 am happy with it. What do you think @lindig @jonludlam ?
EDIT: can you add one more test?
@mseri |
I am a bit concerned about the new test input result: it should not return ["1"] for that. [("Number of groups found for user 'cnk3@UN'", "1");
("", "Group[1 of 1] name = a|b|c|d\\UN\\KnmOJ (gid = 492513842, sid = S-1-5-31-5921451325-154521381-3135732118-4527)")],
["b"]; |
@mseri
So, it's impossible to have a group\username like BTW, I will try to use regular expression-matching or scanf-matching suggested by @lindig and update this PR later. |
@fillzero Ok, good. Thanks for clarifying! Then you can remove that specific line from the test. |
It looks as if this PR supersedes #3034
to the commit message of the commit in this one. |
…rver 7.0 pool This also fixes CP-22274 Replace string_trim with built-in String.trim Signed-off-by: Liang Dai <liang.dai1@citrix.com>
@mseri |
@jonludlam is it fine to merge? |
Looks lovely now thanks! We've broken the 14% mark too :-) |
…rver 7.0 pool
If the AD group name has parenthesis, the original code parses the wrong sid as below: