SecurityFTW / cs-suite

Cloud Security Suite - One stop tool for auditing the security posture of AWS/GCP/Azure infrastructure.
GNU General Public License v3.0
1.14k stars 217 forks source link

Invalid format timestamp #62

Open balagpy opened 3 years ago

balagpy commented 3 years ago

Hi Team,

I am facing the following error, pls help me..

(venv) ubuntu@ip:~/cs-suite$ python3 cs.py -env aws Traceback (most recent call last): File "cs.py", line 6, in from modules import logger File "/home/ubuntu/cs-suite/modules/logger.py", line 17, in formatter = CustomJsonFormatter('(timestamp) (level) (name) (message)') File "/home/ubuntu/cs-suite/venv/lib/python3.8/site-packages/pythonjsonlogger/jsonlogger.py", line 115, in init logging.Formatter.init(self, *args, **kwargs) File "/usr/lib/python3.8/logging/init.py", line 576, in init self._style.validate() File "/usr/lib/python3.8/logging/init.py", line 429, in validate raise ValueError("Invalid format '%s' for '%s' style" % (self._fmt, self.default_format[0])) ValueError: Invalid format '(timestamp) (level) (name) (message)' for '%' style

shivankar-madaan commented 3 years ago

Hi @balagpy The current tool is un-tested on python3 Could you possibly give a try with python 2.7?

balagpy commented 3 years ago

Thanks for the reply @shivankar-madaan - Let me try on python 2.7

balagpy commented 3 years ago

Hi @shivankar-madaan tried in python 2.7, but it throwing the following error

cs-suite$ sudo python cs.py Traceback (most recent call last): File "cs.py", line 6, in from modules import logger File "/Users/balajipr/cs-suite/modules/logger.py", line 2, in from pythonjsonlogger import jsonlogger ImportError: No module named pythonjsonlogger

shivankar-madaan commented 3 years ago

Hi @balagpy were you able to run setup.py or install all the requirements from requirement.txt or could you try installing python-json-logger module of python

Do let me know if it works

balagpy commented 3 years ago

Installed python-JSON-logger module after getting this error @shivankar-madaan

Traceback (most recent call last): File "cs.py", line 117, in main() File "cs.py", line 67, in main from modules import awsaudit File "/Users/balajipr/cs-suite/modules/awsaudit.py", line 30, in account_name = get_account_alias() or get_account_id() File "/Users/balajipr/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

shivankar-madaan commented 3 years ago

@balagpy have you set the AWS keys on the cli?

balagpy commented 3 years ago

@shivankar-madaan Yes, configured aws keys on the cli.

shivankar-madaan commented 3 years ago

@balagpy what output are you getting for "aws iam list-account-aliases" You don't need to share the output, but is it in json or empty?

harishbsrinivas commented 3 years ago

I worked around this error by adding the validate=False parameter to the CustomJsonFormatter in modules/logger.py

formatter = CustomJsonFormatter('(timestamp) (level) (name) (message)',validate=False)

I have tested this on Python 3.8 after pulling from https://github.com/almoore/cs-suite