Skip to content
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

Feature/ResultTable (master) #1366

Open
wants to merge 4 commits into
base: master
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
74 changes: 65 additions & 9 deletions src/components/visual/ResultCard/result_section.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import AssignmentOutlinedIcon from '@mui/icons-material/AssignmentOutlined';
import CloseOutlinedIcon from '@mui/icons-material/CloseOutlined';
import ExpandLess from '@mui/icons-material/ExpandLess';
import ExpandMore from '@mui/icons-material/ExpandMore';
import LabelOutlinedIcon from '@mui/icons-material/LabelOutlined';
import SimCardOutlinedIcon from '@mui/icons-material/SimCardOutlined';
import { Box, Collapse, IconButton, Menu, MenuItem, Tooltip, useTheme } from '@mui/material';
import TableViewOutlinedIcon from '@mui/icons-material/TableViewOutlined';
import {
Box,
Collapse,
Dialog,
DialogContent,
DialogTitle,
IconButton,
Menu,
MenuItem,
Tooltip,
useTheme
} from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import useClipboard from 'commons/components/utils/hooks/useClipboard';
import useALContext from 'components/hooks/useALContext';
Expand All @@ -16,7 +29,7 @@ import Heuristic from 'components/visual/Heuristic';
import SectionHighlight from 'components/visual/SectionHighlight';
import Tag from 'components/visual/Tag';
import Verdict from 'components/visual/Verdict';
import React, { useCallback, useMemo } from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { GraphBody } from './graph_body';
import { ImageBody } from './image_body';
Expand All @@ -34,6 +47,7 @@ import { URLBody } from './url_body';

const CLIPBOARD_ICON = <AssignmentOutlinedIcon style={{ marginRight: '16px' }} />;
const HEURISTIC_ICON = <SimCardOutlinedIcon style={{ marginRight: '16px' }} />;
const TABLE_ICON = <TableViewOutlinedIcon style={{ marginRight: '16px' }} />;
const TAGS_ICON = <LabelOutlinedIcon style={{ marginRight: '16px' }} />;
const ATTACK_ICON = (
<span
Expand Down Expand Up @@ -97,17 +111,19 @@ const WrappedResultSection: React.FC<Props> = ({
const { t } = useTranslation(['fileDetail']);
const classes = useStyles();
const theme = useTheme();
const [open, setOpen] = React.useState(!section.auto_collapse || printable);
const [render, setRender] = React.useState(!section.auto_collapse || printable);
const [showTags, setShowTags] = React.useState(false);
const [showHeur, setShowHeur] = React.useState(false);
const [showAttack, setShowAttack] = React.useState(false);
const { getKey, hasHighlightedKeys } = useHighlighter();
const { c12nDef } = useALContext();
const [state, setState] = React.useState(null);
const { copy } = useClipboard();
const { getKey, hasHighlightedKeys } = useHighlighter();
const { showSafeResults } = useSafeResults();

const [state, setState] = useState<{ mouseX: number; mouseY: number }>(null);
const [open, setOpen] = useState<boolean>(!section.auto_collapse || printable);
const [render, setRender] = useState<boolean>(!section.auto_collapse || printable);
const [showTags, setShowTags] = useState<boolean>(false);
const [showHeur, setShowHeur] = useState<boolean>(false);
const [showAttack, setShowAttack] = useState<boolean>(false);
const [showTable, setShowTable] = useState<boolean>(false);

const allTags = useMemo(() => {
const tagList = [];
if (!printable) {
Expand Down Expand Up @@ -207,6 +223,18 @@ const WrappedResultSection: React.FC<Props> = ({
{CLIPBOARD_ICON}
{t('clipboard')}
</MenuItem>
{section.body_format === 'TABLE' && (
<MenuItem
dense
onClick={() => {
setShowTable(true);
setState(null);
}}
>
{TABLE_ICON}
{t('table.menubutton')}
</MenuItem>
)}
{!highlighted && section.heuristic && (
<MenuItem
dense
Expand Down Expand Up @@ -243,6 +271,34 @@ const WrappedResultSection: React.FC<Props> = ({
)}
</Menu>
)}
{section.body_format !== 'TABLE' ? null : (
<Dialog
open={showTable}
aria-labelledby="result-table-dialog-title"
aria-describedby="result-table-dialog-description"
maxWidth="xl"
fullWidth
onClose={() => setShowTable(false)}
>
<div>
<IconButton
size="large"
style={{ float: 'right', padding: theme.spacing(2) }}
onClick={() => setShowTable(false)}
>
<CloseOutlinedIcon />
</IconButton>
<DialogTitle id="result-table-dialog-title">{t('table.title')}</DialogTitle>
<DialogContent>
<TblBody
body={section.body}
printable={printable}
order={section.body_config ? section.body_config.column_order : []}
/>
</DialogContent>
</div>
</Dialog>
)}
<div
style={{
display: 'flex',
Expand Down
5 changes: 3 additions & 2 deletions src/components/visual/ResultCard/table_body.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Theme } from '@mui/material';
import type { Theme } from '@mui/material';
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
import createStyles from '@mui/styles/createStyles';
import makeStyles from '@mui/styles/makeStyles';
import withStyles from '@mui/styles/withStyles';
import type { TableBody as TableData } from 'components/models/base/result_body';
import TitleKey from 'components/visual/TitleKey';
import { default as React } from 'react';
import TitleKey from '../TitleKey';
import { KVBody } from './kv_body';
import { TextBody } from './text_body';

Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/file/detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"show_tags": "Tags",
"size": "Size",
"supplementary": "Supplementary files",
"table.menubutton": "Expand the table",
"table.title": "Result Table",
"title": "File Details",
"type": "Type",
"uri_identification": "URI Identification",
Expand Down
2 changes: 2 additions & 0 deletions src/locales/fr/file/detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
"show_tags": "Étiquettes",
"size": "Taille",
"supplementary": "Fichiers supplémentaires",
"table.menubutton": "Agrandir le tableau",
"table.title": "Tableau des résultats",
"tags": "Tags",
"title": "Détails du fichier",
"type": "Type",
Expand Down