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][Cypress] Unskip some tests #117596

Merged
merged 23 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9c5c4cf
Reenable cypress tests for rules
madirey Nov 4, 2021
4502afa
Indicator match is not yet passing
madirey Nov 4, 2021
ea9ffc9
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 5, 2021
847ee6a
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 9, 2021
7f4f2cd
Update refs
madirey Nov 9, 2021
4208753
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 9, 2021
39b682d
Fix eql alert generation original_time and building_block_type
madirey Nov 10, 2021
e7598b0
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 10, 2021
9102699
Unskip a few more tests
madirey Nov 10, 2021
caa573e
Update field names in jest tests
madirey Nov 10, 2021
accc297
Fix unit tests / cypress tests
madirey Nov 11, 2021
80f1353
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 11, 2021
7f17b0c
Have to keep this one skipped for now
madirey Nov 11, 2021
a9aaaad
Fix some more tests?
madirey Nov 11, 2021
025e2c6
cleanup
madirey Nov 15, 2021
eb65f8a
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 16, 2021
6239eea
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 16, 2021
896621d
Fix translation
madirey Nov 16, 2021
a42166a
Merge branch 'main' of github.com:elastic/kibana into unskip-aad-tests
madirey Nov 18, 2021
740111c
Merge branch 'main' into unskip-aad-tests
kibanamachine Nov 18, 2021
38b1b52
Merge branch 'main' into unskip-aad-tests
MadameSheema Nov 23, 2021
afb25e9
fixes conflict issue
MadameSheema Nov 23, 2021
2c1a31c
remove unused code and added signal refs
michaelolo24 Nov 23, 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 @@ -6,8 +6,6 @@
*/

import { Values } from '@kbn/utility-types';
import { AlertExecutorOptions } from '../../../alerting/server';
import { ParsedTechnicalFields } from '../../common/parse_technical_fields';
import {
ALERT_INSTANCE_ID,
ALERT_UUID,
Expand All @@ -20,7 +18,10 @@ import {
SPACE_IDS,
TAGS,
TIMESTAMP,
} from '../../common/technical_rule_data_field_names';
} from '@kbn/rule-data-utils/technical_field_names';

import { AlertExecutorOptions } from '../../../alerting/server';
import { ParsedTechnicalFields } from '../../common/parse_technical_fields';

const commonAlertFieldNames = [
ALERT_RULE_CATEGORY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('Custom detection rules creation', () => {
});
});

