Merge remote-tracking branch 'upstream/feature/configuration_improvement' into feature/configuration_improvements

# Conflicts:
#	monkey/monkey_island/cc/ui/src/components/configuration-components/ValidationFormats.js
This commit is contained in:
VakarisZ 2020-07-27 16:50:19 +03:00
commit fd1d3404e7
38 changed files with 77 additions and 57 deletions

View File

@ -83,7 +83,7 @@ script:
- cd monkey_island/cc/ui
- npm ci # See https://docs.npmjs.com/cli/ci.html
- eslint ./src --quiet # Test for errors
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=70
- JS_WARNINGS_AMOUNT_UPPER_LIMIT=25
- eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # Test for max warnings
# Build documentation

View File

@ -10,7 +10,6 @@ import monkey_island.cc.services.post_breach_files
from monkey_island.cc.database import mongo
from monkey_island.cc.encryptor import encryptor
from monkey_island.cc.network_utils import local_ip_addresses
from monkey_island.cc.services.config_schema.config_schema import SCHEMA
__author__ = "itay.mizeretz"

View File

@ -1,8 +1,11 @@
from monkey_island.cc.services.config_schema.basic import BASIC
from monkey_island.cc.services.config_schema.basic_network import BASIC_NETWORK
from monkey_island.cc.services.config_schema.definitions.exploiter_classes import EXPLOITER_CLASSES
from monkey_island.cc.services.config_schema.definitions.finger_classes import FINGER_CLASSES
from monkey_island.cc.services.config_schema.definitions.post_breach_actions import POST_BREACH_ACTIONS
from monkey_island.cc.services.config_schema.definitions.exploiter_classes import \
EXPLOITER_CLASSES
from monkey_island.cc.services.config_schema.definitions.finger_classes import \
FINGER_CLASSES
from monkey_island.cc.services.config_schema.definitions.post_breach_actions import \
POST_BREACH_ACTIONS
from monkey_island.cc.services.config_schema.definitions.system_info_collector_classes import \
SYSTEM_INFO_COLLECTOR_CLASSES
from monkey_island.cc.services.config_schema.internal import INTERNAL

View File

