-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(cli): OS usernames cannot have Unicode characters #10451
Conversation
When assuming a role for uploading assets in the new-style synthesized stacks, the OS username was used to build the session name out of. OS usernames have a character set that is wider than the allowed characters in `RoleSessionName` though, so we needed to sanitize them. Fixes #10401.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code itself looks good; can we add a test?
* Return the username with characters invalid for a RoleSessionName removed | ||
* | ||
* @see https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html#API_AssumeRole_RequestParameters | ||
*/ | ||
function safeUsername() { | ||
return os.userInfo().username.replace(/[^\w+=,.@-]/g, '@'); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this into a reusable spot? os.ts
sounds appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are addressing the repetition in this PR, please note that the changes are in 2 different packages and there's no good shared package to put this functionality in otherwise.
If you are addressing potential future reuse, I would argue against optimizing for that beforehand.
Co-authored-by: Nick Lynch <nlynch@amazon.com>
Overridden by the senate -- peace treaty signed
Thank you for contributing! Your pull request will be updated from master 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 |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
When assuming a role for uploading assets in the new-style synthesized
stacks, the OS username was used to build the session name out of.
OS usernames have a character set that is wider than the allowed
characters in
RoleSessionName
though, so we needed to sanitizethem.
Fixes #10401.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license