testilo 11.0.3 → 11.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/call.js +3 -5
- package/package.json +1 -1
- package/procs/score/tsp26.js +25 -34
package/call.js
CHANGED
|
@@ -95,14 +95,12 @@ const callScore = async (scorerID, selector = '') => {
|
|
|
95
95
|
// Get the scorer.
|
|
96
96
|
const {scorer} = require(`${functionDir}/score/${scorerID}`);
|
|
97
97
|
// Score the reports.
|
|
98
|
-
|
|
98
|
+
score(scorer, reports);
|
|
99
99
|
const scoredReportDir = `${reportDir}/scored`;
|
|
100
100
|
// For each scored report:
|
|
101
|
-
for (const
|
|
101
|
+
for (const report of reports) {
|
|
102
102
|
// Save it.
|
|
103
|
-
await fs.writeFile(
|
|
104
|
-
`${scoredReportDir}/${scoredReport.id}.json`, JSON.stringify(scoredReport, null, 2)
|
|
105
|
-
);
|
|
103
|
+
await fs.writeFile(`${scoredReportDir}/${report.id}.json`, JSON.stringify(report, null, 2));
|
|
106
104
|
};
|
|
107
105
|
}
|
|
108
106
|
// Otherwise, i.e. if no raw reports are to be scored:
|
package/package.json
CHANGED
package/procs/score/tsp26.js
CHANGED
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
tsp26
|
|
3
3
|
Testilo score proc 26
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Totals the standardized tool totals from a ts26 report and adds them to the report. This proc
|
|
6
|
+
does not compensate for inter-tool duplicativity, treats tool totals as equivalent, and
|
|
7
|
+
weighs ordinal severities linearly from 1 to 4.
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
|
-
// IMPORTS
|
|
9
|
-
|
|
10
|
-
const {issues} = require('./tic26');
|
|
11
|
-
|
|
12
10
|
// CONSTANTS
|
|
13
11
|
|
|
14
12
|
// ID of this proc.
|
|
@@ -29,49 +27,40 @@ const normalLatency = 20;
|
|
|
29
27
|
// How much each prevention adds to the score.
|
|
30
28
|
const preventionWeight = 100;
|
|
31
29
|
|
|
32
|
-
// VARIABLES
|
|
33
|
-
|
|
34
|
-
let summary = {};
|
|
35
|
-
let preventionScores = {};
|
|
36
|
-
|
|
37
30
|
// FUNCTIONS
|
|
38
31
|
|
|
39
32
|
// Scores a report.
|
|
40
|
-
exports.scorer =
|
|
41
|
-
// Initialize the score.
|
|
42
|
-
report.score = {
|
|
43
|
-
scoreProcID,
|
|
44
|
-
summary: {
|
|
45
|
-
total: 0,
|
|
46
|
-
tools: 0,
|
|
47
|
-
preventions: 0,
|
|
48
|
-
log: 0,
|
|
49
|
-
latency: 0
|
|
50
|
-
},
|
|
51
|
-
toolTotals: [],
|
|
52
|
-
tools: {},
|
|
53
|
-
preventions: {}
|
|
54
|
-
};
|
|
33
|
+
exports.scorer = report => {
|
|
55
34
|
// If there are any acts in the report:
|
|
56
35
|
const {acts} = report;
|
|
57
36
|
if (Array.isArray(acts) && acts.length) {
|
|
58
37
|
// If any of them are test acts:
|
|
59
38
|
const testActs = acts.filter(act => act.type === 'test');
|
|
60
39
|
if (testActs.length) {
|
|
61
|
-
// Initialize
|
|
62
|
-
|
|
40
|
+
// Initialize the score data.
|
|
41
|
+
const score = {
|
|
42
|
+
scoreProcID,
|
|
43
|
+
summary: {
|
|
44
|
+
total: 0,
|
|
45
|
+
tools: 0,
|
|
46
|
+
preventions: 0,
|
|
47
|
+
log: 0,
|
|
48
|
+
latency: 0
|
|
49
|
+
},
|
|
50
|
+
toolTotals: [0, 0, 0, 0],
|
|
63
51
|
tools: {},
|
|
64
|
-
|
|
52
|
+
preventions: {}
|
|
65
53
|
};
|
|
66
|
-
const {score} = report;
|
|
67
54
|
const {summary} = score;
|
|
68
55
|
// For each test act:
|
|
69
56
|
testActs.forEach(act => {
|
|
70
|
-
// If a result with totals exists:
|
|
57
|
+
// If a standard result with valid totals exists:
|
|
71
58
|
const {which} = act;
|
|
72
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
act.standardResult && act.standardResult.totals && act.standardResult.totals.length === 4
|
|
61
|
+
) {
|
|
73
62
|
// Add the tool totals to the score.
|
|
74
|
-
const {totals} = act.
|
|
63
|
+
const {totals} = act.standardResult;
|
|
75
64
|
score.tools[which] = totals;
|
|
76
65
|
score.toolTotals.forEach((total, index) => {
|
|
77
66
|
score.toolTotals[index] += totals[index];
|
|
@@ -88,8 +77,8 @@ exports.scorer = async report => {
|
|
|
88
77
|
act.result.prevented = true;
|
|
89
78
|
};
|
|
90
79
|
// Add the tool and the prevention score to the score.
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
score.preventions[which] = preventionWeight;
|
|
81
|
+
summary.preventions += preventionWeight;
|
|
93
82
|
}
|
|
94
83
|
});
|
|
95
84
|
// Add the log score to the score.
|
|
@@ -105,6 +94,8 @@ exports.scorer = async report => {
|
|
|
105
94
|
summary.latency = Math.round(latencyWeight * (jobData.visitLatency - normalLatency));
|
|
106
95
|
// Add the total score to the score.
|
|
107
96
|
summary.total = summary.tools + summary.preventions + summary.log + summary.latency;
|
|
97
|
+
// Add the score to the report.
|
|
98
|
+
report.score = score;
|
|
108
99
|
}
|
|
109
100
|
// Otherwise, i.e. if none of them is a test act:
|
|
110
101
|
else {
|