-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add allowlist filter for Exception list data (#112668)
* Add allowlist filter to exception list telemetry. * Refactor away union type. * Bump interval back to 24h. Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
8cf0efe
commit feae8e7
Showing
10 changed files
with
266 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
x-pack/plugins/security_solution/server/lib/telemetry/filters.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* 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 { copyAllowlistedFields } from './filters'; | ||
|
||
describe('Security Telemetry filters', () => { | ||
describe('allowlistEventFields', () => { | ||
const allowlist = { | ||
a: true, | ||
b: true, | ||
c: { | ||
d: true, | ||
}, | ||
}; | ||
|
||
it('filters top level', () => { | ||
const event = { | ||
a: 'a', | ||
a1: 'a1', | ||
b: 'b', | ||
b1: 'b1', | ||
}; | ||
expect(copyAllowlistedFields(allowlist, event)).toStrictEqual({ | ||
a: 'a', | ||
b: 'b', | ||
}); | ||
}); | ||
|
||
it('filters nested', () => { | ||
const event = { | ||
a: { | ||
a1: 'a1', | ||
}, | ||
a1: 'a1', | ||
b: { | ||
b1: 'b1', | ||
}, | ||
b1: 'b1', | ||
c: { | ||
d: 'd', | ||
e: 'e', | ||
f: 'f', | ||
}, | ||
}; | ||
expect(copyAllowlistedFields(allowlist, event)).toStrictEqual({ | ||
a: { | ||
a1: 'a1', | ||
}, | ||
b: { | ||
b1: 'b1', | ||
}, | ||
c: { | ||
d: 'd', | ||
}, | ||
}); | ||
}); | ||
|
||
it('filters arrays of objects', () => { | ||
const event = { | ||
a: [ | ||
{ | ||
a1: 'a1', | ||
}, | ||
], | ||
b: { | ||
b1: 'b1', | ||
}, | ||
c: [ | ||
{ | ||
d: 'd1', | ||
e: 'e1', | ||
f: 'f1', | ||
}, | ||
{ | ||
d: 'd2', | ||
e: 'e2', | ||
f: 'f2', | ||
}, | ||
{ | ||
d: 'd3', | ||
e: 'e3', | ||
f: 'f3', | ||
}, | ||
], | ||
}; | ||
expect(copyAllowlistedFields(allowlist, event)).toStrictEqual({ | ||
a: [ | ||
{ | ||
a1: 'a1', | ||
}, | ||
], | ||
b: { | ||
b1: 'b1', | ||
}, | ||
c: [ | ||
{ | ||
d: 'd1', | ||
}, | ||
{ | ||
d: 'd2', | ||
}, | ||
{ | ||
d: 'd3', | ||
}, | ||
], | ||
}); | ||
}); | ||
|
||
it("doesn't create empty objects", () => { | ||
const event = { | ||
a: 'a', | ||
b: 'b', | ||
c: { | ||
e: 'e', | ||
}, | ||
}; | ||
expect(copyAllowlistedFields(allowlist, event)).toStrictEqual({ | ||
a: 'a', | ||
b: 'b', | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.