Fix naive datetime warnings/errors#13170
Conversation
|
This pull request includes changes in dojo/tools/cyberwatch_galeax/parser.py where parse_detected_at, parse_fixed_at, and parse_datetime silently default to timezone.now() when input dates are missing or unparseable. This behavior can produce inaccurate detection/fix timestamps, skew remediation metrics, and compromise auditability and reporting by masking parsing errors from external sources.
Inaccurate Timestamps on Parsing Failure in
|
| Vulnerability | Inaccurate Timestamps on Parsing Failure |
|---|---|
| Description | The parse_detected_at function in dojo/tools/cyberwatch_galeax/parser.py falls back to timezone.now() if parsing of the detected_at_str fails due to ValueError or TypeError. This means that if an external source provides a detected_at timestamp in an unexpected or malformed format, the system will record the current time as the detection time, rather than failing or indicating a parsing error. This can lead to inaccurate security metrics, audit trails, and SLA tracking, potentially masking the true age of vulnerabilities or misrepresenting their detection timeline. |
django-DefectDojo/dojo/tools/cyberwatch_galeax/parser.py
Lines 484 to 498 in 3bcda0c
Inaccurate Timestamps on Parsing Failure in dojo/tools/cyberwatch_galeax/parser.py
| Vulnerability | Inaccurate Timestamps on Parsing Failure |
|---|---|
| Description | The parse_fixed_at function in dojo/tools/cyberwatch_galeax/parser.py defaults to returning timezone.now() when the input fixed_at_str is None or cannot be parsed. This behavior can lead to inaccurate mitigation records, as a malformed or missing fixed_at date from an external system will cause the vulnerability to be recorded as fixed at the time of data import, rather than its actual remediation time. This skews remediation metrics, compromises audit trail integrity, and can affect SLA compliance. |
django-DefectDojo/dojo/tools/cyberwatch_galeax/parser.py
Lines 501 to 507 in 3bcda0c
Inaccurate Timestamps on Parsing Failure in dojo/tools/cyberwatch_galeax/parser.py
| Vulnerability | Inaccurate Timestamps on Parsing Failure |
|---|---|
| Description | The parse_datetime function in the Cyberwatch Galeax parser silently replaces any unparseable datetime string with the current timestamp (timezone.now()). This leads to data integrity issues where security-critical event timelines (e.g., detection or mitigation dates from external reports) are misrepresented. This can severely impact auditability, reporting accuracy, and decision-making within the security platform. |
django-DefectDojo/dojo/tools/cyberwatch_galeax/parser.py
Lines 510 to 516 in 3bcda0c
All finding details can be found in the DryRun Security Dashboard.
|
I cannot tell you how much I WILL NOT miss seeing these in the logs... |
* test filter on last_status_update * test filter on last_status_update * make datetimes timezone aware
When filtering on dates, Python throws a WARNING in the logs. And in development/test environments this becomes an ERROR because we've stricter settings there to help us avoid these scenario's early in the dev cycle.
This PR first introduced an integration tests to ensure the URL is crawled during testing. This resulted in the above ERROR, so the test works:
The PR is now extended with fixes in all places I could find that were still using "naive" datetimes without timezone info.