Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][RAC] - Update UI signal references #107713

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
774a475
Replace signals indices with constants
michaelolo24 Aug 4, 2021
c3710c0
remove notes
michaelolo24 Aug 5, 2021
d2f8e25
fix imports
michaelolo24 Aug 5, 2021
02123b2
fix type error
michaelolo24 Aug 5, 2021
9e83cd6
fix errors
michaelolo24 Aug 5, 2021
bf0bcb4
fix merge errors
michaelolo24 Aug 5, 2021
8358664
update indices in timelines
michaelolo24 Aug 6, 2021
ece0e16
make additional changes
michaelolo24 Aug 6, 2021
3c3850a
disable rule-registry in experimental features
michaelolo24 Aug 6, 2021
14e14df
Merge branch 'master' into update-indices
michaelolo24 Aug 16, 2021
b3eb265
Merge branch 'master' into update-indices
michaelolo24 Aug 16, 2021
ec9773a
alerts visible
michaelolo24 Aug 17, 2021
3050f82
fix jest tests
michaelolo24 Aug 17, 2021
bfa882b
fix types
michaelolo24 Aug 17, 2021
ecb4418
Merge branch 'master' into update-indices
michaelolo24 Aug 17, 2021
251f9e4
fixed tests
michaelolo24 Aug 17, 2021
7cfc661
Merge branch 'master' into update-indices
michaelolo24 Aug 19, 2021
90358f3
fix type errors
michaelolo24 Aug 19, 2021
a603a57
additional signal changes
michaelolo24 Aug 19, 2021
53a9439
snapshot updates
michaelolo24 Aug 19, 2021
e4b5397
revert some changes
michaelolo24 Aug 19, 2021
5c3114e
Merge branch 'master' into update-indices
michaelolo24 Aug 20, 2021
a91ad1c
Merge branch 'master' into update-indices
michaelolo24 Aug 23, 2021
36de655
update tests
michaelolo24 Aug 23, 2021
da099ba
Merge branch 'master' into update-indices
michaelolo24 Aug 23, 2021
376b68c
Merge branch 'master' into update-indices
michaelolo24 Aug 24, 2021
b54b767
fix tests
michaelolo24 Aug 24, 2021
12b7f17
fixing update indices
michaelolo24 Aug 24, 2021
d572a2e
update aad mapping
michaelolo24 Aug 24, 2021
d46dd24
Merge branch 'master' into update-indices
michaelolo24 Aug 24, 2021
68f3085
fix severity and risk score
michaelolo24 Aug 24, 2021
d1bdecf
fix cypress tests
michaelolo24 Aug 24, 2021
2d157fa
fix cypress test
michaelolo24 Aug 25, 2021
fbef5b6
Merge branch 'master' into update-indices
michaelolo24 Aug 25, 2021
551629f
pr feedback
michaelolo24 Aug 25, 2021
577376a
Merge branch 'master' into update-indices
michaelolo24 Sep 8, 2021
756470a
fix tests and types
michaelolo24 Sep 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion x-pack/plugins/security_solution/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type { TransformConfigSchema } from './transforms/types';
import { ENABLE_CASE_CONNECTOR } from '../../cases/common';
import { metadataTransformPattern } from './endpoint/constants';
import { ALERT_RULE_THREAT_TACTIC_NAME } from '../../timelines/common/alerts';

