Skip to content

ci: security guardian changes#36110

Merged
mergify[bot] merged 55 commits intomainfrom
security_guardian_changes
Dec 5, 2025
Merged

ci: security guardian changes#36110
mergify[bot] merged 55 commits intomainfrom
security_guardian_changes

Conversation

@kumvprat
Copy link
Copy Markdown
Contributor

Issue # (if applicable)

N/A - Enhancement and bug fixes for Security Guardian tool.

Reason for this change

Security guardian is first line of defense for scanning policy, roles and permissions vended by CDK for customers. This GH Action is critical to determine if a PR change is providing secure-by-default policies for any changes introduced in CDK.

The Security Guardian tool needed several critical improvements to function properly:

  1. CFN Intrinsic Resolution: Missing comprehensive support for CloudFormation intrinsic functions like Fn::Sub, Fn::Select, Fn::Contains, etc.
  2. Rule Coverage: Incomplete security rule coverage across AWS services
  3. Create noise: Current setup of security guardian does not provide benefit as it fails to exclude cases where the generic cfn-guard rule might not work. Like with KMS secrets or secret manager secrets

Description of changes

Added template preprocessing pipeline with intrinsic resolution and policy normalization, details can be found below

Major Enhancements:

  • Complete CFN Intrinsic Function Resolver: Added comprehensive support for all CloudFormation intrinsic functions including Fn::Sub with literal escaping, Fn::Select with bounds checking, Fn::Contains, Fn::Split, Fn::Cidr, Fn::Base64, and shorthand forms (!Ref, !GetAtt, etc.)
  • Cross-Stack Resolution: Implemented resource registry for resolving Fn::ImportValue and cross-template references
  • Policy Normalization: Added IAM policy normalizer to resolve intrinsics within policy documents before validation
  • Output presentation: Integrated JUnit XML output with GitHub Actions using pinned mikepenz/action-junit-report for rich PR feedback ( suggested by cfn-guard here)
  • Security report generation workflow : Separated out report generation into another workflow due to 2 reasons :
    • Gives us flexibility to change the trigger type for security-guardian to lower permissive trigger likepull_request or pull_request_review
    • Allows fork PRs to run : Fork PRs trigger workflow runs with read permissions, and the separate workflow can execute separate from the fork PR call chain with full permissions needed to update checks and annotation on the PR

Security Rule Expansion:

  • Added comprehensive guard rules for 13 AWS services: CodePipeline, DataTrace, DocumentDB, EC2, IAM, Kinesis, Neptune, Redshift, S3, SNS, SQS, and trust scope validation
  • Enhanced existing rules with better coverage for broad principals, wildcard actions, and cross-account access patterns

Describe any new or updated permissions being added

No new IAM permissions required. All changes are to the static analysis tool and GitHub Actions workflow.

Description of how you validated changes

Unit Testing: via

  • Guard Rule Syntax: All 13 guard rule files pass cfn-guard v3 parser validation
  • Cross-Stack Testing: Validated resolution of Fn::ImportValue and cross-template references
  • Example cases to test that the current set of rules PASS and FAIL for different scenarios

Checklist


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

…nsic scanner code to exempt some services from root principal check
…ner by default till it runs consistenly and changing workflow to run on pull_request_target
…summary and output as provided in the tool invocation arguments + Removed s3 bucket versioning requirement + data trace checks only have private key and aws access key id checks
…on : Not and contains with tests + made the resolution function modular
…being resolved by the custom resolver + removed malformed template checks as cdk should always produced a valid template + added policy resolution tests
…prehensive tests + Fix Fn::Sub literal escaping and parameter resolution + Add shorthand form support (etc.) + Improve Fn::Select bounds checking + Add comprehensive test coverage for guard rules and intrinsic functions
…results + changes in security guardian workflow to parse the junit files + removed test.sh + fix faulty guard rules + added action to consume and publish junit result
… fields in a policy are targeted for normalization
…it action report GH action looks for file attribute
…tead oif implementing a reversible function => Works for unresolved cfn temapates
… a PR rather than cehckout action based merge commit
…ecific object inside Properties and only triggers rule when the changes exists + test changes
…ecific object inside Properties and only triggers rule when the changes exists + test changes
@Abogical Abogical added pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exempt-integ-test The PR linter will not require integ test changes labels Dec 4, 2025
@Abogical Abogical changed the title feat(ci): security guardian changes ci: security guardian changes Dec 4, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review December 4, 2025 11:08

✅ 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 Dec 4, 2025
permissions:
checks: write
pull-requests: write
contents: write
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why does it need contents: write permissions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this is something we can remove, will tell this first and see if it's not being used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the permissions as it's not needed.

Thanks, was a good catch

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 4, 2025

Merge Queue Status

🚫 The pull request has left the queue (rule: default-squash)

This pull request spent 3 hours 16 minutes 43 seconds in the queue, with no time running CI.
The checks were run in-place.

Required conditions to merge
  • any of [🛡 GitHub branch protection]:
    • check-neutral = build
    • check-skipped = build
    • check-success = build
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = validate-pr
    • check-neutral = validate-pr
    • check-skipped = validate-pr

Reason

Pull request #36110 has been dequeued by a dequeue command

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio requeue comment.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 4, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 4, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 4, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kumvprat
Copy link
Copy Markdown
Contributor Author

kumvprat commented Dec 4, 2025

@Mergifyio dequeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 4, 2025

dequeue

✅ The pull request has been removed from the queue

@kumvprat kumvprat added pr/do-not-merge This PR should not be merged at this time. and removed pr/do-not-merge This PR should not be merged at this time. labels Dec 4, 2025
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@kumvprat
Copy link
Copy Markdown
Contributor Author

kumvprat commented Dec 5, 2025

@Mergifyio requeue

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 5, 2025

requeue

✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 5, 2025

Merge Queue Status

✅ The pull request has been merged

This pull request spent 39 minutes 32 seconds in the queue, including 39 minutes 23 seconds running CI.
The checks were run in-place.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = validate-pr
    • check-neutral = validate-pr
    • check-skipped = validate-pr
  • any of [🛡 GitHub branch protection]:
    • check-success = build
    • check-neutral = build
    • check-skipped = build

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 87b7e4a into main Dec 5, 2025
17 of 18 checks passed
@mergify mergify bot deleted the security_guardian_changes branch December 5, 2025 10:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 5, 2025

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

contribution/core This is a PR that came from AWS. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants