feat(policies): allow gate=false to override org-wide blocking#2777
feat(policies): allow gate=false to override org-wide blocking#2777matiasinsaurralde wants to merge 8 commits intochainloop-dev:mainfrom
Conversation
206bdbe to
55e399f
Compare
|
Additionally, Both the In order to try the |
| except: | ||
| - EXTENSION_NO_DELETE | ||
| - FIELD_SAME_DEFAULT | ||
| - FIELD_SAME_CARDINALITY |
There was a problem hiding this comment.
I am not sure we want to disable this globally but instead you coudl add an annotation in your specific case?
There was a problem hiding this comment.
Note that breaking change detection doesn't support inline comment ignores.
- buf:lint references in Buf code.
- buf:breaking references in Buf code (no occurrences).
Also exceptions are only per file/directory level.
Given that we control the gRPC clients/servers that use these messages and that the bool to optional bool doesn't imply a wire format change in PB, it should be safe to regenerate the bindings and update any other parts of the code that use this message.
Also buf breaking always compares to latest main. If this PR lands (with or without the exceptions, which we can also leave out), a subsequent PR won't raise a breaking change error - cc @jiparis
There was a problem hiding this comment.
Yeah, unfortunately buf breaking doesn't support inline ignores as buf lint does. To be honest, I'm wondering how this is the first time we are facing this issue. Did we update buf recently?
The only solution is adding this top level except option. The change to optional is safe, as it only affects to generated code. Wired bytes are exactly the same (although with different semantics from now on).
migmartri
left a comment
There was a problem hiding this comment.
great, ptal at my comments, thanks
app/cli/cmd/attestation_push.go
Outdated
| // Effective gate semantics are already resolved in policy evaluations. | ||
| // For backwards compatibility, fall back to aggregate status only if | ||
| // no evaluations are available. | ||
| if len(status.PolicyEvaluations) == 0 && status.HasPolicyViolations { |
There was a problem hiding this comment.
I don't understand this change, mind elaborating a bit?
There was a problem hiding this comment.
This was dead code from backwards compatibility code (that we don't need for this case), I've added comments about it on the cubic thread in this same PR.
| Requirements: attachment.Requirements, | ||
| RawResults: engineRawResultsToAPIRawResults(rawResults), | ||
| Gate: attachment.GetGate(), | ||
| Gate: policyAttachmentGate(attachment, pv.defaultGate), |
There was a problem hiding this comment.
ok, so before the default gate was outside the context of policy verifier and now you are bringing both in?
There was a problem hiding this comment.
Right, PolicyEvaluation.Gate was populated with the raw attachment value (attachment.GetGate()), while the org-level default (block_on_policy_violation) was applied later in CLI enforcement.
The efective gate is now resolved inside PolicyVerifier (policyAttachmentGate(attachment, pv.defaultGate)), following the 3 state behavior (to achieve default on / opt-out per policy):
- Explicit
gate: true: blocking. - Explicit
gate: false: non-blocking (opt-out) - Unset
gate: inherits org default.
e4de61d to
bafe560
Compare
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/cli/cmd/attestation_push.go">
<violation number="1" location="app/cli/cmd/attestation_push.go:199">
P1: Backward-compatible fallback removed: when `MustBlockOnPolicyViolations` is true but no policy evaluations are available (e.g., older server version or edge case), the function no longer blocks on `HasPolicyViolations`. This silently allows attestation pushes through despite policy violations. The PR description mentions "a safe fallback when policy evaluations are unavailable," but the fallback was actually deleted.
The remaining `if` block is also effectively a no-op for control flow — both branches return `nil` — so nothing blocks in the `MustBlockOnPolicyViolations` path anymore.
Consider restoring the fallback for the zero-evaluations case.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…eritance Make PolicyAttachment.gate presence-aware to distinguish unset from explicit false. Resolve effective gate at evaluation time using org default when unset. Update attestation push enforcement to block on effective gated violations. Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Move the FIELD_SAME_CARDINALITY exception from buf.yaml to an inline ignore on PolicyAttachment.gate in crafting_schema.proto limiting the suppression to the specific field change. Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
Remove the `len(PolicyEvaluations) == 0 && HasPolicyViolations` backward-compatibility
fallback from validatePolicyEnforcement. Both fields are always produced together by a
single call to getPolicyEvaluations(), so if the evaluations map is empty HasPolicyViolations
is always false — the condition is structurally unreachable.
Flatten the nested `if MustBlockOnPolicyViolations { if bypassPolicyCheck { ... } }` to
a single `if MustBlockOnPolicyViolations && bypassPolicyCheck { ... }` for clarity.
Signed-off-by: Matías Insaurralde <matias@chainloop.dev>
f7db36c to
075655e
Compare
PR for #2769
This change implements per-policy gate override behavior for policy enforcement.