fix(eks): remove usage of shell=True in helm commands#35148
fix(eks): remove usage of shell=True in helm commands#35148mergify[bot] merged 4 commits intoaws:mainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter fails with the following errors:
❌ Fixes must contain a change to an integration test file and the resulting snapshot.
If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.
1bf66b1 to
bb6b571
Compare
bb6b571 to
f890d14
Compare
packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/kubectl-handler/helm/__init__.py
Show resolved
Hide resolved
ec7e914 to
882f87c
Compare
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). |
|
Comments on closed issues and PRs are hard for our team to see. |
Improve subprocess handling in EKS Helm custom resource handler.
Same PR as: #35141
Reason for this change
The EKS Helm custom resource handler used
shell=Truewith subprocess calls, which is not aligned with security best practices. Following Python's recommended approach for subprocess execution improves code robustness and follows secure coding guidelines.Description of changes
Refactor subprocess execution to follow Python best practices
https://docs.python.org/3/library/subprocess.html#replacing-shell-pipeline
get_oci_cmd()to return structured command objects instead of shell stringsPopenwithPIPEto chainaws ecr get-login-passwordandhelm registry logincommands following Python documentation recommendationsshell=True: Adopted array-based command execution as recommended by Python subprocess documentationFiles modified:
packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/kubectl-handler/helm/__init__.pypackages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.pypackages/@aws-cdk/aws-eks-v2-alpha/test/integ.alb-controller.js.snapshot/asset.*/helm/__init__.pyTechnical approach:
['helm', 'pull', repository, '--version', version, '--untar']Popenwith properPIPEconnectionsDescribe any new or updated permissions being added
No new IAM permissions required. The change maintains the same AWS API calls and functionality.
Description of how you validated changes
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license