-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathWebXML.qll
More file actions
172 lines (147 loc) · 4.26 KB
/
WebXML.qll
File metadata and controls
172 lines (147 loc) · 4.26 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
overlay[local?]
module;
import java
/**
* Holds if any `web.xml` files are included in this snapshot.
*/
predicate isWebXmlIncluded() { exists(WebXmlFile webXml) }
/**
* A deployment descriptor file, typically called `web.xml`.
*/
class WebXmlFile extends XmlFile {
WebXmlFile() {
count(XmlElement e | e = this.getAChild()) = 1 and
this.getAChild().getName() = "web-app"
}
/**
* Gets the value of the context parameter with the given name.
*/
string getContextParamValue(string name) {
exists(WebContextParameter parameter |
// Find a web context parameter in the same file and ...
parameter.getFile() = this and
// ... with the right name.
name = parameter.getParamName().getValue() and
result = parameter.getParamValue().getValue()
)
}
}
/**
* An XML element in a `WebXMLFile`.
*/
class WebXmlElement extends XmlElement {
WebXmlElement() { this.getFile() instanceof WebXmlFile }
/**
* Gets the value for this element, with leading and trailing whitespace trimmed.
*/
string getValue() { result = this.allCharactersString().trim() }
}
/**
* A `<context-param>` element in a `web.xml` file.
*/
class WebContextParameter extends WebXmlElement {
WebContextParameter() { this.getName() = "context-param" }
/**
* Gets the `<param-name>` element of this `<context-param>`.
*/
WebContextParamName getParamName() { result = this.getAChild() }
/**
* Gets the `<param-value>` element of this `<context-param>`.
*/
WebContextParamValue getParamValue() { result = this.getAChild() }
}
/**
* A `<param-name>` element in a `web.xml` file.
*/
class WebContextParamName extends WebXmlElement {
WebContextParamName() { this.getName() = "param-name" }
}
/**
* A `<param-value>` element in a `web.xml` file.
*/
class WebContextParamValue extends WebXmlElement {
WebContextParamValue() { this.getName() = "param-value" }
}
/**
* A `<filter>` element in a `web.xml` file.
*/
class WebFilter extends WebXmlElement {
WebFilter() { this.getName() = "filter" }
}
/**
* A `<filter-class>` element in a `web.xml` file, nested under a `<filter>` element.
*/
class WebFilterClass extends WebXmlElement {
WebFilterClass() {
this.getName() = "filter-class" and
this.getParent() instanceof WebFilter
}
Class getClass() { result.getQualifiedName() = this.getValue() }
}
/**
* A `<servlet>` element in a `web.xml` file.
*/
class WebServlet extends WebXmlElement {
WebServlet() { this.getName() = "servlet" }
}
/**
* A `<servlet-class>` element in a `web.xml` file, nested under a `<servlet>` element.
*/
class WebServletClass extends WebXmlElement {
WebServletClass() {
this.getName() = "servlet-class" and
this.getParent() instanceof WebServlet
}
Class getClass() { result.getQualifiedName() = this.getValue() }
}
/**
* A `<listener>` element in a `web.xml` file.
*/
class WebListener extends WebXmlElement {
WebListener() { this.getName() = "listener" }
}
/**
* A `<listener-class>` element in a `web.xml` file, nested under a `<listener>` element.
*/
class WebListenerClass extends WebXmlElement {
WebListenerClass() {
this.getName() = "listener-class" and
this.getParent() instanceof WebListener
}
/**
* Gets the `Class` instance associated with this element.
*/
Class getClass() { result.getQualifiedName() = this.getValue() }
}
/**
* An `<error-page>` element in a `web.xml` file.
*/
class WebErrorPage extends WebXmlElement {
WebErrorPage() { this.getName() = "error-page" }
/**
* Gets the `<exception-type>` element of this `<error-page>`.
*/
WebErrorPageType getPageType() { result = this.getAChild() }
/**
* Gets the `<location>` element of this `<error-page>`.
*/
WebErrorPageLocation getPageLocation() { result = this.getAChild() }
}
/**
* An `<exception-type>` element in a `web.xml` file, nested under an `<error-page>` element.
*/
class WebErrorPageType extends WebXmlElement {
WebErrorPageType() {
this.getName() = "exception-type" and
this.getParent() instanceof WebErrorPage
}
}
/**
* A `<location>` element in a `web.xml` file, nested under an `<error-page>` element.
*/
class WebErrorPageLocation extends WebXmlElement {
WebErrorPageLocation() {
this.getName() = "location" and
this.getParent() instanceof WebErrorPage
}
}