Skip to content

chore(security-guardian): improve failure messages#37542

Open
gudipati wants to merge 3 commits intomainfrom
gudipatg/main
Open

chore(security-guardian): improve failure messages#37542
gudipati wants to merge 3 commits intomainfrom
gudipatg/main

Conversation

@gudipati
Copy link
Copy Markdown
Contributor

@gudipati gudipati commented Apr 7, 2026

Issue # (if applicable)

N/A

Reason for this change

Currently, when a guard rule fails, the security guardian report only shows the rule name and a pass/fail indicator. After this change, each failure annotation will include a human-readable description of what's wrong and how to fix it.

Description of changes

  1. Updated summary message to include instructions on how to suppress rules as this is an experimental feature
  2. Add custom error messages to each guard rule
  3. Updated Junit XML post processing to include the custom error messages in annotations
  4. Updated unit-tests

Describe any new or updated permissions being added

N/A

Description of how you validated changes

yarn test succeeded

Validated with an incorrect template using yarn security-guardian --enhance_xml=true -

Static:
        <testcase name="sqs-encryption-enabled.guard" time="0">
            <failure message="[Type: Static] SQS queue must have encryption enabled. Set &apos;KmsMasterKeyId&apos; to a KMS key ARN or &apos;SqsManagedSseEnabled&apos; to true.">
Check was not compliant as property [Properties.KmsMasterKeyId] is missing. Value traversed to [Path=/Resources/SourceQueue6E809DF0[L:2,C:25] Value={&quot;Type&quot;:&quot;AWS::SQS::Queue&quot;,&quot;UpdateReplacePolicy&quot;:&quot;Delete&quot;,&quot;DeletionPolicy&quot;:&quot;Delete&quot;}].
Check was not compliant as property [Properties.SqsManagedSseEnabled] to compare from is missing. Value traversed to [Path=/Resources/SourceQueue6E809DF0[L:2,C:25] Value={&quot;Type&quot;:&quot;AWS::SQS::Queue&quot;,&quot;UpdateReplacePolicy&quot;:&quot;Delete&quot;,&quot;DeletionPolicy&quot;:&quot;Delete&quot;}].</failure>
        </testcase>

Resolved:
        <testcase name="kinesis-firehose-encryption-enabled.guard" time="0">
            <failure message="[Type: Resolved] Kinesis Firehose delivery stream must have encryption enabled. Set &apos;DeliveryStreamEncryptionConfigurationInput.KeyType&apos; to &apos;AWS_OWNED_CMK&apos; or &apos;CUSTOMER_MANAGED_CMK&apos;.">
Check was not compliant as property [DeliveryStreamEncryptionConfigurationInput] is missing. Value traversed to [Path=/Resources/DeliveryStream58CF96DB/Properties[L:149,C:20] Value={&quot;DeliveryStreamType&quot;:&quot;DirectPut&quot;,&quot;ExtendedS3DestinationConfiguration&quot;:{&quot;BucketARN&quot;:&quot;arn:aws:s3:::Bucket83908E77&quot;,&quot;BufferingHints&quot;:{&quot;IntervalInSeconds&quot;:30,&quot;SizeInMBs&quot;:5},&quot;RoleARN&quot;:&quot;arn:aws:iam::123456789012:role/DeliveryStreamS3DestinationRoleD96B8345&quot;}}].
Check was not compliant as property [DeliveryStreamEncryptionConfigurationInput.KeyType] is missing. Value traversed to [Path=/Resources/DeliveryStream58CF96DB/Properties[L:149,C:20] Value={&quot;DeliveryStreamType&quot;:&quot;DirectPut&quot;,&quot;ExtendedS3DestinationConfiguration&quot;:{&quot;BucketARN&quot;:&quot;arn:aws:s3:::Bucket83908E77&quot;,&quot;BufferingHints&quot;:{&quot;IntervalInSeconds&quot;:30,&quot;SizeInMBs&quot;:5},&quot;RoleARN&quot;:&quot;arn:aws:iam::123456789012:role/DeliveryStreamS3DestinationRoleD96B8345&quot;}}].
Check was not compliant as property [DeliveryStreamEncryptionConfigurationInput.KeyType] to compare from is missing. Value traversed to [Path=/Resources/DeliveryStream58CF96DB/Properties[L:149,C:20] Value={&quot;DeliveryStreamType&quot;:&quot;DirectPut&quot;,&quot;ExtendedS3DestinationConfiguration&quot;:{&quot;BucketARN&quot;:&quot;arn:aws:s3:::Bucket83908E77&quot;,&quot;BufferingHints&quot;:{&quot;IntervalInSeconds&quot;:30,&quot;SizeInMBs&quot;:5},&quot;RoleARN&quot;:&quot;arn:aws:iam::123456789012:role/DeliveryStreamS3DestinationRoleD96B8345&quot;}}].</failure>
        </testcase>

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gudipati gudipati requested a review from kumvprat April 7, 2026 12:03
@github-actions github-actions bot added the p2 label Apr 7, 2026
@aws-cdk-automation aws-cdk-automation requested a review from a team April 7, 2026 12:03
@github-actions github-actions bot added the repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK label Apr 7, 2026
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 7, 2026
@mergify mergify bot temporarily deployed to automation April 7, 2026 12:03 Inactive
@mergify mergify bot temporarily deployed to automation April 7, 2026 12:03 Inactive
Copy link
Copy Markdown
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This review is outdated)

@aws-cdk-automation aws-cdk-automation added the pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. label Apr 7, 2026
@gudipati gudipati changed the title fix(security-guardian): Improve failure messages fix(security-guardian): improve failure messages Apr 7, 2026
@gudipati gudipati changed the title fix(security-guardian): improve failure messages chore(security-guardian): improve failure messages Apr 7, 2026
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 7, 2026 12:50

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 7, 2026
Gowthami Gudipati added 2 commits April 7, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. p2 pr/needs-further-review PR requires additional review from our team specialists due to the scope or complexity of changes. pr/needs-maintainer-review This PR needs a review from a Core Team Member repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants