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

[--save/--headless] powershell support #44

Merged
merged 20 commits into from
Sep 13, 2023
Merged

[--save/--headless] powershell support #44

merged 20 commits into from
Sep 13, 2023

Conversation

cnuss
Copy link
Member

@cnuss cnuss commented Sep 11, 2023

No description provided.

@boostchicken
Copy link
Contributor

boostchicken commented Sep 12, 2023

You ask boostchicken delivers.

#40 (comment)

I am happy to implement it, but you could probably do it quicker, I just ask that you attribute it in whatever way makes sense for you.

@cnuss
Copy link
Member Author

cnuss commented Sep 12, 2023

@boostchicken thank you for the tip on #40 !

let me figure out the right way to wedge set-item into NodeJS's spawn.

I'll probably clean this up and make --save work on Powershell and do that in a follow-up PR

I can cut a release for --save tomorrow

@boostchicken
Copy link
Contributor

Cool thanks!

@boostchicken
Copy link
Contributor

Btw I think you just have to execute like you do any other command as a massive string. This because it is going scoped only to that process you spawn. It is possible to put it in Machine or Global scope but like I said that would Pwsh in a way I would rather not.

@cnuss
Copy link
Member Author

cnuss commented Sep 13, 2023

@boostchicken I finally got it, I was looking for Invoke-Expression:

iex (saml-to assume the-role-name --headless)
aws sts get-caller-identity

Is working like a charm in Powershell!

Thank you for your guidance it helped me find what I was looking for.

I'll be cutting a release of this now and awaiting your feedback!

@cnuss cnuss changed the title [--save] powershell support [--save/--headless] powershell support Sep 13, 2023
@cnuss cnuss merged commit 2b14c07 into main Sep 13, 2023
96 checks passed
@cnuss cnuss deleted the feat/windows-powershell branch September 13, 2023 04:03
@boostchicken
Copy link
Contributor

IEX is generally cnniusdered bad practice. You can very easily see how I could do some RCEs

All I need you to do is get on my Wifi and I am just going to return the code I wanna run instead of AWSs response.
https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/avoid-using-invoke-expression?view=powershell-7.3

Usually, I wouldn't really care so much, however I would hate for you or saml.to to be in a headline or one of customers get attacked internally by a bad actor

@boostchicken
Copy link
Contributor

https://docs.aws.amazon.com/cli/latest/userguide/sso-using-profile.html

I think wyou should consider adoptin the CLI directly using Identity Center

@cnuss
Copy link
Member Author

cnuss commented Oct 18, 2023

@boostchicken using iex is a matter of user preference and not required, it's especially useful if you have two+ terminal windows open and want roles in each one and prefer not to use AWS CLI Profiles.

However, it is possible to leverage AWS Profiles, you can do:

Create a named profile:

saml-to assume some-role --save
aws s3api list-buckets --profile some-role

☝️ in this scenario you can see your ~/.aws/* now include some-role.

Alternatives to this are:

# use the full role arn as the profile name
saml-to assume arn:aws:iam:0123456789012:role/some-role --save
aws s3api list-buckets --profile arn:aws:iam:0123456789012:role/some-role

# create a custom named profile
saml-to assume some-role --save some-profile-name
aws s3api list-buckets --profile some-profile-name

# set the default profile
saml-to assume some-role --save default
aws s3api list-buckets

let me know if this resolves your concerns!

cheers,
Christian

@boostchicken
Copy link
Contributor

sure does! Also do you plan on making a container? If not I will. I use containers for all my binaries (fzf, aws, zoxide, kdig) Makes it very easy to update and config.

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.

2 participants