Skip to content

Commit

Permalink
Merge branch 'main' into security-solution-fix-skipped-test-143718
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko authored Oct 24, 2022
2 parents 3b2c01f + 21c7f5e commit d4d62d5
Show file tree
Hide file tree
Showing 31 changed files with 3,542 additions and 3,500 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ enabled:
- x-pack/test/detection_engine_api_integration/security_and_spaces/group8/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group9/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group10/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/rule_execution_logic/config.ts
- x-pack/test/encrypted_saved_objects_api_integration/config.ts
- x-pack/test/endpoint_api_integration_no_ingest/config.ts
- x-pack/test/examples/config.ts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const thresholdExecutor = async ({
: await getThresholdSignalHistory({
from: tuple.from.toISOString(),
to: tuple.to.toISOString(),
ruleId: ruleParams.ruleId,
frameworkRuleId: completeRule.alertId,
bucketByFields: ruleParams.threshold.field,
ruleDataReader,
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ describe('buildPreviousThresholdAlertRequest', () => {
const bucketByFields: string[] = [];
const to = 'now';
const from = 'now-6m';
const ruleId = 'threshold-rule';
const frameworkRuleId = 'threshold-rule';

expect(
buildPreviousThresholdAlertRequest({ from, to, ruleId, bucketByFields })
buildPreviousThresholdAlertRequest({ from, to, frameworkRuleId, bucketByFields })
).toMatchSnapshot();
});

it('should generate a proper request when bucketByFields contains multiple fields', async () => {
const bucketByFields: string[] = ['host.name', 'user.name'];
const to = 'now';
const from = 'now-6m';
const ruleId = 'threshold-rule';
const frameworkRuleId = 'threshold-rule';

expect(
buildPreviousThresholdAlertRequest({ from, to, ruleId, bucketByFields })
buildPreviousThresholdAlertRequest({ from, to, frameworkRuleId, bucketByFields })
).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,23 @@

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { IRuleDataReader } from '@kbn/rule-registry-plugin/server';
import { ALERT_RULE_UUID } from '@kbn/rule-data-utils';
import type { ThresholdSignalHistory } from '../types';
import { buildThresholdSignalHistory } from './build_signal_history';
import { createErrorsFromShard } from '../utils';

interface GetThresholdSignalHistoryParams {
from: string;
to: string;
ruleId: string;
frameworkRuleId: string;
bucketByFields: string[];
ruleDataReader: IRuleDataReader;
}

export const getThresholdSignalHistory = async ({
from,
to,
ruleId,
frameworkRuleId,
bucketByFields,
ruleDataReader,
}: GetThresholdSignalHistoryParams): Promise<{
Expand All @@ -32,7 +33,7 @@ export const getThresholdSignalHistory = async ({
const request = buildPreviousThresholdAlertRequest({
from,
to,
ruleId,
frameworkRuleId,
bucketByFields,
});

Expand All @@ -48,12 +49,12 @@ export const getThresholdSignalHistory = async ({
export const buildPreviousThresholdAlertRequest = ({
from,
to,
ruleId,
frameworkRuleId,
bucketByFields,
}: {
from: string;
to: string;
ruleId: string;
frameworkRuleId: string;
bucketByFields: string[];
}): estypes.SearchRequest => {
return {
Expand All @@ -80,7 +81,7 @@ export const buildPreviousThresholdAlertRequest = ({
},
{
term: {
'signal.rule.rule_id': ruleId,
[ALERT_RULE_UUID]: frameworkRuleId,
},
},
// We might find a signal that was generated on the interval for old data... make sure to exclude those.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function createTestConfig(options: CreateTestConfigOptions, testFiles?: s
`--xpack.securitySolution.enableExperimental=${JSON.stringify([
'previewTelemetryUrlEnabled',
])}`,
'--xpack.task_manager.poll_interval=1000',
...(ssl
? [
`--elasticsearch.hosts=${servers.elasticsearch.protocol}://${servers.elasticsearch.hostname}:${servers.elasticsearch.port}`,
Expand Down
Loading

0 comments on commit d4d62d5

Please sign in to comment.