-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SIEM][Detection Engine] - Update DE to work with new exceptions schema #69715
Changes from 8 commits
3b19da1
3388918
e977f00
55e29c9
65e47ca
a2f6286
6b728fe
53536f8
1713e7f
373fe8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { pipe } from 'fp-ts/lib/pipeable'; | ||
import { left } from 'fp-ts/lib/Either'; | ||
|
||
import { foldLeftRight, getPaths } from '../../siem_common_deps'; | ||
|
||
import { DefaultNamespace } from './default_namespace'; | ||
|
||
describe('default_namespace', () => { | ||
test('it should validate "single"', () => { | ||
const payload = 'single'; | ||
const decoded = DefaultNamespace.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual(payload); | ||
}); | ||
|
||
test('it should validate "agnostic"', () => { | ||
const payload = 'agnostic'; | ||
const decoded = DefaultNamespace.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual(payload); | ||
}); | ||
|
||
test('it defaults to "single" if "undefined"', () => { | ||
const payload = undefined; | ||
const decoded = DefaultNamespace.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual('single'); | ||
}); | ||
|
||
test('it defaults to "single" if "null"', () => { | ||
const payload = null; | ||
const decoded = DefaultNamespace.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([]); | ||
expect(message.schema).toEqual('single'); | ||
}); | ||
|
||
test('it should NOT validate if not "single" or "agnostic"', () => { | ||
const payload = 'something else'; | ||
const decoded = DefaultNamespace.decode(payload); | ||
const message = pipe(decoded, foldLeftRight); | ||
|
||
expect(getPaths(left(message.errors))).toEqual([ | ||
`Invalid value "something else" supplied to "DefaultNamespace"`, | ||
]); | ||
expect(message.schema).toEqual({}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
|
||
import * as t from 'io-ts'; | ||
|
||
import { operator } from '../common/schemas'; | ||
import { operator, type } from '../common/schemas'; | ||
import { DefaultStringArray } from '../../siem_common_deps'; | ||
|
||
export const entriesMatch = t.exact( | ||
|
@@ -34,9 +34,9 @@ export type EntryMatchAny = t.TypeOf<typeof entriesMatchAny>; | |
export const entriesList = t.exact( | ||
t.type({ | ||
field: t.string, | ||
list: t.exact(t.type({ id: t.string, type })), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: Changed this to |
||
operator, | ||
type: t.keyof({ list: null }), | ||
value: DefaultStringArray, | ||
}) | ||
); | ||
export type EntryList = t.TypeOf<typeof entriesList>; | ||
|
@@ -52,7 +52,7 @@ export type EntryExists = t.TypeOf<typeof entriesExists>; | |
|
||
export const entriesNested = t.exact( | ||
t.type({ | ||
entries: t.array(t.union([entriesMatch, entriesMatchAny, entriesList, entriesExists])), | ||
entries: t.array(entriesMatch), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NOTE: Looking at KQL nested support, looks like it would only support our |
||
field: t.string, | ||
type: t.keyof({ nested: null }), | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"item_id": "endpoint_list_item_lg_val_list", | ||
yctercero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"_tags": ["endpoint", "process", "malware", "os:windows"], | ||
"tags": ["user added string for a tag", "malware"], | ||
"type": "simple", | ||
"description": "This is a sample exception list item with a large value list included", | ||
"name": "Sample Endpoint Exception List Item with large value list", | ||
"comments": [], | ||
"entries": [ | ||
{ | ||
"field": "event.module", | ||
"operator": "excluded", | ||
"type": "match_any", | ||
"value": ["zeek"] | ||
}, | ||
{ | ||
"field": "source.ip", | ||
"operator": "excluded", | ||
"type": "list", | ||
"list": { "id": "list-ip", "type": "ip" } | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export { EntryList, EntriesArray, namespaceType } from '../../../lists/common/schemas'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: Exported to use in detection engine.