Skip to content

Conversation

@migmartri
Copy link
Member

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 skip field to policy group attachments in workflow contracts.

Implementation

  • Added skip field to PolicyGroupAttachment protobuf message
  • Implemented policy name resolution for both embedded and referenced policies
  • Filtered skipped policies in material and attestation evaluation paths
  • Added validation with warnings for non-existent policy names
  • Comprehensive test coverage for all skip scenarios

Usage

apiVersion: chainloop.dev/v1 kind: Contract metadata: name: example-contract spec: policyGroups: - ref: file://groups/sbom-quality-group.yaml with: bannedComponents: log4j@2.14.1 skip: - sbom-present - my-other-policy

Behavior

  • Policies are matched by their metadata.name field
  • Works for both material and attestation policies
  • Unknown policy names in skip list generate warnings but allow execution to continue
  • Empty skip list has no effect on evaluation

Closes #2557

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>
@migmartri migmartri requested a review from jiparis November 18, 2025 18:08
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant