From a3cae51a6b70df833f8d00f9df61af78a9654e31 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 3 Dec 2019 10:53:25 +0200 Subject: [PATCH] CR improvements: /report/ redirect to /report/security, component renaming and other small fixes --- monkey/monkey_island/cc/ui/src/components/Main.js | 11 +++++++++-- .../{MatrixComponent.js => ConfigMatrixComponent.js} | 8 ++++---- .../cc/ui/src/components/pages/ConfigurePage.js | 10 +++++----- .../src/components/report-components/AttackReport.js | 12 ++++++------ .../{ReportMatrix.js => ReportMatrixComponent.js} | 10 +++++----- .../report-components/attack/SelectedTechnique.js | 2 +- .../report-components/common/ReportHeader.js | 2 +- .../cc/ui/src/styles/report/AttackReport.scss | 2 +- 8 files changed, 32 insertions(+), 25 deletions(-) rename monkey/monkey_island/cc/ui/src/components/attack/{MatrixComponent.js => ConfigMatrixComponent.js} (92%) rename monkey/monkey_island/cc/ui/src/components/report-components/attack/{ReportMatrix.js => ReportMatrixComponent.js} (90%) diff --git a/monkey/monkey_island/cc/ui/src/components/Main.js b/monkey/monkey_island/cc/ui/src/components/Main.js index fce10525d..cfba40fb7 100644 --- a/monkey/monkey_island/cc/ui/src/components/Main.js +++ b/monkey/monkey_island/cc/ui/src/components/Main.js @@ -1,5 +1,5 @@ import React from 'react'; -import {BrowserRouter as Router, NavLink, Redirect, Route, Switch} from 'react-router-dom'; +import {BrowserRouter as Router, NavLink, Redirect, Route, Switch, withRouter} from 'react-router-dom'; import {Col, Grid, Row} from 'react-bootstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faCheck, faUndo } from '@fortawesome/free-solid-svg-icons' @@ -83,6 +83,13 @@ class AppComponent extends AuthComponent { } }; + redirectTo = (userPath, targetPath) => { + let pathQuery = new RegExp(userPath+"[\/]?$", "g"); + if(window.location.pathname.match(pathQuery)){ + return + } + }; + constructor(props) { super(props); this.state = { @@ -198,12 +205,12 @@ class AppComponent extends AuthComponent { {this.renderRoute('/infection/map', )} {this.renderRoute('/infection/telemetry', )} {this.renderRoute('/start-over', )} + {this.redirectTo('/report', '/report/security')} {this.renderRoute('/report/security', )} {this.renderRoute('/report/attack', )} {this.renderRoute('/report/zeroTrust', )} - {this.renderRoute(reportZeroTrustRoute, )} {this.renderRoute('/license', )} diff --git a/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js b/monkey/monkey_island/cc/ui/src/components/attack/ConfigMatrixComponent.js similarity index 92% rename from monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js rename to monkey/monkey_island/cc/ui/src/components/attack/ConfigMatrixComponent.js index 42ee57aa4..d6fd2d12a 100644 --- a/monkey/monkey_island/cc/ui/src/components/attack/MatrixComponent.js +++ b/monkey/monkey_island/cc/ui/src/components/attack/ConfigMatrixComponent.js @@ -11,7 +11,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCircle as faCircle } from '@fortawesome/free-solid-svg-icons'; import { faCircle as faCircleThin } from '@fortawesome/free-regular-svg-icons'; -class MatrixComponent extends AuthComponent { +class ConfigMatrixComponent extends AuthComponent { constructor(props) { super(props); this.state = {lastAction: 'none'} @@ -81,8 +81,8 @@ class MatrixComponent extends AuthComponent { getTableData = (config) => { let configCopy = JSON.parse(JSON.stringify(config)); - let maxTechniques = MatrixComponent.findMaxTechniques(Object.values(configCopy)); - let matrixTableData = MatrixComponent.parseTechniques(Object.values(configCopy), maxTechniques); + let maxTechniques = ConfigMatrixComponent.findMaxTechniques(Object.values(configCopy)); + let matrixTableData = ConfigMatrixComponent.parseTechniques(Object.values(configCopy), maxTechniques); let columns = this.getColumns(matrixTableData); return {'columns': columns, 'matrixTableData': matrixTableData, 'maxTechniques': maxTechniques} }; @@ -120,4 +120,4 @@ class MatrixComponent extends AuthComponent { } } -export default MatrixComponent; +export default ConfigMatrixComponent; diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js index eff8f5d2f..6d9325487 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -5,7 +5,7 @@ import FileSaver from 'file-saver'; import AuthComponent from '../AuthComponent'; import {FilePond} from 'react-filepond'; import 'filepond/dist/filepond.min.css'; -import MatrixComponent from '../attack/MatrixComponent'; +import ConfigMatrixComponent from '../attack/ConfigMatrixComponent'; const ATTACK_URL = '/api/attack'; const CONFIG_URL = '/api/configuration/island'; @@ -450,10 +450,10 @@ class ConfigurePageComponent extends AuthComponent { } renderMatrix = () => { - return () + return () }; diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/AttackReport.js b/monkey/monkey_island/cc/ui/src/components/report-components/AttackReport.js index 0b4bd0860..71707d70b 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/AttackReport.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/AttackReport.js @@ -7,7 +7,7 @@ import { faCircle } from '@fortawesome/free-solid-svg-icons'; import ReportHeader, {ReportTypes} from './common/ReportHeader'; import {ScanStatus} from '../attack/techniques/Helpers'; -import Matrix from './attack/ReportMatrix'; +import Matrix from './attack/ReportMatrixComponent'; import SelectedTechnique from './attack/SelectedTechnique'; import TechniqueDropdowns from './attack/TechniqueDropdowns'; import ReportLoader from './common/ReportLoader'; @@ -46,7 +46,7 @@ class AttackReport extends React.Component { } } - onTechniqueSelect = (technique, value, mapped = false) => { + onTechniqueSelect = (technique, value) => { let selectedTechnique = this.getTechniqueByTitle(technique); if (selectedTechnique === false){ return; @@ -89,7 +89,7 @@ class AttackReport extends React.Component {

