From 25f7654c051c17ef34c38e76b4a2dc04d4336541 Mon Sep 17 00:00:00 2001 From: Joakim Uddholm Date: Tue, 14 Nov 2023 18:26:03 +0100 Subject: [PATCH] fix: stop SeveritySlider from crashing if severity is null. Migrates existing null severity threats to 'low'. While it shouldn't be set if action_item is not marked, null severity is still allowed, but it will be treated as if set to 'low'. --- app/src/components/model/modals/SeveritySlider.js | 2 +- core/src/data/migrations/24_update_threats_with_no_severity.sql | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 core/src/data/migrations/24_update_threats_with_no_severity.sql diff --git a/app/src/components/model/modals/SeveritySlider.js b/app/src/components/model/modals/SeveritySlider.js index 8232970e..597f25a8 100644 --- a/app/src/components/model/modals/SeveritySlider.js +++ b/app/src/components/model/modals/SeveritySlider.js @@ -35,7 +35,7 @@ export function SeveritySlider({ severity, onChange, ...props }) { onChangeCommitted={(value) => { onChange(value); }} - value={severity} + value={severity || "low"} // Default to low in the odd case where we get a null severity value, allowed by backend. {...props} /> ); diff --git a/core/src/data/migrations/24_update_threats_with_no_severity.sql b/core/src/data/migrations/24_update_threats_with_no_severity.sql new file mode 100644 index 00000000..5d98c8e5 --- /dev/null +++ b/core/src/data/migrations/24_update_threats_with_no_severity.sql @@ -0,0 +1,2 @@ +UPDATE threats +SET severity = 'low' WHERE is_action_item = true and severity = null;