forked from p15670423/monkey
Merge pull request #1317 from guardicore/ransomware_table_ui
Ransomware table UI
This commit is contained in:
commit
8977040d98
|
@ -3,8 +3,12 @@ import React from 'react';
|
||||||
import ReportHeader, {ReportTypes} from './common/ReportHeader';
|
import ReportHeader, {ReportTypes} from './common/ReportHeader';
|
||||||
import ReportLoader from './common/ReportLoader';
|
import ReportLoader from './common/ReportLoader';
|
||||||
import pluralize from 'pluralize'
|
import pluralize from 'pluralize'
|
||||||
|
import FileEncryptionTable from './ransomware/FileEncryptionTable';
|
||||||
|
|
||||||
|
import '../../styles/pages/report/RansomwareReport.scss';
|
||||||
|
|
||||||
class RansomwareReport extends React.Component {
|
class RansomwareReport extends React.Component {
|
||||||
|
|
||||||
stillLoadingDataFromServer() {
|
stillLoadingDataFromServer() {
|
||||||
return Object.keys(this.props.report).length === 0;
|
return Object.keys(this.props.report).length === 0;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +17,7 @@ class RansomwareReport extends React.Component {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{this.getExploitationStats()}
|
{this.getExploitationStats()}
|
||||||
|
<FileEncryptionTable tableData={this.props.report.encrypted_files_table} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -20,9 +25,9 @@ class RansomwareReport extends React.Component {
|
||||||
getExploitationStats() {
|
getExploitationStats() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<h2>
|
<h3 className={'report-section-header'}>
|
||||||
Propagation
|
Propagation
|
||||||
</h2>
|
</h3>
|
||||||
{this.getScannedVsExploitedStats()}
|
{this.getScannedVsExploitedStats()}
|
||||||
{this.getExploitationStatsPerExploit()}
|
{this.getExploitationStatsPerExploit()}
|
||||||
</div>
|
</div>
|
||||||
|
@ -69,7 +74,7 @@ class RansomwareReport extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='report-page'>
|
<div className={`report-page ransomware-report`}>
|
||||||
<ReportHeader report_type={ReportTypes.ransomware}/>
|
<ReportHeader report_type={ReportTypes.ransomware}/>
|
||||||
<hr/>
|
<hr/>
|
||||||
{content}
|
{content}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
import React from 'react';
|
||||||
|
import ReactTable from 'react-table';
|
||||||
|
import {renderArray} from '../common/RenderArrays';
|
||||||
|
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
tableData: [TableRow]
|
||||||
|
}
|
||||||
|
|
||||||
|
type TableRow = {
|
||||||
|
exploits: [string],
|
||||||
|
total_attempts: number,
|
||||||
|
successful_encryptions: number,
|
||||||
|
hostname: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const pageSize = 10;
|
||||||
|
|
||||||
|
|
||||||
|
const FileEncryptionTable = (props: Props) => {
|
||||||
|
let defaultPageSize = props.tableData.length > pageSize ? pageSize : props.tableData.length;
|
||||||
|
let showPagination = props.tableData.length > pageSize;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h3 className={'report-section-header'}>
|
||||||
|
File encryption
|
||||||
|
</h3>
|
||||||
|
<div className="data-table-container">
|
||||||
|
<ReactTable
|
||||||
|
columns={columns}
|
||||||
|
data={props.tableData}
|
||||||
|
showPagination={showPagination}
|
||||||
|
defaultPageSize={defaultPageSize}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const columns = [
|
||||||
|
{
|
||||||
|
Header: 'Ransomware info',
|
||||||
|
columns: [
|
||||||
|
{Header: 'Machine', id: 'machine', accessor: x => x.hostname},
|
||||||
|
{Header: 'Exploits', id: 'exploits', accessor: x => renderArray(x.exploits)},
|
||||||
|
{Header: 'Files encrypted',
|
||||||
|
id: 'files_encrypted',
|
||||||
|
accessor: x => renderFileEncryptionStats(x.successful_encryptions, x.total_attempts)}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
function renderFileEncryptionStats(successful: number, total: number) {
|
||||||
|
let textClassName = ''
|
||||||
|
|
||||||
|
if(successful > 0) {
|
||||||
|
if (successful === total) {
|
||||||
|
textClassName = 'text-danger'
|
||||||
|
} else {
|
||||||
|
textClassName = 'text-warning'
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
textClassName = 'text-success'
|
||||||
|
}
|
||||||
|
|
||||||
|
return (<p className={textClassName}>{successful} out of {total}</p>);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export default FileEncryptionTable;
|
|
@ -0,0 +1,3 @@
|
||||||
|
.ransomware-report .report-section-header {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
Loading…
Reference in New Issue