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

fix: Default username in RoleSessionName #20188

Merged
merged 5 commits into from
May 27, 2022

Conversation

adambro
Copy link
Contributor

@adambro adambro commented May 3, 2022

In case user does not have entry in /etc/passwd the os.userInfo()
call will throw SystemError exception as documented:
https://nodejs.org/docs/latest-v16.x/api/os.html#osuserinfooptions

Fixes #19401 issue.

It can be tested inside Docker for ad-hoc 1234 user ID:

docker run -u 1234 -e CDK_HOME=/tmp npm run cdk diff

The CDK_HOME=/tmp is a workaround for #7937 issue, where CDK complains
that it can't write cached info in user homedir, because it does not
exists.

Once #7937 will be fixed then #19401 will most likely hit users. However
above workaround is a viable option. Hence those two issues are related,
but not duplicated.


All Submissions:

Yes, followed the guide.

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

No new dependencies.

New Features

  • Have you added the new feature to an integration test?
    • Did you use yarn integ to deploy the infrastructure and generate the snapshot (i.e. yarn integ without --dry-run)?

No, it's a bugfix, not a feature.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

In case user does not have entry in `/etc/passwd` the `os.userInfo()`
call will throw `SystemError` exception as documented:
https://nodejs.org/docs/latest-v16.x/api/os.html#osuserinfooptions

Fixes aws#19401 issue.

It can be tested inside Docker for ad-hoc 1234 user ID:
```sh
docker run -u 1234 -e CDK_HOME=/tmp npm run cdk diff
```

The `CDK_HOME=/tmp` is a workaround for aws#7937 issue, where CDK complains
that it can't write cached info in user homedir, because it does not
exists.

Once aws#7937 will be fixed then aws#19401 will most likely hit users. However
above workaround is a viable option. Hence those two issues are related,
but not duplicated.
@gitpod-io
Copy link

gitpod-io bot commented May 3, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team May 3, 2022 11:14
@github-actions github-actions bot added bug This issue is a bug. p2 labels May 3, 2022
@adambro
Copy link
Contributor Author

adambro commented May 3, 2022

Linter is complaining about missing change in test file. I can add superficial test for this helper function, but it's not going to be useful.

@adambro
Copy link
Contributor Author

adambro commented May 10, 2022

The code change I've done is just basically handling SystemError exception and returning a sane default value (instead of unhandled error) when it happens. Pretty straightforward to review.

comcalvi
comcalvi previously approved these changes May 16, 2022
@mergify mergify bot dismissed comcalvi’s stale review May 16, 2022 20:20

Pull request has been modified.

@adambro
Copy link
Contributor Author

adambro commented May 16, 2022

@comcalvi thanks for review and approve. Can you disable lint rule for missing test, please? I don’t think the test will provide any value here. It seems the the outstanding thing to do here.

@comcalvi comcalvi added pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes and removed pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels May 18, 2022
Copy link
Contributor

@comcalvi comcalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you actually a unit test (no need for an integ test here) for this? I'd like to see one that verifies that noname is used when that call throws an error.

adambro added 2 commits May 20, 2022 09:51
Test case is essentially a copy of the following one:
`assuming a role sanitizes the username into the session name`
@mergify mergify bot dismissed comcalvi’s stale review May 20, 2022 07:56

Pull request has been modified.

@adambro
Copy link
Contributor Author

adambro commented May 20, 2022

@comcalvi I've added a test case for one of the functions, because test structure was already there and it was fairly straightforward. Check out the ea4db71 commit, please :)

@mergify
Copy link
Contributor

mergify bot commented May 27, 2022

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-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 80c5c92
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit b7bc10c into aws:master May 27, 2022
@mergify
Copy link
Contributor

mergify bot commented May 27, 2022

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).

@adambro adambro deleted the default_username_for_session branch May 27, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(api/aws-auth): Error on CDK commands when user does not exist
3 participants