-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution][Rules] - Remove rule selection for read only users (
#126827) (#127097) Resolves #126328 and #126314. (cherry picked from commit 18a5344) Co-authored-by: Yara Tercero <yctercero@users.noreply.github.com>
- Loading branch information
1 parent
eb178a8
commit c2d8771
Showing
13 changed files
with
175 additions
and
62 deletions.
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
60 changes: 60 additions & 0 deletions
60
...plugins/security_solution/cypress/integration/detection_rules/all_rules_read_only.spec.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,60 @@ | ||
/* | ||
* 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 { ROLES } from '../../../common/test'; | ||
import { getNewRule } from '../../objects/rule'; | ||
import { | ||
COLLAPSED_ACTION_BTN, | ||
RULE_CHECKBOX, | ||
RULE_NAME, | ||
} from '../../screens/alerts_detection_rules'; | ||
import { PAGE_TITLE } from '../../screens/common/page'; | ||
import { waitForRulesTableToBeLoaded } from '../../tasks/alerts_detection_rules'; | ||
import { createCustomRule } from '../../tasks/api_calls/rules'; | ||
import { cleanKibana } from '../../tasks/common'; | ||
import { dismissCallOut, getCallOut, waitForCallOutToBeShown } from '../../tasks/common/callouts'; | ||
import { loginAndWaitForPageWithoutDateRange } from '../../tasks/login'; | ||
import { SECURITY_DETECTIONS_RULES_URL } from '../../urls/navigation'; | ||
|
||
const MISSING_PRIVILEGES_CALLOUT = 'missing-user-privileges'; | ||
|
||
describe('All rules - read only', () => { | ||
before(() => { | ||
cleanKibana(); | ||
createCustomRule(getNewRule(), '1'); | ||
loginAndWaitForPageWithoutDateRange(SECURITY_DETECTIONS_RULES_URL, ROLES.reader); | ||
waitForRulesTableToBeLoaded(); | ||
cy.get(RULE_NAME).should('have.text', getNewRule().name); | ||
}); | ||
|
||
it('Does not display select boxes for rules', () => { | ||
cy.get(RULE_CHECKBOX).should('not.exist'); | ||
}); | ||
|
||
it('Does not display action options', () => { | ||
// These are the 3 dots at the end of the row that opens up | ||
// options to take action on the rule | ||
cy.get(COLLAPSED_ACTION_BTN).should('not.exist'); | ||
}); | ||
|
||
it('Displays missing privileges primary callout', () => { | ||
waitForCallOutToBeShown(MISSING_PRIVILEGES_CALLOUT, 'primary'); | ||
}); | ||
|
||
context('When a user clicks Dismiss on the callouts', () => { | ||
it('We hide them and persist the dismissal', () => { | ||
waitForCallOutToBeShown(MISSING_PRIVILEGES_CALLOUT, 'primary'); | ||
|
||
dismissCallOut(MISSING_PRIVILEGES_CALLOUT); | ||
cy.reload(); | ||
cy.get(PAGE_TITLE).should('be.visible'); | ||
cy.get(RULE_NAME).should('have.text', getNewRule().name); | ||
|
||
getCallOut(MISSING_PRIVILEGES_CALLOUT).should('not.exist'); | ||
}); | ||
}); | ||
}); |
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
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/security_solution/public/exceptions/translations.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 { i18n } from '@kbn/i18n'; | ||
|
||
export const READ_ONLY_BADGE_TOOLTIP = i18n.translate( | ||
'xpack.securitySolution.exceptions.badge.readOnly.tooltip', | ||
{ | ||
defaultMessage: 'Unable to create, edit or delete exceptions', | ||
} | ||
); |
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
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/security_solution/public/rules/translations.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 { i18n } from '@kbn/i18n'; | ||
|
||
export const READ_ONLY_BADGE_TOOLTIP = i18n.translate( | ||
'xpack.securitySolution.rules.badge.readOnly.tooltip', | ||
{ | ||
defaultMessage: 'Unable to create, edit or delete rules', | ||
} | ||
); |
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,12 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const READ_ONLY_BADGE_TEXT = i18n.translate('xpack.securitySolution.badge.readOnly.text', { | ||
defaultMessage: 'Read only', | ||
}); |
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/security_solution/public/use_readonly_header.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,37 @@ | ||
/* | ||
* 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 { useEffect } from 'react'; | ||
|
||
import * as i18n from './translations'; | ||
import { useKibana } from './common/lib/kibana'; | ||
import { useAlertsPrivileges } from './detections/containers/detection_engine/alerts/use_alerts_privileges'; | ||
|
||
/** | ||
* This component places a read-only icon badge in the header | ||
* if user only has read *Kibana* privileges, not individual data index | ||
* privileges | ||
*/ | ||
export function useReadonlyHeader(tooltip: string) { | ||
const { hasKibanaREAD, hasKibanaCRUD } = useAlertsPrivileges(); | ||
const chrome = useKibana().services.chrome; | ||
|
||
useEffect(() => { | ||
if (hasKibanaREAD && !hasKibanaCRUD) { | ||
chrome.setBadge({ | ||
text: i18n.READ_ONLY_BADGE_TEXT, | ||
tooltip, | ||
iconType: 'glasses', | ||
}); | ||
} | ||
|
||
// remove the icon after the component unmounts | ||
return () => { | ||
chrome.setBadge(); | ||
}; | ||
}, [chrome, hasKibanaREAD, hasKibanaCRUD, tooltip]); | ||
} |
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