Skip to content

Commit

Permalink
Type fixes
Browse files Browse the repository at this point in the history
The executor version of experimentalFeatures is optional, but we need a
guaranteed version (which comes from createOptions)
  • Loading branch information
rylnd committed Apr 10, 2024
1 parent 52d3711 commit d744cf1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { getIsAlertSuppressionActive } from '../utils/get_is_alert_suppression_a
export const createEqlAlertType = (
createOptions: CreateRuleOptions
): SecurityAlertType<EqlRuleParams, {}, {}, 'default'> => {
const { version, licensing } = createOptions;
const { experimentalFeatures, version, licensing } = createOptions;
return {
id: EQL_RULE_TYPE_ID,
name: 'Event Correlation Rule',
Expand Down Expand Up @@ -78,7 +78,6 @@ export const createEqlAlertType = (
alertTimestampOverride,
publicBaseUrl,
alertWithSuppression,
experimentalFeatures,
},
services,
state,
Expand All @@ -104,7 +103,7 @@ export const createEqlAlertType = (
});
const isNonSeqAlertSuppressionActive = await getIsAlertSuppressionActive({
alertSuppression: completeRule.ruleParams.alertSuppression,
isFeatureDisabled: !experimentalFeatures?.alertSuppressionForNonSequenceEqlRuleEnabled,
isFeatureDisabled: !experimentalFeatures.alertSuppressionForNonSequenceEqlRuleEnabled,
licensing,
});
const result = await eqlExecutor({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { RuleExecutorServicesMock } from '@kbn/alerting-plugin/server/mocks
import { alertsMock } from '@kbn/alerting-plugin/server/mocks';
import { getExceptionListItemSchemaMock } from '@kbn/lists-plugin/common/schemas/response/exception_list_item_schema.mock';
import { DEFAULT_INDEX_PATTERN } from '../../../../../common/constants';
import type { ExperimentalFeatures } from '../../../../../common';
import { getIndexVersion } from '../../routes/index/get_index_version';
import { SIGNALS_TEMPLATE_VERSION } from '../../routes/index/get_signals_template';
import type { EqlRuleParams } from '../../rule_schema';
Expand All @@ -31,6 +32,7 @@ describe('eql_executor', () => {
to: dateMath.parse(params.to)!,
maxSignals: params.maxSignals,
};
const mockExperimentalFeatures = {} as ExperimentalFeatures;

beforeEach(() => {
jest.clearAllMocks();
Expand Down Expand Up @@ -64,6 +66,7 @@ describe('eql_executor', () => {
alertTimestampOverride: undefined,
alertWithSuppression: jest.fn(),
isAlertSuppressionActive: false,
experimentalFeatures: mockExperimentalFeatures,
});
expect(result.warningMessages).toEqual([
`The following exceptions won't be applied to rule execution: ${
Expand Down Expand Up @@ -112,6 +115,7 @@ describe('eql_executor', () => {
alertTimestampOverride: undefined,
alertWithSuppression: jest.fn(),
isAlertSuppressionActive: true,
experimentalFeatures: mockExperimentalFeatures,
});

expect(result.warningMessages).toContain(
Expand Down Expand Up @@ -140,6 +144,11 @@ describe('eql_executor', () => {
primaryTimestamp: '@timestamp',
exceptionFilter: undefined,
unprocessedExceptions: [],
wrapSuppressedHits: jest.fn(),
alertTimestampOverride: undefined,
alertWithSuppression: jest.fn(),
isAlertSuppressionActive: true,
experimentalFeatures: mockExperimentalFeatures,
});
expect(result.userError).toEqual(true);
});
Expand Down

0 comments on commit d744cf1

Please sign in to comment.