Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ export const RISK_ENGINE_CLEANUP_URL = `${PUBLIC_RISK_ENGINE_URL}/dangerously_de
export const RISK_ENGINE_CONFIGURE_SO_URL =
`${PUBLIC_RISK_ENGINE_URL}/saved_object/configure` as const;

type ClusterPrivilege = 'manage_index_templates' | 'manage_transform';
type ClusterPrivilege = 'manage_index_templates' | 'manage_transform' | 'manage_ingest_pipelines';
// These are the required privileges to install the risk engine - enabling and running require less privileges
// However, we check the full set for simplicity, since the UI does not distinguish between installing and enabling
export const RISK_ENGINE_REQUIRED_ES_CLUSTER_PRIVILEGES = [
'manage_index_templates',
'manage_transform',
] as ClusterPrivilege[];
'manage_ingest_pipelines',
] satisfies ClusterPrivilege[];

export const RISK_SCORE_INDEX_PATTERN = 'risk-score.risk-score-*';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('getMissingRiskEnginePrivileges', () => {
cluster: {
manage_index_templates: false,
manage_transform: false,
manage_ingest_pipelines: false,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -28,7 +29,7 @@ describe('getMissingRiskEnginePrivileges', () => {
const missingPrivileges = getMissingRiskEnginePrivileges(noClusterPrivileges);

expect(missingPrivileges).toEqual({
clusterPrivileges: ['manage_index_templates', 'manage_transform'],
clusterPrivileges: ['manage_index_templates', 'manage_transform', 'manage_ingest_pipelines'],
indexPrivileges: [],
});
});
Expand All @@ -39,6 +40,7 @@ describe('getMissingRiskEnginePrivileges', () => {
cluster: {
manage_index_templates: true,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('_getMissingPrivilegesMessage', () => {
cluster: {
manage_index_templates: false,
manage_transform: false,
manage_ingest_pipelines: false,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -31,7 +32,7 @@ describe('_getMissingPrivilegesMessage', () => {
const result = _getMissingPrivilegesMessage(noClusterPrivileges);

expect(result).toMatchInlineSnapshot(
`"User is missing risk engine privileges. Missing cluster privileges: manage_index_templates, manage_transform."`
`"User is missing risk engine privileges. Missing cluster privileges: manage_index_templates, manage_transform, manage_ingest_pipelines."`
);
});

Expand All @@ -42,6 +43,7 @@ describe('_getMissingPrivilegesMessage', () => {
cluster: {
manage_index_templates: true,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -68,6 +70,7 @@ describe('_getMissingPrivilegesMessage', () => {
cluster: {
manage_index_templates: false,
manage_transform: false,
manage_ingest_pipelines: false,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -83,7 +86,7 @@ describe('_getMissingPrivilegesMessage', () => {
const result = _getMissingPrivilegesMessage(noClusterOrIndexPrivileges);

expect(result).toMatchInlineSnapshot(
`"User is missing risk engine privileges. Missing index privileges for index \\"risk-score.risk-score-*\\": read, write. Missing cluster privileges: manage_index_templates, manage_transform."`
`"User is missing risk engine privileges. Missing index privileges for index \\"risk-score.risk-score-*\\": read, write. Missing cluster privileges: manage_index_templates, manage_transform, manage_ingest_pipelines."`
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ describe('risk engine cleanup route', () => {
expect(response.status).toBe(403);
expect(response.body).toEqual({
message:
'User is missing risk engine privileges. Missing cluster privileges: manage_index_templates, manage_transform.',
'User is missing risk engine privileges. Missing cluster privileges: manage_index_templates, manage_transform, manage_ingest_pipelines.',
status_code: 403,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ const ROLES = [
},
},
},
{
name: 'manage_ingest_pipelines',
privileges: {
elasticsearch: {
cluster: ['manage_ingest_pipelines'],
},
},
},
{
name: 'risk_score_index_read',
privileges: {
Expand Down Expand Up @@ -113,6 +121,7 @@ export default ({ getService }: FtrProviderContext) => {
cluster: {
manage_index_templates: true,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -132,6 +141,7 @@ export default ({ getService }: FtrProviderContext) => {
cluster: {
manage_index_templates: true,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -151,6 +161,7 @@ export default ({ getService }: FtrProviderContext) => {
cluster: {
manage_index_templates: true,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -170,6 +181,7 @@ export default ({ getService }: FtrProviderContext) => {
cluster: {
manage_index_templates: true,
manage_transform: false,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand All @@ -189,6 +201,7 @@ export default ({ getService }: FtrProviderContext) => {
cluster: {
manage_index_templates: false,
manage_transform: true,
manage_ingest_pipelines: true,
},
index: {
'risk-score.risk-score-*': {
Expand Down