Skip to content
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][Case][Bug] Prevent closing collection when pushing #93095

Merged
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
28 changes: 24 additions & 4 deletions x-pack/plugins/case/server/client/cases/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
SavedObjectsClientContract,
SavedObjectsUpdateResponse,
Logger,
SavedObjectsFindResponse,
SavedObject,
} from 'kibana/server';
import { ActionResult, ActionsClient } from '../../../../actions/server';
import { flattenCaseSavedObject, getAlertIndicesAndIDs } from '../../routes/api/utils';
Expand All @@ -25,6 +27,8 @@ import {
CommentAttributes,
CaseUserActionsResponse,
User,
ESCasesConfigureAttributes,
CaseType,
} from '../../../common/api';
import { buildCaseUserActionItem } from '../../services/user_actions/helpers';

Expand All @@ -37,6 +41,22 @@ import {
import { CaseClientHandler } from '../client';
import { createCaseError } from '../../common/error';

/**
* Returns true if the case should be closed based on the configuration settings and whether the case
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment, super helpful!

* is a collection. Collections are not closable because we aren't allowing their status to be changed.
* In the future we could allow push to close all the sub cases of a collection but that's not currently supported.
*/
function shouldCloseByPush(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for moving this out to it's own fn

configureSettings: SavedObjectsFindResponse<ESCasesConfigureAttributes>,
caseInfo: SavedObject<ESCaseAttributes>
): boolean {
return (
configureSettings.total > 0 &&
configureSettings.saved_objects[0].attributes.closure_type === 'close-by-pushing' &&
caseInfo.attributes.type !== CaseType.collection
);
}

interface PushParams {
savedObjectsClient: SavedObjectsClientContract;
caseService: CaseServiceSetup;
Expand Down Expand Up @@ -190,14 +210,15 @@ export const push = async ({
let updatedCase: SavedObjectsUpdateResponse<ESCaseAttributes>;
let updatedComments: SavedObjectsBulkUpdateResponse<CommentAttributes>;

const shouldMarkAsClosed = shouldCloseByPush(myCaseConfigure, myCase);

try {
[updatedCase, updatedComments] = await Promise.all([
caseService.patchCase({
client: savedObjectsClient,
caseId,
updatedAttributes: {
...(myCaseConfigure.total > 0 &&
myCaseConfigure.saved_objects[0].attributes.closure_type === 'close-by-pushing'
...(shouldMarkAsClosed
? {
status: CaseStatuses.closed,
closed_at: pushedDate,
Expand Down Expand Up @@ -228,8 +249,7 @@ export const push = async ({
userActionService.postUserActions({
client: savedObjectsClient,
actions: [
...(myCaseConfigure.total > 0 &&
myCaseConfigure.saved_objects[0].attributes.closure_type === 'close-by-pushing'
...(shouldMarkAsClosed
? [
buildCaseUserActionItem({
action: 'update',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ const ClosureOptionsComponent: React.FC<ClosureOptionsProps> = ({
<EuiDescribedFormGroup
fullWidth
title={<h3>{i18n.CASE_CLOSURE_OPTIONS_TITLE}</h3>}
description={i18n.CASE_CLOSURE_OPTIONS_DESC}
description={
<>
<p>{i18n.CASE_CLOSURE_OPTIONS_DESC}</p>
<p>{i18n.CASE_COLSURE_OPTIONS_SUB_CASES}</p>
</>
}
data-test-subj="case-closure-options-form-group"
>
<EuiFormRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ export const CASE_CLOSURE_OPTIONS_DESC = i18n.translate(
}
);

export const CASE_COLSURE_OPTIONS_SUB_CASES = i18n.translate(
'xpack.securitySolution.case.configureCases.caseClosureOptionsSubCases',
{
defaultMessage: 'Automated closures of sub-cases is not currently supported.',
}
);

export const CASE_CLOSURE_OPTIONS_LABEL = i18n.translate(
'xpack.securitySolution.case.configureCases.caseClosureOptionsLabel',
{
Expand Down
82 changes: 41 additions & 41 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -2588,15 +2588,6 @@
"indexPatternManagement.actions.deleteButton": "削除",
"indexPatternManagement.actions.saveButton": "フィールドを保存",
"indexPatternManagement.aliasLabel": "エイリアス",
"indexPatternFieldEditor.color.actions": "アクション",
"indexPatternFieldEditor.color.addColorButton": "色を追加",
"indexPatternFieldEditor.color.backgroundLabel": "背景色",
"indexPatternFieldEditor.color.deleteAria": "削除",
"indexPatternFieldEditor.color.deleteTitle": "色のフォーマットを削除",
"indexPatternFieldEditor.color.exampleLabel": "例",
"indexPatternFieldEditor.color.patternLabel": "パターン(正規表現)",
"indexPatternFieldEditor.color.rangeLabel": "範囲(min:max)",
"indexPatternFieldEditor.color.textColorLabel": "文字の色",
"indexPatternManagement.createHeader": "スクリプトフィールドを作成",
"indexPatternManagement.createIndexPattern.betaLabel": "ベータ",
"indexPatternManagement.createIndexPattern.description": "インデックスパターンは、{single}または{multiple}データソース、{star}と一致します。",
Expand Down Expand Up @@ -2660,10 +2651,6 @@
"indexPatternManagement.createIndexPatternHeader": "{indexPatternName}の作成",
"indexPatternManagement.customLabel": "カスタムラベル",
"indexPatternManagement.dataStreamLabel": "データストリーム",
"indexPatternFieldEditor.date.documentationLabel": "ドキュメント",
"indexPatternFieldEditor.date.momentLabel": "Moment.jsのフォーマットパターン(デフォルト: {defaultPattern})",
"indexPatternFieldEditor.defaultErrorMessage": "このフォーマット構成の使用を試みた際にエラーが発生しました: {message}",
"indexPatternFieldEditor.defaultFormatDropDown": "- デフォルト -",
"indexPatternManagement.defaultFormatHeader": "フォーマット (デフォルト: {defaultFormat})",
"indexPatternManagement.deleteField.cancelButton": "キャンセル",
"indexPatternManagement.deleteField.deleteButton": "削除",
Expand All @@ -2673,11 +2660,6 @@
"indexPatternManagement.deleteFieldLabel": "削除されたフィールドは復元できません。{separator}続行してよろしいですか?",
"indexPatternManagement.disabledCallOutHeader": "スクリプティングが無効です",
"indexPatternManagement.disabledCallOutLabel": "Elasticsearchでのすべてのインラインスクリプティングが無効になっています。Kibanaでスクリプトフィールドを使用するには、インラインスクリプティングを有効にする必要があります。",
"indexPatternFieldEditor.duration.decimalPlacesLabel": "小数部分の桁数",
"indexPatternFieldEditor.duration.inputFormatLabel": "インプット形式",
"indexPatternFieldEditor.duration.outputFormatLabel": "アウトプット形式",
"indexPatternFieldEditor.duration.showSuffixLabel": "接尾辞を表示",
"indexPatternFieldEditor.durationErrorMessage": "小数部分の桁数は0から20までの間で指定する必要があります",
"indexPatternManagement.editHeader": "{fieldName}を編集",
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonDescription": "すべてのデータに完全アグリゲーションを実行",
"indexPatternManagement.editIndexPattern.createIndex.defaultButtonText": "標準インデックスパターン",
Expand Down Expand Up @@ -2793,27 +2775,13 @@
"indexPatternManagement.nameErrorMessage": "名前が必要です",
"indexPatternManagement.nameLabel": "名前",
"indexPatternManagement.namePlaceholder": "新規スクリプトフィールド",
"indexPatternFieldEditor.number.documentationLabel": "ドキュメント",
"indexPatternFieldEditor.number.numeralLabel": "Numeral.js のフォーマットパターン (デフォルト: {defaultPattern})",
"indexPatternManagement.popularityLabel": "利用頻度",
"indexPatternFieldEditor.samples.inputHeader": "インプット",
"indexPatternFieldEditor.samples.outputHeader": "アウトプット",
"indexPatternFieldEditor.samplesHeader": "サンプル",
"indexPatternManagement.script.accessWithLabel": "{code} でフィールドにアクセスします。",
"indexPatternManagement.script.getHelpLabel": "構文のヒントを得たり、スクリプトの結果をプレビューしたりできます。",
"indexPatternManagement.scriptingLanguages.errorFetchingToastDescription": "Elasticsearchから利用可能なスクリプト言語の取得中にエラーが発生しました",
"indexPatternManagement.scriptInvalidErrorMessage": "スクリプトが無効です。詳細については、スクリプトプレビューを表示してください",
"indexPatternManagement.scriptLabel": "スクリプト",
"indexPatternManagement.scriptRequiredErrorMessage": "スクリプトが必要です",
"indexPatternFieldEditor.staticLookup.actions": "アクション",
"indexPatternFieldEditor.staticLookup.addEntryButton": "エントリーを追加",
"indexPatternFieldEditor.staticLookup.deleteAria": "削除",
"indexPatternFieldEditor.staticLookup.deleteTitle": "エントリーの削除",
"indexPatternFieldEditor.staticLookup.keyLabel": "キー",
"indexPatternFieldEditor.staticLookup.leaveBlankPlaceholder": "値をそのままにするには空欄にします",
"indexPatternFieldEditor.staticLookup.unknownKeyLabel": "不明なキーの値",
"indexPatternFieldEditor.staticLookup.valueLabel": "値",
"indexPatternFieldEditor.string.transformLabel": "変換",
"indexPatternManagement.syntax.default.formatLabel": "doc['some_field'].value",
"indexPatternManagement.syntax.defaultLabel.defaultDetail": "デフォルトで、KibanaのスクリプトフィールドはElasticsearchでの使用を目的に特別に開発されたシンプルでセキュアなスクリプト言語の{painless}を使用します。ドキュメントの値にアクセスするには次のフォーマットを使用します。",
"indexPatternManagement.syntax.defaultLabel.painlessLink": "Painless",
Expand Down Expand Up @@ -2844,8 +2812,48 @@
"indexPatternManagement.testScript.resultsLabel": "最初の10件",
"indexPatternManagement.testScript.resultsTitle": "結果を表示",
"indexPatternManagement.testScript.submitButtonLabel": "スクリプトを実行",
"indexPatternFieldEditor.truncate.lengthLabel": "フィールドの長さ",
"indexPatternManagement.typeLabel": "型",
"indexPatternManagement.warningCallOut.descriptionLabel": "計算値の表示と集約にスクリプトフィールドが使用できます。そのため非常に遅い場合があり、適切に行わないとKibanaが使用できなくなる可能性もあります。この場合安全策はありません。入力ミスがあると、あちこちに予期せぬ例外が起こります!",
"indexPatternManagement.warningCallOutHeader": "十分ご注意ください",
"indexPatternManagement.warningCallOutLabel.callOutDetail": "スクリプトフィールドを使う前に、{scripFields}と{scriptsInAggregation}についてよく理解するようにしてください。",
"indexPatternManagement.warningCallOutLabel.scripFieldsLink": "スクリプトフィールド",
"indexPatternManagement.warningCallOutLabel.scriptsInAggregationLink": "集約におけるスクリプト",
"indexPatternManagement.warningHeader": "廃止警告:",
"indexPatternManagement.warningLabel.painlessLinkLabel": "Painless",
"indexPatternManagement.warningLabel.warningDetail": "{language}は廃止され、KibanaとElasticsearchの次のメジャーバージョンではサポートされなくなります。新規スクリプトフィールドには{painlessLink}を使うことをお勧めします。",
"indexPatternFieldEditor.color.actions": "アクション",
"indexPatternFieldEditor.color.addColorButton": "色を追加",
"indexPatternFieldEditor.color.backgroundLabel": "背景色",
"indexPatternFieldEditor.color.deleteAria": "削除",
"indexPatternFieldEditor.color.deleteTitle": "色のフォーマットを削除",
"indexPatternFieldEditor.color.exampleLabel": "例",
"indexPatternFieldEditor.color.patternLabel": "パターン(正規表現)",
"indexPatternFieldEditor.color.rangeLabel": "範囲(min:max)",
"indexPatternFieldEditor.color.textColorLabel": "文字の色",
"indexPatternFieldEditor.date.documentationLabel": "ドキュメント",
"indexPatternFieldEditor.date.momentLabel": "Moment.jsのフォーマットパターン(デフォルト: {defaultPattern})",
"indexPatternFieldEditor.defaultErrorMessage": "このフォーマット構成の使用を試みた際にエラーが発生しました: {message}",
"indexPatternFieldEditor.defaultFormatDropDown": "- デフォルト -",
"indexPatternFieldEditor.duration.decimalPlacesLabel": "小数部分の桁数",
"indexPatternFieldEditor.duration.inputFormatLabel": "インプット形式",
"indexPatternFieldEditor.duration.outputFormatLabel": "アウトプット形式",
"indexPatternFieldEditor.duration.showSuffixLabel": "接尾辞を表示",
"indexPatternFieldEditor.durationErrorMessage": "小数部分の桁数は0から20までの間で指定する必要があります",
"indexPatternFieldEditor.number.documentationLabel": "ドキュメント",
"indexPatternFieldEditor.number.numeralLabel": "Numeral.js のフォーマットパターン (デフォルト: {defaultPattern})",
"indexPatternFieldEditor.samples.inputHeader": "インプット",
"indexPatternFieldEditor.samples.outputHeader": "アウトプット",
"indexPatternFieldEditor.samplesHeader": "サンプル",
"indexPatternFieldEditor.staticLookup.actions": "アクション",
"indexPatternFieldEditor.staticLookup.addEntryButton": "エントリーを追加",
"indexPatternFieldEditor.staticLookup.deleteAria": "削除",
"indexPatternFieldEditor.staticLookup.deleteTitle": "エントリーの削除",
"indexPatternFieldEditor.staticLookup.keyLabel": "キー",
"indexPatternFieldEditor.staticLookup.leaveBlankPlaceholder": "値をそのままにするには空欄にします",
"indexPatternFieldEditor.staticLookup.unknownKeyLabel": "不明なキーの値",
"indexPatternFieldEditor.staticLookup.valueLabel": "値",
"indexPatternFieldEditor.string.transformLabel": "変換",
"indexPatternFieldEditor.truncate.lengthLabel": "フィールドの長さ",
"indexPatternFieldEditor.url.heightLabel": "高さ",
"indexPatternFieldEditor.url.labelTemplateHelpText": "ラベルテンプレートのヘルプ",
"indexPatternFieldEditor.url.labelTemplateLabel": "ラベルテンプレート",
Expand All @@ -2856,14 +2864,6 @@
"indexPatternFieldEditor.url.typeLabel": "型",
"indexPatternFieldEditor.url.urlTemplateLabel": "URLテンプレート",
"indexPatternFieldEditor.url.widthLabel": "幅",
"indexPatternManagement.warningCallOut.descriptionLabel": "計算値の表示と集約にスクリプトフィールドが使用できます。そのため非常に遅い場合があり、適切に行わないとKibanaが使用できなくなる可能性もあります。この場合安全策はありません。入力ミスがあると、あちこちに予期せぬ例外が起こります!",
"indexPatternManagement.warningCallOutHeader": "十分ご注意ください",
"indexPatternManagement.warningCallOutLabel.callOutDetail": "スクリプトフィールドを使う前に、{scripFields}と{scriptsInAggregation}についてよく理解するようにしてください。",
"indexPatternManagement.warningCallOutLabel.scripFieldsLink": "スクリプトフィールド",
"indexPatternManagement.warningCallOutLabel.scriptsInAggregationLink": "集約におけるスクリプト",
"indexPatternManagement.warningHeader": "廃止警告:",
"indexPatternManagement.warningLabel.painlessLinkLabel": "Painless",
"indexPatternManagement.warningLabel.warningDetail": "{language}は廃止され、KibanaとElasticsearchの次のメジャーバージョンではサポートされなくなります。新規スクリプトフィールドには{painlessLink}を使うことをお勧めします。",
"inputControl.control.noIndexPatternTooltip": "index-pattern id が見つかりませんでした: {indexPatternId}.",
"inputControl.control.notInitializedTooltip": "コントロールが初期化されていません",
"inputControl.control.noValuesDisableTooltip": "「{indexPatternName}」インデックスパターンでいずれのドキュメントにも存在しない「{fieldName}」フィールドがフィルターの対象になっています。異なるフィールドを選択するか、このフィールドに値が入力されているドキュメントをインデックスしてください。",
Expand Down
Loading