Skip to content

Commit 4a802a8

Browse files
kevinlogkibanamachine
authored andcommitted
[Security Solution] Correct linux OS lookup for Endpoint Exceptions (#103038)
1 parent 00c2047 commit 4a802a8

4 files changed

Lines changed: 76 additions & 72 deletions

File tree

x-pack/plugins/security_solution/public/common/components/exceptions/exceptionable_endpoint_fields.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
[
22
"Endpoint.policy.applied.id",
3-
"Target.process.Ext.code_signature.status",
4-
"Target.process.Ext.code_signature.subject_name",
5-
"Target.process.Ext.code_signature.trusted",
6-
"Target.process.Ext.code_signature.valid",
73
"Target.process.Ext.services",
84
"Target.process.Ext.user",
95
"Target.process.hash.md5",
106
"Target.process.hash.sha1",
117
"Target.process.hash.sha256",
128
"Target.process.hash.sha512",
13-
"Target.process.parent.Ext.code_signature.status",
14-
"Target.process.parent.Ext.code_signature.subject_name",
15-
"Target.process.parent.Ext.code_signature.trusted",
16-
"Target.process.parent.Ext.code_signature.valid",
179
"Target.process.parent.hash.md5",
1810
"Target.process.parent.hash.sha1",
1911
"Target.process.parent.hash.sha256",
@@ -38,10 +30,6 @@
3830
"event.outcome",
3931
"event.provider",
4032
"event.type",
41-
"file.Ext.code_signature.status",
42-
"file.Ext.code_signature.subject_name",
43-
"file.Ext.code_signature.trusted",
44-
"file.Ext.code_signature.valid",
4533
"file.attributes",
4634
"file.device",
4735
"file.directory",
@@ -78,20 +66,12 @@
7866
"host.os.platform",
7967
"host.os.version",
8068
"host.type",
81-
"process.Ext.code_signature.status",
82-
"process.Ext.code_signature.subject_name",
83-
"process.Ext.code_signature.trusted",
84-
"process.Ext.code_signature.valid",
8569
"process.Ext.services",
8670
"process.Ext.user",
8771
"process.hash.md5",
8872
"process.hash.sha1",
8973
"process.hash.sha256",
9074
"process.hash.sha512",
91-
"process.parent.Ext.code_signature.status",
92-
"process.parent.Ext.code_signature.subject_name",
93-
"process.parent.Ext.code_signature.trusted",
94-
"process.parent.Ext.code_signature.valid",
9575
"process.parent.hash.md5",
9676
"process.parent.hash.sha1",
9777
"process.parent.hash.sha256",

x-pack/plugins/security_solution/public/common/components/exceptions/exceptionable_windows_mac_fields.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,21 @@
1818
"process.parent.executable.caseless",
1919
"process.parent.name.caseless",
2020
"process.parent.working_directory.caseless",
21-
"process.working_directory.caseless"
21+
"process.working_directory.caseless",
22+
"Target.process.Ext.code_signature.status",
23+
"Target.process.Ext.code_signature.subject_name",
24+
"Target.process.Ext.code_signature.trusted",
25+
"Target.process.Ext.code_signature.valid",
26+
"Target.process.parent.Ext.code_signature.status",
27+
"Target.process.parent.Ext.code_signature.subject_name",
28+
"Target.process.parent.Ext.code_signature.trusted",
29+
"Target.process.parent.Ext.code_signature.valid",
30+
"file.Ext.code_signature.status",
31+
"file.Ext.code_signature.subject_name",
32+
"file.Ext.code_signature.trusted",
33+
"file.Ext.code_signature.valid",
34+
"process.parent.Ext.code_signature.status",
35+
"process.parent.Ext.code_signature.subject_name",
36+
"process.parent.Ext.code_signature.trusted",
37+
"process.parent.Ext.code_signature.valid"
2238
]

x-pack/plugins/security_solution/public/common/components/exceptions/helpers.test.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,6 @@ const mockLinuxEndpointFields = [
8787
aggregatable: false,
8888
readFromDocValues: false,
8989
},
90-
{
91-
name: 'file.Ext.code_signature.status',
92-
type: 'string',
93-
esTypes: ['text'],
94-
count: 0,
95-
scripted: false,
96-
searchable: true,
97-
aggregatable: false,
98-
readFromDocValues: false,
99-
subType: { nested: { path: 'file.Ext.code_signature' } },
100-
},
10190
];
10291

