Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent mixing profiles #207

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

thetathaurus
Copy link

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

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
@gpotter2
Copy link
Collaborator

gpotter2 commented Nov 3, 2020

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:

lambda-local/test/test.js

Lines 182 to 213 in ece4389

describe("# Environment Variables (destroy)", function () {
var done, err;
before(function (cb) {
var lambdalocal = require(lambdalocal_path);
lambdalocal.setLogger(winston);
lambdalocal.execute({
event: require(path.join(__dirname, "./events/test-event.js")),
lambdaPath: path.join(__dirname, "./functs/test-func.js"),
lambdaHandler: functionName,
profilePath: path.join(__dirname, "./other/debug.aws"),
callbackWaitsForEmptyEventLoop: false,
timeoutMs: timeoutMs,
callback: function (_err, _done) {
err = _err;
done = _done;
cb();
},
environment: {
"isnetestlambda": "I should not exist"
},
envdestroy: true,
envfile: path.join(__dirname, "./other/env"),
verboseLevel: 1
});
});
it("environment should have been deleted", function () {
assert.equal(("isnetestlambda" in process.env), false);
});
it("should contain an awsRequestId different from the first one", function () {
assert.notEqual(done.context.awsRequestId, firstawsRequestId);
});
});

@thetathaurus
Copy link
Author

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
Copy link
Author

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

@gpotter2 gpotter2 force-pushed the develop branch 2 times, most recently from 4e730df to cbc4901 Compare June 19, 2021 00:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants