ibmresilient / resilient-community-apps

Source code for IBM SOAR Apps that are available on our App Exchange
https://ibm.biz/soar-apps-docs
MIT License
91 stars 95 forks source link

Fixed timestamp from string extraction in 'ds_to_millis()' function. … #49

Closed rudimeyer closed 2 years ago

rudimeyer commented 4 years ago

…In some cases Microsoft Security Graph Alerts will contain timestamps formatted with less than 3 digit values for microseconds.

DCO 1.1 Signed-off-by: [Rudi Meyer] [hello@rudimeyer.dk]

Description

Changed substring in ds_to_millis() from looking forward (:23) to looking backward (:-1), solving the issue of varying length of microsecond values (1-3 digits) in some alert timestamps

Motivation and Context

When using 'fn_microsoft_security_graph' extension with Resilient i get the following error: 2020-03-27 14:20:48,928 ERROR [microsoft_security_graph_alerts_integrations] 2020-03-27T11:57:22.29Z Not in expected timestamp format YYYY-MM-DDTHH:MM:SS.mmmZ Traceback (most recent call last): File "/home/integration/.local/lib/python3.6/site-packages/fn_microsoft_security_graph/components/microsoft_security_graph_alerts_integrations.py", line 394, in ds_to_millis dt = datetime.strptime(ts, ts_format) File "/usr/lib64/python3.6/_strptime.py", line 565, in _strptime_datetime tt, fraction = _strptime(data_string, format) File "/usr/lib64/python3.6/_strptime.py", line 365, in _strptime data_string[found.end():]) ValueError: unconverted data remains: Z

How Has This Been Tested?

I tested this in my Resilient test installation. I have updated the existing test for ds_to_millis() to reflect the new requirement.

Checklist:

Signed-off-by: Rudi Meyer hello@rudimeyer.dk

annmarien commented 2 years ago

We have made an update to MS Security Graph 1.2.0 on the App Exchange to include this timestamp fix.