-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SecuritySolution][Detections] Fix "Closing a signal silently fails with reduced privileges" #86908
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9c14fdf
Add a new hasIndexUpdateDelete flag
banderror e19a29a
Update read-only alerts callout component to use the flag
banderror 05a789e
Update alert context menu component to use the flag
banderror d2afcac
Add links to docs to our read-only callouts
banderror e1e8f70
Make links to docs localizable and move to common
banderror 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
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/security_solution/public/common/components/links_to_docs/doc_link.tsx
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,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FC, memo } from 'react'; | ||
import { useKibana } from '../../lib/kibana'; | ||
import { ExternalLink } from './external_link'; | ||
import { COMMON_ARIA_LABEL_ENDING } from './links_translations'; | ||
|
||
interface DocLinkProps { | ||
guidePath?: string; | ||
docPath: string; | ||
linkText: string; | ||
} | ||
|
||
const DocLink: FC<DocLinkProps> = ({ guidePath = 'security', docPath, linkText }) => { | ||
const { services } = useKibana(); | ||
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = services.docLinks; | ||
|
||
const url = `${ELASTIC_WEBSITE_URL}guide/en/${guidePath}/${DOC_LINK_VERSION}/${docPath}`; | ||
const ariaLabel = `${linkText} - ${COMMON_ARIA_LABEL_ENDING}`; | ||
|
||
return <ExternalLink url={url} text={linkText} ariaLabel={ariaLabel} />; | ||
}; | ||
|
||
/** | ||
* A simple text link to documentation. | ||
*/ | ||
const DocLinkWrapper = memo(DocLink); | ||
|
||
export { DocLinkWrapper as DocLink }; |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/security_solution/public/common/components/links_to_docs/external_link.tsx
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,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React, { FC } from 'react'; | ||
import { EuiLink } from '@elastic/eui'; | ||
|
||
interface ExternalLinkProps { | ||
url: string; | ||
text: string; | ||
ariaLabel?: string; | ||
} | ||
|
||
/** | ||
* A simplistic text link for opening external urls in a new browser tab. | ||
*/ | ||
export const ExternalLink: FC<ExternalLinkProps> = ({ url, text, ariaLabel }) => { | ||
return ( | ||
<EuiLink href={url} aria-label={ariaLabel} external target="_blank" rel="noopener"> | ||
{text} | ||
</EuiLink> | ||
); | ||
}; | ||
7 changes: 7 additions & 0 deletions
7
x-pack/plugins/security_solution/public/common/components/links_to_docs/index.tsx
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,7 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
export * from './links_components'; |
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/security_solution/public/common/components/links_to_docs/links_components.tsx
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,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { DocLink } from './doc_link'; | ||
import * as i18n from './links_translations'; | ||
|
||
export const SecuritySolutionRequirementsLink = () => ( | ||
<DocLink | ||
docPath={i18n.SOLUTION_REQUIREMENTS_LINK_PATH} | ||
linkText={i18n.SOLUTION_REQUIREMENTS_LINK_TEXT} | ||
/> | ||
); | ||
|
||
export const DetectionsRequirementsLink = () => ( | ||
<DocLink | ||
docPath={i18n.DETECTIONS_REQUIREMENTS_LINK_PATH} | ||
linkText={i18n.DETECTIONS_REQUIREMENTS_LINK_TEXT} | ||
/> | ||
); |
34 changes: 34 additions & 0 deletions
34
...ck/plugins/security_solution/public/common/components/links_to_docs/links_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,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
/** | ||
* If a link's text is "Docs", its aria-label will be set to | ||
* "Docs - ${COMMON_ARIA_LABEL_ENDING}". | ||
*/ | ||
export const COMMON_ARIA_LABEL_ENDING = i18n.translate( | ||
'xpack.securitySolution.documentationLinks.ariaLabelEnding', | ||
{ | ||
defaultMessage: 'click to open documentation in a new tab', | ||
} | ||
); | ||
|
||
export const SOLUTION_REQUIREMENTS_LINK_PATH = 'sec-requirements.html'; | ||
export const SOLUTION_REQUIREMENTS_LINK_TEXT = i18n.translate( | ||
'xpack.securitySolution.documentationLinks.solutionRequirements.text', | ||
{ | ||
defaultMessage: 'Elastic Security system requirements', | ||
} | ||
); | ||
|
||
export const DETECTIONS_REQUIREMENTS_LINK_PATH = 'detections-permissions-section.html'; | ||
export const DETECTIONS_REQUIREMENTS_LINK_TEXT = i18n.translate( | ||
'xpack.securitySolution.documentationLinks.detectionsRequirements.text', | ||
{ | ||
defaultMessage: 'Detections prerequisites and requirements', | ||
} | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,16 +14,16 @@ const readOnlyAccessToAlertsMessage: CallOutMessage = { | |
type: 'primary', | ||
id: 'read-only-access-to-alerts', | ||
title: i18n.READ_ONLY_ALERTS_CALLOUT_TITLE, | ||
description: <p>{i18n.READ_ONLY_ALERTS_CALLOUT_MSG}</p>, | ||
description: i18n.readOnlyAlertsCallOutBody(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice - I'm guilty of not following the docs and not using all caps when it's a function. |
||
}; | ||
|
||
const ReadOnlyAlertsCallOutComponent = () => { | ||
const [{ hasIndexWrite }] = useUserData(); | ||
const [{ hasIndexUpdateDelete }] = useUserData(); | ||
|
||
return ( | ||
<CallOutSwitcher | ||
namespace="detections" | ||
condition={hasIndexWrite != null && !hasIndexWrite} | ||
condition={hasIndexUpdateDelete != null && !hasIndexUpdateDelete} | ||
yctercero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
message={readOnlyAccessToAlertsMessage} | ||
/> | ||
); | ||
|
22 changes: 0 additions & 22 deletions
22
...y_solution/public/detections/components/callouts/read_only_alerts_callout/translations.ts
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
..._solution/public/detections/components/callouts/read_only_alerts_callout/translations.tsx
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,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
SecuritySolutionRequirementsLink, | ||
DetectionsRequirementsLink, | ||
} from '../../../../common/components/links_to_docs'; | ||
|
||
export const READ_ONLY_ALERTS_CALLOUT_TITLE = i18n.translate( | ||
'xpack.securitySolution.detectionEngine.readOnlyAlertsCallOut.messageTitle', | ||
{ | ||
defaultMessage: 'You cannot change alert states', | ||
} | ||
); | ||
|
||
export const readOnlyAlertsCallOutBody = () => ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.detectionEngine.readOnlyAlertsCallOut.messageBody.messageDetail" | ||
defaultMessage="{essence} Related documentation: {docs}" | ||
values={{ | ||
essence: ( | ||
<p> | ||
<FormattedMessage | ||
id="xpack.securitySolution.detectionEngine.readOnlyAlertsCallOut.messageBody.essenceDescription" | ||
defaultMessage="You only have permissions to view alerts. If you need to update alert states (open or close alerts), contact your Kibana administrator." | ||
/> | ||
</p> | ||
), | ||
docs: ( | ||
<ul> | ||
<li> | ||
<DetectionsRequirementsLink /> | ||
</li> | ||
<li> | ||
<SecuritySolutionRequirementsLink /> | ||
</li> | ||
</ul> | ||
), | ||
}} | ||
/> | ||
); |
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
22 changes: 0 additions & 22 deletions
22
...ty_solution/public/detections/components/callouts/read_only_rules_callout/translations.ts
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
...y_solution/public/detections/components/callouts/read_only_rules_callout/translations.tsx
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,47 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
SecuritySolutionRequirementsLink, | ||
DetectionsRequirementsLink, | ||
} from '../../../../common/components/links_to_docs'; | ||
|
||
export const READ_ONLY_RULES_CALLOUT_TITLE = i18n.translate( | ||
'xpack.securitySolution.detectionEngine.readOnlyRulesCallOut.messageTitle', | ||
{ | ||
defaultMessage: 'Rule permissions required', | ||
} | ||
); | ||
|
||
export const readOnlyRulesCallOutBody = () => ( | ||
<FormattedMessage | ||
id="xpack.securitySolution.detectionEngine.readOnlyRulesCallOut.messageBody.messageDetail" | ||
defaultMessage="{essence} Related documentation: {docs}" | ||
values={{ | ||
essence: ( | ||
<p> | ||
<FormattedMessage | ||
id="xpack.securitySolution.detectionEngine.readOnlyRulesCallOut.messageBody.essenceDescription" | ||
defaultMessage="You are currently missing the required permissions to create/edit detection engine rule. Please contact your administrator for further assistance." | ||
/> | ||
</p> | ||
), | ||
docs: ( | ||
<ul> | ||
<li> | ||
<DetectionsRequirementsLink /> | ||
</li> | ||
<li> | ||
<SecuritySolutionRequirementsLink /> | ||
</li> | ||
</ul> | ||
), | ||
}} | ||
/> | ||
); |
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
Oops, something went wrong.
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.
I think that there's already an
ExternalLink
component found here -x-pack/plugins/security_solution/public/common/components/links/index.tsx
- we may want to make use of that one, or move this one into that file?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.
Thank you, this file seemed too busy for me and containing specific implementations like
HostDetailsLinkComponent
, so I overlookedExternalLink
there.I'll check how it works and looks with the
ExternalLink
component fromx-pack/plugins/security_solution/public/common/components/links/index.tsx
and try to submit some quick improvement if possible.