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

modules not outputting to json #50

Open
coltleese17 opened this issue Sep 26, 2019 · 2 comments
Open

modules not outputting to json #50

coltleese17 opened this issue Sep 26, 2019 · 2 comments

Comments

@coltleese17
Copy link

Hi there, I just tried to run this tool today with -env aws.

I kept getting this exception in a few different spots:

File "cs.py", line 89, in <module>
    main()
  File "cs.py", line 53, in main
    from modules import awsaudit
  File "/Users/coltonleese/cs-suite/modules/awsaudit.py", line 30, in <module>
    account_name = get_account_alias() or get_account_id()
  File "/Users/coltonleese/cs-suite/modules/awsaudit.py", line 15, in get_account_alias
    account_details = json.loads(str(account_details))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

I fixed it by changing the command

subprocess.check_output(['aws sts get-caller-identity')], shell=True

to

 subprocess.check_output(['aws sts get-caller-identity --output json')], shell=True

I can submit a PR if you want but don't know if this is widely applicable.

thanks.

@HD421
Copy link

HD421 commented Oct 14, 2019

Hi @coltleese17, thanks for info. I used your solution to solve same problem, but fall into this error next step:

> Traceback (most recent call last):
>   File "cs.py", line 89, in <module>
>     main()
>   File "cs.py", line 53, in main
>     from modules import awsaudit
>   File "/Users/aaa/AWS/cs-suite/modules/awsaudit.py", line 38, in <module>
>     identity = json.loads(str(identity))
>   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
>     return _default_decoder.decode(s)
>   File "/usr/local/Cellar/python@2/2.7.16/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 367, in decode
>     raise ValueError(errmsg("Extra data", s, end, len(s)))
> ValueError: Extra data: line 1 column 2 - line 2 column 1 (char 1 - 73)

So I think it's more than single PR to fix this framework.

@robin-w-ford
Copy link

This is an issue but the simple way to fix this i found was to update aws configuration to be json output but this should be in code as for ease of reading my normal CLI output is text

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

No branches or pull requests

3 participants