Skip to content

fix: Escape hyphen in SSM dynamic reference pattern - #4700

Merged
kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4692
Sep 10, 2026
Merged

kddejong merged 1 commit into
aws-cloudformation:mainfrom
kddejong:fix/issue/4692

Conversation

@kddejong

Copy link
Copy Markdown
Contributor

Fixes #4692

The _ssm pattern [a-zA-Z0-9_.-/]+ treated .-/ as an ASCII range (46-47) rather than a literal hyphen, so an SSM parameter segment composed solely of hyphens would fail E1050 validation. Escaping the hyphen matches the intent and aligns with the already-correct REGEX_DYN_REF_SSM in helpers.py.

Note: because cfn-lint's pattern keyword uses re.search, the exact template in the issue lints clean today (any alphanumeric char in the path satisfies the search). This fixes the latent correctness bug and adds a regression test for the minimal failing case ({{resolve:ssm:-:1}}).

Added test: test/unit/rules/functions/test_dynamic_reference.py.

The character class [a-zA-Z0-9_.-/] treated .-/ as an ASCII range
(46-47) instead of matching a literal hyphen, so an SSM parameter
segment made up solely of hyphens failed E1050 validation. Escape the
hyphen to align with REGEX_DYN_REF_SSM in helpers.py.

aws-cloudformation#4692
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.66%. Comparing base (5caad1e) to head (06cd89a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4700   +/-   ##
=======================================
  Coverage   94.66%   94.66%           
=======================================
  Files         434      434           
  Lines       15561    15561           
  Branches     3019     3019           
=======================================
  Hits        14731    14731           
  Misses        453      453           
  Partials      377      377           
Flag Coverage Δ
unittests 94.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kddejong
kddejong merged commit 1ccc068 into aws-cloudformation:main Sep 10, 2026
21 checks passed
@kddejong
kddejong deleted the fix/issue/4692 branch September 10, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] E1050 false positive on SSM dynamic references containing hyphens due to unescaped regex range

1 participant