amplify-cli
amplify-cli copied to clipboard
fix Type confusion through parameter tampering
https://github.com/aws-amplify/amplify-cli/blob/aaef95c5a46232fac5105201c490210ac67c93b7/packages/amplify-storage-simulator/src/server/utils.ts#L77-L77
fix the issue need to ensure that the buf parameter in the stripChunkSignature function is of the expected type (Buffer). If buf is not a Buffer, the function should either throw an error or return the input unchanged, depending on the desired behavior. This can be achieved by adding a runtime type check at the beginning of the function.
- Add a type check to verify that
bufis aBufferusingBuffer.isBuffer(buf). - If the check fails, return the input unchanged or handle the error appropriately.
- This change ensures that the function behaves predictably even if
bufis tampered with.
Checklist
- [x] PR description included
- [x]
yarn testpasses - [x] Tests are changed or added
- [x] Relevant documentation is changed or added (and PR referenced)
- [x] New AWS SDK calls or CloudFormation actions have been added to relevant test and service IAM policies
- [x] Pull request labels are added
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.