Skip to content

Commit

Permalink
[frontend/backend] wip
Browse files Browse the repository at this point in the history
  • Loading branch information
savacano28 committed Dec 5, 2024
1 parent 3db0a74 commit 35319ba
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 33 deletions.
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "Anzahl der Entitäten",
"Number of errors": "Anzahl der Fehler",
"Number of history entries": "Anzahl der Historieneinträge",
"Number of injects by attack pattern": "Anzahl der Injektionen nach Angriffsmuster",
"Number of injects generated by attack pattern and platform": "Anzahl der Injektionen, die durch Angriffsmuster und Plattform erzeugt wurden",
"Number of lowercase chars must be greater or equals to": "Anzahl der Kleinbuchstaben muss größer oder gleich sein",
"Number of messages: ": "Anzahl der Nachrichten:",
"Number of node(s)": "Anzahl der Knoten(s)",
Expand Down
3 changes: 2 additions & 1 deletion opencti-platform/opencti-front/lang/front/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "Number of entities",
"Number of errors": "Number of errors",
"Number of history entries": "Number of history entries",
"Number of injects by attack pattern": "Number of injects by attack pattern",
"Number of injects generated by attack pattern and platform": "Number of injects generated by attack pattern and platform",
"Number of lowercase chars must be greater or equals to": "Number of lowercase chars must be greater or equals to",
"Number of messages: ": "Number of messages: ",
"Number of node(s)": "Number of node(s)",
Expand Down Expand Up @@ -2587,6 +2587,7 @@
"takedown_types": "takedown types",
"tanium-signal": "Tanium Signal",
"Target": "Target",
"Targeted architecture": "Targeted architecture",
"Targeted by this actor": "Targeted by this actor",
"Targeted by this intrusion set": "Targeted by this intrusion set",
"Targeted by this malware": "Targeted by this malware",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "Número de entidades",
"Number of errors": "Número de erores",
"Number of history entries": "Número de entradas del historial",
"Number of injects by attack pattern": "Número de inyecciones por patrón de ataque",
"Number of injects generated by attack pattern and platform": "Número de inyecciones generadas por el patrón de ataque y la plataforma",
"Number of lowercase chars must be greater or equals to": "Número de caracteres en minúscula debe ser mayor o igual a",
"Number of messages: ": "Número de mensajes:",
"Number of node(s)": "Número de nodo(s)",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "Nombre d'entités",
"Number of errors": "Nombre d'erreurs",
"Number of history entries": "Nombre d'entrées dans l'historique",
"Number of injects by attack pattern": "Nombre d'injections par modèle d'attaque",
"Number of injects generated by attack pattern and platform": "Nombre d'injections générées par le modèle d'attaque et la plateforme",
"Number of lowercase chars must be greater or equals to": "Le nombre de caractères minuscules doit être supérieur ou égal à",
"Number of messages: ": "Nombre de messages :",
"Number of node(s)": "Nombre de nœuds",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "エンティティ数",
"Number of errors": "エラー数",
"Number of history entries": "履歴エントリ数",
"Number of injects by attack pattern": "攻撃パターン別インジェクト数",
"Number of injects generated by attack pattern and platform": "攻撃パターンとプラットフォームによって生成されたインジェクトの数",
"Number of lowercase chars must be greater or equals to": "小文字の数は次の値以上でなければなりません",
"Number of messages: ": "メッセージ数:",
"Number of node(s)": "ノード数",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "엔터티 수",
"Number of errors": "오류 수",
"Number of history entries": "히스토리 항목 수",
"Number of injects by attack pattern": "공격 패턴별 주입",
"Number of injects generated by attack pattern and platform": "공격 패턴과 플랫폼에 의해 생성된 인젝션",
"Number of lowercase chars must be greater or equals to": "소문자 수는 더 크거나 같아야 합니다",
"Number of messages: ": "메시지 수입니다:",
"Number of node(s)": "노드 수",
Expand Down
2 changes: 1 addition & 1 deletion opencti-platform/opencti-front/lang/front/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
"Number of entities": "实体数量",
"Number of errors": "错误数量",
"Number of history entries": "历史记录条数",
"Number of injects by attack pattern": "按攻击模式注入的次数",
"Number of injects generated by attack pattern and platform": "攻击模式和平台生成的注入次数",
"Number of lowercase chars must be greater or equals to": "小写字符的数量必须大于或等于",
"Number of messages: ": "信息数量",
"Number of node(s)": "节点数量",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React, { FunctionComponent, useState } from 'react';
import { Autocomplete, TextField, FormControl } from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import { Option } from '@components/common/form/ReferenceField';

const useStyles = makeStyles(() => ({
text: {
display: 'inline-block',
flexGrow: 1,
marginLeft: 10,
},
}));

interface PlatformFieldProps {
id: string;
label: string;
onChange: (value: string[]) => void;
containerStyle?: Record<string, string | number>;
helpertext?: string;
required?: boolean;
value: string[];
}

const PlatformOptions = [
{ label: 'Windows', value: 'windows' },
{ label: 'Linux', value: 'linux' },
{ label: 'MacOS', value: 'macos' },
];

const PlatformField: FunctionComponent<PlatformFieldProps> = ({
id,
label,
containerStyle,
helpertext,
onChange,
value,
}) => {
const classes = useStyles();
const [platforms] = useState(PlatformOptions);

const handleChange = (_event: any, newValue: Option[]) => {
onChange(newValue.map((v) => v.value));
};

return (
<FormControl style={{ width: '100%', ...containerStyle }} error={!!helpertext}>
<Autocomplete
id={id}
multiple
options={platforms}
value={platforms.filter((platform) => value.includes(platform.value))}
onChange={handleChange}
getOptionLabel={(option) => option.label}
renderInput={(params) => (
<TextField
{...params}
label={label}
variant="standard"
helperText={helpertext}
/>
)}
renderOption={(props, option) => (
<li {...props}>
<div className={classes.text}>{option.label ?? ''}</div>
</li>
)}
/>
</FormControl>
);
};

