From 183cc4e20641a337c3131209a03d326d321aabcd Mon Sep 17 00:00:00 2001 From: Amardeepsingh Siglani Date: Fri, 28 Jun 2024 14:01:40 -0700 Subject: [PATCH] addressed PR comments Signed-off-by: Amardeepsingh Siglani --- .../components/DetectorSchedule/DetectorSchedule.tsx | 9 ++------- .../UpdateDetectorBasicDetails.test.tsx.snap | 8 ++++---- .../FindingsTable/ThreatIntelFindingsTable.tsx | 1 + .../pages/Findings/containers/Findings/Findings.tsx | 1 - .../ConfigureThreatIntelAlertTriggers.tsx} | 4 ++-- .../EditThreatIntelAlertTriggers.tsx | 10 ---------- .../ThreatIntel/components/IoCsTable/IoCsTable.tsx | 8 ++++---- .../SelectThreatIntelLogSourcesForm.tsx | 4 +--- .../ThreatIntelSourceDetails.tsx | 1 - .../ScanConfiguration/ThreatIntelScanConfigForm.tsx | 4 ++-- .../ThreatIntelSource/ThreatIntelSource.tsx | 10 +++++----- public/pages/ThreatIntel/utils/helpers.ts | 12 ++++++------ 12 files changed, 27 insertions(+), 45 deletions(-) rename public/pages/ThreatIntel/components/{SetupThreatIntelAlertTriggers/SetupThreatIntelAlertTriggers.tsx => ConfigureThreatIntelAlertTriggers/ConfigureThreatIntelAlertTriggers.tsx} (95%) delete mode 100644 public/pages/ThreatIntel/components/EditThreatIntelAlertTriggers/EditThreatIntelAlertTriggers.tsx diff --git a/public/pages/CreateDetector/components/DefineDetector/components/DetectorSchedule/DetectorSchedule.tsx b/public/pages/CreateDetector/components/DefineDetector/components/DetectorSchedule/DetectorSchedule.tsx index 8b229613..0bafe87e 100644 --- a/public/pages/CreateDetector/components/DefineDetector/components/DetectorSchedule/DetectorSchedule.tsx +++ b/public/pages/CreateDetector/components/DefineDetector/components/DetectorSchedule/DetectorSchedule.tsx @@ -15,12 +15,7 @@ export interface DetectorScheduleProps { onDetectorScheduleChange(schedule: PeriodSchedule): void; } -export interface DetectorScheduleState {} - -export class DetectorSchedule extends React.Component< - DetectorScheduleProps, - DetectorScheduleState -> { +export class DetectorSchedule extends React.Component { constructor(props: DetectorScheduleProps) { super(props); } @@ -34,7 +29,7 @@ export class DetectorSchedule extends React.Component< } + label={} onScheduleChange={this.props.onDetectorScheduleChange} /> diff --git a/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap b/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap index d48fd06c..d43c43dd 100644 --- a/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap +++ b/public/pages/Detectors/components/UpdateBasicDetails/__snapshots__/UpdateDetectorBasicDetails.test.tsx.snap @@ -1358,7 +1358,7 @@ exports[` spec renders the component 1`] = ` } onScheduleChange={[Function]} @@ -1381,7 +1381,7 @@ exports[` spec renders the component 1`] = ` isInvalid={false} label={ } labelType="label" @@ -1407,7 +1407,7 @@ exports[` spec renders the component 1`] = ` htmlFor="some_html_id" > spec renders the component 1`] = ` className="euiText euiText--small" > - Runs every + Run every diff --git a/public/pages/Findings/components/FindingsTable/ThreatIntelFindingsTable.tsx b/public/pages/Findings/components/FindingsTable/ThreatIntelFindingsTable.tsx index 2a7efac1..c13ff443 100644 --- a/public/pages/Findings/components/FindingsTable/ThreatIntelFindingsTable.tsx +++ b/public/pages/Findings/components/FindingsTable/ThreatIntelFindingsTable.tsx @@ -50,6 +50,7 @@ export const ThreatIntelFindingsTable: React.FC = iconType={'inspect'} onClick={ () => {} + // TODO: implement finding flyout // DataStore.findings.openFlyout(finding, this.state.filteredFindings) } /> diff --git a/public/pages/Findings/containers/Findings/Findings.tsx b/public/pages/Findings/containers/Findings/Findings.tsx index 49d08b78..2a8aabe3 100644 --- a/public/pages/Findings/containers/Findings/Findings.tsx +++ b/public/pages/Findings/containers/Findings/Findings.tsx @@ -497,7 +497,6 @@ class Findings extends Component { selectedTabId, findingStateByTabId, } = this.state; - // let { findings } = this.state.findingStateByTabId[this.]; let findings = findingStateByTabId[selectedTabId].findings; const rules = findingStateByTabId[FindingTabId.DetectionRules].rules; diff --git a/public/pages/ThreatIntel/components/SetupThreatIntelAlertTriggers/SetupThreatIntelAlertTriggers.tsx b/public/pages/ThreatIntel/components/ConfigureThreatIntelAlertTriggers/ConfigureThreatIntelAlertTriggers.tsx similarity index 95% rename from public/pages/ThreatIntel/components/SetupThreatIntelAlertTriggers/SetupThreatIntelAlertTriggers.tsx rename to public/pages/ThreatIntel/components/ConfigureThreatIntelAlertTriggers/ConfigureThreatIntelAlertTriggers.tsx index 2c293250..63dd0f98 100644 --- a/public/pages/ThreatIntel/components/SetupThreatIntelAlertTriggers/SetupThreatIntelAlertTriggers.tsx +++ b/public/pages/ThreatIntel/components/ConfigureThreatIntelAlertTriggers/ConfigureThreatIntelAlertTriggers.tsx @@ -15,7 +15,7 @@ import { EuiButton, EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui'; import { ThreatIntelIocType } from '../../../../../common/constants'; import { getEmptyThreatIntelAlertTrigger } from '../../utils/helpers'; -export interface SetupThreatIntelAlertTriggersProps { +export interface ConfigureThreatIntelAlertTriggersProps { alertTriggers: ThreatIntelAlertTrigger[]; notificationsService: NotificationsService; enabledIocTypes: ThreatIntelIocType[]; @@ -24,7 +24,7 @@ export interface SetupThreatIntelAlertTriggersProps { updateTriggers: (alertTriggers: ThreatIntelAlertTrigger[]) => void; } -export const SetupThreatIntelAlertTriggers: React.FC = ({ +export const ConfigureThreatIntelAlertTriggers: React.FC = ({ alertTriggers, enabledIocTypes, logSources, diff --git a/public/pages/ThreatIntel/components/EditThreatIntelAlertTriggers/EditThreatIntelAlertTriggers.tsx b/public/pages/ThreatIntel/components/EditThreatIntelAlertTriggers/EditThreatIntelAlertTriggers.tsx deleted file mode 100644 index 11fd4d33..00000000 --- a/public/pages/ThreatIntel/components/EditThreatIntelAlertTriggers/EditThreatIntelAlertTriggers.tsx +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright OpenSearch Contributors - * SPDX-License-Identifier: Apache-2.0 - */ - -// export const EditThreatIntelAlertTriggers = () => { -// return ( -// < -// ) -// }; diff --git a/public/pages/ThreatIntel/components/IoCsTable/IoCsTable.tsx b/public/pages/ThreatIntel/components/IoCsTable/IoCsTable.tsx index eb85b530..5ba498ee 100644 --- a/public/pages/ThreatIntel/components/IoCsTable/IoCsTable.tsx +++ b/public/pages/ThreatIntel/components/IoCsTable/IoCsTable.tsx @@ -8,13 +8,13 @@ import { EuiBasicTableColumn, EuiInMemoryTable, EuiPanel, EuiSpacer, EuiText } f import { ThreatIntelIocData } from '../../../../../types'; import { renderTime } from '../../../../utils/helpers'; -export interface IoCstableProps { +export interface IoCsTableProps { sourceId?: string; - loadingIocs: boolean; + loadingIoCs: boolean; iocs: ThreatIntelIocData[]; } -export const IoCstable: React.FC = ({ sourceId, iocs, loadingIocs }) => { +export const IoCsTable: React.FC = ({ sourceId, iocs, loadingIoCs }) => { const columns: EuiBasicTableColumn[] = [ { name: 'Value', @@ -55,7 +55,7 @@ export const IoCstable: React.FC = ({ sourceId, iocs, loadingIoc items={iocs} search pagination - loading={!sourceId || loadingIocs} + loading={!sourceId || loadingIoCs} /> ); diff --git a/public/pages/ThreatIntel/components/SelectLogSourcesForm/SelectThreatIntelLogSourcesForm.tsx b/public/pages/ThreatIntel/components/SelectLogSourcesForm/SelectThreatIntelLogSourcesForm.tsx index aa2ed263..6e4d35cb 100644 --- a/public/pages/ThreatIntel/components/SelectLogSourcesForm/SelectThreatIntelLogSourcesForm.tsx +++ b/public/pages/ThreatIntel/components/SelectLogSourcesForm/SelectThreatIntelLogSourcesForm.tsx @@ -65,7 +65,7 @@ export const SelectThreatIntelLogSources: React.FC { const selectedSourcesByName: Map = new Map(); @@ -187,9 +187,7 @@ export const SelectThreatIntelLogSources: React.FC ({ label: name }))} - // onBlur={() => this.setState({ fieldTouched: true })} onChange={onLogSourceSelectionChange} - // isInvalid={!!errorMessage} isClearable={true} data-test-subj={'define-detector-select-data-source'} renderOption={(option: IndexOption) => { diff --git a/public/pages/ThreatIntel/components/ThreatIntelSourceDetails/ThreatIntelSourceDetails.tsx b/public/pages/ThreatIntel/components/ThreatIntelSourceDetails/ThreatIntelSourceDetails.tsx index 60d071a4..7f536608 100644 --- a/public/pages/ThreatIntel/components/ThreatIntelSourceDetails/ThreatIntelSourceDetails.tsx +++ b/public/pages/ThreatIntel/components/ThreatIntelSourceDetails/ThreatIntelSourceDetails.tsx @@ -238,7 +238,6 @@ export const ThreatIntelSourceDetails: React.FC = ); case ConfigureThreatIntelScanStep.SetupAlertTriggers: return ( - = ({ source?.id ?? location.pathname.replace(`${ROUTES.THREAT_INTEL_SOURCE_DETAILS}/`, ''); const [showDeleteModal, setShowDeleteModal] = useState(false); const [iocs, setIocs] = useState([]); - const [loadingIocs, setLoadingIocs] = useState(true); + const [loadingIoCs, setLoadingIoCs] = useState(true); const getSource = async (sourceId: string) => { const res = await threatIntelService.getThreatIntelSource(sourceId); @@ -64,13 +64,13 @@ export const ThreatIntelSource: React.FC = ({ const getIocs = async () => { if (sourceId) { - setLoadingIocs(true); + setLoadingIoCs(true); const iocsRes = await threatIntelService.getThreatIntelIocs({}); if (iocsRes.ok) { setIocs(iocsRes.response.iocs); } - setLoadingIocs(false); + setLoadingIoCs(false); } }; @@ -98,7 +98,7 @@ export const ThreatIntelSource: React.FC = ({ { id: 'iocs', name: Indicators of Compromise, - content: , + content: , }, { id: 'source-details', diff --git a/public/pages/ThreatIntel/utils/helpers.ts b/public/pages/ThreatIntel/utils/helpers.ts index be5cd366..1a84aac1 100644 --- a/public/pages/ThreatIntel/utils/helpers.ts +++ b/public/pages/ThreatIntel/utils/helpers.ts @@ -150,12 +150,9 @@ export function deriveFormModelFromConfig( }, }; } else { - logSourcesByName[index].iocConfigMap = { - ...logSourcesByName[index].iocConfigMap, - [ioc_type]: { - fieldAliases, - enabled: true, - }, + logSourcesByName[index].iocConfigMap[ioc_type] = { + fieldAliases, + enabled: true, }; } }); @@ -259,6 +256,9 @@ export function readIocsFromFile( onRead({ ok: false, errorMessage: e?.message || e?.toString?.() }); } }; + reader.onerror = function () { + onRead({ ok: false, errorMessage: 'Error reading file.' }); + }; } export function threatIntelSourceItemToBasePayload(