oslopolicy-checker should pass data unaltered to policy enforcer
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oslo.policy |
Confirmed
|
Medium
|
Unassigned |
Bug Description
oslopolicy-checker is making unfounded assumptions on the input data it is provided or not provided as may be the case. The point of the tool is to be able to test policy evaluation standalone without needing to run a full OpenStack deployment.
The following input data is required as input to the policy engine:
* policy rules
* credential data
* target data
* rule to evaluate (or all rules)
In it's current form oslopolicy-checker is making assumptions about the credential data (it calls it access data). It tries to cherry-pick certain value out of the input access data and then omits all other data it didn't cherry-pick out. If the access data did not contain an expected key the tool fails with a KeyError (this is bad). It's also bad it throws away the rest of the data. This means if you know exactly what the inputs are, let's say because you captured it from log data or some other mechanism and want to test the policy enforcement based on the data passed to the oslo.policy enforcer you can't, this means you can't evaluate actual data.
In a similar vein if target data is not passed oslopolicy-checker will "invent" target data (project_id), once again making the wild assumption the project_id key is in the credential data (it might not be, which then raises a KeyError exception).
Actual runtime collection of data being passed to the oslo.policy enforcer demonstrates some of these assumptions cannot be satisfied.
The oslopolicy-checker should pass the EXACT data to the rule evaluation function that is provided as input to the tool, it should not be in the business of trying to impose it's interpretation of the data.
As an aside the --is-admin command line arg required a value of "true" is a non-standard way to enable a value, it should be just --is-admin which is easily done with an arparse action of 'store_true'. If we're going to adjust the behavior of the command line arguments we might as well address this as well.
FYI, I do have a patch ready and will submit shortly.