From 80b8336073ceddb2f04fad6b0bae080f08b47faa Mon Sep 17 00:00:00 2001 From: itzzdev09 Date: Sun, 13 Sep 2026 22:51:57 +0530 Subject: [PATCH] fix(report): keep a dependent field the revision restates unchanged ReportState.update_vulnerability_report skipped a supplied field equal to the stored value when building `changed`, then decided which dependents were superseded from `changed`. A rationale the revision explicitly restated therefore counted as absent and was dropped: moving confidence from low to medium while resubmitting the same confidence_rationale stored medium with no rationale, the state create_vulnerability_report rejects. The same happened to unchanged severity_change_conditions sent with a severity-moving cvss_breakdown. Record every field the revision states, equal or not, and only drop a dependent that was not supplied. Restating a rationale affirms it still holds for the new rating. `changed` is built exactly as before, so no-op detection and update_history.fields are unaffected. Reported by review on #1307. Co-Authored-By: Claude Opus 5 --- strix/report/state.py | 7 +++++- tests/test_reporting_fields.py | 42 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/strix/report/state.py b/strix/report/state.py index ac15db899..7a952e71b 100644 --- a/strix/report/state.py +++ b/strix/report/state.py @@ -442,6 +442,10 @@ class ReportState: return None changed: dict[str, Any] = {} + # Every field the revision states, including one that repeats the stored + # value. Resubmitting a rationale unchanged affirms it still holds for the + # new rating, so it must not be dropped as superseded below. + supplied: set[str] = set() for key, raw_value in fields.items(): if key not in UPDATABLE_REPORT_FIELDS or raw_value is None: continue @@ -452,6 +456,7 @@ class ReportState: value = value.lower() if not value: continue + supplied.add(key) if report.get(key) == value: continue changed[key] = value @@ -461,7 +466,7 @@ class ReportState: for primary, dependents in _DEPENDENT_REPORT_FIELDS.items() if primary in changed for dependent in dependents - if dependent not in changed and report.get(dependent) not in (None, "", [], {}) + if dependent not in supplied and report.get(dependent) not in (None, "", [], {}) } if not changed and not superseded: diff --git a/tests/test_reporting_fields.py b/tests/test_reporting_fields.py index 9ce39c8b0..73b297331 100644 --- a/tests/test_reporting_fields.py +++ b/tests/test_reporting_fields.py @@ -2109,3 +2109,45 @@ def test_update_does_not_apply_dynamic_rules_to_a_dependency_finding( ) assert result["success"] is True + + +def test_update_keeps_a_rationale_resubmitted_unchanged_with_a_new_confidence( + report_state: ReportState, +) -> None: + """Restating the stored rationale affirms it for the new rating; it must survive.""" + _seed_weak_report(report_state) + report_state.vulnerability_reports[0]["confidence_rationale"] = "Static trace only." + + result = _do_update( + report_id="vuln-0009", + update_reason="Reachability confirmed statically; still no runtime access.", + fields={"confidence": "medium", "confidence_rationale": "Static trace only."}, + ) + + assert result["success"] is True + report = report_state.vulnerability_reports[0] + assert report["confidence"] == "medium" + assert report["confidence_rationale"] == "Static trace only.", ( + "an explicitly resubmitted rationale must not be dropped as superseded" + ) + assert "dropped_fields" not in report["update_history"][-1] + + +def test_update_keeps_severity_conditions_resubmitted_unchanged_with_a_new_vector( + report_state: ReportState, +) -> None: + _seed_weak_report(report_state) + conditions = "A guard before the write would remove the impact." + report_state.vulnerability_reports[0]["severity_change_conditions"] = conditions + + result = _do_update( + report_id="vuln-0009", + update_reason="Confirmed unauthenticated write.", + fields={"cvss_breakdown": _CVSS, "severity_change_conditions": conditions}, + ) + + assert result["success"] is True + assert result["severity"] == "critical" + report = report_state.vulnerability_reports[0] + assert report["severity_change_conditions"] == conditions + assert "dropped_fields" not in report["update_history"][-1]