Skip to content
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][Endpoint] Adds new integration tests for Endpoint Artifacts API RBAC #143273

Conversation

dasansol92
Copy link
Contributor

@dasansol92 dasansol92 commented Oct 13, 2022

Summary

  • Add new test cases checking RBAC privileges for all artifacts integration tests

For maintainers

@dasansol92 dasansol92 changed the title [Security Solution][Endpoint] Adds new integration tests for Trusted Apps API RBAC [Security Solution][Endpoint] Adds new integration tests for Endpoint Artifacts API RBAC Dec 21, 2022
@dasansol92 dasansol92 marked this pull request as ready for review December 21, 2022 14:12
@dasansol92 dasansol92 requested review from a team as code owners December 21, 2022 14:12
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-onboarding-and-lifecycle-mgt (Team:Onboarding and Lifecycle Mgt)

@dasansol92
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@paul-tavares paul-tavares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you.

I did notice something that did not appear right to me - some tests are checking for a expect(400) error. 400 errors are normally due to user input, and I would not have expected any of these tests to return a 400. Do you know why that is?

@dasansol92
Copy link
Contributor Author

I did notice something that did not appear right to me - some tests are checking for a expect(400) error. 400 errors are normally due to user input, and I would not have expected any of these tests to return a 400. Do you know why that is?

@paul-tavares Yes, I think all expect(400) are related to user input:

  • no values
  • invalid OS for signer field
  • more than one OS
  • invalid hash
  • etc.

Does that makes sense to you?

@paul-tavares
Copy link
Contributor

@dasansol92 ,

Ok... Cool. thanks for that and yes, that makes sense. Did not realize we were doing schema type of validation from FTR.

👍

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Security Solution Tests #2 / Import rules Imports a custom rule with exceptions

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 61 67 +6
osquery 109 115 +6
securitySolution 439 445 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 70 76 +6
osquery 110 117 +7
securitySolution 515 521 +6
total +21

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@ashokaditya ashokaditya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the detailed tests 🔥 I have a minor suggestion but this is good to 🚢

'item_id' | 'namespace_type' | 'os_types' | 'tags' | 'entries'
>;
type HostIsolationExceptionApiCallsInterface<BodyGetter = UnknownBodyGetter> = Array<{
method: keyof Pick<typeof supertest, 'post' | 'put' | 'get' | 'delete' | 'patch'>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have to change but you could use RouteMethod here instead that is imported as

import type { RouteMethod } from '@kbn/core-http-server';

describe('and has authorization to manage endpoint security', () => {
for (const blocklistApiCall of blocklistApiCalls) {
it(`should error on [${blocklistApiCall.method}] if invalid condition entry fields are used`, async () => {
const body = blocklistApiCall.getBody();

body.entries[0].field = 'some.invalid.field';
await supertest[blocklistApiCall.method](blocklistApiCall.path)
await supertestWithoutAuth[blocklistApiCall.method](blocklistApiCall.path)
.auth(ROLE.analyst_hunter, 'changeme')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider updating this role to have a username and the default password so you don't have to duplicate the default password in every test. So it can be used as:

.auth(ROLE.analyst_hunter.username, ROLE.analyst_hunter.password)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, we can work on this on a subsequent pr! Thanks for the suggestion!

Copy link
Member

@ashokaditya ashokaditya Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fleet side does something similar as I learned recently.

@dasansol92 dasansol92 merged commit 8d7f570 into elastic:main Dec 22, 2022
simianhacker pushed a commit to simianhacker/kibana that referenced this pull request Dec 22, 2022
… Artifacts API RBAC (elastic#143273)

## Summary

- Add new test cases checking RBAC privileges for all artifacts
integration tests

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Kibana Machine <[email protected]>
pgayvallet pushed a commit to pgayvallet/kibana that referenced this pull request Dec 22, 2022
… Artifacts API RBAC (elastic#143273)

## Summary

- Add new test cases checking RBAC privileges for all artifacts
integration tests

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Kibana Machine <[email protected]>
crespocarlos pushed a commit to crespocarlos/kibana that referenced this pull request Dec 23, 2022
… Artifacts API RBAC (elastic#143273)

## Summary

- Add new test cases checking RBAC privileges for all artifacts
integration tests

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants