-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Cloud Security] Adding Auth check on API #186937
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9d79d9f
phase 1
animehart 3ced682
new FTR for testing tags auth
animehart 50c050a
update
animehart 4c035d6
improvements
animehart 076929d
fix
animehart ca24ec1
skipping read benchmark test due to tech debt
animehart 9d0948a
fix conflict
animehart 0169baf
improvements
animehart 71df02f
change name
animehart 0768782
quick checks fix
animehart 079b182
Merge branch 'main' into tags-authz-api
animehart 31fcd6f
pr comments
animehart c5f934f
Merge branch 'tags-authz-api' of github.com:animehart/kibana into tag…
animehart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
70 changes: 70 additions & 0 deletions
70
.../test/cloud_security_posture_api/routes/get_detection_engine_alerts_count_by_rule_tags.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,70 @@ | ||
/* | ||
* 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 { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common'; | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../ftr_provider_context'; | ||
import { CspSecurityCommonProvider } from './helper/user_roles_utilites'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function (providerContext: FtrProviderContext) { | ||
const { getService } = providerContext; | ||
|
||
const retry = getService('retry'); | ||
const supertest = getService('supertest'); | ||
const log = getService('log'); | ||
const supertestWithoutAuth = getService('supertestWithoutAuth'); | ||
const cspSecurity = CspSecurityCommonProvider(providerContext); | ||
|
||
/** | ||
* required before indexing findings | ||
*/ | ||
const waitForPluginInitialized = (): Promise<void> => | ||
retry.try(async () => { | ||
log.debug('Check CSP plugin is initialized'); | ||
const response = await supertest | ||
.get('/internal/cloud_security_posture/status?check=init') | ||
.set(ELASTIC_HTTP_VERSION_HEADER, '1') | ||
.expect(200); | ||
expect(response.body).to.eql({ isPluginInitialized: true }); | ||
log.debug('CSP plugin is initialized'); | ||
}); | ||
|
||
describe('/internal/cloud_security_posture/detection_engine_rules/alerts/_status', () => { | ||
describe('GET detection_engine_rules API with user that has specific access', async () => { | ||
before(async () => { | ||
await waitForPluginInitialized(); | ||
}); | ||
it('GET detection_engine_rules API with user with read access', async () => { | ||
const { status } = await supertestWithoutAuth | ||
.get( | ||
'/internal/cloud_security_posture/detection_engine_rules/alerts/_status?tags=["CIS"]' | ||
) | ||
.set(ELASTIC_HTTP_VERSION_HEADER, '1') | ||
.set('kbn-xsrf', 'xxxx') | ||
.auth( | ||
'role_security_read_user_alerts', | ||
cspSecurity.getPasswordForUser('role_security_read_user_alerts') | ||
); | ||
expect(status).to.be(200); | ||
}); | ||
|
||
it('GET detection_engine_rules API with user without read access', async () => { | ||
const { status } = await supertestWithoutAuth | ||
.get( | ||
'/internal/cloud_security_posture/detection_engine_rules/alerts/_status?tags=["CIS"]' | ||
) | ||
.set(ELASTIC_HTTP_VERSION_HEADER, '1') | ||
.set('kbn-xsrf', 'xxxx') | ||
.auth( | ||
'role_security_no_read_user_alerts', | ||
cspSecurity.getPasswordForUser('role_security_no_read_user_alerts') | ||
); | ||
expect(status).to.be(403); | ||
}); | ||
}); | ||
}); | ||
} |
15 changes: 15 additions & 0 deletions
15
x-pack/test/cloud_security_posture_api/routes/helper/index.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,15 @@ | ||
/* | ||
* 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 { CspSecurityCommonProvider } from './user_roles_utilites'; | ||
|
||
export const cloudSecurityPosturePageObjects = { | ||
cspSecurity: CspSecurityCommonProvider, | ||
}; | ||
export const pageObjects = { | ||
...cloudSecurityPosturePageObjects, | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
good catch