diff --git a/.travis.yml b/.travis.yml index 8586aaf38..fcd9fc36b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,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=28 +- JS_WARNINGS_AMOUNT_UPPER_LIMIT=4 - eslint ./src --max-warnings $JS_WARNINGS_AMOUNT_UPPER_LIMIT # Test for max warnings # Build documentation diff --git a/monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js b/monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js index 27800cb97..9007194b0 100644 --- a/monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js +++ b/monkey/monkey_island/cc/ui/src/components/map/preview-pane/PreviewPane.js @@ -274,9 +274,9 @@ class PreviewPaneComponent extends AuthComponent { let label = ''; if (!this.props.item) { label = ''; - } else if (this.props.item.hasOwnProperty('label')) { + } else if (Object.prototype.hasOwnProperty.call(this.props.item, 'label')) { label = this.props.item['label']; - } else if (this.props.item.hasOwnProperty('_label')) { + } else if (Object.prototype.hasOwnProperty.call(this.props.item, '_label')) { label = this.props.item['_label']; } 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 f3b3e190c..426e66c0a 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ConfigurePage.js @@ -140,7 +140,7 @@ class ConfigurePageComponent extends AuthComponent { // Change value in attack configuration // Go trough each column in matrix, searching for technique Object.entries(this.state.attackConfig).forEach(techType => { - if (techType[1].properties.hasOwnProperty(technique)) { + if (Object.prototype.hasOwnProperty.call(techType[1].properties, technique)) { let tempMatrix = this.state.attackConfig; tempMatrix[techType[0]].properties[technique].value = value; this.setState({attackConfig: tempMatrix}); @@ -151,7 +151,8 @@ class ConfigurePageComponent extends AuthComponent { Object.entries(this.state.attackConfig).forEach(otherType => { Object.entries(otherType[1].properties).forEach(otherTech => { // If this technique depends on a technique that was changed - if (otherTech[1].hasOwnProperty('depends_on') && otherTech[1]['depends_on'].includes(technique)) { + if (Object.prototype.hasOwnProperty.call(otherTech[1], 'depends_on') && + otherTech[1]['depends_on'].includes(technique)) { this.attackTechniqueChange(otherTech[0], value, true) } }) @@ -393,7 +394,7 @@ class ConfigurePageComponent extends AuthComponent { render() { let displayedSchema = {}; - if (this.state.schema.hasOwnProperty('properties') && this.state.selectedSection !== 'attack') { + if (Object.prototype.hasOwnProperty.call(this.state.schema, 'properties') && this.state.selectedSection !== 'attack') { displayedSchema = this.state.schema['properties'][this.state.selectedSection]; displayedSchema['definitions'] = this.state.schema['definitions']; } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js b/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js index cf082f5b3..da11c7ed6 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/MapPage.js @@ -64,7 +64,7 @@ class MapPageComponent extends AuthComponent { this.authFetch('/api/netmap') .then(res => res.json()) .then(res => { - if (res.hasOwnProperty('edges')) { + if (Object.prototype.hasOwnProperty.call(res, 'edges')) { res.edges.forEach(edge => { edge.color = {'color': edgeGroupToColor(edge.group)}; }); diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RegisterPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RegisterPage.js index 657e8645a..3b8188221 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RegisterPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RegisterPage.js @@ -3,7 +3,7 @@ import {Row, Col, Container, Form, Button} from 'react-bootstrap'; import AuthService from '../../services/AuthService'; import monkeyDetective from '../../images/detective-monkey.svg'; -import ParticleBackground from "../ui-components/ParticleBackground"; +import ParticleBackground from '../ui-components/ParticleBackground'; class RegisterPageComponent extends React.Component { diff --git a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js index 5329cfe06..cb30ba117 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/ReportPage.js @@ -31,7 +31,7 @@ class ReportPageComponent extends AuthComponent { static selectReport(reports) { let url = window.location.href; for (let report_name in reports) { - if (reports.hasOwnProperty(report_name) && url.endsWith(reports[report_name])) { + if (Object.prototype.hasOwnProperty.call(reports, report_name) && url.endsWith(reports[report_name])) { return reports[report_name]; } } diff --git a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js index 48a11f008..467812373 100644 --- a/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js +++ b/monkey/monkey_island/cc/ui/src/components/pages/RunMonkeyPage.js @@ -229,7 +229,7 @@ class RunMonkeyPageComponent extends AuthComponent { // update existing state, not run-over let prevRes = this.awsTable.state.result; for (let key in result) { - if (result.hasOwnProperty(key)) { + if (Object.prototype.hasOwnProperty.call(result, key)) { prevRes[key] = result[key]; } } 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 97f3c1a18..6a6d0c75f 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 @@ -134,7 +134,7 @@ class AttackReport extends React.Component { getTechniqueByTitle(title){ for (const tech_id in this.state.techniques){ - if (! this.state.techniques.hasOwnProperty(tech_id)) {return false;} + if (! Object.prototype.hasOwnProperty.call(this.state.techniques, tech_id)) {return false;} let technique = this.state.techniques[tech_id]; if (technique.title === title){ technique['tech_id'] = tech_id; @@ -148,10 +148,10 @@ class AttackReport extends React.Component { // add links to techniques schema = schema.properties; for(const type in schema){ - if (! schema.hasOwnProperty(type)) {return false;} + if (! Object.prototype.hasOwnProperty.call(schema, type)) {return false;} let typeTechniques = schema[type].properties; for(const tech_id in typeTechniques){ - if (! typeTechniques.hasOwnProperty(tech_id)) {return false;} + if (! Object.prototype.hasOwnProperty.call(typeTechniques, 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/ReportMatrixComponent.js b/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js index a110da5ea..00420f095 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/attack/ReportMatrixComponent.js @@ -15,7 +15,7 @@ class ReportMatrixComponent extends React.Component { getColumns() { let columns = []; for(const type_key in this.state.schema.properties){ - if (! this.state.schema.properties.hasOwnProperty(type_key)){ + if (! Object.prototype.hasOwnProperty.call(this.state.schema.properties, type_key)){ continue; } let tech_type = this.state.schema.properties[type_key]; @@ -32,11 +32,11 @@ class ReportMatrixComponent extends React.Component { getTableRows() { let rows = []; for (const tech_id in this.state.techniques) { - if (this.state.techniques.hasOwnProperty(tech_id)){ + if (Object.prototype.hasOwnProperty.call(this.state.techniques, tech_id)){ let technique_added = false; let technique = this.state.techniques[tech_id]; for(const row of rows){ - if (! row.hasOwnProperty(technique.type)){ + if (! Object.prototype.hasOwnProperty.call(row, technique.type)){ row[technique.type] = technique; technique_added = true; break; diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/attack/TechniqueDropdowns.js b/monkey/monkey_island/cc/ui/src/components/report-components/attack/TechniqueDropdowns.js index c32c4e16e..1ba9285e6 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/attack/TechniqueDropdowns.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/attack/TechniqueDropdowns.js @@ -79,13 +79,13 @@ class TechniqueDropdowns extends React.Component{ getOrderedTechniqueList(){ let content = []; for(const type_key in this.state.schema.properties){ - if (! this.state.schema.properties.hasOwnProperty(type_key)){ + if (! Object.prototype.hasOwnProperty.call(this.state.schema.properties, type_key)){ continue; } let tech_type = this.state.schema.properties[type_key]; content.push(

