auditforge / backend /src /lib /custom-generator.js
Kaballas's picture
initialize project structure with essential configurations and components
56b6519
var expressions = require('angular-expressions');
// Apply all customs functions
function apply(data) {}
exports.apply = apply;
// *** Custom modifications of audit data for usage in word template
// *** Custome Angular expressions filters ***
var filters = {};
// Convert input CVSS criteria into French: {input | criteriaFR}
expressions.filters.criteriaFR = function (input) {
var result = 'Non défini';
if (input === 'Network') result = 'Réseau';
else if (input === 'Adjacent Network') result = 'Réseau Local';
else if (input === 'Local') result = 'Local';
else if (input === 'Physical') result = 'Physique';
else if (input === 'None') result = 'Aucun';
else if (input === 'Low') result = 'Faible';
else if (input === 'High') result = 'Haute';
else if (input === 'Required') result = 'Requis';
else if (input === 'Unchanged') result = 'Inchangé';
else if (input === 'Changed') result = 'Changé';
return result;
};
// Convert input date with parameter s (full,short): {input | convertDate: 's'}
expressions.filters.convertDateFR = function (input, s) {
var date = new Date(input);
if (date !== 'Invalid Date') {
var monthsFull = [
'Janvier',
'Février',
'Mars',
'Avril',
'Mai',
'Juin',
'Juillet',
'Août',
'Septembre',
'Octobre',
'Novembre',
'Décembre',
];
var monthsShort = [
'01',
'02',
'03',
'04',
'05',
'06',
'07',
'08',
'09',
'10',
'11',
'12',
];
var days = [
'Dimanche',
'Lundi',
'Mardi',
'Mercredi',
'Jeudi',
'Vendredi',
'Samedi',
];
var day = date.getUTCDate();
var month = date.getUTCMonth();
var year = date.getUTCFullYear();
if (s === 'full') {
return (
days[date.getUTCDay()] +
' ' +
(day < 10 ? '0' + day : day) +
' ' +
monthsFull[month] +
' ' +
year
);
}
if (s === 'short') {
return (
(day < 10 ? '0' + day : day) + '/' + monthsShort[month] + '/' + year
);
}
}
};
exports.expressions = expressions;