Skip to content

Commit 01120d8

Browse files
committed
[Security Solution][Detections][Threshold Rules] Threshold Rule Bug Fixes (elastic#84918)
* Move threshold dupe detection logic to its own function * Minor fixup * Refactor and remove property injection for threshold signals * Only show aggregatable fields for threshold rule grouping * Add threshold rule kql filter to timeline * Remove outdated getThresholdSignalQueryFields tests * Filter aggregatable fields on client * Revert "Only show aggregatable fields for threshold rule grouping" This reverts commit 539fa49. * Fix bug with incorrect calculation of threshold signal dupes when no threshold field present * Revert "Add threshold rule kql filter to timeline" This reverts commit 6482374. * Add test skeleton * Finish tests * Address comment
1 parent 5db8193 commit 01120d8

File tree

8 files changed

+228
-436
lines changed

8 files changed

+228
-436
lines changed

x-pack/plugins/security_solution/public/detections/components/rules/step_define_rule/index.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import {
5252
} from '../../../../../common/detection_engine/utils';
5353
import { EqlQueryBar } from '../eql_query_bar';
5454
import { ThreatMatchInput } from '../threatmatch_input';
55-
import { useFetchIndex } from '../../../../common/containers/source';
55+
import { BrowserField, BrowserFields, useFetchIndex } from '../../../../common/containers/source';
5656
import { PreviewQuery, Threshold } from '../query_preview';
5757

5858
const CommonUseField = getUseField({ component: Field });
@@ -168,6 +168,26 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
168168
const queryBarQuery =
169169
formQuery != null ? formQuery.query.query : '' || initialState.queryBar.query.query;
170170
const [indexPatternsLoading, { browserFields, indexPatterns }] = useFetchIndex(index);
171+
const aggregatableFields = Object.entries(browserFields).reduce<BrowserFields>(
172+
(groupAcc, [groupName, groupValue]) => {
173+
return {
174+
...groupAcc,
175+
[groupName]: {
176+
fields: Object.entries(groupValue.fields ?? {}).reduce<Partial<BrowserField>>(
177+
(fieldAcc, [fieldName, fieldValue]) => {
178+
if (fieldValue.aggregatable === true) {
179+
return { ...fieldAcc, [fieldName]: fieldValue };
180+
}
181+
return fieldAcc;
182+
},
183+
{}
184+
),
185+
} as Partial<BrowserField>,
186+
};
187+
},
188+
{}
189+
);
190+
171191
const [
172192
threatIndexPatternsLoading,
173193
{ browserFields: threatBrowserFields, indexPatterns: threatIndexPatterns },
@@ -262,12 +282,12 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
262282
const ThresholdInputChildren = useCallback(
263283
({ thresholdField, thresholdValue }) => (
264284
<ThresholdInput
265-
browserFields={browserFields}
285+
browserFields={aggregatableFields}
266286
thresholdField={thresholdField}
267287
thresholdValue={thresholdValue}
268288
/>
269289
),
270-
[browserFields]
290+
[aggregatableFields]
271291
);
272292

273293
const ThreatMatchInputChildren = useCallback(

0 commit comments

Comments
 (0)