This repository was archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathFieldResult.js
More file actions
113 lines (102 loc) · 3.33 KB
/
Copy pathFieldResult.js
File metadata and controls
113 lines (102 loc) · 3.33 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Copyright 2007 Security Compass
This file is part of SQL Inject Me.
SQL Inject Me is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SQL Inject Me is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with SQL Inject Me. If not, see <http://www.gnu.org/licenses/>.
If you have any questions regarding SQL Inject Me please contact
tools@securitycompass.com
*/
/**
* FieldResult.js
* A FieldResult represents the resulting "value" of a form's field after all
* testing has been performed.
* It holds all the results generated for a field.
* This object is used for sorting.
* @requires result.js
*/
function FieldResult(formIndex, fieldIndex){
this.fieldIndex = fieldIndex;
this.formIndex = formIndex;
this.results = new Array();
this.maxValue = 0;
this.maxValueType = 0;
this.state = 0;
}
/**
* These consts are used to check what kind of rsults does this fieldresult
* have.
*/
const fieldresult_has_pass = 0x0001;
const fieldresult_has_warn = 0x0002;
const fieldresult_has_error = 0x0004;
FieldResult.prototype = {
addResults: function (resultsToAdd) {
for each(var result in resultsToAdd) {
if (this.maxValueType < result.type){
this.maxValue = result.value;
this.maxValueType = result.type;
}
else if (this.maxValueType === result.type ) {
if (this.maxValue < result.value) {
this.maxValue = result.value;
}
}
this.state = this.state | result.type;
this.results.push(result);
}
}
,
getLength: function(){
var numTestsRun = 0;
var numPasses = 0;
var numWarnings = 0;
var numFailes = 0;
for each(var r in this.results) {
numTestsRun++;
switch(r.type){
case RESULT_TYPE_ERROR:
numFailes++;
break;
case RESULT_TYPE_WARNING:
numWarnings++;
break;
case RESULT_TYPE_PASS:
numPasses++;
break;
}
}
return [numTestsRun, numFailes, numWarnings, numPasses];
}
,
getSubmitState: function(){
return this.results[0].testData;
}
,
sort: function(){
var errors = new Array();
var warnings = new Array();
var passes = new Array();
for each(var result in this.results) {
switch(result.type){
case RESULT_TYPE_ERROR:
errors.push(result);
break;
case RESULT_TYPE_WARNING:
warnings.push(result);
break;
case RESULT_TYPE_PASS:
passes.push(result);
break;
}
}
return this.results = errors.concat(warnings, passes);
}
}