Skip to content

Conversation

QuantumNeuralCoder
Copy link
Contributor

@QuantumNeuralCoder QuantumNeuralCoder commented Apr 11, 2025

Issue # (if applicable)

None

Closes #.
None

Reason for this change

  • Adds a new tool to run cfn-guard
  • Enhances PR linter to find added or updated snapshot templates and run cfn-guard through them for detecting inline broad trust policy

Description of changes

Refer README.md

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Tested on personal fork. Refer QuantumNeuralCoder#6
PR Linter output shows test results.

Checklist


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

@aws-cdk-automation aws-cdk-automation requested a review from a team April 11, 2025 20:06
@github-actions github-actions bot added the p2 label Apr 11, 2025
@QuantumNeuralCoder QuantumNeuralCoder added pr/do-not-merge This PR should not be merged at this time. and removed p2 labels Apr 11, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Apr 11, 2025
Copy link
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)

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.00%. Comparing base (74cbe27) to head (b52d3d3).
Report is 35 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #34115      +/-   ##
==========================================
+ Coverage   83.98%   84.00%   +0.01%     
==========================================
  Files         120      121       +1     
  Lines        6976     6984       +8     
  Branches     1178     1179       +1     
==========================================
+ Hits         5859     5867       +8     
  Misses       1005     1005              
  Partials      112      112              
Flag Coverage Δ
suite.unit 84.00% <ø> (+0.01%) ⬆️

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

Components Coverage Δ
packages/aws-cdk ∅ <ø> (∅)
packages/aws-cdk-lib/core 84.00% <ø> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@QuantumNeuralCoder QuantumNeuralCoder changed the title feat(cfn-guard-action): Adding cfn guard run to pr linter feat(cfn-guard-action): new tool to run cfn-guard to detect inline broad scoped permissions Apr 11, 2025
@github-actions github-actions bot added the p2 label Apr 11, 2025
@QuantumNeuralCoder
Copy link
Contributor Author

Exemption Request since github workflow separately tested on personal fork.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Apr 11, 2025
@QuantumNeuralCoder QuantumNeuralCoder removed the pr/do-not-merge This PR should not be merged at this time. label Apr 11, 2025
@QuantumNeuralCoder QuantumNeuralCoder changed the title feat(cfn-guard-action): new tool to run cfn-guard to detect inline broad scoped permissions chore: new tool to run cfn-guard to detect inline broad scoped permissions Apr 11, 2025
@aws-cdk-automation aws-cdk-automation dismissed their stale review April 11, 2025 22:58

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

required: false
default: "single-line-summary"

runs:
Copy link
Contributor

Choose a reason for hiding this comment

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

since cfn-guard is required, I believe it worth adding a step to install cfn-guard, so we do not need every time we use this GH action to add a step to install it

Comment on lines 41 to 45
if (!rulePathToUse && ruleSetUrl) {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'rules-'));
rulePathToUse = path.join(tempDir, 'rules.guard');
await downloadFile(ruleSetUrl, rulePathToUse);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the rules set file will be always a local file in the repo, why shall we download it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed all in latest commit

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Apr 11, 2025
Comment on lines 10 to 14
# Triggered from a separate job when a review is added
workflow_run:
workflows: [PR Linter Trigger]
types:
- completed
Copy link
Contributor

Choose a reason for hiding this comment

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

not really following, based on lines 2,3

on:
  pull_request: {}

This action will be invoked whenever the PR got created, synchronized, reopened, updated. So, why we still need to link this action to another flow, what will be the added value

Comment on lines 21 to 26
permissions:
contents: read
pull-requests: read
statuses: read
issues: read
checks: read
Copy link
Contributor

Choose a reason for hiding this comment

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

at least from my understanding, I do not see that this action do any updates to the PR, so why do we need these permissions. Also, I think the comment on line 20 is not aligning withe the given permissions, since all permissions are read

Comment on lines 1 to 3
# Security Guardian

A GitHub Action tool designed to validate changed AWS CloudFormation templates against custom [cfn-guard](https://github.com/aws-cloudformation/cloudformation-guard) rules. Supports both local paths and remote URLs for rule sets.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this tool is planned to do more checks than running cfn-guard. As I understood, for now it will run cfn-guard against one rule, with a plan to extend these rules.
Also, there is some static check logic is planned to be done on the snapshot templates, that will be done in the tool, and not by cfn-guard.

Copy link
Contributor

Choose a reason for hiding this comment

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

If my understanding is not correct, so I think we do not need to implement this tool in TS, it can be as simple as running a bash script.

Comment on lines 7 to 10
permissions:
contents: read
pages: write
id-token: write
Copy link
Contributor

Choose a reason for hiding this comment

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

why we these permissions are needed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For codecov for this PR. On side note, pull_request_target will run in main branch context. We can only see the gh action once its merged.

@QuantumNeuralCoder QuantumNeuralCoder changed the title chore: new tool to run cfn-guard to detect inline broad scoped permissions chore: new github action to run security-guardian Apr 14, 2025
Copy link
Contributor

@moelasmar moelasmar left a comment

Choose a reason for hiding this comment

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

Thanks Indranil. I am approving the PR, but as we agreed, we need a follow up PR to allow contributors to execute the security guardian tool locally.

Copy link
Contributor

mergify bot commented Apr 15, 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
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: effd556
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Apr 15, 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 beb42fd into aws:main Apr 15, 2025
13 of 14 checks passed
Copy link
Contributor

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 Apr 15, 2025
@QuantumNeuralCoder QuantumNeuralCoder deleted the cfn-guard-action branch May 14, 2025 21:18
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 pr/needs-maintainer-review This PR needs a review from a Core Team Member pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants