improsec / calderaToAttire

7 stars 3 forks source link

Errors running against Caldera JSON output #1

Closed PurpleWaveIO closed 2 years ago

PurpleWaveIO commented 2 years ago

I have tested the code against the Caldera Beta 4.0.0 JSON output and receive the error: ValueError: time data '2022-04-27T14:56:53Z' does not match format '%Y-%m-%d %H:%M:%S'

I have also tested against Caldera 3.1.0 and that JSON output receives the error: _KeyError: 'agent_reportedtime'

Any tips?

python3 CalderaToAttire.py Test_full-report.json Traceback (most recent call last): File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 105, in main(sys.argv[1]) File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 98, in main outputAgent(data, agentDict[agent], agent) File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 85, in outputAgent out = outputJson(fulldata, agentDict, agent) File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 80, in outputJson output['procedures'].append(procs(ability, index)) File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 69, in procs procDict['steps'] = steps(step, index) File "/home/kali/Documents/calderaToAttire-main/CalderaToAttire.py", line 50, in steps x = datetime.datetime.strptime(date_time_str, "%Y-%m-%d %H:%M:%S") File "/usr/lib/python3.9/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) File "/usr/lib/python3.9/_strptime.py", line 349, in _strptime raise ValueError("time data %r does not match format %r" % ValueError: time data '2022-04-27T14:56:53Z' does not match format '%Y-%m-%d %H:%M:%S'

improg00n commented 2 years ago

I have updated to deal with the specific case and added error handling. If you experience any more issues, please let me know. Also feel free to include your json file, so that I can make sure it works properly :)

PurpleWaveIO commented 2 years ago

Thanks for the quick follow up and fix! I have re-tested against the Caldera Beta 4.0.0 JSON output and it is now successful in generating the output. Also successful upload into Vectr of the output file.