-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
SCC sorting by priority #5543
SCC sorting by priority #5543
Conversation
fixing commits so I don't incur rebase wrath, I packaged v1beta3 in with non-v1beta3. edit: fixed. Last 3 commits need reviewed |
a711f59
to
209fc92
Compare
Ones with priority specified should come before ones without. Equal priority should maybe sort by the current sort behavior, rather than name, for backwards compatibility |
In the case of a tie between priority AND old security score, name is fine to break the tie |
// SortPriority influences the sort order of SCCs when evaluating which SCCs to try first for | ||
// a given pod request based on access in the Users and Groups fields. The higher the int, the | ||
// higher priority. If scores for multiple SCCs are equal they will be sorted by name. | ||
SortPriority int `json:"sortPriority" description:"influences the sort order when evaluating SCCs available to the user"` |
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.
"determines which SCC is used when multiple SCCs allow a particular pod; higher priority SCCs are preferred"
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 would prefer priority
over sortPriority
... priority implies a sort, I think
I was wondering this during SCC review as well. Why not simply merge all the user's available SCCs together, taking the highest privilege and preserving ranges alongside the "any's" for defaulting purposes. Then attempt to fill in the default pod a single time instead of once per SCC with the full set of available options. Wouldn't that solve the union problem, the separate of SCCs without specifying all combinations problem, the improper priority problem, and make the code easier to understand all at the same time? Seems like that would only become weird if you wanted crazy things like, "you can use these GIDs, but only as this UID". I'm guessing you guys considered and discarded this, but I'd like to understand why. |
Mixing and matching bits of different SCCs isn't a good idea... privileges can combine to allow things that weren't intended. For example:
Mixing and matching would let someone host mount without getting the accompanying uid and selinux restriction the admin specified. |
Maybe there's a better structure to use for constraints or the bindings. Having to specify every possible combination is pretty ridiculous and scales horribly as more options are added. Even just assuming on/off, we have 11 options making 2048 different potential policies to manage instead of 11. Also for amusement, 2048 options taken 2048 at a time where order matters yields 1.6x10^5894 options. A simple, predictable system, :). |
Sounds pretty powerful to me :) |
I doubt you're going to see more than 10 in use at any one site. And we On Oct 31, 2015, at 8:25 AM, David Eads [email protected] wrote: Maybe there's a better structure to use for constraints or the bindings. — |
@liggitt - round 2 ready for your eyes
|
// Priority influences the sort order of SCCs when evaluating which SCCs to try first for | ||
// a given pod request based on access in the Users and Groups fields. The higher the int, the | ||
// higher priority. If scores for multiple SCCs are equal they will be sorted by name. | ||
Priority int `json:"sortPriority" description:"determines which SCC is used when multiple SCCs allow a particular pod; higher priority SCCs are preferred"` |
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.
change json field name to priority
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.
Damn, you're too quick. I just caught it. Fixed.
2abbb7b
to
d40d15e
Compare
@@ -68,9 +68,11 @@ func TestAdmit(t *testing.T) { | |||
Type: kapi.SupplementalGroupsStrategyMustRunAs, | |||
}, | |||
Groups: []string{"system:serviceaccounts"}, | |||
// give this scc priority since it is what we want to validate with | |||
SortPriority: 1, |
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.
don't you need a more restrictive SCC that also matches to actually check that you're matching on sort priority, and not just the secondary pointScore
sort?
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, I don't need this priority at all. The SCC below it is more restrictive (a MustRunAs uid strategy rather than a MustRunAsRange) that is in scc-sa
. Removing the priority they would have equal priorities. The scores should ensure that scc-sa-exact
is tried before scc-sa
but it should be failing to validate. We check the matched name in the test run which will ensure we're matching against what we expect....removing.
390e56c
to
3ee3f37
Compare
LGTM |
it matters when we want to set defaults if the admin hasn't expressed a priority intent. Also, validate priority to be |
I would expect the following behavior: Missing priority behaves like priority=0 for purposes of sorting |
I see what you're saying here. I was considering it an option of either "overwrite all priorities" or "don't touch priorities" during reconcile but if the options are really "set missing" or "overwrite all" then nil makes sense. That was my disconnect. In that case, the first reconcile run (regardless of option) will set all the missing priorities on bootstrapped commands and subsequent changes to the bootstrap SCC priorities will never update until |
Yes, so choose priorities carefully (or just set the one we care about to 1?) |
25e7686
to
0b829bc
Compare
@liggitt - updated to be a pointer, added checks in sorting, and a nil vs non-nil test. Also updated the printer so that nil priority doesn't show as 0 which would be confusing since 0 > nil now. Please take another pass. |
oh, btw, I set anyuid to 10 to give wiggle room if an admin wants to adjust other priorities (so they don't have to immediately adjust anyuid just to keep it prioritized). |
0 should equal nil for sorting purposes, imo |
add validation to make sure non-nil priority is >= 0 |
var ( | ||
// this is set to 10 to allow wiggle room for admins to set other priorities without | ||
// having to adjust anyUID. | ||
securityContextConstraintsAnyUIDPriority = 10 |
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.
10 PRINT "HELLO"
20 PRINT "WORLD"
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.
parse exception. Do you want the lower score (except 0) to be considered higher priority?
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 was just amused at setting to 10 to allow space... took me back...
made nil == 0 for sorting, added in the printer, added validation method for negative priorities. |
LGTM |
[test] |
Evaluated for origin test up to 4c9aeb1 |
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/6827/) |
Sorts SCCs by a priority field and then by name. Adds a priority to the privileged SCC so that if you have administrative access you will use that SCC by default (though this is largely unnecessary since the first commit allows authenticated users to run as any uid).
Builds on #5498 which is hanging out in the merge queue right now so only the last three commits need reviewed.
Fixes #5317
@liggitt @smarterclayton