10392
export const getEndpointField = (name: string) =>

x-pack/plugins/security_solution/public/common/components/exceptions/helpers.tsx

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,10 @@ export const enrichExceptionItemsWithOS = (
236236
export const retrieveAlertOsTypes = (alertData?: AlertData): OsTypeArray => {
237237
const osDefaults: OsTypeArray = ['windows', 'macos'];
238238
if (alertData != null) {
239-
const os = alertData.host && alertData.host.os && alertData.host.os.family;
239+
const os =
240+
alertData?.agent?.type === 'endpoint'
241+
? alertData.host?.os?.name?.toLowerCase()
242+
: alertData.host?.os?.family;
240243
if (os != null) {
241244
return osType.is(os) ? [os] : osDefaults;
242245
}
@@ -361,48 +364,64 @@ export const getPrepopulatedEndpointException = ({
361364
const { file, host } = alertEcsData;
362365
const filePath = file?.path ?? '';
363366
const sha256Hash = file?.hash?.sha256 ?? '';
364-
const filePathDefault = host?.os?.family === 'linux' ? 'file.path' : 'file.path.caseless';
367+
const isLinux = host?.os?.name === 'Linux';
368+
369+
const commonFields: Array<{
370+
field: string;
371+
operator: 'excluded' | 'included';
372+
type: 'match';
373+
value: string;
374+
}> = [
375+
{
376+
field: isLinux ? 'file.path' : 'file.path.caseless',
377+
operator: 'included',
378+
type: 'match',
379+
value: filePath ?? '',
380+
},
381+
{
382+
field: 'file.hash.sha256',
383+
operator: 'included',
384+
type: 'match',
385+
value: sha256Hash ?? '',
386+
},
387+
{
388+
field: 'event.code',
389+
operator: 'included',
390+
type: 'match',
391+
value: eventCode ?? '',
392+
},
393+
];
394+
const entriesToAdd = () => {
395+
if (isLinux) {
396+
return addIdToEntries(commonFields);
397+
} else {
398+
return addIdToEntries([
399+
{
400+
field: 'file.Ext.code_signature',
401+
type: 'nested',
402+
entries: [
403+
{
404+
field: 'subject_name',
405+
operator: 'included',
406+
type: 'match',
407+
value: codeSignature != null ? codeSignature.subjectName : '',
408+
},
409+
{
410+
field: 'trusted',
411+
operator: 'included',
412+
type: 'match',
413+
value: codeSignature != null ? codeSignature.trusted : '',
414+
},
415+
],
416+
},
417+
...commonFields,
418+
]);
419+
}
420+
};
365421

366422
return {
367423
...getNewExceptionItem({ listId, namespaceType: listNamespace, ruleName }),
368-
entries: addIdToEntries([
369-
{
370-
field: 'file.Ext.code_signature',
371-
type: 'nested',
372-
entries: [
373-
{
374-
field: 'subject_name',
375-
operator: 'included',
376-
type: 'match',
377-
value: codeSignature != null ? codeSignature.subjectName : '',
378-
},
379-
{
380-
field: 'trusted',
381-
operator: 'included',
382-
type: 'match',
383-
value: codeSignature != null ? codeSignature.trusted : '',
384-
},
385-
],
386-
},
387-
{
388-
field: filePathDefault,
389-
operator: 'included',
390-
type: 'match',
391-
value: filePath ?? '',
392-
},
393-
{
394-
field: 'file.hash.sha256',
395-
operator: 'included',
396-
type: 'match',
397-
value: sha256Hash ?? '',
398-
},
399-
{
400-
field: 'event.code',
401-
operator: 'included',
402-
type: 'match',
403-
value: eventCode ?? '',
404-
},
405-
]),
424+
entries: entriesToAdd(),
406425
};
407426
};
408427

0 commit comments

Comments
 (0)