Skip to content

fix: isAcknowledged() misses acknowledgments on aws-cdk-lib >=2.262.1 due to prefix casing - #2362

Merged
mergify[bot] merged 1 commit into
cdklabs:mainfrom
ben-buitendijk:fix-caseinsenstive-annotations-prefix
Aug 4, 2026
Merged

fix: isAcknowledged() misses acknowledgments on aws-cdk-lib >=2.262.1 due to prefix casing#2362
mergify[bot] merged 1 commit into
cdklabs:mainfrom
ben-buitendijk:fix-caseinsenstive-annotations-prefix

Conversation

@ben-buitendijk

Copy link
Copy Markdown
Contributor

NagPack.isAcknowledged() strips a synthetic prefix that aws-cdk-lib's Validations.acknowledge() adds to bare (non-namespaced) rule IDs before writing them to construct metadata, so the stripped key can be compared against the real rule ID (e.g. AwsSolutions-S1).

Through aws-cdk-lib@2.261.0, that prefix was always lowercase annotation::, matching the regex here:

const ids = Object.keys(entry.data as Record<string, string>).map(
  (k) => k.replace(/^annotation::/, '')
);

As of aws-cdk-lib@2.262.1, Validations.qualifyId() was refactored to reuse a new shared constant, AnnotationPlugin.RULE_PREFIX = "Annotation" (capitalized), instead of its own internal lowercase constant. The prefix written to metadata is now Annotation::AwsSolutions-S1 instead of annotation::AwsSolutions-S1.

The regex above only matches the lowercase form, so on aws-cdk-lib >=2.262.1 the prefix is never stripped, the key never reduces to the bare rule ID, and Validations.of(construct).acknowledge({ id: "AwsSolutions-S1", ... }) silently stops suppressing anything — no error, the finding just reappears as if never acknowledged.

Compound rule IDs that embed their own :: (e.g. AwsSolutions-IAM5[Action::s3:GetBucket*]) are unaffected — qualifyId() passes those through unqualified because they don't hit the "add a prefix" branch, so this only breaks acknowledgment of simple, colon-free rule IDs like AwsSolutions-S1 or AwsSolutions-IAM4.

Here is a link to the commit that introduced the change in aws-cdk-lib: aws/aws-cdk@75893d9

@mrgrain
mrgrain force-pushed the fix-caseinsenstive-annotations-prefix branch from c7eeb46 to 287d596 Compare August 4, 2026 09:56
@mergify mergify Bot added the queued label Aug 4, 2026
@mergify

mergify Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • Entered queue2026-08-04 10:02 UTC · Rule: default · triggered by rule Automatic merge on approval and successful build
  • Checks skipped · PR is already up-to-date
  • Merged2026-08-04 10:03 UTC · at 287d596b1ac2fdd5e3d14e28bd50f4d10e55c5a6 · squash

This pull request spent 25 seconds in the queue, including 4 seconds running CI.

Required conditions to merge

@mergify
mergify Bot merged commit 67ae6d0 into cdklabs:main Aug 4, 2026
14 of 15 checks passed
@mergify mergify Bot removed the queued label Aug 4, 2026
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.

2 participants