Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 12x 12x 87x 12x 24x 24x 5x 5x 19x 19x 41x 19x 22x 22x 19x 12x 12x 12x 12x 80x 80x | /* eslint-disable security/detect-object-injection */ const utils = (module.exports = {}); /** * Check if object is empty * * @param {Object} obj The object to examine. * @return {boolean} True if it is empty. */ utils.isObjectEmpty = function (obj) { return Object.keys(obj).length === 0 && obj.constructor === Object; }; /** * Assigns the value on the target using the path. * * @param {string} path Dot notation path to save the value. * @param {Object} target The target object to save the value on. * @param {*} value The value to save. * @return {Object} The target object. */ utils.assignPath = function (path, target, value) { const parts = path.split('.'); if (parts.length === 1) { // Save on root target[path] = value; return target; } let ref = target; parts.forEach(function (part, index) { if (index === parts.length - 1) { ref[part] = value; } else { ref[part] = ref[part] || {}; ref = ref[part]; } }); return target; }; /** * Returns the process name, required for testing. * * @return {string} The process name. */ utils.getProcessName = function () { return process.argv[0]; }; /** * Returns the process id, required for testing. * * @return {string} The process id. */ utils.getProcessId = function () { return process.pid; }; /** * Clean HTTP Headers from sensitive data. * * @param {Object} headers The headers. * @return {Object} Sanitized headers. */ utils.sanitizeHttpHeaders = function (headers) { if (typeof headers !== 'object') { return headers; } const REMOVE = ['cookie', 'authorization']; REMOVE.forEach(function (header) { if (headers[header]) { headers[header] = '-- REMOVED FOR SAFETY --'; } }); return headers; }; /** * Return an ISO8601 formatted date. * * @return {string} The formatted date. */ utils.getDt = function () { const dt = new Date(); return dt.toISOString(); }; |