Skip to content

Commit

Permalink
addressed PR comments
Browse files Browse the repository at this point in the history
Signed-off-by: Amardeepsingh Siglani <amardeep7194@gmail.com>
  • Loading branch information
amsiglan committed Jun 28, 2024
1 parent 5dd580c commit 183cc4e
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<DetectorScheduleProps> {
constructor(props: DetectorScheduleProps) {
super(props);
}
Expand All @@ -34,7 +29,7 @@ export class DetectorSchedule extends React.Component<
<EuiSpacer />
<Interval
schedule={this.props.detector.schedule}
label={<FormFieldHeader headerTitle={'Runs every'} />}
label={<FormFieldHeader headerTitle={'Run every'} />}
onScheduleChange={this.props.onDetectorScheduleChange}
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
<Interval
label={
<FormFieldHeader
headerTitle="Runs every"
headerTitle="Run every"
/>
}
onScheduleChange={[Function]}
Expand All @@ -1381,7 +1381,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
isInvalid={false}
label={
<FormFieldHeader
headerTitle="Runs every"
headerTitle="Run every"
/>
}
labelType="label"
Expand All @@ -1407,7 +1407,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
htmlFor="some_html_id"
>
<FormFieldHeader
headerTitle="Runs every"
headerTitle="Run every"
>
<EuiText
size="s"
Expand All @@ -1416,7 +1416,7 @@ exports[`<UpdateDetectorBasicDetails /> spec renders the component 1`] = `
className="euiText euiText--small"
>
<strong>
Runs every
Run every
</strong>
</div>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const ThreatIntelFindingsTable: React.FC<ThreatIntelFindingsTableProps> =
iconType={'inspect'}
onClick={
() => {}
// TODO: implement finding flyout
// DataStore.findings.openFlyout(finding, this.state.filteredFindings)
}
/>
Expand Down
1 change: 0 additions & 1 deletion public/pages/Findings/containers/Findings/Findings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@ class Findings extends Component<FindingsProps, FindingsState> {
selectedTabId,
findingStateByTabId,
} = this.state;
// let { findings } = this.state.findingStateByTabId[this.];
let findings = findingStateByTabId[selectedTabId].findings;
const rules = findingStateByTabId[FindingTabId.DetectionRules].rules;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -24,7 +24,7 @@ export interface SetupThreatIntelAlertTriggersProps {
updateTriggers: (alertTriggers: ThreatIntelAlertTrigger[]) => void;
}

export const SetupThreatIntelAlertTriggers: React.FC<SetupThreatIntelAlertTriggersProps> = ({
export const ConfigureThreatIntelAlertTriggers: React.FC<ConfigureThreatIntelAlertTriggersProps> = ({
alertTriggers,
enabledIocTypes,
logSources,
Expand Down

This file was deleted.

8 changes: 4 additions & 4 deletions public/pages/ThreatIntel/components/IoCsTable/IoCsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<IoCstableProps> = ({ sourceId, iocs, loadingIocs }) => {
export const IoCsTable: React.FC<IoCsTableProps> = ({ sourceId, iocs, loadingIoCs }) => {
const columns: EuiBasicTableColumn<ThreatIntelIocData>[] = [
{
name: 'Value',
Expand Down Expand Up @@ -55,7 +55,7 @@ export const IoCstable: React.FC<IoCstableProps> = ({ sourceId, iocs, loadingIoc
items={iocs}
search
pagination
loading={!sourceId || loadingIocs}
loading={!sourceId || loadingIoCs}
/>
</EuiPanel>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const SelectThreatIntelLogSources: React.FC<SelectThreatIntelLogSourcesPr
});
}
},
[saContext]
[saContext, logSourceMappingByName]
);
const [selectedSourcesMap, setSelectedSourcesMap] = useState(() => {
const selectedSourcesByName: Map<string, ThreatIntelLogSource> = new Map();
Expand Down Expand Up @@ -187,9 +187,7 @@ export const SelectThreatIntelLogSources: React.FC<SelectThreatIntelLogSourcesPr
placeholder={'Select an input source for the detector.'}
isLoading={loadingLogSourceOptions}
selectedOptions={sources.map(({ name }) => ({ label: name }))}
// onBlur={() => this.setState({ fieldTouched: true })}
onChange={onLogSourceSelectionChange}
// isInvalid={!!errorMessage}
isClearable={true}
data-test-subj={'define-detector-select-data-source'}
renderOption={(option: IndexOption) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ export const ThreatIntelSourceDetails: React.FC<ThreatIntelSourceDetailsProps> =
<EuiFlexGroup alignItems="center">
<EuiFlexItem>
<Interval
label=""
schedule={{
period: {
interval: schedule.interval.period,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ThreatIntelLogSource,
ThreatIntelScanConfigFormModel,
} from '../../../../../types';
import { SetupThreatIntelAlertTriggers } from '../../components/SetupThreatIntelAlertTriggers/SetupThreatIntelAlertTriggers';
import { ConfigureThreatIntelAlertTriggers } from '../../components/ConfigureThreatIntelAlertTriggers/ConfigureThreatIntelAlertTriggers';
import { NotificationsService, ThreatIntelService } from '../../../../services';
import {
configFormModelToMonitorPayload,
Expand Down Expand Up @@ -222,7 +222,7 @@ export const ThreatIntelScanConfigForm: React.FC<ThreatIntelScanConfigFormProps>
);
case ConfigureThreatIntelScanStep.SetupAlertTriggers:
return (
<SetupThreatIntelAlertTriggers
<ConfigureThreatIntelAlertTriggers
alertTriggers={configureScanFormInputs.triggers}
notificationsService={notificationsService}
enabledIocTypes={configFormModelToMonitorPayload(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
EuiTitle,
} from '@elastic/eui';
import { DescriptionGroup } from '../../../../components/Utility/DescriptionGroup';
import { IoCstable } from '../../components/IoCsTable/IoCsTable';
import { IoCsTable } from '../../components/IoCsTable/IoCsTable';
import { ThreatIntelSourceDetails } from '../../components/ThreatIntelSourceDetails/ThreatIntelSourceDetails';
import { IocLabel } from '../../../../../common/constants';
import { ThreatIntelService } from '../../../../services';
Expand All @@ -47,7 +47,7 @@ export const ThreatIntelSource: React.FC<ThreatIntelSource> = ({
source?.id ?? location.pathname.replace(`${ROUTES.THREAT_INTEL_SOURCE_DETAILS}/`, '');
const [showDeleteModal, setShowDeleteModal] = useState(false);
const [iocs, setIocs] = useState<ThreatIntelIocData[]>([]);
const [loadingIocs, setLoadingIocs] = useState(true);
const [loadingIoCs, setLoadingIoCs] = useState(true);
const getSource = async (sourceId: string) => {
const res = await threatIntelService.getThreatIntelSource(sourceId);

Expand All @@ -64,13 +64,13 @@ export const ThreatIntelSource: React.FC<ThreatIntelSource> = ({

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);
}
};

Expand Down Expand Up @@ -98,7 +98,7 @@ export const ThreatIntelSource: React.FC<ThreatIntelSource> = ({
{
id: 'iocs',
name: <span>Indicators of Compromise</span>,
content: <IoCstable sourceId={source?.id} iocs={iocs} loadingIocs={loadingIocs} />,
content: <IoCsTable sourceId={source?.id} iocs={iocs} loadingIoCs={loadingIoCs} />,
},
{
id: 'source-details',
Expand Down
12 changes: 6 additions & 6 deletions public/pages/ThreatIntel/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
});
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 183cc4e

Please sign in to comment.