@@ -16,10 +16,10 @@ import semmle.code.asp.WebConfig
16
16
import semmle.code.csharp.frameworks.system.Web
17
17
18
18
/**
19
- * Holds if there exists a `Web.config` file in the snapshot that adds an `X-Frame-Options` header.
19
+ * Holds if the `Web.config` file `webConfig` adds an `X-Frame-Options` header.
20
20
*/
21
- predicate hasWebConfigXFrameOptions ( ) {
22
- // Looking for an entry in a Web.config file that looks like this:
21
+ predicate hasWebConfigXFrameOptions ( WebConfigXML webConfig ) {
22
+ // Looking for an entry in `webConfig` that looks like this:
23
23
// ```
24
24
// <system.webServer>
25
25
// <httpProtocol>
@@ -29,17 +29,13 @@ predicate hasWebConfigXFrameOptions() {
29
29
// </httpProtocol>
30
30
// </system.webServer>
31
31
// ```
32
- exists ( XMLElement element |
33
- element =
34
- any ( WebConfigXML webConfig )
35
- .getARootElement ( )
36
- .getAChild ( "system.webServer" )
37
- .getAChild ( "httpProtocol" )
38
- .getAChild ( "customHeaders" )
39
- .getAChild ( "add" )
40
- |
41
- element .getAttributeValue ( "name" ) = "X-Frame-Options"
42
- )
32
+ webConfig
33
+ .getARootElement ( )
34
+ .getAChild ( "system.webServer" )
35
+ .getAChild ( "httpProtocol" )
36
+ .getAChild ( "customHeaders" )
37
+ .getAChild ( "add" )
38
+ .getAttributeValue ( "name" ) = "X-Frame-Options"
43
39
}
44
40
45
41
/**
@@ -57,6 +53,6 @@ predicate hasCodeXFrameOptions() {
57
53
58
54
from WebConfigXML webConfig
59
55
where
60
- not hasWebConfigXFrameOptions ( ) and
56
+ not hasWebConfigXFrameOptions ( webConfig ) and
61
57
not hasCodeXFrameOptions ( )
62
58
select webConfig , "Configuration file is missing the X-Frame-Options setting."
0 commit comments