-
Notifications
You must be signed in to change notification settings - Fork 40
feat: add skip field to policy group attachments #2564
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
feat: add skip field to policy group attachments #2564
Conversation
Add support for explicitly disabling specific policies within a policy group
by specifying their metadata names in a skip list. This allows users to
selectively exclude policies from evaluation without modifying the policy
group itself.
Changes:
- Add skip field to PolicyGroupAttachment protobuf message
- Implement getPolicyName() helper to extract policy names from attachments
- Filter skipped policies in both material and attestation evaluation paths
- Add validateSkipList() to warn about non-existent policy names
- Add comprehensive test coverage for skip functionality
Example usage:
```yaml
policyGroups:
- ref: file://groups/sbom-quality.yaml
with:
bannedLicenses: AGPL-3.0
skip:
- sbom-present
- license-check
```
Policies are matched by metadata.name. Unknown policy names in the skip list
generate warnings but allow execution to continue.
Closes chainloop-dev#2557
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Change validateSkipList() to return an error instead of logging warnings directly. This allows the function to be reused in contexts where validation errors should block execution, while still supporting the current behavior of logging warnings and continuing. Changes: - Update validateSkipList() to collect unknown policy names and return error - Callers in VerifyMaterial() and VerifyStatement() log errors as warnings - Add comprehensive tests for validateSkipList() error returns - All existing tests continue to pass The current user-facing behavior is unchanged: unknown policy names generate warnings but do not block execution. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Update the warning log message to be more user-friendly. The error object already contains the group name and list of unknown policies, so the message now clearly indicates what the issue is. Changed message from "skip list validation warning" to "some policies in skip list were not found in the policy group". The error details include the specific policy names and group name. Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
|
@jiparis ready to review, tested it locally :) |
| - name: chainloop | ||
| default: true | ||
| url: http://localhost:8002/v1 | ||
| # policy_providers: |
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.
this was added by mistake in another PR
pkg/policies/policy_groups.go
Outdated
| } | ||
|
|
||
| // Validate skip list and log warnings for unknown policy names | ||
| if err := pgv.validateSkipList(ctx, group, groupAtt); err != nil { |
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.
this call is overloading the verification step, since it's downloading all policies just to get their names. Verification is also downloading them in the same call.
I'd suggest skipping the validation at this point, since it has no effect. It could probably be moved to att init or contract command line options.
Another option / improvement would be to preload all policies in advance so that they can be used for the validation and for the verification.
Same comment for VerifyMaterial
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.
good catch, I think you are right, not worth the tradeoff at runtime indeed
jiparis
left a comment
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.
Accepting, but check my comment please. I think it's important for a good user experience.
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Summary
Add support for explicitly disabling specific policies within a policy group by specifying their metadata names in a skip list.
Users can now selectively exclude policies from evaluation without modifying the policy group itself by adding a
skipfield to policy group attachments in workflow contracts.Implementation
skipfield toPolicyGroupAttachmentprotobuf messageUsage
Behavior
metadata.namefieldCloses #2557