Skip to content

Commit ec59f59

Browse files
committed
[Security Solution] Fix time duration normalization at rule schedule for day units (#224083)
**Addresses:** #223446 ## Summary This PR fixes an issue when time duration normalized to day(s) is shown as 0 seconds. The fix is performed by allowing using days time unit at rule schedule. ## Details The issue happens when rule schedule's look-back gets normalized to day(s). The reason is that look-backs input doesn't support Days time unit. It leads to inability to parse the value and displaying the default value which is 0 seconds. Rule schedule is shown to the users as rule `interval` and `look-back` while rule's SO saves the schedule by using three fields `interval`, `from` and `to`. Where `look-back` represents a logical value calculated as `lookback` = `to` - `from` - `interval`. Taking that into account it's becomes harder to maintain the original time duration unit value during prebuilt rules upgrade workflow (See #204317 for more details). The easiest way to fix this issue is to allow Days time unit in rule schedule inputs. On top of that 24 hours are always 1 day making hours the largest simply convertible time unit. The PR allows hours in rule schedule. **Before:** https://github.com/user-attachments/assets/4f2038f1-4a6a-4a88-b86e-381a5b717605 **After:** https://github.com/user-attachments/assets/74875bf2-9341-425f-a35f-c8b088c1ef6a (cherry picked from commit a013929)
1 parent bcd87cc commit ec59f59

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

  • x-pack/solutions/security

x-pack/solutions/security/packages/kbn-securitysolution-utils/src/time_duration/time_duration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* - 5s
1313
* - 3m
1414
* - 7h
15+
* - 9d
1516
*/
1617
export class TimeDuration {
1718
/**

x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_creation/components/schedule_item_field/schedule_item_field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export function ScheduleItemField({
168168
);
169169
}
170170

171-
const DEFAULT_TIME_DURATION_UNITS = ['s', 'm', 'h'];
171+
const DEFAULT_TIME_DURATION_UNITS = ['s', 'm', 'h', 'd'];
172172

173173
function saturate(input: number, minValue: number, maxValue: number): number {
174174
return Math.max(minValue, Math.min(input, maxValue));

0 commit comments

Comments
 (0)