binbashar / le-docker-leverage-toolbox

Docker image for https://github.com/binbashar/leverage
3 stars 0 forks source link

Bug | Unexpected behavior when aborting `aws-mfa` script. #16

Closed angelofenoglio closed 1 year ago

angelofenoglio commented 2 years ago

Describe the Bug

When running an operation that requires the execution of the multi-factor authentication handling script, if the user decides to interrupt this execution during the OTP prompt, and does so by spamming Ctrl + c, the script will re-prompt for OTP instead of actually quitting. Not only that, but it will prompt the same way for the rest of the identified profiles, and it will end up displaying a successful execution message instead of quitting.

Expected Behavior

Whether Ctrl + c is pressed once or spammed, the script should immediately quit.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Enable MFA in your project
  2. cd into a layer
  3. Run leverage tf plan
  4. When the MFA handling script is executed, and it prompts for the OTP code, spam Ctrl + c

Output

Pressing Ctrl + c once to interrupt the command:

$ leverage tf plan
[22:23:20]   INFO       MFA: Found 2 profile/s
[22:23:20]   INFO       MFA: Attempting to get temporary credentials for profile project-apps-qa-devops
MFA: Please type in your OTP: ^C[22:23:24]   ERROR      Aborted!

Spamming Ctrl + c:

$ leverage tf plan
[22:25:05]   INFO       MFA: Found 2 profile/s
[22:25:05]   INFO       MFA: Attempting to get temporary credentials for profile project-apps-qa-devops
MFA: Please type in your OTP: ^C^CMFA: Please type in your OTP: ^C^CMFA: Please type in your OTP: ^C^C^CTraceback (most recent call last):
  File "PyInstaller/hooks/rthooks/pyi_rth_multiprocessing.py", line 16, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/usr/local/cpython-exe-builder/lib/python3.8/re.py", line 125, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 241, in load_module
  File "<frozen zipimport>", line 711, in _get_module_code
  File "<frozen zipimport>", line 628, in _unmarshal_code
KeyboardInterrupt
[173] Failed to execute script pyi_rth_multiprocessing
[22:25:13]   INFO       MFA: Credentials written succesfully!
[22:25:13]   INFO       MFA: Attempting to get temporary credentials for profile project-shared-devops
MFA: Please type in your OTP: ^C^CMFA: Please type in your OTP: ^C^CMFA: Please type in your OTP: ^C^C^C[22:25:47]   INFO       MFA: Credentials written succesfully!

Environment (please complete the following information):

Run on Bash on a Linux environment.

Additional Context

This issue was initially reported by @marianod92, however in his case, after re-prompting, the process would actually hang, forcing him to kill the terminal session. This may or may not be influenced by the platform in which leverage is run, an M1 Macbook in this case.

exequielrafaela commented 2 years ago

@angelofenoglio thanks for creating this issue with such a great level of detail. Hope we can work it out during 2022 Q4

CC: @juanmatias @diego-ojeda-binbash

exequielrafaela commented 1 year ago

@angelofenoglio we'll request @rodriguez-matias help to validate if this is still happening with the latest version of the CLI and Ref Arch, in case everything looks good we can close it. If not we can re-float it's priority and how to solve it.

CC: @diego-ojeda-binbash

rodriguez-matias commented 1 year ago

@angelofenoglio @exequielrafaela I tested this issue with both toolbox images and got the same result. Everything seems to works well so far.

leverage, version 1.9.1
`binbash/leverage-toolbox` ==1.2.7-0.1.1
`binbash/leverage-toolbox` ==1.3.5-0.0.2

Also tested with another version of leverage and I was able to abort the MFA script correctly.

leverage, version 1.8.0
`binbash/leverage-toolbox`==1.2.7-0.0.5

image