Repository navigation
refactor(server): split policy config into evaluations and operations - #2354
Conversation
|
The latest Buf updates on your PR. Results from workflow Buf CI / verify-proto (pull_request).
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
542d1e7 to
4ee0c9e
Compare
|
This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size. |
4ee0c9e to
485def6
Compare
| expressions []string | ||
| } | ||
|
|
||
| func validateProviderFields(where, provider string, f providerFields) error { |
There was a problem hiding this comment.
Small thought, since this is the config people will start using: each provider's settings are top-level fields, and this switch only knows oasf/opa/cel. Adding a provider later means changing this struct and this function. Would a block per provider work (cel: {expressions: ...}, opa: {file: ...}), or letting each provider check its own settings? You'd still get the "doesn't apply to this provider" error. Not a blocker, it's just easier to change now than after a release.
485def6 to
1177006
Compare
There was a problem hiding this comment.
Approved as part of the stack, with one request before this reaches a release.
mode on an operation policy is read from the config but never used. Setting mode: off or mode: shadow is accepted, and the policy still rejects records exactly as in enforce. I checked with a push policy that rejects everything: it refused the record in all four cases (no mode, enforce, shadow, off). Someone who sets off to switch a policy off would get it enforced. Please make the config reject off and shadow for operation policies until they are implemented. Nothing is released yet, so this costs nothing.
Also, operation policies now need a name. Before, only evaluation policies did. The description says there is no behaviour change, so it's worth mentioning there.
19f018c to
9149c61
Compare
|
This PR exceeds the recommended size of 2000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note that this PR might take longer to review due to large size. |
9149c61 to
f983bd6
Compare
Signed-off-by: Tibor Kircsi <[email protected]>
f983bd6 to
bbb3e78
Compare
Content policies lived in one list distinguished only by op, whose four values were three points in a record's lifecycle and "evaluate", which is not one. That conflation made an evaluation policy look like an operation, and it is upstream of most of what makes the model hard to explain: an evaluation policy has no op and no mode because it never acts, while an operation policy has both and no scheduling.
They are now two blocks, each carrying only the fields that apply to it. config: is gone with them, since splitting by kind leaves each block's settings mostly common; a setting belonging to another provider is now rejected rather than silently ignored.
No semantics change: the same policies run at the same points with the same results.
policy.enforcement stays as a third block, which is one more than the two kinds this change describes. It survives because it is still the only thing driving the read gate: the search mode injects SQL into the index query, and the fetch mode runs a separate count for a record read by CID. Neither read is expressed as an operation policy yet, so dropping the block now would remove the gate with nothing in its place. It is retired once pull and search are operation policies, at which point the IDs it lists become a condition inside such a policy and its two modes become that policy's mode.
Mode moves to the validators config package, with policyconfig.Mode an alias for it, so the read gate and an operation policy cannot drift into meaning different things by the same word. All three values parse; only enforce is acted on until the operation write path lands.
OPA's name still defaults to the file name without .rego, and oasf can no longer appear as an evaluation, because a verdict is stored against hashed policy content and a schema behind an HTTP endpoint has none.
Refs #2340