aws-samples / aws-sam-terraform-examples

MIT No Attribution
45 stars 14 forks source link

Dangerous potenital to delete all files #4

Closed philipws closed 1 year ago

philipws commented 1 year ago

If there is a problem with the ${build_path} var, or the py_build.sh is run directly in an attempt to test the build (therefore, no ${build_path} var), then this line will delete all user files.

https://github.com/aws-samples/aws-sam-terraform-examples/blob/6e6c7a71bff059cb4e5b2a4a5d40f355e3e19401/zip_based_lambda_functions/api-lambda-dynamodb-example/py_build.sh#L18

Please add validation to ensure it has a value and forcing a base working path to start from.

Yoimer commented 1 year ago

It happened to me too. Is there any chance this can be avoided/fixed, please? Thanks in advance.

Yoimer commented 1 year ago

When running this from AWS CloudShell console it does work OK

philipws commented 1 year ago

@Yoimer I've created a PR for this #6 which will capture it for the Linux/OSX side. I don't know PowerShell to address the Windows side (if it exists there too).

Hoping @sebastiankasprzak , @psuresh78 , or @moelasmar can review and merge this.

Yoimer commented 1 year ago

@philipws Thanks for responding. You mean that if I apply this change you made(I have attached snapshot, this could work with no errors? image

philipws commented 1 year ago

@Yoimer the PR has now been merged into the project. You can try again. Do note that I addressed it for Linux/OSX systems, not Windows, as I am not as familiar with PowerShell to determine if the same concern exists.