Skip to content

Commit

Permalink
Merge pull request #1146 from fparuce/feat/extra-value-for-Priority-f…
Browse files Browse the repository at this point in the history
…ield

Add extra value for Priority field, and change default value
  • Loading branch information
fparuce authored Dec 19, 2024
2 parents c6599ab + c1b70ca commit 732ab46
Show file tree
Hide file tree
Showing 21 changed files with 158 additions and 149 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG NODE_VERSION=20.14
ARG NODE_VERSION=20.17

# The base image with updates applied
FROM node:$NODE_VERSION-alpine AS base-node
Expand Down
4 changes: 3 additions & 1 deletion td.vue/src/components/ThreatEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ export default {
},
priorities() {
return [
{ value: 'TBA', text: this.$t('threats.priority.tba') },
{ value: 'Low', text: this.$t('threats.priority.low') },
{ value: 'Medium', text: this.$t('threats.priority.medium') },
{ value: 'High', text: this.$t('threats.priority.high') }
{ value: 'High', text: this.$t('threats.priority.high') },
{ value: 'Critical', text: this.$t('threats.priority.critical') }
];
},
modalTitle() { return this.$t('threats.edit') + ' #' + this.number; }
Expand Down
193 changes: 64 additions & 129 deletions td.vue/src/components/ThreatSuggestDialog.vue
Original file line number Diff line number Diff line change
@@ -1,116 +1,65 @@
<template>
<div>
<b-modal
id="threat-edit"
size="lg"
ok-variant="primary"
header-bg-variant="primary"
header-text-variant="light"
:title="modalTitle"
ref="editModal"
>
<b-modal id="threat-edit" size="lg" ok-variant="primary" header-bg-variant="primary" header-text-variant="light"
:title="modalTitle" ref="editModal">
<b-form>
<b-form-row>
<b-col>
<b-form-group
id="title-group"
:label="$t('threats.properties.title')"
label-for="title">
<b-form-input
id="title"
v-model="threat.title"
type="text"
required
></b-form-input>
<b-form-group id="title-group" :label="$t('threats.properties.title')" label-for="title">
<b-form-input id="title" v-model="threat.title" type="text" required></b-form-input>
</b-form-group>
</b-col>
</b-form-row>

<b-form-row>
<b-col>
<b-form-group
id="threat-type-group"
:label="$t('threats.properties.type')"
<b-form-group id="threat-type-group" :label="$t('threats.properties.type')"
label-for="threat-type">
<b-form-select
id="threat-type"
v-model="threat.type"
:options="types">
<b-form-select id="threat-type" v-model="threat.type" :options="types">
</b-form-select>
</b-form-group>
</b-col>
</b-form-row>

<b-form-row>
<b-col md=5>
<b-form-group
id="status-group"
class="float-left"
:label="$t('threats.properties.status')"
<b-form-group id="status-group" class="float-left" :label="$t('threats.properties.status')"
label-for="status">
<b-form-radio-group
id="status"
v-model="threat.status"
:options="statuses"
buttons
></b-form-radio-group>
<b-form-radio-group id="status" v-model="threat.status" :options="statuses"
buttons></b-form-radio-group>
</b-form-group>
</b-col>

<b-col md=2>
<b-form-group
id="score-group"
:label="$t('threats.properties.score')"
label-for="score">
<b-form-input
id="score"
v-model="threat.score"
type="text"
></b-form-input>
<b-form-group id="score-group" :label="$t('threats.properties.score')" label-for="score">
<b-form-input id="score" v-model="threat.score" type="text"></b-form-input>
</b-form-group>
</b-col>

<b-col md=5>
<b-form-group
id="priority-group"
class="float-right"
:label="$t('threats.properties.priority')"
<b-form-group id="priority-group" class="float-right" :label="$t('threats.properties.priority')"
label-for="priority">
<b-form-radio-group
id="priority"
v-model="threat.severity"
:options="priorities"
buttons
></b-form-radio-group>
<b-form-radio-group id="priority" v-model="threat.severity" :options="priorities"
buttons></b-form-radio-group>
</b-form-group>
</b-col>
</b-form-row>

<b-form-row>
<b-col>
<b-form-group
id="description-group"
:label="$t('threats.properties.description')"
<b-form-group id="description-group" :label="$t('threats.properties.description')"
label-for="description">
<b-form-textarea
id="description"
v-model="threat.description"
rows="5">
<b-form-textarea id="description" v-model="threat.description" rows="5">
</b-form-textarea>
</b-form-group>
</b-col>
</b-form-row>

