Skip to content

Commit

Permalink
Registers the required kibana privileges in the connector adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Apr 10, 2024
1 parent 9d3b79e commit a7ddc63
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions x-pack/plugins/cases/server/connectors/cases/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,22 @@ describe('getCasesConnectorType', () => {
expect(connectorParams.subActionParams.owner).toBe('cases');
});
});

describe('getKibanaPrivileges', () => {
it('constructs the correct privileges from the consumer', () => {
const adapter = getCasesConnectorAdapter();

expect(adapter.getKibanaPrivileges?.({ consumer: AlertConsumers.SIEM })).toEqual([
'cases:securitySolution/createCase',
'cases:securitySolution/updateCase',
'cases:securitySolution/deleteCase',
'cases:securitySolution/pushCase',
'cases:securitySolution/createComment',
'cases:securitySolution/updateComment',
'cases:securitySolution/deleteComment',
'cases:securitySolution/findConfigurations',
]);
});
});
});
});
4 changes: 4 additions & 0 deletions x-pack/plugins/cases/server/connectors/cases/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ export const getCasesConnectorAdapter = (): ConnectorAdapter<

return { subAction: 'run', subActionParams };
},
getKibanaPrivileges: ({ consumer }) => {
const owner = getOwnerFromRuleConsumer(consumer);
return constructRequiredKibanaPrivileges(owner);
},
};
};

Expand Down

0 comments on commit a7ddc63

Please sign in to comment.