fix(jira): stop sending numeric hours to Time to Detect/Contain (datetime fields)
Aegis CI / lint-and-test (push) Has been cancelled
Snyk Security Scan / Python vulnerabilities (backend) (push) Has been cancelled
Snyk Security Scan / npm vulnerabilities (frontend) (push) Has been cancelled
Snyk Security Scan / Docker image vulnerabilities (backend) (push) Has been cancelled

Confirmed via issue_editmeta and a real production failure log: Time to
Detect / Time to Contain are Jira datetime fields despite the name, not
numeric duration fields. Pushing a computed hour count made Jira reject
the entire fields payload (validated atomically), silently sinking BT End
Date and Attack Detected on the same call even though only these two
fields were actually invalid. Now pushes the real detection_time/
containment_time timestamps. Removed the now-unused _compute_hours.
This commit is contained in:
kitos
2026-07-14 12:48:14 +02:00
parent 92d65374ef
commit bdc6579c10
2 changed files with 21 additions and 20 deletions
+8 -5
View File
@@ -570,15 +570,18 @@ def test_push_rt_submitted_rt_start_date_survives_reopen(mock_get_client, mock_c
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)
@patch("app.services.jira_service.get_admin_jira_client")
def test_push_bt_submitted_includes_detection_and_hours(mock_get_client, mock_configured, db):
def test_push_bt_submitted_includes_detection_and_timestamps(mock_get_client, mock_configured, db):
"""Regression: Time to Detect / Time to Contain are Jira *datetime*
fields, not numeric hour counts — pushing a computed duration made Jira
reject the whole fields payload (atomic validation), silently sinking
BT End Date and Attack Detected too even though only these two were
actually wrong."""
mock_jira = MagicMock()
mock_get_client.return_value = mock_jira
exec_end = datetime(2026, 1, 1, 10, 0, 0)
detect = datetime(2026, 1, 1, 12, 0, 0)
contain = datetime(2026, 1, 1, 13, 30, 0)
test = _make_test(
detection_result=MagicMock(value="detected"),
execution_end_time=exec_end,
detection_time=detect,
containment_time=contain,
)
@@ -590,8 +593,8 @@ def test_push_bt_submitted_includes_detection_and_hours(mock_get_client, mock_co
fields = mock_jira.update_issue_field.call_args[1]["fields"]
assert fields[jira_service.JIRA_FIELD_ATTACK_DETECTED] == {"value": "Yes"}
assert fields[jira_service.JIRA_FIELD_TIME_TO_DETECT] == 2.0
assert fields[jira_service.JIRA_FIELD_TIME_TO_CONTAIN] == 1.5
assert fields[jira_service.JIRA_FIELD_TIME_TO_DETECT] == "2026-01-01T12:00:00.000+0000"
assert fields[jira_service.JIRA_FIELD_TIME_TO_CONTAIN] == "2026-01-01T13:30:00.000+0000"
@patch("app.services.jira_service.has_admin_jira_configured", return_value=True)