-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Security Solution][Rules] - Remove rule selection for read only users #126827
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c1b1556
Update rules management table to hide rule selection for read only
yctercero 2d9b73a
Adds read only glasses icon to alerts, rules, exceptions pages
yctercero 290bd72
update to use existing privileges values
yctercero 846f7c1
remove unused translations
yctercero fa7ddfd
Merge branch 'main' into 126314
kibanamachine 4e3b91d
Merge branch 'main' of github.com:elastic/kibana into 126314
yctercero 360cf66
update hook being used to update privileges, one performs better than…
yctercero 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
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
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.
Do we need to do anything about these translations? It looks like only the path has changed from
xpack.securitySolution.alerts.badge.readOnly.text
toxpack.securitySolution.badge.readOnly.text
, but I don't know if that means the translation might still need to be updated.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.
I beliiieve that if the path changes it is treated as a new translation needed. I'll double check there.