mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Security Solution][Endpoint] Fix create of endpoint artifacts to ensure global items require the global artifact management privilege (#225157)
## Summary - Fix the create of Event Filters, Blocklists, Endpoint Exceptions and Host Isolation Exceptions so that an error is returned when space awareness feature is enabled and the user does not have the Global Artifact Management privilege. > [!NOTE] > Trusted Applications were already correctly validating this during create of an artifact ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
3b0c225c38
commit
c28fd76508
6 changed files with 48 additions and 1 deletions
|
@ -242,6 +242,7 @@ export class BlocklistValidator extends BaseValidator {
|
|||
await this.validateBlocklistData(item);
|
||||
await this.validateCanCreateByPolicyArtifacts(item);
|
||||
await this.validateByPolicyItem(item);
|
||||
await this.validateCanCreateGlobalArtifacts(item);
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
|
||||
return item;
|
||||
|
|
|
@ -43,6 +43,7 @@ export class EndpointExceptionsValidator extends BaseValidator {
|
|||
|
||||
async validatePreCreateItem(item: CreateExceptionListItemOptions) {
|
||||
await this.validateHasWritePrivilege();
|
||||
await this.validateCanCreateGlobalArtifacts(item);
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
|
||||
return item;
|
||||
|
@ -54,6 +55,7 @@ export class EndpointExceptionsValidator extends BaseValidator {
|
|||
) {
|
||||
await this.validateHasWritePrivilege();
|
||||
await this.validateUpdateOwnerSpaceIds(item, currentItem);
|
||||
await this.validateCanUpdateItemInActiveSpace(item, currentItem);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ export class EventFilterValidator extends BaseValidator {
|
|||
}
|
||||
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
await this.validateCanCreateGlobalArtifacts(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ export class HostIsolationExceptionsValidator extends BaseValidator {
|
|||
await this.validateHasWritePrivilege();
|
||||
await this.validateHostIsolationData(item);
|
||||
await this.validateByPolicyItem(item);
|
||||
await this.validateCanCreateGlobalArtifacts(item);
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
|
||||
return item;
|
||||
|
|
|
@ -227,8 +227,8 @@ export class TrustedAppValidator extends BaseValidator {
|
|||
await this.validateTrustedAppData(item);
|
||||
await this.validateCanCreateByPolicyArtifacts(item);
|
||||
await this.validateByPolicyItem(item);
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
await this.validateCanCreateGlobalArtifacts(item);
|
||||
await this.validateCreateOwnerSpaceIds(item);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -346,6 +346,25 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
describe('and user does NOT have global artifact management privilege', () => {
|
||||
it('should error if attempting to create a global artifact', async () => {
|
||||
const { body } = await supertestArtifactManager
|
||||
.post(addSpaceIdToPath('/', spaceOneId, EXCEPTION_LIST_ITEM_URL))
|
||||
.set('elastic-api-version', '2023-10-31')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.set('kbn-xsrf', 'true')
|
||||
.on('error', createSupertestErrorLogger(log).ignoreCodes([403]))
|
||||
.send(
|
||||
Object.assign(exceptionItemToCreateExceptionItem(spaceOneGlobalArtifact.artifact), {
|
||||
item_id: undefined,
|
||||
})
|
||||
)
|
||||
.expect(403);
|
||||
|
||||
expect(body.message).to.eql(
|
||||
`EndpointArtifactError: Endpoint authorization failure. Management of global artifacts requires additional privilege (global artifact management)`
|
||||
);
|
||||
});
|
||||
|
||||
it('should error when attempting to create artifact with additional owner space id tags', async () => {
|
||||
await supertestArtifactManager
|
||||
.post(addSpaceIdToPath('/', spaceOneId, EXCEPTION_LIST_ITEM_URL))
|
||||
|
@ -472,6 +491,29 @@ export default function ({ getService }: FtrProviderContext) {
|
|||
});
|
||||
|
||||
describe('and user has privilege to manage global artifacts', () => {
|
||||
it('should allow creating global artifact', async () => {
|
||||
const { body } = await supertestGlobalArtifactManager
|
||||
.post(addSpaceIdToPath('/', spaceOneId, EXCEPTION_LIST_ITEM_URL))
|
||||
.set('elastic-api-version', '2023-10-31')
|
||||
.set('x-elastic-internal-origin', 'kibana')
|
||||
.set('kbn-xsrf', 'true')
|
||||
.on('error', createSupertestErrorLogger(log))
|
||||
.send(
|
||||
Object.assign(exceptionItemToCreateExceptionItem(spaceOneGlobalArtifact.artifact), {
|
||||
item_id: undefined,
|
||||
})
|
||||
)
|
||||
.expect(200);
|
||||
|
||||
const itemCreated = body as ExceptionListItemSchema;
|
||||
|
||||
afterEachDataCleanup.push({
|
||||
cleanup: () => {
|
||||
return endpointArtifactTestResources.deleteExceptionItem(itemCreated);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should allow creating artifact with additional owner space id tags', async () => {
|
||||
const { body } = await supertestGlobalArtifactManager
|
||||
.post(addSpaceIdToPath('/', spaceOneId, EXCEPTION_LIST_ITEM_URL))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue