-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathWebConfig.qll
More file actions
142 lines (122 loc) · 4.14 KB
/
WebConfig.qll
File metadata and controls
142 lines (122 loc) · 4.14 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
/**
* Provides classes and predicates related to ASP.NET Web.config files.
*/
import csharp
/**
* A `Web.config` file.
*/
class WebConfigXml extends XmlFile {
WebConfigXml() { this.getName().toLowerCase().matches("%web.config") }
}
/**
* A `Web.config` transformation file.
*/
class WebConfigReleaseTransformXml extends XmlFile {
WebConfigReleaseTransformXml() { this.getName().toLowerCase().matches("%web.release.config") }
}
/** A `<configuration>` tag in an ASP.NET configuration file. */
class ConfigurationXmlElement extends XmlElement {
ConfigurationXmlElement() { this.getName().toLowerCase() = "configuration" }
}
/** A `<compilation>` tag in an ASP.NET configuration file. */
class CompilationXmlElement extends XmlElement {
CompilationXmlElement() { this.getName().toLowerCase() = "compilation" }
}
/** A `<location>` tag in an ASP.NET configuration file. */
class LocationXmlElement extends XmlElement {
LocationXmlElement() {
this.getParent() instanceof ConfigurationXmlElement and
this.getName().toLowerCase() = "location"
}
}
/** A `<system.web>` tag in an ASP.NET configuration file. */
class SystemWebXmlElement extends XmlElement {
SystemWebXmlElement() {
(
this.getParent() instanceof ConfigurationXmlElement
or
this.getParent() instanceof LocationXmlElement
) and
this.getName().toLowerCase() = "system.web"
}
}
/** A `<system.webServer>` tag in an ASP.NET configuration file. */
class SystemWebServerXmlElement extends XmlElement {
SystemWebServerXmlElement() {
(
this.getParent() instanceof ConfigurationXmlElement
or
this.getParent() instanceof LocationXmlElement
) and
this.getName().toLowerCase() = "system.webserver"
}
}
/** A `<customErrors>` tag in an ASP.NET configuration file. */
class CustomErrorsXmlElement extends XmlElement {
CustomErrorsXmlElement() {
this.getParent() instanceof SystemWebXmlElement and
this.getName().toLowerCase() = "customerrors"
}
}
/** A `<httpRuntime>` tag in an ASP.NET configuration file. */
class HttpRuntimeXmlElement extends XmlElement {
HttpRuntimeXmlElement() {
this.getParent() instanceof SystemWebXmlElement and
this.getName().toLowerCase() = "httpruntime"
}
}
/** A `<forms>` tag under `<system.web><authentication>` in an ASP.NET configuration file. */
class FormsElement extends XmlElement {
FormsElement() {
this = any(SystemWebXmlElement sw).getAChild("authentication").getAChild("forms")
}
/**
* Gets attribute's `requireSSL` value.
*/
string getRequireSsl() {
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
}
/**
* Holds if `requireSSL` value is true.
*/
predicate isRequireSsl() { this.getRequireSsl() = "true" }
}
/** A `<httpCookies>` tag in an ASP.NET configuration file. */
class HttpCookiesElement extends XmlElement {
HttpCookiesElement() { this = any(SystemWebXmlElement sw).getAChild("httpCookies") }
/**
* Gets attribute's `httpOnlyCookies` value.
*/
string getHttpOnlyCookies() {
result = this.getAttribute("httpOnlyCookies").getValue().trim().toLowerCase()
}
/**
* Holds if there is any chance that `httpOnlyCookies` is set to `true`.
*/
predicate isHttpOnlyCookies() { this.getHttpOnlyCookies() = "true" }
/**
* Gets attribute's `requireSSL` value.
*/
string getRequireSsl() {
result = this.getAttribute("requireSSL").getValue().trim().toLowerCase()
}
/**
* Holds if there is any chance that `requireSSL` is set to `true` either globally or for Forms.
*/
predicate isRequireSsl() {
this.getRequireSsl() = "true"
or
not this.getRequireSsl() = "false" and // not set all, i.e. default
exists(FormsElement forms | forms.getFile() = this.getFile() | forms.isRequireSsl())
}
}
/** A `Transform` attribute in a Web.config transformation file. */
class TransformXmlAttribute extends XmlAttribute {
TransformXmlAttribute() { this.getName().toLowerCase() = "transform" }
/**
* Gets the list of attribute removals in `Transform=RemoveAttributes(list)`.
*/
string getRemoveAttributes() {
result = this.getValue().regexpCapture("RemoveAttributes\\((.*)\\)", 1).splitAt(",")
}
}