Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/views/portfolio/projects/FindingAudit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@
}"
:disabled="analysisState === null"
/>
<b-datepicker
v-model="suppressionExpiration"
type="date"
format="YYYY-MM-DD"
placeholder="Suppression Expiration"
:disabled="!isSuppressed"
:clearable="true"
@input="makeAnalysis"
:min="today"
style="margin-left: 2rem"
reset-button
close-button
/>
</b-input-group>
</b-form-group>
<b-row v-if="this.isPermitted(this.PERMISSIONS.VULNERABILITY_ANALYSIS)">
Expand Down Expand Up @@ -264,6 +277,8 @@ export default {
auditTrail: null,
comment: null,
isSuppressed: !!this.finding?.analysis?.isSuppressed,
suppressionExpiration: null,
today: this.getToday(),
analysisChoices: [
{ value: 'NOT_SET', text: this.$t('message.not_set') },
{ value: 'EXPLOITABLE', text: this.$t('message.exploitable') },
Expand Down Expand Up @@ -331,13 +346,17 @@ export default {
watch: {
isSuppressed: function (currentValue, oldValue) {
if (oldValue != null) {
if (!currentValue) {
this.suppressionExpiration = null;
}
this.callRestEndpoint(
this.analysisState,
this.analysisJustification,
this.analysisResponse,
null,
null,
currentValue,
currentValue ? this.suppressionExpiration : null,
);
}
},
Expand All @@ -350,6 +369,26 @@ export default {
aliases,
);
},
getToday() {
const today = new Date();
const yyyy = today.getFullYear();
const mm = (today.getMonth() + 1).toString().padStart(2, '0');
const dd = today.getDate().toString().padStart(2, '0');
return `${yyyy}-${mm}-${dd}`;
},
convertTimestampToDateString(timestamp) {
if (!timestamp) return null;
const date = new Date(timestamp);
const yyyy = date.getFullYear();
const mm = (date.getMonth() + 1).toString().padStart(2, '0');
const dd = date.getDate().toString().padStart(2, '0');
return `${yyyy}-${mm}-${dd}`;
},
convertDateStringToTimestamp(dateString) {
if (!dateString) return null;
const date = new Date(dateString + 'T00:00:00.000Z');
return date.getTime();
},
getAnalysis: function () {
let queryString =
'?project=' +
Expand Down Expand Up @@ -408,6 +447,13 @@ export default {
} else {
this.isSuppressed = false;
}
if (
Object.prototype.hasOwnProperty.call(analysis, 'suppressionExpiration')
) {
this.suppressionExpiration = analysis.suppressionExpiration
? this.convertTimestampToDateString(analysis.suppressionExpiration)
: null;
}
},
makeAnalysis: function () {
this.callRestEndpoint(
Expand All @@ -417,6 +463,7 @@ export default {
this.analysisDetails,
null,
null,
this.suppressionExpiration,
);
},
addComment: function () {
Expand All @@ -428,6 +475,7 @@ export default {
this.analysisDetails,
this.comment,
null,
this.suppressionExpiration,
);
}
this.comment = null;
Expand All @@ -439,8 +487,14 @@ export default {
analysisDetails,
comment,
isSuppressed,
suppressionExpiration,
) {
let url = `${this.$api.BASE_URL}/${this.$api.URL_ANALYSIS}`;

const suppressionExpirationTimestamp = this.convertDateStringToTimestamp(
suppressionExpiration,
);

this.axios
.put(url, {
project: this.projectUuid,
Expand All @@ -452,6 +506,7 @@ export default {
analysisDetails: analysisDetails,
comment: comment,
isSuppressed: isSuppressed,
suppressionExpiration: suppressionExpirationTimestamp,
})
.then((response) => {
this.$toastr.s(this.$t('message.updated'));
Expand Down