Skip to content

Commit

Permalink
[Security Solution][Detections] Update rule integration tests (#98512)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee authored May 29, 2021
1 parent 1c5b302 commit 418a3d3
Show file tree
Hide file tree
Showing 2 changed files with 560 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { isEqual } from 'lodash';
import { get, isEqual } from 'lodash';
import expect from '@kbn/expect';

import { CreateRulesSchema } from '../../../../plugins/security_solution/common/detection_engine/schemas/request';
Expand Down Expand Up @@ -150,6 +150,97 @@ export default ({ getService }: FtrProviderContext) => {
await waitForSignalsToBePresent(supertest, 10, [id]);
const signalsOpen = await getSignalsByIds(supertest, [id]);
expect(signalsOpen.hits.hits.length).equal(10);
const fullSource = signalsOpen.hits.hits.find(
(signal) => signal._source.signal.parents[0].id === 'UBXOBmkBR346wHgnLP8T'
);
const fullSignal = fullSource!._source; // If this doesn't exist the test is going to fail anyway so using a bang operator here to get rid of ts error
expect(fullSignal).eql({
'@timestamp': fullSignal['@timestamp'],
agent: {
ephemeral_id: '1b4978a0-48be-49b1-ac96-323425b389ab',
hostname: 'zeek-sensor-amsterdam',
id: 'e52588e6-7aa3-4c89-a2c4-d6bc5c286db1',
type: 'auditbeat',
version: '8.0.0',
},
cloud: {
instance: {
id: '133551048',
},
provider: 'digitalocean',
region: 'ams3',
},
ecs: {
version: '1.0.0-beta2',
},
event: {
action: 'boot',
dataset: 'login',
kind: 'signal',
module: 'system',
origin: '/var/log/wtmp',
},
host: {
architecture: 'x86_64',
containerized: false,
hostname: 'zeek-sensor-amsterdam',
id: '2ce8b1e7d69e4a1d9c6bcddc473da9d9',
name: 'zeek-sensor-amsterdam',
os: {
codename: 'bionic',
family: 'debian',
kernel: '4.15.0-45-generic',
name: 'Ubuntu',
platform: 'ubuntu',
version: '18.04.2 LTS (Bionic Beaver)',
},
},
message: 'System boot',
service: {
type: 'system',
},
signal: {
_meta: {
version: 35,
},
ancestors: [
{
depth: 0,
id: 'UBXOBmkBR346wHgnLP8T',
index: 'auditbeat-8.0.0-2019.02.19-000001',
type: 'event',
},
],
depth: 1,
original_event: {
action: 'boot',
dataset: 'login',
kind: 'event',
module: 'system',
origin: '/var/log/wtmp',
},
original_time: fullSignal.signal.original_time,
parent: {
depth: 0,
id: 'UBXOBmkBR346wHgnLP8T',
index: 'auditbeat-8.0.0-2019.02.19-000001',
type: 'event',
},
parents: [
{
depth: 0,
id: 'UBXOBmkBR346wHgnLP8T',
index: 'auditbeat-8.0.0-2019.02.19-000001',
type: 'event',
},
],
rule: fullSignal.signal.rule,
status: 'open',
},
threat: {
indicator: get(fullSignal, 'threat.indicator'),
},
});
});

it('should return 0 matches if the mapping does not match against anything in the mapping', async () => {
Expand Down
Loading

0 comments on commit 418a3d3

Please sign in to comment.