Skip to content

Commit a72da60

Browse files
committed
Modal, Scan, Display working
1 parent 880d0aa commit a72da60

12 files changed

+370
-191
lines changed

package-lock.json

+43-54
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/assets.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.gif' {
2+
const src: string;
3+
export default src;
4+
}

src/assets/pngwing.com (1).png

88.8 KB
Loading

src/extension.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,9 @@ export function activate(context: vscode.ExtensionContext) {
150150
break;
151151
}
152152
case 'runVirusTotalScan': {
153-
const {value: apiKey, extensionName,
154-
// setModalOpen
155-
} = message;
156-
console.log('In ext.ts in the runVirusTOtalScan didRecieveMessage and this shoudl be the apikey and ext name: ' + apiKey + ' name: ' + extensionName)
157-
158-
virusTotalScan(apiKey, extensionName, panel
159-
// , setModalOpen
160-
);
153+
const {value: apiKey, extensionName } = message;
154+
console.log('In ext.ts in the runVirusTOtalScan didRecieveMessage and this shoudl be the apikey and ext name: ' + apiKey + ' name: ' + extensionName);
155+
virusTotalScan(apiKey, extensionName, panel);
161156
break;
162157
}
163158
case 'vtResultsTimedOut': {
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,98 @@
1-
// import { Typography } from "@mui/material";
2-
// import React from "react";
1+
import * as React from 'react';
2+
import Box from '@mui/material/Box';
3+
import Collapse from '@mui/material/Collapse';
4+
import IconButton from '@mui/material/IconButton';
5+
import Table from '@mui/material/Table';
6+
import TableBody from '@mui/material/TableBody';
7+
import TableCell from '@mui/material/TableCell';
8+
import TableContainer from '@mui/material/TableContainer';
9+
import TableHead from '@mui/material/TableHead';
10+
import TableRow from '@mui/material/TableRow';
11+
import Typography from '@mui/material/Typography';
12+
import Paper from '@mui/material/Paper';
13+
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
14+
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
15+
import CircularProgress from '@mui/material/CircularProgress';
316

17+
function createRow(file: any, name: string, i: number) {
18+
const [open, setOpen] = React.useState(false);
19+
const inLoading = file?.stats?.malicious === undefined;
20+
const mali = inLoading ? <CircularProgress sx={{color:'#b3b3b5', size: '25'}} /> : file?.stats?.malicious ?? 0;
21+
22+
return (
23+
<React.Fragment key={i}>
24+
<TableRow sx={{borderBottom: 'none', paddingBottom: '2px'}}>
25+
<TableCell sx={{color: '#97D8C4', fontSize: '16px', borderBottom: 'none', paddingBottom: '3px'}} >{name}</TableCell>
26+
<TableCell align='left' sx={{color: file?.status === 'completed' ? '#97D8C4' : '#b3b3b5', borderBottom: 'none', paddingBottom: '3px',marginBottom: 'none', fontSize: '14px'}} >{file?.status || 'Scanning...'}</TableCell>
27+
<TableCell align='left' sx={{color: mali > 0 ? '#F56960' : '#97D8C4' , borderBottom: 'none', paddingBottom: '3px', width: 'auto', fontSize: '14px'}} >{mali}</TableCell>
28+
<TableCell sx={{borderBottom: 'none', paddingBottom: '3px'}}>
29+
{/* perhaps this below can be conditional if I find any errors. */}
30+
<IconButton onClick={() => setOpen(!open)}>
31+
{open ? <KeyboardArrowUpIcon sx={{color: '#b3b3b5'}} /> : <KeyboardArrowDownIcon sx={{color: mali > 0 ? '#F56960' : '#b3b3b5'}} />}
32+
</IconButton>
33+
</TableCell>
34+
</TableRow>
35+
<TableRow>
36+
<TableCell colSpan={3} sx={{
37+
// bgcolor: 'purple',
38+
height: open ? 'auto' : '0',
39+
padding: open ? '8px' : '0',
40+
paddingTop: '0',
41+
marginTop: '0',
42+
borderBottom: 'none',
43+
overflow: 'hidden',
44+
transition: 'height 0.3s ease, padding 0.3s ease',
45+
}}>
46+
<Collapse in={open} sx={{
47+
margin: '0',
48+
borderBottom: 'none',
49+
// bgcolor: 'purple',
50+
padding: '1px',
51+
}}>
52+
{file?.stats?.malicious > 0 ? (
53+
Object.entries(file.results).filter(([key, scan]:[string, any], index: number) =>
54+
scan.category === 'malicious').map(([key, scan]:[string, any], index) => {
55+
return <Box key={index}><strong>{scan.engine_name}</strong> found {scan.category}: {scan.result}</Box>;
56+
})
57+
) : (
58+
<Typography sx={{color: '#b3b3b5', fontSize: '14px', marginTop: 'none', paddingLeft: '20px', paddingTop: '0px'}}>No threats found</Typography>
59+
)}
60+
</Collapse>
61+
</TableCell>
62+
</TableRow>
63+
</React.Fragment>
64+
);
65+
}
66+
export default function VirusTotalResults(props: any) {
67+
const { VTResults, keyError } = props;
68+
console.log('these are the VTResults in virus total results: ', VTResults);
69+
70+
if (!VTResults || Object.keys(VTResults).length === 0 || keyError === true) {
71+
return null;
72+
} else if (VTResults) {
73+
return (
74+
<TableContainer component={Paper} sx={{bgcolor: '#3D3D3D'}} >
75+
<Table aria-label="collapsible table" sx={{
76+
// '& .MuiTableRow-root': { height: '36px', margin: '0px'},
77+
// '& .MuiTableCell-root': { padding: '0px 4px', margin: '0px' },
78+
}}>
79+
<TableHead>
80+
<TableRow >
81+
{/* <TableCell /> */}
82+
<TableCell sx={{color: '#97D8C4', fontWeight: 'bold', fontSize: '20px'}}>File Name</TableCell>
83+
<TableCell sx={{color: '#97D8C4', fontWeight: 'bold', marginTop: '0px', fontSize: '20px'}} align="left">Status</TableCell>
84+
<TableCell sx={{color: '#97D8C4', fontWeight: 'bold', fontSize: '20px'}} align="left">Potential Threats Found</TableCell>
85+
{/* <TableCell align="right">Carbs&nbsp;(g)</TableCell>
86+
<TableCell align="right">Protein&nbsp;(g)</TableCell> */}
87+
</TableRow>
88+
</TableHead>
89+
<TableBody >
90+
{ Object.keys(VTResults).map((key, i)=> {
91+
return createRow(VTResults[key], key, i);
92+
})}
93+
</TableBody>
94+
</Table>
95+
</TableContainer>
96+
);
97+
}
98+
}

src/panel/components/tabContext.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Button } from '@mui/material';
1313

1414
export default function TabContextDiv(props: any) {
1515
const [value, setValue] = useState<number>(0);
16-
const { displayNames, patternMatchPanelState, telemetryPanelState, readMe, virusTotal, setVirusTotal } =
16+
const { displayNames, patternMatchPanelState, telemetryPanelState, readMe} =
1717
props;
1818

1919
return (
@@ -33,8 +33,6 @@ export default function TabContextDiv(props: any) {
3333
patternMatchPanelState={patternMatchPanelState}
3434
telemetryPanelState={telemetryPanelState}
3535
//////////////////add virus total state
36-
virsuTotal={virusTotal} /////<----'
37-
setVirusTotal={setVirusTotal}
3836
readMe={readMe}
3937
/>
4038
</TabContext>

0 commit comments

Comments
 (0)