forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SECURITY_SOLUTIONS] Only query security alerts with current user (el…
…astic#174216) ## Summary We just got an [SDH#814](elastic/sdh-security-team#814) that tell us that some feature like `KPIs` and `grouping` are not acting as they should be. @PhilippeOberti is doing an investigation to check which feature has been impacted by this bug. This bug has been introduced in this elastic#112113 since 8.0.0 I think this simple solution should not impact any features.
- Loading branch information
Showing
4 changed files
with
176 additions
and
12 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
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
153 changes: 153 additions & 0 deletions
153
...on_api_integration/test_suites/detections_response/default_license/alerts/query_alerts.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,153 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
|
||
import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '@kbn/security-solution-plugin/common/constants'; | ||
import { FtrProviderContext } from '../../../../ftr_provider_context'; | ||
|
||
const roleToAccessSecuritySolution = { | ||
name: 'sec_all_spaces', | ||
privileges: { | ||
elasticsearch: { | ||
indices: [ | ||
{ | ||
names: ['.alerts-security.alerts-default'], | ||
privileges: ['all'], | ||
}, | ||
], | ||
}, | ||
kibana: [ | ||
{ | ||
feature: { | ||
siem: ['all'], | ||
}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}, | ||
}; | ||
const roleToAccessSecuritySolutionWithDls = { | ||
name: 'sec_all_spaces_with_dls', | ||
privileges: { | ||
elasticsearch: { | ||
indices: [ | ||
{ | ||
names: ['.alerts-security.alerts-default'], | ||
privileges: ['read'], | ||
query: | ||
'{"wildcard" : { "kibana.alert.ancestors.index" : { "value": ".ds-kibana_does_not_exist" } } }', | ||
}, | ||
], | ||
}, | ||
kibana: [ | ||
{ | ||
feature: { | ||
siem: ['all'], | ||
}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}, | ||
}; | ||
const userAllSec = { | ||
username: 'user_all_sec', | ||
password: 'user_all_sec', | ||
full_name: 'userAllSec', | ||
email: '[email protected]', | ||
roles: [roleToAccessSecuritySolution.name], | ||
}; | ||
const userAllSecWithDls = { | ||
username: 'user_all_sec_with_dls', | ||
password: 'user_all_sec_with_dls', | ||
full_name: 'userAllSecWithDls', | ||
email: '[email protected]', | ||
roles: [roleToAccessSecuritySolutionWithDls.name], | ||
}; | ||
|
||
export default ({ getService }: FtrProviderContext) => { | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
const esArchiver = getService('esArchiver'); | ||
const security = getService('security'); | ||
|
||
describe('find alert with/without doc level security', () => { | ||
before(async () => { | ||
await security.role.create( | ||
roleToAccessSecuritySolution.name, | ||
roleToAccessSecuritySolution.privileges | ||
); | ||
await security.role.create( | ||
roleToAccessSecuritySolutionWithDls.name, | ||
roleToAccessSecuritySolutionWithDls.privileges | ||
); | ||
await security.user.create(userAllSec.username, { | ||
password: userAllSec.password, | ||
roles: userAllSec.roles, | ||
full_name: userAllSec.full_name, | ||
email: userAllSec.email, | ||
}); | ||
await security.user.create(userAllSecWithDls.username, { | ||
password: userAllSecWithDls.password, | ||
roles: userAllSecWithDls.roles, | ||
full_name: userAllSecWithDls.full_name, | ||
email: userAllSecWithDls.email, | ||
}); | ||
|
||
await esArchiver.load( | ||
'x-pack/test/functional/es_archives/security_solution/alerts/8.8.0_multiple_docs', | ||
{ | ||
useCreate: true, | ||
docsOnly: true, | ||
} | ||
); | ||
}); | ||
|
||
after(async () => { | ||
await security.user.delete(userAllSec.username); | ||
await security.user.delete(userAllSecWithDls.username); | ||
await security.role.delete(roleToAccessSecuritySolution.name); | ||
await security.role.delete(roleToAccessSecuritySolutionWithDls.name); | ||
await esArchiver.unload( | ||
'x-pack/test/functional/es_archives/security_solution/alerts/8.8.0_multiple_docs' | ||
); | ||
}); | ||
|
||
it('should return alerts with user who has access to security solution privileges', async () => { | ||
const query = { | ||
query: { | ||
bool: { | ||
should: [{ match_all: {} }], | ||
}, | ||
}, | ||
}; | ||
const { body } = await supertestWithoutAuth | ||
.post(DETECTION_ENGINE_QUERY_SIGNALS_URL) | ||
.auth(userAllSec.username, userAllSec.password) | ||
.set('kbn-xsrf', 'true') | ||
.send(query) | ||
.expect(200); | ||
expect(body.hits.total.value).to.eql(3); | ||
}); | ||
|
||
it('should filter out alerts with user who has access to security solution privileges and document level security', async () => { | ||
const query = { | ||
query: { | ||
bool: { | ||
should: [{ match_all: {} }], | ||
}, | ||
}, | ||
}; | ||
const { body } = await supertestWithoutAuth | ||
.post(DETECTION_ENGINE_QUERY_SIGNALS_URL) | ||
.auth(userAllSecWithDls.username, userAllSecWithDls.password) | ||
.set('kbn-xsrf', 'true') | ||
.send(query) | ||
.expect(200); | ||
expect(body.hits.total.value).to.eql(0); | ||
}); | ||
}); | ||
}; |