export const APP_ID = 'securitySolution';
export const SERVER_APP_ID = 'siem';
Expand Down Expand Up @@ -299,7 +300,7 @@ export const showAllOthersBucket: string[] = [
'event.category',
'event.dataset',
'event.module',
'signal.rule.threat.tactic.name',
ALERT_RULE_THREAT_TACTIC_NAME,
'source.ip',
'destination.ip',
'user.name',
Expand Down
110 changes: 74 additions & 36 deletions x-pack/plugins/security_solution/common/ecs/ecs_fields/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@
* 2.0.
*/

import {
ALERT_RULE_CREATED_AT,
ALERT_RULE_CREATED_BY,
ALERT_RULE_DESCRIPTION,
ALERT_RULE_ENABLED,
ALERT_RULE_FROM,
ALERT_RULE_UUID,
ALERT_RULE_NAME,
ALERT_RULE_NOTE,
ALERT_RULE_REFERENCES,
ALERT_RULE_RISK_SCORE,
ALERT_RULE_RULE_ID,
ALERT_RULE_SEVERITY,
ALERT_RULE_TAGS,
ALERT_RULE_TO,
ALERT_RULE_TYPE,
ALERT_RULE_UPDATED_AT,
ALERT_RULE_UPDATED_BY,
ALERT_RULE_VERSION,
} from '@kbn/rule-data-utils';
import {
ALERT_ORIGINAL_TIME,
ALERT_RULE_EXCEPTIONS_LIST,
ALERT_RULE_FALSE_POSITIVES,
ALERT_RULE_FILTERS,
ALERT_RULE_IMMUTABLE,
ALERT_RULE_INDEX,
ALERT_RULE_LANGUAGE,
ALERT_RULE_MAX_SIGNALS,
ALERT_RULE_OUTPUT_INDEX,
ALERT_RULE_QUERY,
ALERT_RULE_SAVED_ID,
ALERT_RULE_SIZE,
ALERT_RULE_THREAT,
ALERT_RULE_THRESHOLD,
ALERT_RULE_TIMELINE_ID,
ALERT_RULE_TIMELINE_TITLE,
} from '../../../../timelines/common/alerts';
import { extendMap } from './extend_map';

export const auditdMap: Readonly<Record<string, string>> = {
Expand Down Expand Up @@ -290,41 +328,41 @@ export const systemFieldsMap: Readonly<Record<string, string>> = {
'system.auth.ssh.method': 'system.auth.ssh.method',
};

export const signalFieldsMap: Readonly<Record<string, string>> = {
'signal.original_time': 'signal.original_time',
'signal.rule.id': 'signal.rule.id',
'signal.rule.saved_id': 'signal.rule.saved_id',
'signal.rule.timeline_id': 'signal.rule.timeline_id',
'signal.rule.timeline_title': 'signal.rule.timeline_title',
'signal.rule.output_index': 'signal.rule.output_index',
'signal.rule.from': 'signal.rule.from',
'signal.rule.index': 'signal.rule.index',
'signal.rule.language': 'signal.rule.language',
'signal.rule.query': 'signal.rule.query',
'signal.rule.to': 'signal.rule.to',
'signal.rule.filters': 'signal.rule.filters',
'signal.rule.rule_id': 'signal.rule.rule_id',
'signal.rule.false_positives': 'signal.rule.false_positives',
'signal.rule.max_signals': 'signal.rule.max_signals',
'signal.rule.risk_score': 'signal.rule.risk_score',
'signal.rule.description': 'signal.rule.description',
'signal.rule.name': 'signal.rule.name',
'signal.rule.immutable': 'signal.rule.immutable',
'signal.rule.references': 'signal.rule.references',
'signal.rule.severity': 'signal.rule.severity',
'signal.rule.tags': 'signal.rule.tags',
'signal.rule.threat': 'signal.rule.threat',
'signal.rule.type': 'signal.rule.type',
'signal.rule.size': 'signal.rule.size',
'signal.rule.enabled': 'signal.rule.enabled',
'signal.rule.created_at': 'signal.rule.created_at',
'signal.rule.updated_at': 'signal.rule.updated_at',
'signal.rule.created_by': 'signal.rule.created_by',
'signal.rule.updated_by': 'signal.rule.updated_by',
'signal.rule.version': 'signal.rule.version',
'signal.rule.note': 'signal.rule.note',
'signal.rule.threshold': 'signal.rule.threshold',
'signal.rule.exceptions_list': 'signal.rule.exceptions_list',
export const alertFieldsMap: Readonly<Record<string, string>> = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this mapping from/to? As far as I can tell, it's only used in eventFieldsMap and that map doesn't appear to be used by anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this file is actually ported across three different plugins and I don't think any of them are being used. I'll delete them and see what happens 🤷🏾‍♂️

[ALERT_ORIGINAL_TIME]: ALERT_ORIGINAL_TIME,
[ALERT_RULE_UUID]: ALERT_RULE_UUID,
[ALERT_RULE_SAVED_ID]: ALERT_RULE_SAVED_ID,
[ALERT_RULE_TIMELINE_ID]: ALERT_RULE_TIMELINE_ID,
[ALERT_RULE_TIMELINE_TITLE]: ALERT_RULE_TIMELINE_TITLE,
[ALERT_RULE_OUTPUT_INDEX]: ALERT_RULE_OUTPUT_INDEX,
[ALERT_RULE_FROM]: ALERT_RULE_FROM,
[ALERT_RULE_INDEX]: ALERT_RULE_INDEX,
[ALERT_RULE_LANGUAGE]: ALERT_RULE_LANGUAGE,
[ALERT_RULE_QUERY]: ALERT_RULE_QUERY,
[ALERT_RULE_TO]: ALERT_RULE_TO,
[ALERT_RULE_FILTERS]: ALERT_RULE_FILTERS,
[ALERT_RULE_RULE_ID]: ALERT_RULE_RULE_ID,
[ALERT_RULE_FALSE_POSITIVES]: ALERT_RULE_FALSE_POSITIVES,
[ALERT_RULE_MAX_SIGNALS]: ALERT_RULE_MAX_SIGNALS,
[ALERT_RULE_RISK_SCORE]: ALERT_RULE_RISK_SCORE,
[ALERT_RULE_DESCRIPTION]: ALERT_RULE_DESCRIPTION,
[ALERT_RULE_NAME]: ALERT_RULE_NAME,
[ALERT_RULE_IMMUTABLE]: ALERT_RULE_IMMUTABLE,
[ALERT_RULE_REFERENCES]: ALERT_RULE_REFERENCES,
[ALERT_RULE_SEVERITY]: ALERT_RULE_SEVERITY,
[ALERT_RULE_TAGS]: ALERT_RULE_TAGS,
[ALERT_RULE_THREAT]: ALERT_RULE_THREAT,
[ALERT_RULE_TYPE]: ALERT_RULE_TYPE,
[ALERT_RULE_SIZE]: ALERT_RULE_SIZE,
[ALERT_RULE_ENABLED]: ALERT_RULE_ENABLED,
[ALERT_RULE_CREATED_AT]: ALERT_RULE_CREATED_AT,
[ALERT_RULE_UPDATED_AT]: ALERT_RULE_UPDATED_AT,
[ALERT_RULE_CREATED_BY]: ALERT_RULE_CREATED_BY,
[ALERT_RULE_UPDATED_BY]: ALERT_RULE_UPDATED_BY,
[ALERT_RULE_VERSION]: ALERT_RULE_VERSION,
[ALERT_RULE_NOTE]: ALERT_RULE_NOTE,
[ALERT_RULE_THRESHOLD]: ALERT_RULE_THRESHOLD,
[ALERT_RULE_EXCEPTIONS_LIST]: ALERT_RULE_EXCEPTIONS_LIST,
};

export const ruleFieldsMap: Readonly<Record<string, string>> = {
Expand All @@ -336,6 +374,7 @@ export const eventFieldsMap: Readonly<Record<string, string>> = {
'@timestamp': '@timestamp',
message: 'message',
...{ ...agentFieldsMap },
...{ ...alertFieldsMap },
...{ ...auditdMap },
...{ ...destinationFieldsMap },
...{ ...dnsFieldsMap },
Expand All @@ -346,7 +385,6 @@ export const eventFieldsMap: Readonly<Record<string, string>> = {
...{ ...hostFieldsMap },
...{ ...networkFieldsMap },
...{ ...ruleFieldsMap },
...{ ...signalFieldsMap },
...{ ...sourceFieldsMap },
...{ ...suricataFieldsMap },
...{ ...systemFieldsMap },
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/security_solution/common/ecs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { EventEcs } from './event';
import { FileEcs } from './file';
import { GeoEcs } from './geo';
import { HostEcs } from './host';
import { KibanaEcs } from './kibana';
import { NetworkEcs } from './network';
import { RegistryEcs } from './registry';
import { RuleEcs } from './rule';
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface Ecs {
event?: EventEcs;
geo?: GeoEcs;
host?: HostEcs;
kibana?: KibanaEcs;
Copy link
Contributor

@madirey madirey Aug 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were you able to verify that these are coming back as nested objects, rather than a flattened set of key/values at the top level of the Ecs object? On the backend, we're handling as a flat set of key/value pairs before indexing.

Copy link
Contributor Author

@michaelolo24 michaelolo24 Aug 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the search strategy call for the timeline (the count table just happened to be at the same level as the data in the console)

image

network?: NetworkEcs;
registry?: RegistryEcs;
rule?: RuleEcs;
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/security_solution/common/ecs/kibana/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { RuleEcs } from '../rule';

export interface KibanaEcs {
alert?: {
rule?: RuleEcs;
original_time?: string[];
status?: string[];
group?: {
id?: string[];
};
threshold_result?: unknown;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
* 2.0.
*/

import { eventDetailsFormattedFields, eventHit } from '@kbn/securitysolution-t-grid';
import { ALERT_RULE_NAME, ALERT_WORKFLOW_STATUS } from '@kbn/rule-data-utils';
import { EventHit, EventSource } from '../search_strategy';
import { getDataFromFieldsHits, getDataFromSourceHits, getDataSafety } from './field_formatters';
import { eventDetailsFormattedFields, eventHit } from '@kbn/securitysolution-t-grid';

describe('Events Details Helpers', () => {
const fields: EventHit['fields'] = eventHit.fields;
Expand Down Expand Up @@ -135,8 +136,8 @@ describe('Events Details Helpers', () => {
it('#getDataFromSourceHits', () => {
const _source: EventSource = {
'@timestamp': '2021-02-24T00:41:06.527Z',
'signal.status': 'open',
'signal.rule.name': 'Rawr',
[ALERT_WORKFLOW_STATUS]: 'open',
[ALERT_RULE_NAME]: 'Rawr',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rawr 😂

'threat.indicator': [
{
provider: 'yourself',
Expand All @@ -161,15 +162,15 @@ describe('Events Details Helpers', () => {
isObjectArray: false,
},
{
category: 'signal',
field: 'signal.status',
category: 'kibana',
field: ALERT_WORKFLOW_STATUS,
values: ['open'],
originalValue: ['open'],
isObjectArray: false,
},
{
category: 'signal',
field: 'signal.rule.name',
category: 'kibana',
field: ALERT_RULE_NAME,
values: ['Rawr'],
originalValue: ['Rawr'],
isObjectArray: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { ALERT_RULE_RISK_SCORE } from '@kbn/rule-data-utils';
import { formatMitreAttackDescription } from '../../helpers/rules';
import {
getIndexPatterns,
Expand Down Expand Up @@ -139,7 +140,7 @@ describe('Detection rules, override', () => {
getDetails(RISK_SCORE_DETAILS).should('have.text', this.rule.riskScore);
getDetails(RISK_SCORE_OVERRIDE_DETAILS).should(
'have.text',
`${this.rule.riskOverride}signal.rule.risk_score`
`${this.rule.riskOverride}${ALERT_RULE_RISK_SCORE}`
);
getDetails(RULE_NAME_OVERRIDE_DETAILS).should('have.text', this.rule.nameOverride);
getDetails(REFERENCE_URLS_DETAILS).should((details) => {
Expand Down
9 changes: 5 additions & 4 deletions x-pack/plugins/security_solution/cypress/screens/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ export const ALERT_GRID_CELL = '[data-test-subj="dataGridRowCell"]';
export const ALERT_ID = '[data-test-subj="draggable-content-_id"]';

export const ALERT_RISK_SCORE_HEADER =
'[data-test-subj="dataGridHeaderCell-signal.rule.risk_score"]';
'[data-test-subj="dataGridHeaderCell-kibana.alert.rule.risk_score"]';
michaelolo24 marked this conversation as resolved.
Show resolved Hide resolved

export const ALERT_RULE_NAME = '[data-test-subj="formatted-field-signal.rule.name"]';
export const ALERT_RULE_NAME = '[data-test-subj="formatted-field-kibana.alert.rule.name"]';

export const ALERT_RULE_RISK_SCORE = '[data-test-subj="formatted-field-signal.rule.risk_score"]';
export const ALERT_RULE_RISK_SCORE =
'[data-test-subj="formatted-field-kibana.alert.rule.risk_score"]';

export const ALERT_RULE_SEVERITY = '[data-test-subj="formatted-field-signal.rule.severity"]';
export const ALERT_RULE_SEVERITY = '[data-test-subj="formatted-field-kibana.alert.rule.severity"]';

export const ALERT_DATA_GRID = '[data-test-subj="dataGridWrapper"]';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { ALERT_RULE_NAME } from '@kbn/rule-data-utils';
import { omit } from 'lodash/fp';
import { DropResult } from 'react-beautiful-dnd';
import { getTimelineIdFromColumnDroppableId } from '../../../../../timelines/public';
Expand Down Expand Up @@ -663,7 +664,7 @@ describe('helpers', () => {
expect(
allowTopN({
browserField: undefined,
fieldName: 'signal.rule.name',
fieldName: ALERT_RULE_NAME,
})
).toBe(true);
});
Expand Down
Loading