-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(iam): missing validation for actions added post instantiation of a policy statement #21906
Conversation
Need some guidance in fixing the following failing unit test. aws-cdk/packages/@aws-cdk/aws-iam/test/policy-document.test.ts Lines 324 to 336 in 1a37331
As per my understanding, aws-cdk/packages/@aws-cdk/aws-iam/lib/policy-statement.ts Lines 232 to 233 in 1a37331
Thus causing the above unit test to fail. Is this is a bug |
You don't seem to have any tokens in
You've created a token list but then are evaluating each individual token as a string. The formatting for list vs string are different. |
Thank you so much @TheRealAmazonKendra for helping out. |
@Mergifyio update |
✅ Branch has been successfully updated |
Hi @TheRealAmazonKendra |
Bumping up for visibility. |
@Mergifyio update |
✅ Branch has been successfully updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Pull Request Linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
PRs must pass status checks before we can provide a meaningful review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make sure that your PR title confirms to the conventional commit standard (fix, feat, chore) and that it is written in a style that will reflect correctly in the change log (See Contributing Guide, Pull Requests).
Additionally, we need test cases for failure cases. The tests in this PR only covers success cases.
Sorry for the delay.
|
Hello, have you looked at https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md already? |
Yes, I did. I was confused regarding what kind of integration should I be adding in this case, since this PR fixes a validation check that was previously missed. I have added unit tests to assert the validation. |
✅ Updated pull request passes all PRLinter validations. Dissmissing previous PRLinter review.
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 CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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). |
…a policy statement (aws#21906) ## Bug Description The validation for actions/nonActions currently only exists in the constructor of the PolicyStatement class as shown below - https://github.com/aws/aws-cdk/blob/56ba2ab2c2d9240b76ece17c3296488a63f0b232/packages/%40aws-cdk/aws-iam/lib/policy-statement.ts#L88-L95 The above validation is missing when we add an action/nonAction post instantiation of the IAM policy statement leading to discrepancy in the behaviour. The following snippet doesn't throw any error - ```typescript const statement = new iam.PolicyStatement({ resources: ['*'] }); statement.addActions('action'); statement.addNonActions('nonaction'); ``` ## Solution - Refactored the validation in the constructor into a separate private method called `validatePolicyActions()` - Executing this new validation method in the `addActions()` and `addNonActions()` - Fixed existing unit tests which assumed the above behaviour fixes aws#21821 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Bug Description
The validation for actions/nonActions currently only exists in the constructor of the PolicyStatement class as shown below -
aws-cdk/packages/@aws-cdk/aws-iam/lib/policy-statement.ts
Lines 88 to 95 in 56ba2ab
The above validation is missing when we add an action/nonAction post instantiation of the IAM policy statement leading to discrepancy in the behaviour.
The following snippet doesn't throw any error -
Solution
validatePolicyActions()
addActions()
andaddNonActions()
fixes #21821
All Submissions:
Adding new Unconventional Dependencies:
New Features
yarn integ
to deploy the infrastructure and generate the snapshot (i.e.yarn integ
without--dry-run
)?By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license