@@ -21,8 +21,10 @@ if (!Array.prototype.includes) {
21
21
} ) ;
22
22
}
23
23
24
- var totalUrls ;
25
- var totalAlerts ;
24
+ var totalUrls = 0 ;
25
+ var totalAlerts = 0 ;
26
+ var sectionUrls ;
27
+ var sectionAlerts ;
26
28
27
29
var FileWriter = Java . type ( 'java.io.FileWriter' ) ;
28
30
var PrintWriter = Java . type ( 'java.io.PrintWriter' ) ;
@@ -56,12 +58,12 @@ function listChildren(pw, node, type, rules) {
56
58
continue ;
57
59
}
58
60
if ( ! IGNORE_PATHS . includes ( path ) ) {
59
- totalUrls ++ ;
61
+ sectionUrls ++ ;
60
62
pw . println ( '- path: ' + path ) ;
61
63
var pluginId = nodeHasAlert ( child , rules ) ;
62
64
// Following test is JS equiv of XOR
63
65
if ( path . indexOf ( "FalsePositives" ) > 0 ? ! pluginId : pluginId ) {
64
- totalAlerts ++ ;
66
+ sectionAlerts ++ ;
65
67
pw . println ( ' result: Pass' ) ;
66
68
pw . println ( ' rule: ' + pluginId ) ;
67
69
} else {
@@ -84,12 +86,28 @@ function scoreChildren(file, name, type, rules) {
84
86
pw . println ( 'url: ' + type ) ;
85
87
pw . println ( 'details:' ) ;
86
88
87
- totalUrls = 0 ;
88
- totalAlerts = 0 ;
89
+ sectionUrls = 0 ;
90
+ sectionAlerts = 0 ;
89
91
90
92
91
93
listChildren ( pw , root , type , rules ) ;
92
94
95
+ pw . println ( 'tests: ' + sectionUrls ) ;
96
+ pw . println ( 'passes: ' + sectionAlerts ) ;
97
+ pw . println ( 'fails: ' + ( sectionUrls - sectionAlerts ) ) ;
98
+ pw . println ( 'score: ' + Math . round ( sectionAlerts * 100 / sectionUrls ) + '%' ) ;
99
+
100
+ totalUrls += sectionUrls ;
101
+ totalAlerts += sectionAlerts ;
102
+
103
+ pw . close ( ) ;
104
+ }
105
+
106
+ function scoreTotal ( ) {
107
+ var YAML_FILE = DIR + "/totals.yml" ;
108
+ var fw = new FileWriter ( YAML_FILE ) ;
109
+ var pw = new PrintWriter ( fw ) ;
110
+
93
111
pw . println ( 'tests: ' + totalUrls ) ;
94
112
pw . println ( 'passes: ' + totalAlerts ) ;
95
113
pw . println ( 'fails: ' + ( totalUrls - totalAlerts ) ) ;
@@ -135,22 +153,24 @@ scoreChildren("rxss-post", "Reflected XSS POST", "/RXSS-Detection-Evaluation-POS
135
153
scoreChildren ( "rxss-post-exp" , "Reflected XSS POST Experimental" , "/RXSS-Detection-Evaluation-POST-Experimental/" , [ 40012 ] ) ;
136
154
scoreChildren ( "rxss-fps" , "Reflected XSS GET False Positives" , "/RXSS-FalsePositives-GET/" , [ 40012 ] ) ;
137
155
138
- scoreChildren ( "sqli-get-200-err" , "SQL Injection GET 200 Error" , "/SInjection-Detection-Evaluation-GET-200Error/" , [ 40018 ] ) ;
139
- scoreChildren ( "sqli-get-200-err-exp" , "SQL Injection GET 200 Error Experimental" , "/SInjection-Detection-Evaluation-GET-200Error-Experimental/" , [ 40018 ] ) ;
140
- scoreChildren ( "sqli-get-200-id" , "SQL Injection GET 200 Identical" , "/SInjection-Detection-Evaluation-GET-200Identical/" , [ 40018 ] ) ;
141
- scoreChildren ( "sqli-get-200-valid" , "SQL Injection GET 200 Valid" , "/SInjection-Detection-Evaluation-GET-200Valid/" , [ 40018 ] ) ;
142
- scoreChildren ( "sqli-get-500-err" , "SQL Injection GET 500 Error" , "/SInjection-Detection-Evaluation-GET-500Error/" , [ 40018 ] ) ;
143
- scoreChildren ( "sqli-post-200-err" , "SQL Injection POST 200 Error" , "/SInjection-Detection-Evaluation-POST-200Error/" , [ 40018 ] ) ;
144
- scoreChildren ( "sqli-post-200-err-exp" , "SQL Injection POST 200 Error Experimental" , "/SInjection-Detection-Evaluation-POST-200Error-Experimental/" , [ 40018 ] ) ;
145
- scoreChildren ( "sqli-post-200-id" , "SQL Injection POST 200 Identical" , "/SInjection-Detection-Evaluation-POST-200Identical/" , [ 40018 ] ) ;
146
- scoreChildren ( "sqli-post-200-valid" , "SQL Injection POST 200 Valid" , "/SInjection-Detection-Evaluation-POST-200Valid/" , [ 40018 ] ) ;
147
- scoreChildren ( "sqli-post-500-err" , "SQL Injection POST 500 Error" , "/SInjection-Detection-Evaluation-POST-500Error/" , [ 40018 ] ) ;
148
- scoreChildren ( "sqli-get-fp" , "SQL Injection GET False Positives" , "/SInjection-FalsePositives-GET/" , [ 40018 ] ) ;
156
+ scoreChildren ( "sqli-get-200-err" , "SQL Injection GET 200 Error" , "/SInjection-Detection-Evaluation-GET-200Error/" , [ 40018 , 40019 ] ) ;
157
+ scoreChildren ( "sqli-get-200-err-exp" , "SQL Injection GET 200 Error Experimental" , "/SInjection-Detection-Evaluation-GET-200Error-Experimental/" , [ 40018 , 40019 ] ) ;
158
+ scoreChildren ( "sqli-get-200-id" , "SQL Injection GET 200 Identical" , "/SInjection-Detection-Evaluation-GET-200Identical/" , [ 40018 , 40019 ] ) ;
159
+ scoreChildren ( "sqli-get-200-valid" , "SQL Injection GET 200 Valid" , "/SInjection-Detection-Evaluation-GET-200Valid/" , [ 40018 , 40019 ] ) ;
160
+ scoreChildren ( "sqli-get-500-err" , "SQL Injection GET 500 Error" , "/SInjection-Detection-Evaluation-GET-500Error/" , [ 40018 , 40019 ] ) ;
161
+ scoreChildren ( "sqli-post-200-err" , "SQL Injection POST 200 Error" , "/SInjection-Detection-Evaluation-POST-200Error/" , [ 40018 , 40019 ] ) ;
162
+ scoreChildren ( "sqli-post-200-err-exp" , "SQL Injection POST 200 Error Experimental" , "/SInjection-Detection-Evaluation-POST-200Error-Experimental/" , [ 40018 , 40019 ] ) ;
163
+ scoreChildren ( "sqli-post-200-id" , "SQL Injection POST 200 Identical" , "/SInjection-Detection-Evaluation-POST-200Identical/" , [ 40018 , 40019 ] ) ;
164
+ scoreChildren ( "sqli-post-200-valid" , "SQL Injection POST 200 Valid" , "/SInjection-Detection-Evaluation-POST-200Valid/" , [ 40018 , 40019 ] ) ;
165
+ scoreChildren ( "sqli-post-500-err" , "SQL Injection POST 500 Error" , "/SInjection-Detection-Evaluation-POST-500Error/" , [ 40018 , 40019 ] ) ;
166
+ scoreChildren ( "sqli-get-fp" , "SQL Injection GET False Positives" , "/SInjection-FalsePositives-GET/" , [ 40018 , 40019 ] ) ;
149
167
150
168
scoreChildren ( "redir-get-302" , "Unvalidated Redirect GET 200" , "/Redirect-Detection-Evaluation-GET-302Redirect/" , [ 20019 ] ) ;
151
169
scoreChildren ( "redir-post-302" , "Unvalidated Redirect POST 302" , "/Redirect-Detection-Evaluation-POST-302Redirect/" , [ 20019 ] ) ;
152
170
scoreChildren ( "redir-get-fp" , "Unvalidated Redirect GET False Positives" , "/Redirect-FalsePositives-GET/" , [ 20019 ] ) ;
153
171
scoreChildren ( "redir-get-200-valid" , "Unvalidated Redirect GET 200 Valid" , "/Redirect-JavaScript-Detection-Evaluation-GET-200Valid/" , [ 20019 ] ) ;
154
172
scoreChildren ( "redir-post-200-valid" , "Unvalidated Redirect POST 200 Valid" , "/Redirect-JavaScript-Detection-Evaluation-POST-200Valid/" , [ 20019 ] ) ;
155
173
174
+ scoreTotal ( ) ;
175
+
156
176
print ( 'Done' ) ;
0 commit comments