Skip to content

Commit

Permalink
Fixes to alerts table and timeline functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
madirey committed Oct 25, 2021
1 parent d4bc86c commit ba67a5f
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 317 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('useHoverActionItems', () => {
const defaultProps: UseHoverActionItemsProps = {
dataProvider: [{} as DataProvider],
defaultFocusedButtonRef: null,
field: 'signal.rule.name',
field: 'kibana.alert.rule.name',
handleHoverActionClicked: jest.fn(),
hideTopN: false,
isCaseView: false,
Expand Down Expand Up @@ -97,7 +97,7 @@ describe('useHoverActionItems', () => {
'hover-actions-filter-out'
);
expect(result.current.overflowActionItems[2].props['data-test-subj']).toEqual(
'more-actions-signal.rule.name'
'more-actions-kibana.alert.rule.name'
);
expect(result.current.overflowActionItems[2].props.items[0].props['data-test-subj']).toEqual(
'hover-actions-toggle-column'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const isAlertFromEndpointEvent = ({
}: {
data: TimelineEventsDetailsItem[];
}): boolean => {
const isAlert = some({ category: 'signal', field: 'signal.rule.id' }, data);
const isAlert = some({ category: 'kibana', field: 'kibana.alert.rule.uuid' }, data);

if (!isAlert) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
import type { AlertsStackByOption } from './types';

export const alertsStackByOptions: AlertsStackByOption[] = [
{ text: 'signal.rule.risk_score', value: 'signal.rule.risk_score' },
{ text: 'signal.rule.severity', value: 'signal.rule.severity' },
{ text: 'signal.rule.threat.tactic.name', value: 'signal.rule.threat.tactic.name' },
{ text: 'kibana.alert.rule.risk_score', value: 'kibana.alert.rule.risk_score' },
{ text: 'kibana.alert.rule.severity', value: 'kibana.alert.rule.severity' },
{ text: 'kibana.alert.rule.threat.tactic.name', value: 'kibana.alert.rule.threat.tactic.name' },
{ text: 'destination.ip', value: 'destination.ip' },
{ text: 'event.action', value: 'event.action' },
{ text: 'event.category', value: 'event.category' },
{ text: 'host.name', value: 'host.name' },
{ text: 'signal.rule.type', value: 'signal.rule.type' },
{ text: 'signal.rule.name', value: 'signal.rule.name' },
{ text: 'kibana.alert.rule.type', value: 'kibana.alert.rule.type' },
{ text: 'kibana.alert.rule.name', value: 'kibana.alert.rule.name' },
{ text: 'source.ip', value: 'source.ip' },
{ text: 'user.name', value: 'user.name' },
{ text: 'process.name', value: 'process.name' },
{ text: 'file.name', value: 'file.name' },
{ text: 'hash.sha256', value: 'hash.sha256' },
];

export const DEFAULT_STACK_BY_FIELD = 'signal.rule.name';
export const DEFAULT_STACK_BY_FIELD = 'kibana.alert.rule.name';

export const PANEL_HEIGHT = 300;
export const MOBILE_PANEL_HEIGHT = 500;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ export interface AlertsStackByOption {
}

export type AlertsStackByField =
| 'signal.rule.risk_score'
| 'signal.rule.severity'
| 'signal.rule.threat.tactic.name'
| 'kibana.alert.rule.risk_score'
| 'kibana.alert.rule.severity'
| 'kibana.alert.rule.threat.tactic.name'
| 'destination.ip'
| 'event.action'
| 'event.category'
| 'host.name'
| 'signal.rule.type'
| 'signal.rule.name'
| 'kibana.alert.rule.type'
| 'kibana.alert.rule.name'
| 'source.ip'
| 'user.name'
| 'process.name'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ export const buildShowBuildingBlockFilterRuleRegistry = (
negate: true,
disabled: false,
type: 'exists',
key: 'kibana.rule.building_block_type',
key: 'kibana.alert.rule.building_block_type',
value: 'exists',
},
query: { exists: { field: 'kibana.rule.building_block_type' } },
query: { exists: { field: 'kibana.alert.rule.building_block_type' } },
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ export const columns: Array<
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'signal.rule.name',
id: 'kibana.alert.rule.name',
displayAsText: i18n.ALERTS_HEADERS_RULE_NAME,
linkField: 'signal.rule.id',
linkField: 'kibana.alert.rule.uuid',
initialWidth: 212,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'signal.rule.severity',
id: 'kibana.alert.rule.severity',
displayAsText: i18n.ALERTS_HEADERS_SEVERITY,
initialWidth: 104,
},
{
columnHeaderType: defaultColumnHeaderType,
id: 'signal.reason',
id: 'kibana.alert.reason',
displayAsText: i18n.ALERTS_HEADERS_REASON,
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ const EventDetailsPanelComponent: React.FC<EventDetailsPanelProps> = ({
}
}, []);

const isAlert = some({ category: 'signal', field: 'signal.rule.id' }, detailsData);
const isAlert = some({ category: 'kibana', field: 'kibana.alert.rule.uuid' }, detailsData);

const ruleName = useMemo(
() => getFieldValue({ category: 'signal', field: 'signal.rule.name' }, detailsData),
() => getFieldValue({ category: 'kibana', field: 'kibana.alert.rule.name' }, detailsData),
[detailsData]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ export const getHostRulesColumns = (): HostRulesColumns => [
id,
name: ruleName,
kqlQuery: '',
queryMatch: { field: 'signal.rule.name', value: ruleName, operator: IS_OPERATOR },
queryMatch: {
field: 'kibana.alert.rule.name',
value: ruleName,
operator: IS_OPERATOR,
},
}}
render={(dataProvider, _, snapshot) =>
snapshot.isDragging ? (
Expand Down Expand Up @@ -73,7 +77,11 @@ export const getHostRulesColumns = (): HostRulesColumns => [
id,
name: ruleType,
kqlQuery: '',
queryMatch: { field: 'signal.rule.type', value: ruleType, operator: IS_OPERATOR },
queryMatch: {
field: 'kibana.alert.rule.type',
value: ruleType,
operator: IS_OPERATOR,
},
}}
render={(dataProvider, _, snapshot) =>
snapshot.isDragging ? (
Expand Down Expand Up @@ -109,7 +117,7 @@ export const getHostRulesColumns = (): HostRulesColumns => [
name: `${riskScore}`,
kqlQuery: '',
queryMatch: {
field: 'signal.rule.risk_score',
field: 'kibana.alert.rule.risk_score',
value: riskScore,
operator: IS_OPERATOR,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const setSignalsStatusRoute = (router: SecuritySolutionPluginRouter) => {
const siemClient = context.securitySolution?.getAppClient();
const siemResponse = buildSiemResponse(response);
const validationErrors = setSignalStatusValidateTypeDependents(request.body);
const spaceId = context.securitySolution.getSpaceId();
const spaceId = context.securitySolution?.getSpaceId() ?? 'default';

if (validationErrors.length) {
return siemResponse.error({ statusCode: 400, body: validationErrors });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,32 @@ export const buildHostRulesQuery = ({
aggs: {
risk_score: {
sum: {
field: 'signal.rule.risk_score',
field: 'kibana.alert.rule.risk_score',
},
},
rule_name: {
terms: {
field: 'signal.rule.name',
field: 'kibana.alert.rule.name',
order: {
risk_score: Direction.desc,
},
},
aggs: {
risk_score: {
sum: {
field: 'signal.rule.risk_score',
field: 'kibana.alert.rule.risk_score',
},
},
rule_type: {
terms: {
field: 'signal.rule.type',
field: 'kibana.alert.rule.type',
},
},
},
},
rule_count: {
cardinality: {
field: 'signal.rule.name',
field: 'kibana.alert.rule.name',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,32 @@ export const buildUserRulesQuery = ({
aggs: {
risk_score: {
sum: {
field: 'signal.rule.risk_score',
field: 'kibana.alert.rule.risk_score',
},
},
rule_name: {
terms: {
field: 'signal.rule.name',
field: 'kibana.alert.rule.name',
order: {
risk_score: Direction.desc,
},
},
aggs: {
risk_score: {
sum: {
field: 'signal.rule.risk_score',
field: 'kibana.alert.rule.risk_score',
},
},
rule_type: {
terms: {
field: 'signal.rule.type',
field: 'kibana.alert.rule.type',
},
},
},
},
rule_count: {
cardinality: {
field: 'signal.rule.name',
field: 'kibana.alert.rule.name',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const getAllFieldsByName = (
keyBy('name', getAllBrowserFields(browserFields));

const linkFields: Record<string, string> = {
'signal.rule.name': 'signal.rule.id',
'kibana.alert.rule.name': 'kibana.alert.rule.uuid',
'event.module': 'rule.reference',
};

Expand Down
Loading

0 comments on commit ba67a5f

Please sign in to comment.