@@ -28,104 +28,25 @@ object Pattern {
28
28
29
29
case class Definition (patternId : Pattern .Id , parameters : Option [Set [Parameter .Definition ]])
30
30
31
- trait Specification {
32
- val patternId : Pattern .Id
33
- val level : Result .Level
34
- val category : Category
35
- val subcategory : Option [Subcategory ]
36
- val parameters : Option [Set [Parameter .Specification ]]
37
- val languages : Option [Set [Language ]]
38
-
39
- def copy (patternId : Pattern .Id = patternId,
40
- level : Result .Level = level,
41
- category : Category = category,
42
- subcategory : Option [Subcategory ] = subcategory,
43
- parameters : Option [Set [Parameter .Specification ]] = parameters,
44
- languages : Option [Set [Language ]] = languages): Specification = {
45
- Specification (patternId, level, category, subcategory, parameters, languages)
46
- }
47
- }
48
-
31
+ case class Specification (patternId : Pattern .Id ,
32
+ level : Result .Level ,
33
+ category : Specification .Category ,
34
+ subcategory : Option [Specification .Subcategory ],
35
+ parameters : Option [Set [Parameter .Specification ]],
36
+ languages : Option [Set [Language ]] = None )
49
37
object Specification {
50
- private case class SpecificationImpl (patternId : Pattern .Id ,
51
- level : Result .Level ,
52
- category : Category ,
53
- subcategory : Option [Subcategory ],
54
- parameters : Option [Set [Parameter .Specification ]],
55
- languages : Option [Set [Language ]] = None )
56
- extends Specification
57
-
58
- def unapply (s : Pattern .Specification ): Option [(Pattern .Id ,
59
- Result .Level ,
60
- Category ,
61
- Option [Subcategory ],
62
- Option [Set [Parameter .Specification ]],
63
- Option [Set [Language ]])] = s match {
64
- case si : SpecificationImpl =>
65
- SpecificationImpl .unapply(si)
38
+ type Category = Category .Value
39
+ object Category extends Enumeration {
40
+ val Security, CodeStyle, ErrorProne, Performance, Compatibility, UnusedCode, Complexity, BestPractice ,
41
+ Comprehensibility , Duplication , Documentation = Value
66
42
}
67
43
68
- def apply (patternId : Pattern .Id ,
69
- level : Result .Level ,
70
- category : Category ,
71
- subcategory : Option [Subcategory ],
72
- parameters : Option [Set [Parameter .Specification ]],
73
- languages : Option [Set [Language ]] = None ): Specification = {
74
- val spec = SpecificationImpl (patternId, level, category, subcategory, parameters, languages)
75
-
76
- spec.subcategory match {
77
- case Some (sc) =>
78
- sc match {
79
- case Subcategory .XSS | Subcategory .Input_validation | Subcategory .File_Access | Subcategory .HTTP |
80
- Subcategory .Cookies | Subcategory .Unexpected_behaviour | Subcategory .Mass_assignment |
81
- Subcategory .Insecure_Storage | Subcategory .Insecure_modules_libraries | Subcategory .Visibility |
82
- Subcategory .CSRF | Subcategory .Android | Subcategory .Malicious_code | Subcategory .Cryptography |
83
- Subcategory .Command_Injection | Subcategory .Firefox_OS | Subcategory .Auth | Subcategory .DoS |
84
- Subcategory .SQL_Injection | Subcategory .Routes | Subcategory .Regex | Subcategory .SSL | Subcategory .Other
85
- if category == Category .Security =>
86
- spec
44
+ type Subcategory = Subcategory .Value
87
45
88
- case _ => throw new Exception ( s " Invalid subcategory: $subcategory is not subcategory of $category " )
89
- }
90
- case None => spec
91
- }
46
+ object Subcategory extends Enumeration {
47
+ val XSS, InputValidation, FileAccess, HTTP, Cookies, UnexpectedBehaviour, MassAssignment, InsecureStorage ,
48
+ InsecureModulesLibraries , Visibility , CSRF , Android , MaliciousCode , Cryptography , CommandInjection , FirefoxOS ,
49
+ Auth , DoS , SQLInjection , Routes , Regex , SSL , Other = Value
92
50
}
93
51
}
94
-
95
- type Category = Category .Value
96
-
97
- object Category extends Enumeration {
98
-
99
- val Security, CodeStyle, ErrorProne, Performance, Compatibility, UnusedCode, Complexity, BestPractice ,
100
- Comprehensibility , Duplication , Documentation = Value
101
- }
102
-
103
- type Subcategory = Subcategory .Value
104
-
105
- object Subcategory extends Enumeration {
106
- val XSS = Value (" XSS" )
107
- val Input_validation = Value (" Input validation" )
108
- val File_Access = Value (" File Access" )
109
- val HTTP = Value (" HTTP" )
110
- val Cookies = Value (" Cookies" )
111
- val Unexpected_behaviour = Value (" Unexpected behaviour" )
112
- val Mass_assignment = Value (" Mass assignment" )
113
- val Insecure_Storage = Value (" Insecure Storage" )
114
- val Insecure_modules_libraries = Value (" Insecure modules/libraries" )
115
- val Visibility = Value (" Visibility" )
116
- val CSRF = Value (" CSRF" )
117
- val Android = Value (" Android" )
118
- val Malicious_code = Value (" Malicious code" )
119
- val Cryptography = Value (" Cryptography" )
120
- val Command_Injection = Value (" Command Injection" )
121
- val Firefox_OS = Value (" Firefox OS" )
122
- val Auth = Value (" Auth" )
123
- val DoS = Value (" DoS" )
124
- val SQL_Injection = Value (" SQL Injection" )
125
- val Routes = Value (" Routes" )
126
- val Regex = Value (" Regex" )
127
- val SSL = Value (" SSL" )
128
- val Other = Value (" Other" )
129
- }
130
-
131
52
}
0 commit comments