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 all 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ export const technicalRuleFieldMap = {
array: false,
required: false,
},
[Fields.ALERT_RISK_SCORE]: {
type: 'float',
array: false,
required: false,
},
[Fields.ALERT_WORKFLOW_STATUS]: {
type: 'keyword',
array: false,
Expand Down
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
108 changes: 72 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,43 @@
* 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_RULE_ID,
ALERT_RULE_TAGS,
ALERT_RULE_TO,
ALERT_RULE_TYPE,
ALERT_RULE_UPDATED_AT,
ALERT_RULE_UPDATED_BY,
ALERT_RULE_VERSION,
ALERT_RISK_SCORE,
ALERT_SEVERITY,
} 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_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 +327,40 @@ 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_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_DESCRIPTION]: ALERT_RULE_DESCRIPTION,
[ALERT_RULE_NAME]: ALERT_RULE_NAME,
[ALERT_RULE_IMMUTABLE]: ALERT_RULE_IMMUTABLE,
[ALERT_RULE_REFERENCES]: ALERT_RULE_REFERENCES,
[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,
[ALERT_SEVERITY]: ALERT_SEVERITY,
[ALERT_RISK_SCORE]: ALERT_RISK_SCORE,
};

export const ruleFieldsMap: Readonly<Record<string, string>> = {
Expand All @@ -336,6 +372,7 @@ export const eventFieldsMap: Readonly<Record<string, string>> = {
'@timestamp': '@timestamp',
message: 'message',
...{ ...agentFieldsMap },
...{ ...alertFieldsMap },
...{ ...auditdMap },
...{ ...destinationFieldsMap },
...{ ...dnsFieldsMap },
Expand All @@ -346,7 +383,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
23 changes: 23 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,23 @@
/*
* 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?: {
risk_score?: string[];
severity?: string[];
rule?: RuleEcs;
original_time?: string[];
status?: string[];
group?: {
id?: string[];
};
threshold_result?: unknown;
workflow_status?: string[];
};
}
2 changes: 1 addition & 1 deletion x-pack/plugins/security_solution/common/ecs/rule/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

export interface RuleEcs {
id?: string[];
rule_id?: string[];
uuid?: string[];
name?: string[];
false_positives?: string[];
saved_id?: string[];
Expand Down
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 @@ -13,7 +13,13 @@ import {
getEditedRule,
getNewOverrideRule,
} from '../../objects/rule';
import { ALERT_GRID_CELL, NUMBER_OF_ALERTS } from '../../screens/alerts';
import {
ALERT_GRID_CELL,
ALERT_RISK_SCORE,
ALERT_RULE_NAME,
ALERT_SEVERITY,
NUMBER_OF_ALERTS,
} from '../../screens/alerts';

import {
CUSTOM_RULES_BTN,
Expand Down Expand Up @@ -215,9 +221,9 @@ describe('Custom detection rules creation', () => {
waitForAlertsToPopulate();

cy.get(NUMBER_OF_ALERTS).should(($count) => expect(+$count.text().split(' ')[0]).to.be.gte(1));
cy.get(ALERT_GRID_CELL).eq(3).contains(this.rule.name);
cy.get(ALERT_GRID_CELL).eq(4).contains(this.rule.severity.toLowerCase());
cy.get(ALERT_GRID_CELL).eq(5).contains(this.rule.riskScore);
cy.get(`${ALERT_GRID_CELL} ${ALERT_RULE_NAME}`).contains(this.rule.name);
cy.get(`${ALERT_GRID_CELL} ${ALERT_SEVERITY}`).contains(this.rule.severity.toLowerCase());
cy.get(`${ALERT_GRID_CELL} ${ALERT_RISK_SCORE}`).contains(this.rule.riskScore);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {

import {
ALERT_RULE_NAME,
ALERT_RULE_RISK_SCORE,
ALERT_RULE_SEVERITY,
ALERT_RISK_SCORE,
ALERT_SEVERITY,
NUMBER_OF_ALERTS,
} from '../../screens/alerts';
import {
Expand Down Expand Up @@ -480,12 +480,10 @@ describe('indicator match', () => {

cy.get(NUMBER_OF_ALERTS).should('have.text', expectedNumberOfAlerts);
cy.get(ALERT_RULE_NAME).first().should('have.text', getNewThreatIndicatorRule().name);
cy.get(ALERT_RULE_SEVERITY)
cy.get(ALERT_SEVERITY)
.first()
.should('have.text', getNewThreatIndicatorRule().severity.toLowerCase());
cy.get(ALERT_RULE_RISK_SCORE)
.first()
.should('have.text', getNewThreatIndicatorRule().riskScore);
cy.get(ALERT_RISK_SCORE).first().should('have.text', getNewThreatIndicatorRule().riskScore);
});

it('Investigate alert in timeline', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import { ALERT_RISK_SCORE } from '@kbn/rule-data-utils';
import { formatMitreAttackDescription } from '../../helpers/rules';
import {
getIndexPatterns,
Expand All @@ -13,7 +14,13 @@ import {
OverrideRule,
} from '../../objects/rule';

import { NUMBER_OF_ALERTS, ALERT_GRID_CELL } from '../../screens/alerts';
import {
NUMBER_OF_ALERTS,
ALERT_GRID_CELL,
ALERT_RISK_SCORE as ALERT_RISK_SCORE_FIELD,
ALERT_RULE_NAME,
ALERT_SEVERITY,
} from '../../screens/alerts';

import {
CUSTOM_RULES_BTN,
Expand Down Expand Up @@ -139,7 +146,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_RISK_SCORE}`
);
getDetails(RULE_NAME_OVERRIDE_DETAILS).should('have.text', this.rule.nameOverride);
getDetails(REFERENCE_URLS_DETAILS).should((details) => {
Expand Down Expand Up @@ -187,12 +194,8 @@ describe('Detection rules, override', () => {
waitForAlertsToPopulate();

cy.get(NUMBER_OF_ALERTS).should(($count) => expect(+$count.text().split(' ')[0]).to.be.gte(1));
cy.get(ALERT_GRID_CELL).eq(3).contains('auditbeat');
cy.get(ALERT_GRID_CELL).eq(4).contains('critical');

// TODO: Is this necessary?
// sortRiskScore();

cy.get(ALERT_GRID_CELL).eq(5).contains('80');
cy.get(`${ALERT_GRID_CELL} ${ALERT_RULE_NAME}`).contains('auditbeat');
cy.get(`${ALERT_GRID_CELL} ${ALERT_SEVERITY}`).contains('critical');
cy.get(`${ALERT_GRID_CELL} ${ALERT_RISK_SCORE_FIELD}`).contains('80');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
ThresholdRule,
} from '../../objects/rule';

import { ALERT_GRID_CELL, NUMBER_OF_ALERTS } from '../../screens/alerts';
import {
ALERT_GRID_CELL,
ALERT_RISK_SCORE,
ALERT_RULE_NAME,
ALERT_SEVERITY,
NUMBER_OF_ALERTS,
} from '../../screens/alerts';

import {
CUSTOM_RULES_BTN,
Expand Down Expand Up @@ -171,9 +177,9 @@ describe('Detection rules, threshold', () => {
waitForAlertsToPopulate();

cy.get(NUMBER_OF_ALERTS).should(($count) => expect(+$count.text().split(' ')[0]).to.be.lt(100));
cy.get(ALERT_GRID_CELL).eq(3).contains(rule.name);
cy.get(ALERT_GRID_CELL).eq(4).contains(rule.severity.toLowerCase());
cy.get(ALERT_GRID_CELL).eq(5).contains(rule.riskScore);
cy.get(`${ALERT_GRID_CELL} ${ALERT_RULE_NAME}`).contains(rule.name);
cy.get(`${ALERT_GRID_CELL} ${ALERT_SEVERITY}`).contains(rule.severity.toLowerCase());
cy.get(`${ALERT_GRID_CELL} ${ALERT_RISK_SCORE}`).contains(rule.riskScore);
});

it('Preview results of keyword using "host.name"', () => {
Expand Down
Loading