lambda-local icon indicating copy to clipboard operation
lambda-local copied to clipboard

prevent mixing profiles

Open thetathaurus opened this issue 5 years ago • 3 comments

prevent mixing of aws profiles

Without this change, the regexp search for the next available token, but don't take profile boundaries (starting with [ ) into consideration. Assuming target profile is [default] but the [default] profile don't have an aws_session_token, the procedure would take aws_access_key_id is taken from profile [default] but the the aws_session_token from any other profile which leads to an authorization error

thetathaurus avatar Nov 03 '20 14:11 thetathaurus

Thanks for the PR. Could you provide an example of a file that triggered the bug? If possible, it would be great if you could add a test. You can base the test on this one: https://github.com/ashiina/lambda-local/blob/ece4389322d33f11785bdff055979157c6d34fab/test/test.js#L182-L213

gpotter2 avatar Nov 03 '20 14:11 gpotter2

Sure. The following credentials file would result in taking aws_session_token from profile "dev2" and the aws_access_key_id from "default" for the profile "default"

`[default] aws_access_key_id = DUMMYDUMMYDUMMYDUMMY aws_secret_access_key = 95d78fgfd976gdummydummy6g78dfz6g87fd6g78

[dev1] aws_access_key_id = DUMMYDUMMYDUMMYDUMMY aws_secret_access_key = 95d78fgfd976gdummydummy6g78dfz6g87fd6g78

[dev2] aws_access_key_id = DUMMYDUMMYDUMMYDUMMY aws_secret_access_key = 95d78fgfd976gdummydummy6g78dfz6g87fd6g78 aws_session_token = FwoGZXIvYXdzEecaDNAh7gK0W37rBngBiSKEAp3ZyYf4u7gK6E1FhX+uUNwt2XWy3S1G9E5qLD42nW7mJ2kF5fsHez7HUb1EGst1Rx3c2UYTk8oikGnFPX/FUyi6TECYGUjrD7dEbaS4oU3MICi2y46wwfz1J+k1gDC78JyxV3ZUfE5buuyYgnvpcL37bwl0hxMKnnVYsEVg/Ge5Oco7tCB6FbNv67xehwbudtt6AJLi8SYRM5+liW/KU6XOovlXG6FGZIrLrgdvW4BLf5AlKCWBFJFBBZSoGwLWQQ74ZYA5T+b/9KkhSC9lfwLxN53KKE3MqqYCLhMONKc0q6jwF+rJJJHOzuvFlNb3VXH3fzs5lDcX8HYE+yPLl+8g/ny2KJe1hf0FMjLK1RMYmUKQIvyj0E+3fCeN/G6qt00oUBXD3IT71XDbQW34mnE1aktyYpbG7vRHydg4pw== `

thetathaurus avatar Nov 03 '20 14:11 thetathaurus

I will check to create a test, but not that experienced in this. May take a while.

thetathaurus avatar Nov 03 '20 14:11 thetathaurus