Skip to content

Commit

Permalink
Add attack pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
johanah29 committed Nov 4, 2024
1 parent 9bd8d4c commit b048cb8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions openbas-front/src/actions/payloads/Payload.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export type PayloadStore = Omit<Payload, 'payload_collector'> & {
file_drop_file?: string;
executable_file?: string;
executable_arch?: string;
payload_attack_patterns?: string[];
};
8 changes: 6 additions & 2 deletions openbas-front/src/admin/components/payloads/Payloads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { Chip, Grid, List, ListItem, ListItemIcon, ListItemSecondaryAction, List
import { makeStyles } from '@mui/styles';
import { CSSProperties, useMemo, useState } from 'react';

import { AttackPatternHelper } from '../../../actions/attack_patterns/attackpattern-helper';
import { fetchAttackPatterns } from '../../../actions/AttackPattern';
import { fetchCollectors } from '../../../actions/Collector';
import type { CollectorHelper } from '../../../actions/collectors/collector-helper';
import { fetchDocuments } from '../../../actions/Document';
Expand Down Expand Up @@ -110,13 +112,15 @@ const Payloads = () => {
const dispatch = useAppDispatch();

const [selectedPayload, setSelectedPayload] = useState<PayloadStore | null>(null);
const { documentsMap, collectorsMap } = useHelper((helper: DocumentHelper & CollectorHelper) => ({
const { documentsMap, collectorsMap, attackPatternsMap } = useHelper((helper: DocumentHelper & CollectorHelper & AttackPatternHelper) => ({
documentsMap: helper.getDocumentsMap(),
collectorsMap: helper.getCollectorsMap(),
attackPatternsMap: helper.getAttackPatternsMap(),
}));
useDataLoader(() => {
dispatch(fetchDocuments());
dispatch(fetchCollectors());
dispatch(fetchAttackPatterns());
});

// Headers
Expand Down Expand Up @@ -402,7 +406,7 @@ const Payloads = () => {
>
{t('Attack pattern')}
</Typography>
{selectedPayload?.payload_attack_patterns && selectedPayload?.payload_attack_patterns.length === 0 ? '-' : selectedPayload?.payload_attack_patterns?.map((attackPattern: AttackPattern) => (
{selectedPayload?.payload_attack_patterns && selectedPayload?.payload_attack_patterns.length === 0 ? '-' : selectedPayload?.payload_attack_patterns?.map((attackPatternId: string) => attackPatternsMap[attackPatternId]).map((attackPattern: AttackPattern) => (
<Tooltip key={attackPattern.attack_pattern_id} title={`[${attackPattern.attack_pattern_external_id}] ${attackPattern.attack_pattern_name}`}>
<Chip
variant="outlined"
Expand Down

0 comments on commit b048cb8

Please sign in to comment.