@@ -16,10 +16,10 @@ import semmle.code.asp.WebConfig
1616import semmle.code.csharp.frameworks.system.Web
1717
1818/**
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.
2020 */
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:
2323 // ```
2424 // <system.webServer>
2525 // <httpProtocol>
@@ -29,17 +29,13 @@ predicate hasWebConfigXFrameOptions() {
2929 // </httpProtocol>
3030 // </system.webServer>
3131 // ```
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"
4339}
4440
4541/**
@@ -57,6 +53,6 @@ predicate hasCodeXFrameOptions() {
5753
5854from WebConfigXML webConfig
5955where
60- not hasWebConfigXFrameOptions ( ) and
56+ not hasWebConfigXFrameOptions ( webConfig ) and
6157 not hasCodeXFrameOptions ( )
6258select webConfig , "Configuration file is missing the X-Frame-Options setting."
0 commit comments