Skip to content

Commit

Permalink
[Rule Registry][Security Solution] Populate kibana.alert.rule.tags by…
Browse files Browse the repository at this point in the history
… default (#121480)

* Populate kibana.alert.rule.tags by default

* Remove internal tags from field

* Update lifecycle rule unit test

* Fix tests

* Undo moving commonRuleParams

* Remove unused import

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
marshallmain and kibanamachine authored Jan 6, 2022
1 parent 57377d3 commit b0c3ec5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
ALERT_WORKFLOW_STATUS,
EVENT_ACTION,
EVENT_KIND,
TAGS,
TIMESTAMP,
VERSION,
} from '../../common/technical_rule_data_field_names';
Expand Down Expand Up @@ -267,6 +268,7 @@ export const createLifecycleExecutor =
[EVENT_KIND]: 'signal',
[EVENT_ACTION]: isNew ? 'open' : isActive ? 'active' : 'close',
[VERSION]: ruleDataClient.kibanaVersion,
[TAGS]: options.tags,
...(isRecovered ? { [ALERT_END]: commonRuleFields[TIMESTAMP] } : {}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ describe('createLifecycleRuleTypeFactory', () => {
"kibana.alert.rule.name": "name",
"kibana.alert.rule.producer": "producer",
"kibana.alert.rule.rule_type_id": "ruleTypeId",
"kibana.alert.rule.tags": Array [
"tags",
],
"kibana.alert.rule.uuid": "alertId",
"kibana.alert.start": "2021-06-16T09:01:00.000Z",
"kibana.alert.status": "active",
Expand All @@ -251,6 +254,9 @@ describe('createLifecycleRuleTypeFactory', () => {
"kibana.alert.rule.name": "name",
"kibana.alert.rule.producer": "producer",
"kibana.alert.rule.rule_type_id": "ruleTypeId",
"kibana.alert.rule.tags": Array [
"tags",
],
"kibana.alert.rule.uuid": "alertId",
"kibana.alert.start": "2021-06-16T09:01:00.000Z",
"kibana.alert.status": "active",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
ALERT_RULE_TYPE_ID,
ALERT_RULE_UUID,
SPACE_IDS,
TAGS,
ALERT_RULE_TAGS,
TIMESTAMP,
} from '@kbn/rule-data-utils';

Expand All @@ -31,7 +31,7 @@ const commonAlertFieldNames = [
ALERT_RULE_TYPE_ID,
ALERT_RULE_UUID,
SPACE_IDS,
TAGS,
ALERT_RULE_TAGS,
TIMESTAMP,
];
export type CommonAlertFieldName = Values<typeof commonAlertFieldNames>;
Expand All @@ -52,7 +52,7 @@ export const getCommonAlertFields = (
[ALERT_RULE_TYPE_ID]: options.rule.ruleTypeId,
[ALERT_RULE_UUID]: options.alertId,
[SPACE_IDS]: [options.spaceId],
[TAGS]: options.tags,
[ALERT_RULE_TAGS]: options.tags,
[TIMESTAMP]: options.startedAt.toISOString(),
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ALERT_UUID,
ALERT_WORKFLOW_STATUS,
SPACE_IDS,
TAGS,
VERSION,
} from '@kbn/rule-data-utils';
import { flattenWithPrefix } from '@kbn/securitysolution-rules';
Expand Down Expand Up @@ -159,7 +158,6 @@ export default ({ getService }: FtrProviderContext) => {
[ALERT_WORKFLOW_STATUS]: 'open',
[ALERT_STATUS]: 'active',
[SPACE_IDS]: ['default'],
[TAGS]: [`__internal_rule_id:${createdRule.rule_id}`, '__internal_immutable:false'],
[ALERT_SEVERITY]: 'critical',
[ALERT_RISK_SCORE]: 50,
[ALERT_RULE_PARAMETERS]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
ALERT_WORKFLOW_STATUS,
SPACE_IDS,
VERSION,
TAGS,
} from '@kbn/rule-data-utils';
import { flattenWithPrefix } from '@kbn/securitysolution-rules';

Expand Down Expand Up @@ -285,7 +284,6 @@ export default ({ getService }: FtrProviderContext) => {
[ALERT_WORKFLOW_STATUS]: 'open',
[SPACE_IDS]: ['default'],
[VERSION]: fullSignal[VERSION],
[TAGS]: [`__internal_rule_id:${createdRule.rule_id}`, '__internal_immutable:false'],
threat: {
enrichments: get(fullSignal, 'threat.enrichments'),
},
Expand Down

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

0 comments on commit b0c3ec5

Please sign in to comment.