fix(eks-v2): remove usage of shell=True in helm commands#35141
fix(eks-v2): remove usage of shell=True in helm commands#35141mergify[bot] merged 2 commits intoaws:mainfrom
Conversation
|
I think it would help reviewers if you can share the relevant Python documentation which is referenced in the description. |
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
| logger.info("Found AWS private repository") | ||
| cmnd = [ | ||
| f"aws ecr get-login-password --region {private_registry['region']} | " \ | ||
| f"helm registry login --username AWS --password-stdin {private_registry['registry']}; helm pull {repository} --version {version} --untar" |
There was a problem hiding this comment.
Just checking - is the removal of helm pull... intentional?
There was a problem hiding this comment.
It is there, not removed. It is built at the top
# Build helm pull command as array
helm_cmd = ['helm', 'pull', repository]
```
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-eks-v2-alpha/lib/kubectl-handler/helm/__init__.py
Outdated
Show resolved
Hide resolved
7ed7bf9 to
5afe70b
Compare
Added: https://docs.python.org/3/library/subprocess.html#replacing-shell-pipeline |
5afe70b to
1d7fb6d
Compare
5300e1e to
891b510
Compare
8bef254 to
39ebd01
Compare
39ebd01 to
0e7ba4e
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing 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 |
|
Comments on closed issues and PRs are hard for our team to see. |
Improve subprocess handling in EKS Helm custom resource handler.
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