-
Notifications
You must be signed in to change notification settings - Fork 43
add policy spec and component name to Rego input #3077
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
base: main
Are you sure you want to change the base?
Conversation
Add policySpec field to ApplicationSnapshotImage struct and store p.Spec() in the constructor. This is the foundation for exposing the policy configuration to Rego policies. - Add ecc import for EnterpriseContractPolicySpec type - Add policySpec field to ApplicationSnapshotImage struct - Store p.Spec() in NewApplicationSnapshotImage constructor Refs: https://issues.redhat.com/browse/EC-1615
Add ComponentName field to the Input struct for Rego policy evaluation. This enables Rego policies to scope volatile config warnings to specific components. - Add ComponentName field to Input struct with json tag - Populate ComponentName from a.component.Name in WriteInputFile Refs: https://issues.redhat.com/browse/EC-1615
Add PolicySpec field to the Input struct for Rego policy evaluation. This exposes the full EnterpriseContractPolicySpec including volatile configuration (include/exclude rules with effectiveOn, effectiveUntil, imageRef, imageDigest, componentNames) to Rego policies. - Add PolicySpec field to Input struct with json tag - Populate PolicySpec from a.policySpec in WriteInputFile - Update snapshot files for new policy_spec field in JSON output Refs: https://issues.redhat.com/browse/EC-1615
Add test cases to verify the new input fields are correctly serialized to JSON for Rego policy evaluation. - Add ecc import for EnterpriseContractPolicySpec type - Add test case for component_name serialization - Add test case for policy_spec with volatile config including: - sources[].volatileConfig.include with effectiveOn/effectiveUntil - sources[].volatileConfig.exclude with imageDigest - Update snapshots with new test case output Refs: https://issues.redhat.com/browse/EC-1615
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
862ce33 to
d6e1a79
Compare
Update snapshots to include the new component_name and policy_spec fields added to the Rego input JSON. Fixed field ordering to match actual output: - component_name and policy_spec come after snapshot - policy_spec includes correct URL format (no https://, includes ref param) - policy_spec includes additional fields (rekorUrl, publicKey) Affected tests: - policy input output - OLM manifests Refs: https://issues.redhat.com/browse/EC-1615
d6e1a79 to
05e8bf8
Compare
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
0b64eb9 to
af1d18b
Compare
Add acceptance test scenario that validates the schema contract between ec-cli and ec-policies for volatile config warnings. This test: 1. Creates a policy with volatileConfig.include rules containing: - Rule with no expiration (triggers no_expiration warning) - Rule with effectiveUntil in future (triggers expiring_rule warning) - Rule with effectiveOn in future (triggers pending_rule warning) - Rule scoped to component name (tests componentNames field) 2. Uses a Rego policy (package main) that reads from: - input.policy_spec.sources[_].volatileConfig.include[_] - input.component_name - All VolatileCriteria fields (effectiveOn, effectiveUntil, componentNames, etc.) 3. If either the CLI or ec-policies changes the schema in a breaking way, this test will fail, providing early detection of contract violations. Fixed: Added deny rule (always false) required by ec validation framework.
af1d18b to
778c61f
Compare
|
/retest |
User description
Add PolicySpec and ComponentName fields to the Rego input JSON (input.json) to enable Rego policies to evaluate volatile configuration rules and generate image-scoped warnings.
https://issues.redhat.com/browse/EC-1615
PR Type
Enhancement
Description
Add PolicySpec field to Input struct for Rego policy evaluation
Add ComponentName field to Input struct for component-scoped warnings
Store policy specification in ApplicationSnapshotImage during construction
Add test cases for new ComponentName and PolicySpec serialization
Diagram Walkthrough
File Walkthrough
application_snapshot_image.go
Add PolicySpec and ComponentName to Input structinternal/evaluation_target/application_snapshot_image/application_snapshot_image.go
eccpackage for EnterpriseContractPolicySpec typepolicySpecfield to ApplicationSnapshotImage structp.Spec()in NewApplicationSnapshotImageconstructor
ComponentNameandPolicySpecfields to Input struct with JSON tagsmethod
application_snapshot_image_test.go
Add tests for ComponentName and PolicySpec fieldsinternal/evaluation_target/application_snapshot_image/application_snapshot_image_test.go
eccpackage for EnterpriseContractPolicySpec typeinclude/exclude rules
imageDigest fields