-
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
[Security Solution] [Sourcerer] KIP Feature Branch Kickoff, remove config index patterns #106460
Changes from all commits
4deabab
8c452c2
fde9056
919a310
3b6cf6a
957bb97
8458b6f
c3df135
0342da6
af76d50
a386a11
d10ec88
33d44f1
e79a9b1
3c13e86
6cc917c
343354d
86bc00d
255bc1f
434f9bb
49098d4
de97889
ffc08eb
23fba2c
11c741d
32025be
e986d9d
19a1e9a
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 |
---|---|---|
|
@@ -18,182 +18,26 @@ import { | |
filterStatusOpen, | ||
} from '../../tasks/create_new_case'; | ||
import { | ||
constructUrlWithUser, | ||
getEnvAuth, | ||
loginAndWaitForHostDetailsPage, | ||
loginWithUserAndWaitForPageWithoutDateRange, | ||
logout, | ||
} from '../../tasks/login'; | ||
import { | ||
createUsersAndRoles, | ||
deleteUsersAndRoles, | ||
secAll, | ||
secAllUser, | ||
secReadCasesAllUser, | ||
secReadCasesAll, | ||
} from '../../tasks/privileges'; | ||
|
||
import { CASES_URL } from '../../urls/navigation'; | ||
|
||
interface User { | ||
username: string; | ||
password: string; | ||
description?: string; | ||
roles: string[]; | ||
} | ||
|
||
interface UserInfo { | ||
username: string; | ||
full_name: string; | ||
email: string; | ||
} | ||
|
||
interface FeaturesPrivileges { | ||
[featureId: string]: string[]; | ||
} | ||
|
||
interface ElasticsearchIndices { | ||
names: string[]; | ||
privileges: string[]; | ||
} | ||
|
||
interface ElasticSearchPrivilege { | ||
cluster?: string[]; | ||
indices?: ElasticsearchIndices[]; | ||
} | ||
|
||
interface KibanaPrivilege { | ||
spaces: string[]; | ||
base?: string[]; | ||
feature?: FeaturesPrivileges; | ||
} | ||
|
||
interface Role { | ||
name: string; | ||
privileges: { | ||
elasticsearch?: ElasticSearchPrivilege; | ||
kibana?: KibanaPrivilege[]; | ||
}; | ||
} | ||
|
||
const secAll: Role = { | ||
name: 'sec_all_role', | ||
privileges: { | ||
elasticsearch: { | ||
indices: [ | ||
{ | ||
names: ['*'], | ||
privileges: ['all'], | ||
}, | ||
], | ||
}, | ||
kibana: [ | ||
{ | ||
feature: { | ||
siem: ['all'], | ||
actions: ['all'], | ||
actionsSimulators: ['all'], | ||
}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const secAllUser: User = { | ||
username: 'sec_all_user', | ||
password: 'password', | ||
roles: [secAll.name], | ||
}; | ||
|
||
const secReadCasesAll: Role = { | ||
name: 'sec_read_cases_all_role', | ||
privileges: { | ||
elasticsearch: { | ||
indices: [ | ||
{ | ||
names: ['*'], | ||
privileges: ['all'], | ||
}, | ||
], | ||
}, | ||
kibana: [ | ||
{ | ||
feature: { | ||
siem: ['minimal_read', 'cases_all'], | ||
actions: ['all'], | ||
actionsSimulators: ['all'], | ||
}, | ||
spaces: ['*'], | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
const secReadCasesAllUser: User = { | ||
username: 'sec_read_cases_all_user', | ||
password: 'password', | ||
roles: [secReadCasesAll.name], | ||
}; | ||
|
||
const usersToCreate = [secAllUser, secReadCasesAllUser]; | ||
const rolesToCreate = [secAll, secReadCasesAll]; | ||
|
||
const getUserInfo = (user: User): UserInfo => ({ | ||
username: user.username, | ||
full_name: user.username.replace('_', ' '), | ||
email: `${user.username}@elastic.co`, | ||
}); | ||
|
||
const createUsersAndRoles = (users: User[], roles: Role[]) => { | ||
const envUser = getEnvAuth(); | ||
for (const role of roles) { | ||
cy.log(`Creating role: ${JSON.stringify(role)}`); | ||
cy.request({ | ||
body: role.privileges, | ||
headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, | ||
method: 'PUT', | ||
url: constructUrlWithUser(envUser, `/api/security/role/${role.name}`), | ||
}) | ||
.its('status') | ||
.should('eql', 204); | ||
} | ||
|
||
for (const user of users) { | ||
const userInfo = getUserInfo(user); | ||
cy.log(`Creating user: ${JSON.stringify(user)}`); | ||
cy.request({ | ||
body: { | ||
username: user.username, | ||
password: user.password, | ||
roles: user.roles, | ||
full_name: userInfo.full_name, | ||
email: userInfo.email, | ||
}, | ||
headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, | ||
method: 'POST', | ||
url: constructUrlWithUser(envUser, `/internal/security/users/${user.username}`), | ||
}) | ||
.its('status') | ||
.should('eql', 200); | ||
} | ||
}; | ||
|
||
const deleteUsersAndRoles = (users: User[], roles: Role[]) => { | ||
const envUser = getEnvAuth(); | ||
for (const user of users) { | ||
cy.log(`Deleting user: ${JSON.stringify(user)}`); | ||
cy.request({ | ||
headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, | ||
method: 'DELETE', | ||
url: constructUrlWithUser(envUser, `/internal/security/users/${user.username}`), | ||
failOnStatusCode: false, | ||
}) | ||
.its('status') | ||
.should('oneOf', [204, 404]); | ||
} | ||
|
||
for (const role of roles) { | ||
cy.log(`Deleting role: ${JSON.stringify(role)}`); | ||
cy.request({ | ||
headers: { 'kbn-xsrf': 'cypress-creds-via-config' }, | ||
method: 'DELETE', | ||
url: constructUrlWithUser(envUser, `/api/security/role/${role.name}`), | ||
failOnStatusCode: false, | ||
}) | ||
.its('status') | ||
.should('oneOf', [204, 404]); | ||
} | ||
// needed to generate index pattern | ||
const visitSecuritySolution = () => { | ||
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. Worth moving into a util? If you end up moving it to a util, should probably rename it to something like |
||
loginAndWaitForHostDetailsPage(); | ||
logout(); | ||
}; | ||
|
||
const testCase: TestCaseWithoutTimeline = { | ||
|
@@ -203,11 +47,11 @@ const testCase: TestCaseWithoutTimeline = { | |
reporter: 'elastic', | ||
owner: 'securitySolution', | ||
}; | ||
|
||
describe('Cases privileges', () => { | ||
before(() => { | ||
cleanKibana(); | ||
createUsersAndRoles(usersToCreate, rolesToCreate); | ||
visitSecuritySolution(); | ||
}); | ||
|
||
after(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { loginAndWaitForPage } from '../../tasks/login'; | ||
import { | ||
loginAndWaitForPage, | ||
loginWithUserAndWaitForPageWithoutDateRange, | ||
} from '../../tasks/login'; | ||
|
||
import { HOSTS_URL } from '../../urls/navigation'; | ||
import { waitForAllHostsToBeLoaded } from '../../tasks/hosts/all_hosts'; | ||
|
@@ -28,20 +31,33 @@ import { openTimelineUsingToggle } from '../../tasks/security_main'; | |
import { populateTimeline } from '../../tasks/timeline'; | ||
import { SERVER_SIDE_EVENT_COUNT } from '../../screens/timeline'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { createUsersAndRoles, secReadCasesAll, secReadCasesAllUser } from '../../tasks/privileges'; | ||
import { TOASTER } from '../../screens/configure_cases'; | ||
|
||
const usersToCreate = [secReadCasesAllUser]; | ||
const rolesToCreate = [secReadCasesAll]; | ||
// Skipped at the moment as this has flake due to click handler issues. This has been raised with team members | ||
// and the code is being re-worked and then these tests will be unskipped | ||
describe.skip('Sourcerer', () => { | ||
before(() => { | ||
describe('Sourcerer', () => { | ||
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. Thanks for cleaning this up! |
||
beforeEach(() => { | ||
cleanKibana(); | ||
}); | ||
|
||
beforeEach(() => { | ||
cy.clearLocalStorage(); | ||
loginAndWaitForPage(HOSTS_URL); | ||
describe('permissions', () => { | ||
before(() => { | ||
createUsersAndRoles(usersToCreate, rolesToCreate); | ||
}); | ||
it(`role(s) ${secReadCasesAllUser.roles.join()} shows error when user does not have permissions`, () => { | ||
loginWithUserAndWaitForPageWithoutDateRange(HOSTS_URL, secReadCasesAllUser); | ||
cy.get(TOASTER).should('have.text', 'Write role required to generate data'); | ||
}); | ||
}); | ||
|
||
describe('Default scope', () => { | ||
describe.skip('Default scope', () => { | ||
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. these were already skipped if thats confusing |
||
beforeEach(() => { | ||
cy.clearLocalStorage(); | ||
loginAndWaitForPage(HOSTS_URL); | ||
}); | ||
|
||
it('has SIEM index patterns selected on initial load', () => { | ||
openSourcerer(); | ||
isSourcererSelection(`auditbeat-*`); | ||
|
@@ -76,7 +92,12 @@ describe.skip('Sourcerer', () => { | |
}); | ||
}); | ||
|
||
describe('Timeline scope', () => { | ||
describe.skip('Timeline scope', () => { | ||
beforeEach(() => { | ||
cy.clearLocalStorage(); | ||
loginAndWaitForPage(HOSTS_URL); | ||
}); | ||
|
||
const alertPatterns = ['.siem-signals-default']; | ||
const rawPatterns = ['auditbeat-*']; | ||
const allPatterns = [...alertPatterns, ...rawPatterns]; | ||
|
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.
Just curious, is there some standard pattern for these across Kibana? I.e. camel-case, snake-case, etc.. ?
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.
no, the id is generated and looks like
a855f700-f5f9-11eb-8763-01917c58cbf9
so i followed that. i think-
is standard for URL which is where these are stored