PyPDNS icon indicating copy to clipboard operation
PyPDNS copied to clipboard

Using UTC timezone for `time_first` & `time_last` datetime values

Open chrisr3d opened this issue 1 year ago • 1 comments

The recorded values for those fields are UTC timestamps.

I discovered the UTC timezone was not specified while playing with the Passive DNS MISP module, where I had different values displayed - and displayed only - between the first_seen field of the MISP object and the time_first attribute - same with respectively last_seen and time_last attribute - even though it is the same value that is used.

It is not as bad as I first thought it was in my case though, as MISP interprets datetime values with no specific timezone as UTC by default, and I had the timestamps converted into the right UTC datetime values in the final result on MISP Events/Attributes/Objects.
But I would still set the UTC timezone to avoid issue with third party services or scripts querying MISP modules and potentially parsing the results before pushing them to MISP.

This is only the MISP integration point of view, but I don't think it should break any code using pypdns, as the fields that are concerned by the change still have the exact same datetime format, the only difference is the timezone parameter.
Let me know if you see any blocker

chrisr3d avatar Sep 26 '24 16:09 chrisr3d

I think it is correct, good catch. In Python a datetime without a TZ is considered as local TZ, but when importing from a timestamp (which is UTC), it will break it, you're 100% correct.

I'll validate it before merging.

Rafiot avatar Sep 26 '24 17:09 Rafiot