From a52c47f5a50f43111d8a5cd3ca54f45675b786ea Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 3 Dec 2019 13:41:44 +0200 Subject: [PATCH] Ordered list according to technique type --- .../report-components/AttackReport.js | 3 +- .../attack/TechniqueDropdowns.js | 30 +++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) 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 30c7defe8..ed73c05ba 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 @@ -109,7 +109,8 @@ class AttackReport extends React.Component { techniques={this.state.techniques} selected={this.state.selectedTechnique}/> + techComponents={techComponents} + schema={this.state.schema}/>
) 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 d667cf922..6095ac478 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 @@ -15,6 +15,7 @@ class TechniqueDropdowns extends React.Component{ this.state = { techniques: this.props.techniques, techComponents: this.props.techComponents, + schema: this.props.schema, collapseOpen: '', techniquesHidden: true }; @@ -72,15 +73,34 @@ class TechniqueDropdowns extends React.Component{ this.setState({techniquesHidden: (! this.state.techniquesHidden)}) } - render(){ - let listClass = ''; + getOrderedTechniqueList(){ let content = []; + for(const type_key in this.state.schema.properties){ + if (! this.state.schema.properties.hasOwnProperty(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)){ + continue; + } + let technique = this.state.techniques[tech_id]; + if(technique.type === tech_type.title){ + content.push(this.getTechniqueCollapse(tech_id)) + } + } + } + return content + } + + render(){ + let content = []; + let listClass = ''; if (this.state.techniquesHidden){ listClass = 'hidden-list' } else { - Object.keys(this.state.techniques).forEach((tech_id) => { - content.push(this.getTechniqueCollapse(tech_id)) - }); + content = this.getOrderedTechniqueList() } return (