Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EventPatternonAWS::Events::RuleandAWS::Events::Archiveis typed only as object-or-string, so nothing looksinside it, and a malformed pattern fails at deployment with "Event pattern is not valid". This adds
E9014(Error,engine origin), which walks the pattern (object or JSON string) and reports unknown matcher keys, malformed
numeric/anything-but/prefix/suffix/exists/wildcard operands,
$orwith sibling keys, empty arrays, and scalars wherean array or object is required.
The walk lives in
template-model/src/event_pattern.rsand is shared by both engines: the CEL engine calls itdirectly, and the Rego policy calls it through a new
event_pattern_violations()builtin (documented inCUSTOM_RULES.md), following the shape of #452. Values that are unknown until deployment (Ref, GetAtt, Sub, If,overridable parameters) are never judged.
Related issue
Closes #467
Validation behavior changes
Evidence: the EventBridge event pattern documentation (links in the issue) and deployments to a real account, in which
each rejected shape rolled back the stack with "Event pattern is not valid. Reason: ..." and the accepted controls
deployed (details in the issue).
Rejected cases:
resources/templates/bad/E9014_invalid_event_patterns.yaml(one resource per shape, ten findings,including a JSON string pattern and an
AWS::Events::Archive).Accepted cases:
resources/templates/good/E9014_valid_event_patterns.yaml(every documented matcher shape,$ornested and at the top level, a JSON string pattern, a CommaDelimitedList parameter,
Fn::Sub,Fn::If,RefandFn::GetAttoperands, and an archive).Tests: unit tests in
event_pattern.rs;cel-engine/tests/conformance.rs;rego-engine/tests/integration.rs;cfn-validate/tests/resource_rule_parity.rs(asserts identical findings and the exact message per resource). Snapshotswere regenerated; the only changed report keys are the two new templates, and no existing corpus template gains a
finding.
Checklist
selectors agree.
code quality guide.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license.