it.skip('Creates and activates a new rule', function () {
it('Creates and activates a new rule', function () {
loginAndWaitForPageWithoutDateRange(ALERTS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand Down Expand Up @@ -215,9 +215,7 @@ 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).contains(this.rule.name);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('Detection rules, sequence EQL', () => {
});
});

it.skip('Creates and activates a new EQL rule with a sequence', function () {
it('Creates and activates a new EQL rule with a sequence', function () {
loginAndWaitForPageWithoutDateRange(ALERTS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand Down Expand Up @@ -219,7 +219,6 @@ describe('Detection rules, sequence EQL', () => {
cy.log('ALERT_DATA_GRID', text);
expect(text).contains(this.rule.name);
expect(text).contains(this.rule.severity.toLowerCase());
expect(text).contains(this.rule.riskScore);
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a particular reason we are removing the riskScore checks

});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ describe('indicator match', () => {
loginAndWaitForPageWithoutDateRange(ALERTS_URL);
});

// Skipping until we fix dupe mitigation
it.skip('Creates and activates a new Indicator Match rule', () => {
it('Creates and activates a new Indicator Match rule', () => {
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
goToManageAlertsDetectionRules();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('Detection rules, override', () => {
});
});

it.skip('Creates and activates a new custom rule with override option', function () {
it('Creates and activates a new custom rule with override option', function () {
loginAndWaitForPageWithoutDateRange(ALERTS_URL);
waitForAlertsPanelToBeLoaded();
waitForAlertsIndexToBeCreated();
Expand Down Expand Up @@ -139,7 +139,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}kibana.alert.rule.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 +187,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).contains('auditbeat');
cy.get(ALERT_GRID_CELL).contains('critical');
cy.get(ALERT_GRID_CELL).contains('80');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { refreshPage } from '../../tasks/security_header';
import { ALERTS_URL } from '../../urls/navigation';
import { cleanKibana } from '../../tasks/common';

describe.skip('From rule', () => {
describe('From rule', () => {
const NUMBER_OF_AUDITBEAT_EXCEPTIONS_ALERTS = '1';
beforeEach(() => {
cleanKibana();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { EuiSpacer, EuiHorizontalRule, EuiTitle, EuiText } from '@elastic/eui';
import { ALERT_RULE_UUID } from '@kbn/rule-data-utils';

import React, { useMemo } from 'react';
import styled from 'styled-components';
Expand All @@ -25,7 +26,7 @@ const InvestigationGuideViewComponent: React.FC<{
data: TimelineEventsDetailsItem[];
}> = ({ data }) => {
const ruleId = useMemo(() => {
const item = data.find((d) => d.field === 'signal.rule.id');
const item = data.find((d) => d.field === 'signal.rule.id' || d.field === ALERT_RULE_UUID);
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we have an or here? don't we need just d.field === ALERT_RULE_UUID

return Array.isArray(item?.originalValue)
? item?.originalValue[0]
: item?.originalValue ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import { EuiTextColor, EuiFlexItem, EuiSpacer, EuiHorizontalRule, EuiTitle } from '@elastic/eui';
import { ALERT_REASON, ALERT_RULE_UUID } from '@kbn/rule-data-utils';

import React, { useMemo } from 'react';

import styled from 'styled-components';
Expand Down Expand Up @@ -33,15 +35,20 @@ export const ReasonComponent: React.FC<Props> = ({ eventId, data }) => {
const { navigateToApp } = useKibana().services.application;
const { formatUrl } = useFormatUrl(SecurityPageName.rules);

const reason = useMemo(
() => getFieldValue({ category: 'signal', field: 'signal.reason' }, data),
[data]
);
const reason = useMemo(() => {
const siemSignalsReason = getFieldValue(
{ category: 'signal', field: 'signal.alert.reason' },
data
);
const aadReason = getFieldValue({ category: 'kibana', field: ALERT_REASON }, data);
return aadReason.length > 0 ? aadReason : siemSignalsReason;
}, [data]);

const ruleId = useMemo(
() => getFieldValue({ category: 'signal', field: 'signal.rule.id' }, data),
[data]
);
const ruleId = useMemo(() => {
const siemSignalsRuleId = getFieldValue({ category: 'signal', field: 'signal.rule.id' }, data);
Copy link
Contributor

Choose a reason for hiding this comment

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

so rules continue to have signal.rule.id - does that include newly created rules in 8.0 as well?

const aadRuleId = getFieldValue({ category: 'kibana', field: ALERT_RULE_UUID }, data);
return aadRuleId.length > 0 ? aadRuleId : siemSignalsRuleId;
}, [data]);

if (!eventId) {
return <EuiTextColor color="subdued">{EVENT_DETAILS_PLACEHOLDER}</EuiTextColor>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,18 @@ import {
OsTypeArray,
ExceptionListItemSchema,
} from '@kbn/securitysolution-io-ts-list-types';
import { DataViewBase } from '@kbn/es-query';

import { getExceptionListItemSchemaMock } from '../../../../../lists/common/schemas/response/exception_list_item_schema.mock';
import { getEntryMatchMock } from '../../../../../lists/common/schemas/types/entry_match.mock';
import { getCommentsArrayMock } from '../../../../../lists/common/schemas/types/comment.mock';
import { fields } from '../../../../../../../src/plugins/data/common/mocks';
import { ENTRIES, OLD_DATE_RELATIVE_TO_DATE_NOW } from '../../../../../lists/common/constants.mock';
import { CodeSignature } from '../../../../common/ecs/file';
import type { DataViewBase } from '@kbn/es-query';
import {
ALERT_ORIGINAL_EVENT_KIND,
ALERT_ORIGINAL_EVENT_MODULE,
} from '../../../../common/field_maps/field_names';

jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('123'),
Expand Down Expand Up @@ -432,7 +436,7 @@ describe('Exception helpers', () => {
entries: [
{
...getEntryMatchMock(),
field: 'signal.original_event.kind',
field: ALERT_ORIGINAL_EVENT_KIND,
},
getEntryMatchMock(),
],
Expand All @@ -442,7 +446,7 @@ describe('Exception helpers', () => {
entries: [
{
...getEntryMatchMock(),
field: 'signal.original_event.module',
field: ALERT_ORIGINAL_EVENT_MODULE,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import exceptionableLinuxFields from './exceptionable_linux_fields.json';
import exceptionableWindowsMacFields from './exceptionable_windows_mac_fields.json';
import exceptionableEndpointFields from './exceptionable_endpoint_fields.json';
import exceptionableEndpointEventFields from './exceptionable_endpoint_event_fields.json';
import { ALERT_ORIGINAL_EVENT } from '../../../../common/field_maps/field_names';

export const filterIndexPatterns = (
patterns: DataViewBase,
Expand Down Expand Up @@ -145,7 +146,7 @@ export const prepareExceptionItemsForBulkClose = (
return {
...itemEntry,
field: itemEntry.field.startsWith('event.')
? itemEntry.field.replace(/^event./, 'signal.original_event.')
? itemEntry.field.replace(/^event./, `${ALERT_ORIGINAL_EVENT}.`)
: itemEntry.field,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
*/

/** actions are disabled for these fields in tables and popovers */
export const FIELDS_WITHOUT_CELL_ACTIONS = ['signal.rule.risk_score', 'signal.reason'];
export const FIELDS_WITHOUT_CELL_ACTIONS = [
'signal.rule.risk_score',
'signal.reason',
'kibana.alert.rule.risk_score',
'kibana.alert.reason',
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* 2.0.
*/

import { ALERT_WORKFLOW_STATUS, ALERT_RULE_UUID } from '@kbn/rule-data-utils';

export const buildLastAlertsQuery = (ruleId: string | undefined | null) => {
const queryFilter = [
{
bool: {
should: [{ match: { 'kibana.alert.workflow_status': 'open' } }],
should: [{ match: { [ALERT_WORKFLOW_STATUS]: 'open' } }],
minimum_should_match: 1,
},
},
Expand All @@ -27,7 +29,10 @@ export const buildLastAlertsQuery = (ruleId: string | undefined | null) => {
...queryFilter,
{
bool: {
should: [{ match: { 'signal.rule.id': ruleId } }],
should: [
{ match: { 'signal.rule.id': ruleId } },
{ match: { [ALERT_RULE_UUID]: ruleId } },
],
minimum_should_match: 1,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export const buildAlertsKqlFilter = (
negate: false,
disabled: false,
type: 'phrases',
key: key.replace('signal.', 'kibana.alert.'),
key,
value: alertIds.join(),
params: alertIds,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@

import {
ALERT_DURATION,
ALERT_INSTANCE_ID,
ALERT_RULE_PRODUCER,
ALERT_START,
ALERT_WORKFLOW_STATUS,
ALERT_UUID,
ALERT_RULE_UUID,
ALERT_RULE_NAME,
ALERT_RULE_CATEGORY,
ALERT_RULE_SEVERITY,
ALERT_RULE_RISK_SCORE,
} from '@kbn/rule-data-utils/technical_field_names';

import type { Filter } from '@kbn/es-query';
Expand Down Expand Up @@ -271,10 +272,11 @@ export const buildShowBuildingBlockFilterRuleRegistry = (

export const requiredFieldMappingsForActionsRuleRegistry = {
'@timestamp': '@timestamp',
'alert.instance.id': ALERT_INSTANCE_ID,
'event.kind': 'event.kind',
'alert.start': ALERT_START,
'rule.severity': ALERT_RULE_SEVERITY,
'rule.risk_score': ALERT_RULE_RISK_SCORE,
'alert.uuid': ALERT_UUID,
'alert.start': ALERT_START,
'event.action': 'event.action',
'alert.workflow_status': ALERT_WORKFLOW_STATUS,
'alert.duration.us': ALERT_DURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,18 @@ export const getFieldValues = (
},
data: TimelineEventsDetailsItem[] | null
) => {
return find({ category, field }, data)?.values;
const categoryCompat =
category === 'signal' ? 'kibana' : category === 'kibana' ? 'signal' : category;
const fieldCompat =
category === 'signal'
? field.replace('signal', 'kibana.alert').replace('rule.id', 'rule.uuid')
: category === 'kibana'
? field.replace('kibana.alert', 'signal').replace('rule.uuid', 'rule.id')
: field;
return (
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's coming together now. We keep both versions and search for each if we can't find one or the other. very interesting

find({ category, field }, data)?.values ??
find({ category: categoryCompat, field: fieldCompat }, data)?.values
);
};

export const getFieldValue = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
EuiIcon,
EuiToolTip,
} from '@elastic/eui';
import { ALERT_RULE_RISK_SCORE } from '@kbn/rule-data-utils';

import { isEmpty } from 'lodash/fp';
import React from 'react';
Expand Down Expand Up @@ -353,7 +354,7 @@ export const buildRiskScoreDescription = (riskScore: AboutStepRiskScore): ListIt
<EuiFlexItem grow={false}>
<EuiIcon type={'sortRight'} />
</EuiFlexItem>
<EuiFlexItem>{'signal.rule.risk_score'}</EuiFlexItem>
<EuiFlexItem>{ALERT_RULE_RISK_SCORE}</EuiFlexItem>
</EuiFlexGroup>
),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const DEFAULT_RISK_SCORE = i18n.translate(
export const RISK_SCORE_FIELD = i18n.translate(
'xpack.securitySolution.alerts.riskScoreMapping.riskScoreFieldTitle',
{
defaultMessage: 'signal.rule.risk_score',
defaultMessage: 'kibana.alert.rule.risk_score',
}
);

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

import { EuiDataGridColumn } from '@elastic/eui';
import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names';
import {
ALERT_DURATION,
ALERT_REASON,
ALERT_STATUS,
} from '@kbn/rule-data-utils/technical_field_names';

import { ColumnHeaderOptions } from '../../../../../common';
import { defaultColumnHeaderType } from '../../../../timelines/components/timeline/body/column_headers/default_headers';
Expand Down Expand Up @@ -48,6 +52,6 @@ export const columns: Array<
{
columnHeaderType: defaultColumnHeaderType,
displayAsText: i18n.ALERTS_HEADERS_REASON,
id: 'signal.reason',
id: ALERT_REASON,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import moment from 'moment';
import React from 'react';

import { EuiDataGridCellValueElementProps, EuiLink } from '@elastic/eui';
import { ALERT_DURATION, ALERT_STATUS } from '@kbn/rule-data-utils/technical_field_names';
import {
ALERT_DURATION,
ALERT_REASON,
ALERT_RULE_SEVERITY,
ALERT_STATUS,
} from '@kbn/rule-data-utils/technical_field_names';

import { TruncatableText } from '../../../../common/components/truncatable_text';
import { Severity } from '../../../components/severity';
Expand Down Expand Up @@ -53,9 +58,12 @@ export const RenderCellValue: React.FC<EuiDataGridCellValueElementProps & CellVa
<Status data-test-subj="alert-status" status={random(0, 1) ? 'recovered' : 'active'} />
);
case ALERT_DURATION:
case 'signal.duration.us':
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be nice if the older versions were consts as well

return <span data-test-subj="alert-duration">{moment().fromNow(true)}</span>;
case ALERT_RULE_SEVERITY:
case 'signal.rule.severity':
return <Severity data-test-subj="rule-severity" severity={value} />;
case ALERT_REASON:
case 'signal.reason':
return (
<EuiLink data-test-subj="reason">
Expand Down
Loading