This report shows information about - + techniques used by Infection Monkey.

{this.renderLegend()} @@ -105,7 +105,7 @@ class AttackReport extends React.Component { } getTechniqueByTitle(title){ - for (let tech_id in this.state.techniques){ + for (const tech_id in this.state.techniques){ if (! this.state.techniques.hasOwnProperty(tech_id)) {return false;} let technique = this.state.techniques[tech_id]; if (technique.title === title){ @@ -118,10 +118,10 @@ class AttackReport extends React.Component { static addLinksToTechniques(schema, techniques){ schema = schema.properties; - for(let type in schema){ + for(const type in schema){ if (! schema.hasOwnProperty(type)) {return false;} let typeTechniques = schema[type].properties; - for(let tech_id in typeTechniques){ + for(const tech_id in typeTechniques){ if (! typeTechniques.hasOwnProperty(tech_id)) {return false;} if (typeTechniques[tech_id] !== undefined){ techniques[tech_id]['link'] = typeTechniques[tech_id].link diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrix.js b/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js similarity index 90% rename from monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrix.js rename to monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js index 559262790..9be5d5f0b 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrix.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js @@ -5,7 +5,7 @@ import ReactTable from 'react-table'; import 'filepond/dist/filepond.min.css'; import '../../../styles/report/ReportAttackMatrix.scss'; -class MatrixComponent extends React.Component { +class ReportMatrixComponent extends React.Component { constructor(props) { super(props); this.state = {techniques: this.props.techniques, @@ -14,7 +14,7 @@ class MatrixComponent extends React.Component { getColumns() { let columns = []; - for(let type_key in this.state.schema.properties){ + for(const type_key in this.state.schema.properties){ if (! this.state.schema.properties.hasOwnProperty(type_key)){ continue; } @@ -31,11 +31,11 @@ class MatrixComponent extends React.Component { getTableRows() { let rows = []; - for (let tech_id in this.state.techniques) { + for (const tech_id in this.state.techniques) { if (this.state.techniques.hasOwnProperty(tech_id)){ let technique_added = false; let technique = this.state.techniques[tech_id]; - for(let row of rows){ + for(const row of rows){ if (! row.hasOwnProperty(technique.type)){ row[technique.type] = technique; technique_added = true; @@ -81,4 +81,4 @@ class MatrixComponent extends React.Component { } } -export default MatrixComponent; +export default ReportMatrixComponent; diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/attack/SelectedTechnique.js b/monkey/monkey_island/cc/ui/src/components/report-components/attack/SelectedTechnique.js index 0af502682..10c448e99 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/attack/SelectedTechnique.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/attack/SelectedTechnique.js @@ -62,7 +62,7 @@ class SelectedTechnique extends React.Component { return (
-

Selected technique:

+

Selected technique

{content}
diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js b/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js index 5c86b5c26..39efc0a01 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/common/ReportHeader.js @@ -7,7 +7,7 @@ let monkeyLogoImage = require('../../../images/monkey-icon.svg'); export const ReportTypes = { zeroTrust: 'Zero Trust', security: 'Security', - attack: 'Attack', + attack: 'ATT&CK', null: '' }; diff --git a/monkey/monkey_island/cc/ui/src/styles/report/AttackReport.scss b/monkey/monkey_island/cc/ui/src/styles/report/AttackReport.scss index 2618f4ed8..39ac8b59c 100644 --- a/monkey/monkey_island/cc/ui/src/styles/report/AttackReport.scss +++ b/monkey/monkey_island/cc/ui/src/styles/report/AttackReport.scss @@ -42,5 +42,5 @@ } .attack-link{ - padding: 6px 10px !important; + padding: 0 7px 3px 7px !important; }