Skip to content

[frontend] add ee highlight #2998

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

Open
wants to merge 3 commits into
base: issue/2838-chunk-2
Choose a base branch
from
Open
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
23 changes: 11 additions & 12 deletions openbas-front/src/admin/components/agents/Agents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import PlatformSelector from './PlatformSelector';

const OPENBAS_CALDERA = 'openbas_caldera';
const OPENBAS_AGENT = 'openbas_agent';
const OPENBAS_CROWDSTRIKE = 'openbas_crowdstrike';
const OPENBAS_TANIUM = 'openbas_tanium';

const Executors = () => {
// Standard hooks
Expand Down Expand Up @@ -47,13 +49,9 @@ const Executors = () => {
openbas_tanium: 2,
openbas_crowdstrike: 3,
};
const sortedExecutors = executors
.map((executor: Executor) => ({
...executor,
order: order[executor.executor_type as keyof typeof order],
}))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.sort((a: any, b: any) => a.order - b.order);

const sortedExecutors = executors.sort((a: Executor, b: Executor) => order[a.executor_type as keyof typeof order] - order[b.executor_type as keyof typeof order]);
const needInformationStepper = (selectedExecutor?.executor_type === OPENBAS_AGENT || selectedExecutor?.executor_type === OPENBAS_CALDERA);

// -- Manage Dialogs
const steps = [t('Choose your platform'), t('Installation Instructions')];
Expand Down Expand Up @@ -84,6 +82,7 @@ const Executors = () => {
<ExecutorSelector
executor={executor}
setSelectedExecutor={setSelectedExecutor}
isEEExecutor={executor.executor_type == OPENBAS_TANIUM || executor.executor_type == OPENBAS_CROWDSTRIKE}
Copy link
Member

Choose a reason for hiding this comment

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

question (for the whole PR): shouldn't we add this as a more generic property somewhere ? Maybe we need to add a isEE propetry in all executors in addition to the executor_type ?

/>
</Grid>
))}
Expand All @@ -93,16 +92,16 @@ const Executors = () => {
slots={{ transition: Transition }}
onClose={closeInstall}
slotProps={{ paper: { elevation: 1 } }}
maxWidth="md"
maxWidth={needInformationStepper ? 'md' : 'sm'}
>
<DialogTitle style={{ padding: theme.spacing(4, 4, 4, 5) }}>
<DialogTitle>
{`${selectedExecutor?.executor_name} `}
</DialogTitle>
<DialogContent>
{(selectedExecutor?.executor_type === OPENBAS_AGENT || selectedExecutor?.executor_type === OPENBAS_CALDERA)
{needInformationStepper
&& (
<>
<Stepper activeStep={activeStep} style={{ padding: theme.spacing(0, 1, 3) }}>
<Stepper activeStep={activeStep} style={{ padding: theme.spacing(0, 1, 3, 0) }}>
{steps.map((label, index) => (
<Step key={label}>
<StepButton color="inherit" onClick={() => setActiveStep(index)}>{label}</StepButton>
Expand All @@ -117,7 +116,7 @@ const Executors = () => {
)}
</>
)}
{selectedExecutor?.executor_type !== OPENBAS_AGENT && selectedExecutor?.executor_type !== OPENBAS_CALDERA && selectedExecutor && (
{!needInformationStepper && selectedExecutor && (
<ExecutorDocumentationLink executor={selectedExecutor} />
)}
</DialogContent>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import { Typography } from '@mui/material';
import { Alert, Typography } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { type FunctionComponent } from 'react';
import { type FunctionComponent, useEffect } from 'react';

import { useFormatter } from '../../../components/i18n';
import { type Executor } from '../../../utils/api-types';
import useEnterpriseEdition from '../../../utils/hooks/useEnterpriseEdition';
import EEChip from '../common/entreprise_edition/EEChip';

interface Props { executor: Executor }

const ExecutorDocumentationLink: FunctionComponent<Props> = ({ executor }) => {
// Standard hooks
const { t } = useFormatter();
const theme = useTheme();
const { openDialog, setFeatureDetectedInfo } = useEnterpriseEdition();

useEffect(() => {
}, []);
const onAlertClick = () => {
setFeatureDetectedInfo(executor.executor_name);
openDialog();
};
return (
<div style={{ padding: theme.spacing(0, 2, 2) }}>
<div style={{
display: 'grid',
gap: theme.spacing(2),
}}
>
<Alert style={{ cursor: 'pointer' }} icon={<EEChip style={{ marginTop: theme.spacing(1) }} />} severity="success" onClick={onAlertClick}>
{`${executor.executor_name} ${t('executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.')} `}
</Alert>
{executor.executor_doc && (
<Typography variant="body1">
{t('To install the agent please follow the ')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { makeStyles } from 'tss-react/mui';
import { useFormatter } from '../../../components/i18n';
import PlatformIcon from '../../../components/PlatformIcon';
import { type Executor } from '../../../utils/api-types';
import EEChip from '../common/entreprise_edition/EEChip';
import ExecutorBanner from './ExecutorBanner';

const useStyles = makeStyles()(theme => ({
Expand All @@ -27,9 +28,10 @@ const useStyles = makeStyles()(theme => ({
interface ExecutorSelectorProps {
executor: Executor;
setSelectedExecutor: (executor: Executor) => void;
isEEExecutor?: boolean;
}

const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelectedExecutor }) => {
const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelectedExecutor, isEEExecutor = false }) => {
const theme = useTheme();
const { classes } = useStyles();
const { t } = useFormatter();
Expand All @@ -55,12 +57,13 @@ const ExecutorSelector: React.FC<ExecutorSelectorProps> = ({ executor, setSelect
fontSize: 15,
padding: theme.spacing(2, 0, 1),
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
alignItems: 'center',
color: platforms.length === 0 ? theme.palette.text?.disabled : theme.palette.text?.primary,
}}
>
{`${t('Install')} ${executor.executor_name}`}
{isEEExecutor && <EEChip style={{ marginLeft: theme.spacing(1) }} />}
</Typography>
<Box
sx={{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { DevicesOtherOutlined } from '@mui/icons-material';
import { List, ListItem, ListItemIcon, ListItemText } from '@mui/material';
import { useTheme } from '@mui/material/styles';
import { type CSSProperties, type FunctionComponent } from 'react';
import { makeStyles } from 'tss-react/mui';

Expand All @@ -11,6 +12,7 @@ import { useHelper } from '../../../../../store';
import { type AgentOutput } from '../../../../../utils/api-types';
import { useAppDispatch } from '../../../../../utils/hooks';
import useDataLoader from '../../../../../utils/hooks/useDataLoader';
import EEChip from '../../../common/entreprise_edition/EEChip';
import AssetStatus from '../../AssetStatus';
import AgentDeploymentMode from '../AgentDeploymentMode';
import AgentPrivilege from '../AgentPrivilege';
Expand Down Expand Up @@ -44,6 +46,7 @@ interface Props { agents: AgentOutput[] }

const AgentList: FunctionComponent<Props> = ({ agents }) => {
const { classes } = useStyles();
const theme = useTheme();
const bodyItemsStyles = useBodyItemsStyles();
const dispatch = useAppDispatch();
const { t, fldt } = useFormatter();
Expand Down Expand Up @@ -81,7 +84,9 @@ const AgentList: FunctionComponent<Props> = ({ agents }) => {
}}
/>
)}
{executor?.executor_name ?? t('Unknown')}
{executor.executor_name ?? t('Unknown')}
{(executor.executor_type == 'openbas_tanium' || executor.executor_type == 'openbas_crowdstrike')
&& <EEChip style={{ marginLeft: theme.spacing(1) }} clickable featureDetectedInfo={executor.executor_name} />}
</>
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Tooltip } from '@mui/material';
import { type CSSProperties } from 'react';
import { makeStyles } from 'tss-react/mui';

import { useFormatter } from '../../../../components/i18n';
Expand All @@ -20,21 +21,25 @@ const useStyles = makeStyles<{ isClickable: boolean }>()((theme, { isClickable }
},
}));

const EEChip = ({ clickable = false, featureDetectedInfo = '' }: {
const EEChip = ({ clickable = false, featureDetectedInfo = null, style = {} }: {
clickable?: boolean;
featureDetectedInfo?: string;
featureDetectedInfo?: string | null;
style?: CSSProperties;
}) => {
const { classes } = useStyles({ isClickable: clickable });
const { t } = useFormatter();
const { openDialog, setFeatureDetectedInfo } = useEnterpriseEdition();
const { isValidated: isEnterpriseEdition } = useEnterpriseEdition();
setFeatureDetectedInfo(featureDetectedInfo);
if (featureDetectedInfo) {
setFeatureDetectedInfo(featureDetectedInfo);
}

return (
<Tooltip
title={t('Enterprise Edition Feature')}
className={classes.container}
onClick={() => clickable && !isEnterpriseEdition && openDialog()}
style={style}
>
<span>
EE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,31 @@ const useStyles = makeStyles()(theme => ({

const EnterpriseEditionAgreementDialog = () => {
const { t } = useFormatter();
const { open, closeDialog, featureDetectedInfo } = useEnterpriseEdition();
const { open, closeDialog, featureDetectedInfo, setFeatureDetectedInfo } = useEnterpriseEdition();
const { classes } = useStyles();
const dispatch = useAppDispatch();
const [enterpriseLicense, setEnterpriseLicense] = useState('');

const onCloseEnterpriseEditionDialog = () => {
closeDialog();
setFeatureDetectedInfo('');
};

const updateEnterpriseEdition = (data: SettingsEnterpriseEditionUpdateInput) => {
dispatch(updatePlatformEnterpriseEditionParameters(data));
closeDialog();
onCloseEnterpriseEditionDialog();
};

const enableEnterpriseEdition = () => updateEnterpriseEdition({ platform_enterprise_license: enterpriseLicense });

return (
<Dialog
open={open}
handleClose={closeDialog}
handleClose={onCloseEnterpriseEditionDialog}
title={t('OpenBAS Enterprise Edition (EE) license agreement')}
action={(
<>
<Button onClick={closeDialog}>{t('Cancel')}</Button>
<Button onClick={onCloseEnterpriseEditionDialog}>{t('Cancel')}</Button>
<Button
color="secondary"
onClick={enableEnterpriseEdition}
Expand Down
5 changes: 3 additions & 2 deletions openbas-front/src/utils/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@
"Execution Time": "Execution Time",
"Executor": "Executor",
"Executor Caldera is not responding, your exercises may be impacted.": "Executor Caldera is not responding, your exercises may be impacted.",
"executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.": "executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.",
"Executors": "Executors",
"Exercise": "Simulation",
"Exercise details": "Exercise details",
Expand Down Expand Up @@ -543,6 +544,7 @@
"finding_asset_groups": "Asset groups",
"finding_assets": "Endpoints",
"finding_created_at": "Created at",
"finding_inject_id": "Inject",
"finding_name": "Name",
"finding_scenario": "Scenario",
"finding_simulation": "Simulation",
Expand Down Expand Up @@ -1484,6 +1486,5 @@
"Your file should be a XLS": "Your file should be a XLS",
"Your overall evaluation about this question.": "Your overall evaluation about this question.",
"your trial license online": "your trial license online",
"YYYY": "YYYY",
"finding_inject_id": "Inject"
"YYYY": "YYYY"
}
5 changes: 3 additions & 2 deletions openbas-front/src/utils/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@
"Execution Time": "Temps d'exécution",
"Executor": "Exécuteur",
"Executor Caldera is not responding, your exercises may be impacted.": "L'exécuteur Caldera ne réponds pas, vos exercises peuvent être impactés.",
"executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.": "exécuteur est une fonctionnalité de l'édition Entreprise. Vous pouvez commencer l'installation, mais vous aurez besoin d'une clé de licence pour exécuter vos injections. Nous proposons une période d'essai de 3 mois pour vous permettre de tester la plateforme à pleine capacité.",
"Executors": "Exécuteurs",
"Exercise": "Simulation",
"Exercise details": "Détails de l'exercise",
Expand Down Expand Up @@ -543,6 +544,7 @@
"finding_asset_groups": "Groupes d'actifs",
"finding_assets": "Points finaux",
"finding_created_at": "Créé à",
"finding_inject_id": "Stimuli",
"finding_name": "Nom",
"finding_scenario": "Scénario",
"finding_simulation": "Simulation",
Expand Down Expand Up @@ -1484,6 +1486,5 @@
"Your file should be a XLS": "Votre fichier doit être un XLS",
"Your overall evaluation about this question.": "Votre évaluation globale de cette question.",
"your trial license online": "votre licence d'essai en ligne",
"YYYY": "AAAA",
"finding_inject_id": "Stimuli"
"YYYY": "AAAA"
}
5 changes: 3 additions & 2 deletions openbas-front/src/utils/lang/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@
"Execution Time": "执行时间",
"Executor": "执行者",
"Executor Caldera is not responding, your exercises may be impacted.": "Executor Caldera is not responding, your exercises may be impacted.",
"executor is an enterprise edition feature. You can start the set up but you will need a license key to execute your injects. We provide a 3 month trial to let you test the platform at full capacity.": "执行器是企业版功能。您可以开始设置,但需要许可证密钥才能执行注入。我们提供 3 个月的试用期,让您可以充分测试平台的功能。",
"Executors": "执行者",
"Exercise": "练习",
"Exercise details": "锻炼详情",
Expand Down Expand Up @@ -543,6 +544,7 @@
"finding_asset_groups": "资产组",
"finding_assets": "端点",
"finding_created_at": "创建于",
"finding_inject_id": "注入",
"finding_name": "名称",
"finding_scenario": "场景",
"finding_simulation": "模拟",
Expand Down Expand Up @@ -1484,6 +1486,5 @@
"Your file should be a XLS": "你的文件应该为XLS",
"Your overall evaluation about this question.": "您对此问题的总体评价。",
"your trial license online": "在线试用许可证",
"YYYY": "YYYY",
"finding_inject_id": "注入"
"YYYY": "YYYY"
}