export default PlatformField;
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import InputLabel from '@mui/material/InputLabel';
import Select from '@mui/material/Select';
import MenuItem from '@mui/material/MenuItem';
import TextField from '@mui/material/TextField';
import Switch from '@mui/material/Switch';
import FormControlLabel from '@mui/material/FormControlLabel';
import Box from '@mui/material/Box';
import { graphql } from 'react-relay';
import DialogActions from '@mui/material/DialogActions';
Expand All @@ -20,6 +18,8 @@ import CircularProgress from '@mui/material/CircularProgress';
import Typography from '@mui/material/Typography';
import { Link } from 'react-router-dom';
import Alert from '@mui/material/Alert';
import PlatformField from '@components/common/form/PlatformField';
import EEChip from '@components/common/entreprise_edition/EEChip';
import Drawer from '../drawer/Drawer';
import Chart from '../charts/Chart';
import { useFormatter } from '../../../../components/i18n';
Expand Down Expand Up @@ -119,9 +119,11 @@ const StixCoreObjectSimulationResult = ({ id, type }) => {
const [open, setOpen] = useState(false);
const [openCallToAction, setOpenCallToAction] = useState(false);
const isEnterpriseEdition = useEnterpriseEdition();
const { enabled, configured } = useAI();
const { configured } = useAI();
const { oBasConfigured, oBasDisableDisplay } = useXTM();
const [simulationType, setSimulationType] = useState('technical');
const [simulationPlatforms, setSimulationPlatforms] = useState(['windows']);
const [simulationArchitecture, setSimulationArchitecture] = useState('AMD64');
const [selection, setSelection] = useState('random');
const [interval, setInterval] = useState(2);
const [useGenAI, setUseGenAI] = useState(false);
Expand Down Expand Up @@ -348,6 +350,45 @@ const StixCoreObjectSimulationResult = ({ id, type }) => {
const renderForm = () => {
return (
<>
<FormControl style={fieldSpacingContainerStyle}>
<InputLabel id="simulationType">{t_i18n('Simulation type')}</InputLabel>
<Select
labelId="simulationType"
value={simulationType}
onChange={(event) => setSimulationType(event.target.value)}
fullWidth={true}
>
<MenuItem value="technical">{t_i18n('Technical (payloads)')}</MenuItem>
<MenuItem value="simulated" disabled={ !configured || !isEnterpriseEdition}>{t_i18n('Simulated (emails)')}{!isEnterpriseEdition && <EEChip />}</MenuItem>
<MenuItem value="mixed" disabled={true}>{t_i18n('Mixed (both)')}</MenuItem>
</Select>
</FormControl>
{(!configured || !isEnterpriseEdition) && (
<>
<PlatformField
id="simulationPlatforms"
label="Targeted Platforms"
value={simulationPlatforms}
onChange={(value) => {
setSimulationPlatforms(value);
}}
containerStyle={{ marginTop: 16 }}
required={true}
/>
<FormControl style={fieldSpacingContainerStyle}>
<InputLabel id="simulationArchitecture">{t_i18n('Targeted architecture')}</InputLabel>
<Select
labelId="simulationArchitecture"
value={simulationArchitecture}
onChange={(event) => setSimulationArchitecture(event.target.value)}
fullWidth={true}
>
<MenuItem value="AMD64">{'x86_64'}</MenuItem>
<MenuItem value="ARM64" >{'arm64'}</MenuItem>
</Select>
</FormControl>
</>
)}
<TextField
label={t_i18n('Interval between injections (in minute)')}
fullWidth={true}
Expand All @@ -357,7 +398,7 @@ const StixCoreObjectSimulationResult = ({ id, type }) => {
style={fieldSpacingContainerStyle}
/>
<FormControl style={fieldSpacingContainerStyle}>
<InputLabel id="simulationType">{t_i18n('Number of injects by attack pattern')}</InputLabel>
<InputLabel id="simulationNumberInjects">{t_i18n('Number of injects generated by attack pattern and platform')}</InputLabel>
<Select
labelId="selection"
value={selection}
Expand All @@ -368,27 +409,6 @@ const StixCoreObjectSimulationResult = ({ id, type }) => {
<MenuItem value="random">{t_i18n('One (random)')}</MenuItem>
</Select>
</FormControl>
<FormControlLabel
style={{ marginTop: 20 }}
label={t_i18n('Use AI')}
control={
<Switch disabled={!enabled || !configured || !isEnterpriseEdition} value={useGenAI} onChange={(event) => setUseGenAI(event.target.checked)} />
}
/>
<FormControl style={fieldSpacingContainerStyle}>
<InputLabel id="simulationType">{t_i18n('Simulation type')}</InputLabel>
<Select
labelId="simulationType"
value={simulationType}
onChange={(event) => setSimulationType(event.target.value)}
fullWidth={true}
disabled={!useGenAI}
>
<MenuItem value="technical">{t_i18n('Technical (payloads)')}</MenuItem>
<MenuItem value="simulated">{t_i18n('Simulated (emails)')}</MenuItem>
<MenuItem value="mixed" disabled={true}>{t_i18n('Mixed (both)')}</MenuItem>
</Select>
</FormControl>
<div className={classes.buttons}>
<Button
variant="contained"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ export const generateOpenBasScenario = async (context, user, stixCoreObject, att
dependsOnDuration += (interval * 60);
}
} else {
// TODO
// TODO MIXED Case
}
}
}
Expand Down

0 comments on commit 35319ba

Please sign in to comment.