Skip to content

Disallow AttributeRestrictions in PolicyRules - #13466

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
enj:enj/f/disallow_attribute_restrictions
Mar 21, 2017
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
enj:enj/f/disallow_attribute_restrictions

Conversation

@enj

@enj enj commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

Addresses #13334 (comment)

cc @liggitt

[test]

Signed-off-by: Monis Khan [email protected]

@enj
enj requested a review from deads2k March 20, 2017 16:06
@deads2k

deads2k commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

@smarterclayton I want this to plug a rolling update hole before you tag a level.

@@ -252,7 +252,13 @@ func ValidateRole(role *authorizationapi.Role, isNamespaced bool) field.ErrorLis
}

func validateRole(role *authorizationapi.Role, isNamespaced bool, fldPath *field.Path) field.ErrorList {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

clusterrole too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Everything funnels to validateRole.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Everything funnels to validateRole.

So it does. update text and bug me for merge.

Comment thread pkg/authorization/api/helpers.go Outdated

func (r *PolicyRuleBuilder) Rule() (PolicyRule, error) {
if r.PolicyRule.AttributeRestrictions != nil {
return PolicyRule{}, fmt.Errorf("rule may not have attributeRestrictions as they are deprecated and ignored: %#v", r.PolicyRule)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

because they are deprecated and ignored.

allErrs := validation.ValidateObjectMeta(&role.ObjectMeta, isNamespaced, path.ValidatePathSegmentName, fldPath.Child("metadata"))
for i, rule := range role.Rules {
if rule.AttributeRestrictions != nil {
allErrs = append(allErrs, field.Invalid(fldPath.Child("rules").Index(i).Child("attributeRestrictions"), rule.AttributeRestrictions, "must be null as they are deprecated and ignored"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

because they are ignored.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, don't have to say why, just "must be null"

@enj enj mentioned this pull request Mar 20, 2017
@enj
enj force-pushed the enj/f/disallow_attribute_restrictions branch from 73c2b36 to a29c8a7 Compare March 20, 2017 17:53
- projects
verbs:
- list
- apiGroups: null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add the replacement rule for this

- projects
verbs:
- list
- apiGroups: null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add the replacement rule for this

@enj
enj force-pushed the enj/f/disallow_attribute_restrictions branch from a29c8a7 to aef39f1 Compare March 20, 2017 18:14
@enj
enj force-pushed the enj/f/disallow_attribute_restrictions branch from aef39f1 to 847e3fc Compare March 20, 2017 18:33
@deads2k

deads2k commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

lgtm [merge]

allErrs = append(allErrs, field.Invalid(fldPath.Child("rules").Index(i).Child("attributeRestrictions"), rule.AttributeRestrictions, "must be null"))
}
}
return allErrs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is also where I was expecting to see validation to prevent a single rule from having both resource and non-resource data. if it's not here, it means we allow it, and have to split when converting to kube roles

@liggitt liggitt Mar 20, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we also don't require apigroups, resources, verbs, or nonresourceurls to contain items, which means our converted roles won't pass kube validation... we can either drop rules like that (since they weren't actually granting any permissions), fail the conversion, or fail when attempting to persist the converted role to kube

@deads2k

deads2k commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

this is also where I was expecting to see validation to prevent a single rule from having both resource and non-resource data. if it's not here, it means we allow it, and have to split when converting to kube roles

Or we could provide an oc migrate tool in 1.6 and tighten validation in 1.7. There will just be some rules that don't sync controller-wise until you migrate. I don't see a big issue with that.

@deads2k

deads2k commented Mar 20, 2017

Copy link
Copy Markdown
Contributor

we also don't require apigroups, resources, verbs, or nonresourceurls to contain items, which means our converted roles won't pass kube validation... we can either drop rules like that (since they weren't actually granting any permissions), fail the conversion, or fail when attempting to persist the converted role to kube

Or convert and fail trying to persist it. It's ok if the converted resources don't all validate at first. If we provide oc migrate tools to fix them up and perhaps label failing resources for inspection by the 3.7 update, there's a path forward.

@mfojtik

mfojtik commented Mar 21, 2017

Copy link
Copy Markdown
Contributor

@enj seems like something cracked in the namespace finalizer

@enj

enj commented Mar 21, 2017 •

Copy link
Copy Markdown
Contributor Author

Flake #13067 #11016 (and others - will open issues and tag) re[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 847e3fc

@deads2k

deads2k commented Mar 21, 2017

Copy link
Copy Markdown
Contributor

re[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 847e3fc

@openshift-bot

Copy link
Copy Markdown
Contributor

@openshift-bot

openshift-bot commented Mar 21, 2017 •

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin/168/) (Base Commit: 55e0221) (Image: devenv-rhel7_6093)

@openshift-bot
openshift-bot merged commit d08d28a into openshift:master Mar 21, 2017
@enj

enj commented Mar 21, 2017

Copy link
Copy Markdown
Contributor Author

@deads2k @liggitt Do I need to spawn any followup issues for this?

@jhadvig

jhadvig commented Mar 21, 2017 •

Copy link
Copy Markdown
Member

This change is breaking the upgrade process in a job that installes and upgrades origin cluster:
https://ci.openshift.redhat.com/jenkins/job/test_branch_origin_extended_conformance_install_update/88/consoleFull#-14246886155849c75fe4b0052e114d805c

Not sure if its just a flake, but I could reproduce it seweral times in a row

@liggitt

liggitt commented Mar 21, 2017

Copy link
Copy Markdown
Contributor

Are we sure that reconciliation will never try to persist a role with this attribute set in a rule ? I'm concerned about tightening validation with no announced deprecation or migration in place

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants