common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
957 stars 90 forks source link

fix: assume --exec with multiple arguments/spaces #584

Closed lyoung-confluent closed 6 months ago

lyoung-confluent commented 6 months ago

What changed?

The output from goassume when --exec is provided now returns the arguments with proper escaping/splitting to ensure they are evaluated when passed to sh -c in the assume script.

Why?

Fixes the use of assume --exec when the command has multiple arguments or spaces. This issue was introduced by #549 and this PR resolves #575

How did you test it?

When directly running assumego the final arguments can be seen to be concatenated together incorrectly and the single argument with spaces becomes multiple:

$ assumego <profile> --exec -- cmd with multiple 'arguments and spaces'
...None None cmd withmultiplearguments and spaces

After the fix the commands are properly separated/escaped:

$ dassumego <profile> --exec -- cmd with multiple 'arguments and spaces'
...None None cmd with multiple 'arguments and spaces'

A full end-to-end test:

$ dassume <profile> --exec -- aws sts get-caller-identity
{
    "UserId": "...",
    ...

Potential risks

If someone has come to rely on this broken concatenation/escaping since #549 it could break their usage.

Is patch release candidate?

Yes

Link to relevant docs PRs

N/A