fix(events): Match.cidr rejects IPv6 addresses with an embedded IPv4 address - #38473
fix(events): Match.cidr rejects IPv6 addresses with an embedded IPv4 address#38473devteamaegis wants to merge 1 commit into
Match.cidr rejects IPv6 addresses with an embedded IPv4 address#38473Conversation
…address
The IPv6 branch of the cidr() validation regex lost its backslashes, so
every embedded-IPv4 octet group reads as a literal letter instead of a
digit: (25[0-5]|2[0-4]d|1dd|[1-9]?d) matches 'd', not \d, and the
separator '.' matches any character.
Match.cidr('::ffff:192.168.0.1') therefore threw 'Invalid IP address
range' at synth time, while the nonsense range '::ffff:1dd.1dd.1dd.1dd'
was accepted. Restore \d, \. and \s in that group.
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
✅ A exemption request has been requested. Please wait for a maintainer's review.
Match.cidr rejects IPv6 addresses with an embedded IPv4 address
|
Exemption Request This change is confined to a client-side validation regex in An The two unit tests in Happy to add an integration test instead if you'd prefer one; please say so and I'll follow up. |
|
Exemption Request This is a validation-only change: one line in It only changes which strings are accepted at synth time — for any input that already synthesized, the emitted event pattern is byte-for-byte unchanged. There is no new deployable/runtime behavior for an integration test to exercise; the fix is pure input validation. It's fully covered by the unit tests added in |
Issue # (if applicable)
Closes #38475.
Reason for this change
events.Match.cidr()throws at synth time on any IPv6 range that embeds an IPv4 address, and accepts a nonsense one.IPv4-mapped IPv6 (
::ffff:a.b.c.d, RFC 4291 §2.5.5) is a normal way to write these ranges, so an EventBridge rule using one fails to synth at all. Plain IPv4 and plain IPv6 are unaffected.Description of changes
The IPv6 regex in
Match.cidrlost its backslashes in the embedded-IPv4 alternatives. It readsso
dmatches the literal letterdrather than\d, and the separator.matches any character.192cannot match[1-9]?d, which is why every real address is rejected — and1ddmatches literally, which is why the malformed one passes. The leading/trailings*(for\s*) is wrong the same way.This restores
\d,\.and\sin that group — 14 occurrences, one line, no structural change.The identical regex is also in
aws-ec2/lib/prefix-list.ts; that copy is fixed separately in #38474, since the two modules cannot share a helper.Describe any new or updated permissions being added
None.
Description of how you validated changes
Two unit tests added in
aws-events/test/matchers.test.ts, covering the accepted and rejected cases. Both fail onmain:and pass with the change. Full module suite
jest aws-events/test: 178 passed across 10 suites. ESLint clean.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license