@ -1,9 +1,9 @@
from common.data.system_info_collectors_names import (AWS_COLLECTOR,
AZURE_CRED_COLLECTOR,
ENVIRONMENT_COLLECTOR,
HOSTNAME_COLLECTOR,
PROCESS_LIST_COLLECTOR,
MIMIKATZ_COLLECTOR,
AZURE_CRED_COLLECTOR)
PROCESS_LIST_COLLECTOR)
SYSTEM_INFO_COLLECTOR_CLASSES = {
"title": "System Information Collectors",

View File

@ -1,7 +1,9 @@
from common.data.system_info_collectors_names import (AWS_COLLECTOR,
AZURE_CRED_COLLECTOR,
ENVIRONMENT_COLLECTOR,
HOSTNAME_COLLECTOR,
PROCESS_LIST_COLLECTOR, MIMIKATZ_COLLECTOR, AZURE_CRED_COLLECTOR)
MIMIKATZ_COLLECTOR,
PROCESS_LIST_COLLECTOR)
MONKEY = {
"title": "Monkey",

View File

@ -41,7 +41,7 @@
"global-strict": 0,
"no-underscore-dangle": 0,
"no-console": 0,
"no-unused-vars": 1,
"no-unused-vars": [1, {"vars": "all", "args": "all", "argsIgnorePattern": "^_", "varsIgnorePattern": "^React$" }],
"no-trailing-spaces": [
1,
{

View File

@ -97,7 +97,7 @@ class AppComponent extends AuthComponent {
};
redirectTo = (userPath, targetPath) => {
let pathQuery = new RegExp(userPath + '[\/]?$', 'g');
let pathQuery = new RegExp(userPath + '[/]?$', 'g');
if (window.location.pathname.match(pathQuery)) {
return <Redirect to={{pathname: targetPath}}/>
}

View File

@ -49,7 +49,7 @@ class SideNavComponent extends React.Component {
</li>
<li>
<NavLink to='/report/security'
isActive={(match, location) => {
isActive={(_match, location) => {
return (location.pathname === '/report/attack'
|| location.pathname === '/report/zeroTrust'
|| location.pathname === '/report/security')

View File

@ -1,7 +1,7 @@
import React from 'react';
import ReactTable from 'react-table';
import {renderMachineFromSystemData, ScanStatus} from './Helpers';
import MitigationsComponent from "./MitigationsComponent";
import MitigationsComponent from './MitigationsComponent';
class T1136 extends React.Component {

View File

@ -2,8 +2,18 @@ import Form from 'react-jsonschema-form-bs4';
import React, {useState} from 'react';
import {Nav} from 'react-bootstrap';
const sectionOrder = ['network', 'monkey', 'island_server', 'logging', 'exploits', 'dropper', 'classes', 'general',
'kill_file', 'testing'];
const sectionOrder = [
'network',
'monkey',
'island_server',
'logging',
'exploits',
'dropper',
'classes',
'general',
'kill_file',
'testing'
];
const initialSection = sectionOrder[0];
export default function InternalConfig(props) {
@ -38,7 +48,7 @@ export default function InternalConfig(props) {
className={'config-nav'}>
{sectionOrder.map(section => {
return (
<Nav.Item>
<Nav.Item key={section}>
<Nav.Link eventKey={section}>{getNavTitle(schema, section)}</Nav.Link>
</Nav.Item>);
})}

View File

@ -23,8 +23,8 @@ class PbaInput extends AuthComponent {
};
}
componentDidUpdate(prevProps, prevState, snapshot) {
if(prevProps.options.filename !== this.props.options.filename && this.props.options.filename === ""){
componentDidUpdate(prevProps, _prevState, _snapshot) {
if(prevProps.options.filename !== this.props.options.filename && this.props.options.filename === ''){
this.setState({filename: this.props.options.filename})
}
}
@ -68,7 +68,7 @@ class PbaInput extends AuthComponent {
if (fileItems.length > 0) {
this.state.setPbaFilename(fileItems[0].file.name)
} else {
this.state.setPbaFilename("")
this.state.setPbaFilename('')
}
}}
/>)

View File

@ -11,7 +11,6 @@ export const formValidationFormats = {
};
function buildIpRangeRegex(){
console.log(formValidationFormats);
return new RegExp([
'^'+ipRegex+'$|', // Single: IP
'^'+ipRegex+'-'+ipRegex+'$|', // IP range: IP-IP

View File

@ -101,9 +101,9 @@ class PreviewPaneComponent extends AuthComponent {
.replace(/\\t/g, '\t')
.replace(/\\b/g, '\b')
.replace(/\\f/g, '\f')
.replace(/\\"/g, '\"')
.replace(/\\"/g, '"')
.replace(/\\'/g, '\'')
.replace(/\\&/g, '\&');
.replace(/\\&/g, '&');
}
downloadLog(asset) {

View File

@ -34,7 +34,7 @@ class ConfigurePageComponent extends AuthComponent {
lastAction: 'none',
sections: [],
selectedSection: 'attack',
showAttackAlert: false,
showAttackAlert: false
};
}
@ -384,7 +384,7 @@ class ConfigurePageComponent extends AuthComponent {
{this.state.sections.map(section => {
let classProp = section.key.startsWith('basic') ? 'tab-primary' : '';
return (
<Nav.Item>
<Nav.Item key={section.key}>
<Nav.Link className={classProp} eventKey={section.key}>{section.title}</Nav.Link>
</Nav.Item>);
})}

View File

@ -1,8 +1,8 @@
import React from 'react';
import {Col} from 'react-bootstrap';
import rainge from 'rainge';
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faCopyright} from "@fortawesome/free-regular-svg-icons";
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faCopyright} from '@fortawesome/free-regular-svg-icons';
class LicensePageComponent extends React.Component {
constructor(props) {

View File

@ -2,9 +2,9 @@ import React from 'react';
import {Button, Col, Container, Form, Row} from 'react-bootstrap';
import AuthService from '../../services/AuthService';
import Particles from "react-particles-js";
import {particleParams} from "../../styles/components/particle-component/AuthPageParams";
import monkeyGeneral from "../../images/militant-monkey.svg";
import Particles from 'react-particles-js';
import {particleParams} from '../../styles/components/particle-component/AuthPageParams';
import monkeyGeneral from '../../images/militant-monkey.svg';
class LoginPageComponent extends React.Component {
login = (event) => {

View File

@ -9,7 +9,7 @@ import {ReactiveGraph} from 'components/reactive-graph/ReactiveGraph';
import {getOptions, edgeGroupToColor} from 'components/map/MapOptions';
import AuthComponent from '../AuthComponent';
import '../../styles/components/Map.scss';
import {faInfoCircle} from "@fortawesome/free-solid-svg-icons/faInfoCircle";
import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle';
class MapPageComponent extends AuthComponent {
constructor(props) {

View File

@ -8,8 +8,8 @@ import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faClipboard} from '@fortawesome/free-solid-svg-icons/faClipboard';
import {faCheck} from '@fortawesome/free-solid-svg-icons/faCheck';
import {faSync} from '@fortawesome/free-solid-svg-icons/faSync';
import {faInfoCircle} from "@fortawesome/free-solid-svg-icons/faInfoCircle";
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle';
import {faExclamationTriangle} from '@fortawesome/free-solid-svg-icons/faExclamationTriangle';
import {Link} from 'react-router-dom';
import AuthComponent from '../AuthComponent';

View File

@ -5,8 +5,8 @@ import AuthComponent from '../AuthComponent';
import StartOverModal from '../ui-components/StartOverModal';
import '../../styles/pages/StartOverPage.scss';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faInfoCircle} from "@fortawesome/free-solid-svg-icons/faInfoCircle";
import {faCheck} from "@fortawesome/free-solid-svg-icons/faCheck";
import {faInfoCircle} from '@fortawesome/free-solid-svg-icons/faInfoCircle';
import {faCheck} from '@fortawesome/free-solid-svg-icons/faCheck';
class StartOverPageComponent extends AuthComponent {
constructor(props) {

View File

@ -7,7 +7,7 @@ import download from 'downloadjs';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import '../../styles/pages/TelemetryPage.scss';
import {faDownload} from "@fortawesome/free-solid-svg-icons/faDownload";
import {faDownload} from '@fortawesome/free-solid-svg-icons/faDownload';
const renderJson = (val) => <JSONTree data={val} level={1} theme="eighties" invertTheme={true}/>;
const renderTime = (val) => val.split('.')[0];

View File

@ -48,7 +48,7 @@ class AttackReport extends React.Component {
}
}
onTechniqueSelect = (technique, value) => {
onTechniqueSelect = (technique, _) => {
let selectedTechnique = this.getTechniqueByTitle(technique);
if (selectedTechnique === false){
return;

View File

@ -473,7 +473,7 @@ class ReportPageComponent extends AuthComponent {
}
generateShellshockPathListBadges(paths) {
return paths.map(path => <span className="badge badge-warning" style={{margin: '2px'}}>{path}</span>);
return paths.map(path => <span className="badge badge-warning" style={{margin: '2px'}} key={path}>{path}</span>);
}
generateSmbPasswordIssue(issue) {

View File

@ -1,7 +1,7 @@
import React, {Component} from 'react';
import * as PropTypes from 'prop-types';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
import {faExclamationTriangle} from '@fortawesome/free-solid-svg-icons/faExclamationTriangle';
export default class MonkeysStillAliveWarning extends Component {
render() {

View File

@ -1,7 +1,7 @@
import React, {Component} from 'react';
import {NavLink} from 'react-router-dom';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faExclamationTriangle} from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
import {faExclamationTriangle} from '@fortawesome/free-solid-svg-icons/faExclamationTriangle';
export default class MustRunMonkeyWarning extends Component {
render() {

View File

@ -7,7 +7,7 @@ import { faPrint } from '@fortawesome/free-solid-svg-icons/faPrint';
export default class PrintReportButton extends Component {
render() {
return <div className="text-center no-print">
<Button size="md" variant={"outline-standard"} onClick={this.props.onClick}>
<Button size="md" variant={'outline-standard'} onClick={this.props.onClick}>
<FontAwesomeIcon icon={faPrint}/> Print
Report</Button>
</div>

View File

@ -1,4 +1,4 @@
import React from "react";
import React from 'react';
export let renderArray = function (val) {
return <>{val.map(x => <div key={x}>{x}</div>)}</>;

View File

@ -1,7 +1,7 @@
import React from 'react';
import ReactTable from 'react-table';
import Pluralize from 'pluralize';
import {renderArray, renderIpAddresses} from "../common/RenderArrays";
import {renderArray, renderIpAddresses} from '../common/RenderArrays';
const columns = [

View File

@ -1,7 +1,7 @@
import React from 'react';
import ReactTable from 'react-table';
import Pluralize from 'pluralize';
import {renderIpAddresses} from "../common/RenderArrays";
import {renderIpAddresses} from '../common/RenderArrays';
let renderMachine = function (data) {
return <div>{data.label} ( {renderIpAddresses(data)} )</div>
@ -56,7 +56,7 @@ class PostBreachComponent extends React.Component {
});
let defaultPageSize = pbaMachines.length > pageSize ? pageSize : pbaMachines.length;
let showPagination = pbaMachines > pageSize;
const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine["pba_results"].length, 0);
const pbaCount = pbaMachines.reduce((accumulated, pbaMachine) => accumulated+pbaMachine['pba_results'].length, 0);
return (
<>
<p>

View File

@ -1,7 +1,7 @@
import React from 'react';
import ReactTable from 'react-table';
import Pluralize from 'pluralize';
import {renderArray, renderIpAddresses} from "../common/RenderArrays";
import {renderArray, renderIpAddresses} from '../common/RenderArrays';
const columns = [
@ -32,7 +32,7 @@ class ScannedServersComponent extends React.Component {
let showPagination = this.props.data.length > pageSize;
const scannedMachinesCount = this.props.data.length;
const reducerFromScannedServerToServicesAmount = (accumulated, scannedServer) => accumulated + scannedServer["services"].length;
const reducerFromScannedServerToServicesAmount = (accumulated, scannedServer) => accumulated + scannedServer['services'].length;
const scannedServicesAmount = this.props.data.reduce(reducerFromScannedServerToServicesAmount, 0);
return (

View File

@ -1,6 +1,6 @@
import React from 'react';
import ReactTable from 'react-table'
import {renderArray} from "../common/RenderArrays";
import {renderArray} from '../common/RenderArrays';
const columns = [

View File

@ -18,11 +18,13 @@ const columns = [
{
Header: 'Events', id: 'events',
accessor: x => {
return <EventsButton finding_id={x.finding_id}
const comp = <EventsButton finding_id={x.finding_id}
latest_events={x.latest_events}
oldest_events={x.oldest_events}
event_count={x.event_count}
exportFilename={'Events_' + x.test_key} />;
comp.displayName = 'EventsButton_' + x.finding_id;
return comp;
},
maxWidth: EVENTS_COLUMN_MAX_WIDTH
},
@ -34,7 +36,9 @@ const columns = [
const pillarLabels = pillars.map((pillar) =>
<PillarLabel key={pillar.name} pillar={pillar.name} status={pillar.status}/>
);
return <div style={{textAlign: 'center'}}>{pillarLabels}</div>;
const comp = <div style={{textAlign: 'center'}}>{pillarLabels}</div>;
comp.displayName = 'PillarsLabels';
return comp;
},
maxWidth: PILLARS_COLUMN_MAX_WIDTH,
style: {'whiteSpace': 'unset'}

View File

@ -13,7 +13,9 @@ const columns = [
{
Header: 'Status', id: 'status',
accessor: x => {
return <StatusLabel status={x.status} size="3x" showText={false}/>;
const comp = <StatusLabel status={x.status} size="3x" showText={false}/>;
comp.displayName = 'StatusLabel';
return comp;
},
maxWidth: MAX_WIDTH_STATUS_COLUMN
},
@ -25,7 +27,9 @@ const columns = [
Header: 'Monkey Tests', id: 'tests',
style: {'whiteSpace': 'unset'}, // This enables word wrap
accessor: x => {
return <TestsStatus tests={x.tests}/>;
const comp = <TestsStatus tests={x.tests}/>;
comp.displayName = 'TestsStatus';
return comp;
}
}
]

View File

@ -14,7 +14,7 @@ class ZeroTrustReportLegend extends Component {
super(props, context);
this.state = {
open: false,
open: false
};
}

View File

@ -15,7 +15,7 @@ export default class SinglePillarPrinciplesStatus extends AuthComponent {
super(props, context);
this.state = {
open: false,
open: false
};
}

View File

@ -149,7 +149,7 @@ class VennDiagram extends React.Component {
} else {
// Return z indices to default
Object.keys(this.layout).forEach(function (d_, i_) {
Object.keys(this.layout).forEach(function (_d, i_) {
document.querySelector('#' + self.prefix).appendChild(document.querySelector('#' + self.prefix + 'Node_' + i_).parentNode);
})
}

View File

@ -67,7 +67,7 @@ class AwsRunTableComponent extends React.Component {
this.setState({selectAll, selection});
};
getTrProps = (s, r) => {
getTrProps = (_, r) => {
let color = 'inherit';
if (r) {
let instId = r.original.instance_id;

View File

@ -1,7 +1,7 @@
import {Card, Button} from 'react-bootstrap';
import React from 'react';
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faQuestionCircle} from "@fortawesome/free-solid-svg-icons";
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faQuestionCircle} from '@fortawesome/free-solid-svg-icons';
function InfoPane(props) {

View File

@ -1,6 +1,5 @@
import {Modal} from 'react-bootstrap';
import React from 'react';
import {GridLoader} from 'react-spinners';
class MissingBinariesModal extends React.PureComponent {