<b-form-row>
<b-col>
<b-form-group
id="mitigation-group"
:label="$t('threats.properties.mitigation')"
<b-form-group id="mitigation-group" :label="$t('threats.properties.mitigation')"
label-for="mitigation">
<b-form-textarea
id="mitigation"
v-model="threat.mitigation"
rows="5">
<b-form-textarea id="mitigation" v-model="threat.mitigation" rows="5">
</b-form-textarea>
</b-form-group>
</b-col>
Expand All @@ -119,34 +68,18 @@

<template #modal-footer>
<div class="w-100">
<b-button
variant="danger"
class="float-right"
@click="acceptSuggestion()"
>
{{ $t('forms.apply') }}
</b-button>
<b-button
variant="secondary"
class="float-left"
@click="previous()"
>
{{ $t('forms.previous') }}
</b-button>
<b-button
variant="danger"
class="float-left"
@click="next()"
>
{{ $t('forms.next') }}
</b-button>
<b-button
variant="secondary"
class="float-right mr-2"
@click="hideModal()"
>
{{ $t('forms.cancel') }}
</b-button>
<b-button variant="danger" class="float-right" @click="acceptSuggestion()">
{{ $t('forms.apply') }}
</b-button>
<b-button variant="secondary" class="float-left" @click="previous()">
{{ $t('forms.previous') }}
</b-button>
<b-button variant="danger" class="float-left" @click="next()">
{{ $t('forms.next') }}
</b-button>
<b-button variant="secondary" class="float-right mr-2" @click="hideModal()">
{{ $t('forms.cancel') }}
</b-button>
</div>
</template>
</b-modal>
Expand All @@ -157,7 +90,7 @@
<script>
import { mapState } from 'vuex';
import { createNewTypedThreat } from '@/service/threats/index.js';
import { CELL_DATA_UPDATED} from '@/store/actions/cell.js';
import { CELL_DATA_UPDATED } from '@/store/actions/cell.js';
import tmActions from '@/store/actions/threatmodel.js';
import dataChanged from '@/service/x6/graph/data-changed.js';
import threatModels from '@/service/threats/models/index.js';
Expand All @@ -170,12 +103,12 @@ export default {
modelType: (state) => state.threatmodel.selectedDiagram.diagramType,
threatTop: (state) => state.threatmodel.data.detail.threatTop
}),
threatTypes(){
if(!this.cellRef || !this.threat || !this.modelType)
threatTypes() {
if (!this.cellRef || !this.threat || !this.modelType)
return [];
const res = [];
const threattypes = threatModels.getThreatTypesByElement(this.modelType, this.cellRef.data.type);
Object.keys(threattypes).forEach((type)=>{
Object.keys(threattypes).forEach((type) => {
res.push(this.$t(type));
}, this);
return res;
Expand All @@ -189,19 +122,21 @@ export default {
},
priorities() {
return [
{ value: 'TBA', text: this.$t('threats.priority.tba') },
{ value: 'Low', text: this.$t('threats.priority.low') },
{ value: 'Medium', text: this.$t('threats.priority.medium') },
{ value: 'High', text: this.$t('threats.priority.high') }
{ value: 'High', text: this.$t('threats.priority.high') },
{ value: 'Critical', text: this.$t('threats.priority.critical') }
];
},
modalTitle() { return this.$t('threats.newThreat') + ' #' + (this.threatTop + 1); }
},
data() {
return {
suggestions:[],
suggestions: [],
types: [],
threat: {},
index:0
index: 0
};
},
methods: {
Expand All @@ -210,68 +145,68 @@ export default {
const tmpThreat = createNewTypedThreat(this.modelType, this.cellRef.data.type, this.threatTop + 1);
this.types = [...this.threatTypes];
if (type == 'type') {
this.threatTypes.map((t, ind)=>{
this.threatTypes.map((t, ind) => {
console.log(t);
this.suggestions.push({...tmpThreat});
this.suggestions[ind].type=t;
this.suggestions.push({ ...tmpThreat });
this.suggestions[ind].type = t;
});
} else {
this.suggestions = GetContextSuggestions(this.cellRef.data, this.modelType).map((suggestion) => {
tmpThreat.title = suggestion.title;
tmpThreat.type = this.$t(suggestion.type);
if(!this.types.includes(tmpThreat.type)&&tmpThreat.type !== '')
if (!this.types.includes(tmpThreat.type) && tmpThreat.type !== '')
this.types.push(tmpThreat.type);
tmpThreat.description = suggestion.description;
tmpThreat.mitigation = suggestion.mitigation;
console.log(tmpThreat);
return {...tmpThreat};
return { ...tmpThreat };
});
}
if(this.suggestions.length)
if (this.suggestions.length)
this.threat = this.suggestions[0];
this.$refs.editModal.show();
},
hideModal(){
this.threat={};
hideModal() {
this.threat = {};
this.suggestions = [];
this.types = [];
this.index=0;
this.index = 0;
this.$refs.editModal.hide();
},
next(){
next() {
this.index++;
if(this.index>=this.suggestions.length){
if (this.index >= this.suggestions.length) {
this.hideModal();
this.index=0;
this.index = 0;
return;
}
this.threat = this.suggestions[this.index];
},
acceptSuggestion(){
acceptSuggestion() {
const objRef = this.cellRef.data;
if(!objRef.threatFrequency){
const tmpfreq = threatModels.getFrequencyMapByElement(this.threat.modelType,this.cellRef.data.type);
if(tmpfreq!==null)
if (!objRef.threatFrequency) {
const tmpfreq = threatModels.getFrequencyMapByElement(this.threat.modelType, this.cellRef.data.type);
if (tmpfreq !== null)
objRef.threatFrequency = tmpfreq;
}
if(objRef.threatFrequency){
Object.keys(objRef.threatFrequency).forEach((k)=>{
if(this.$t(`threats.model.${this.modelType.toLowerCase()}.${k}`)===this.threat.type&&this.threatTypes.includes(this.threat.type))
if (objRef.threatFrequency) {
Object.keys(objRef.threatFrequency).forEach((k) => {
if (this.$t(`threats.model.${this.modelType.toLowerCase()}.${k}`) === this.threat.type && this.threatTypes.includes(this.threat.type))
objRef.threatFrequency[k]++;
});
}
this.threat.new=false;
this.threat.new = false;
this.cellRef.data.threats.push(this.threat);
this.cellRef.data.hasOpenThreats = this.cellRef.data.threats.length > 0;
this.$store.dispatch(tmActions.update, {threatTop : this.threatTop+1});
this.$store.dispatch(tmActions.update, { threatTop: this.threatTop + 1 });
this.$store.dispatch(tmActions.modified);
this.$store.dispatch(CELL_DATA_UPDATED,this.cellRef.data);
this.$store.dispatch(CELL_DATA_UPDATED, this.cellRef.data);
dataChanged.updateStyleAttrs(this.cellRef);
this.next();
},
previous(){
if(this.index>0){
previous() {
if (this.index > 0) {
this.index--;
this.threat = this.suggestions[this.index];
}
Expand Down
12 changes: 12 additions & 0 deletions td.vue/src/components/report/ExecutiveSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ export default {
{ name: this.$t('report.threatStats.total'), value: this.total },
{ name: this.$t('report.threatStats.mitigated'), value: this.mitigated },
{ name: this.$t('report.threatStats.notMitigated'), value: this.notMitigated },
{ name: this.$t('report.threatStats.openCritical'), value: this.openCritical },
{ name: this.$t('report.threatStats.openHigh'), value: this.openHigh },
{ name: this.$t('report.threatStats.openMedium'), value: this.openMedium },
{ name: this.$t('report.threatStats.openLow'), value: this.openLow },
{ name: this.$t('report.threatStats.openTba'), value: this.openTba },
{ name: this.$t('report.threatStats.openUnknown'), value: this.openUnknown }
];
},
Expand All @@ -64,6 +66,11 @@ export default {
.filter(threat => threat.status.toLowerCase() !== 'mitigated')
.length;
},
openCritical: function () {
return this.getOpenThreats()
.filter(threat => threat.severity.toLowerCase() === 'critical')
.length;
},
openHigh: function () {
return this.getOpenThreats()
.filter(threat => threat.severity.toLowerCase() === 'high')
Expand All @@ -79,6 +86,11 @@ export default {
.filter(threat => threat.severity.toLowerCase() === 'low')
.length;
},
openTba: function() {
return this.getOpenThreats()
.filter(threat => threat.severity.toLowerCase() === 'tba')
.length;
},
openUnknown: function() {
return this.getOpenThreats()
.filter(threat => !threat.severity)
Expand Down
Loading

0 comments on commit 732ab46

Please sign in to comment.