{tech_type.title}

); for(const tech_id in this.state.techniques){ - if (! this.state.techniques.hasOwnProperty(tech_id)){ + if (! Object.prototype.hasOwnProperty.call(this.state.techniques, tech_id)){ continue; } let technique = this.state.techniques[tech_id]; diff --git a/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/venn-components/VennDiagram.js b/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/venn-components/VennDiagram.js index e6a2ddd36..4eddb420d 100644 --- a/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/venn-components/VennDiagram.js +++ b/monkey/monkey_island/cc/ui/src/components/report-components/zerotrust/venn-components/VennDiagram.js @@ -209,7 +209,7 @@ class VennDiagram extends React.Component { if (key_ === 'Data') { this.layout[key_].fontStyle = this.fontStyles[0]; - } else if (this.layout[key_].hasOwnProperty('cx')) { + } else if (Object.prototype.hasOwnProperty.call(this.layout[key_], 'cx')) { this.layout[key_].fontStyle = this.fontStyles[1]; } else { this.layout[key_].fontStyle = this.fontStyles[2]; @@ -229,7 +229,7 @@ class VennDiagram extends React.Component { // equivalent to center translate (width/2, height/2) let viewPortParameters = (-this.width / 2) + ' ' + (-this.height / 2) + ' ' + this.width + ' ' + this.height; let nodes = Object.values(this.layout).map((d_, i_) => { - if (d_.hasOwnProperty('cx')) { + if (Object.prototype.hasOwnProperty.call(d_, 'cx')) { return ( response.json()) .then(res => { - if (res.hasOwnProperty('access_token')) { + if (Object.prototype.hasOwnProperty.call(res, 'access_token')) { this._setToken(res['access_token']); return {result: true}; } else { @@ -86,7 +86,7 @@ export default class AuthService { headers['Authorization'] = 'Bearer ' + this._getToken(); } - if (options.hasOwnProperty('headers')) { + if (Object.prototype.hasOwnProperty.call(options, 'headers')) { for (let header in headers) { options['headers'][header] = headers[header]; }