File tree Expand file tree Collapse file tree 6 files changed +44
-7
lines changed
src/Security Features/CWE-451 Expand file tree Collapse file tree 6 files changed +44
-7
lines changed Original file line number Diff line number Diff line change @@ -30,13 +30,16 @@ predicate hasWebConfigXFrameOptions(WebConfigXml webConfig) {
3030 // </httpProtocol>
3131 // </system.webServer>
3232 // ```
33- webConfig
34- .getARootElement ( )
35- .getAChild ( "system.webServer" )
36- .getAChild ( "httpProtocol" )
37- .getAChild ( "customHeaders" )
38- .getAChild ( "add" )
39- .getAttributeValue ( "name" ) = "X-Frame-Options"
33+ // This can also be in a `location`
34+ exists ( XmlElement root |
35+ root = webConfig .getARootElement ( ) and
36+ [ root , root .getAChild ( "location" ) ]
37+ .getAChild ( "system.webServer" )
38+ .getAChild ( "httpProtocol" )
39+ .getAChild ( "customHeaders" )
40+ .getAChild ( "add" )
41+ .getAttributeValue ( "name" ) = "X-Frame-Options"
42+ )
4043}
4144
4245/**
Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Web ;
3+
4+ public class AddXFrameOptions : IHttpHandler
5+ {
6+
7+ public void ProcessRequest ( HttpContext ctx )
8+ {
9+ }
10+
11+ public bool IsReusable
12+ {
13+ get
14+ {
15+ return true ;
16+ }
17+ }
18+ }
Original file line number Diff line number Diff line change 1+ Security Features/CWE-451/MissingXFrameOptions.ql
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <configuration >
3+ <location path =" ." inheritInChildApplications =" false" >
4+ <system .webServer>
5+ <httpProtocol >
6+ <customHeaders >
7+ <add name =" X-Frame-Options" value =" SAMEORIGIN" />
8+ </customHeaders >
9+ </httpProtocol >
10+ </system .webServer>
11+ </location >
12+ </configuration >
Original file line number Diff line number Diff line change 1+ semmle-extractor-options: /nostdlib /noconfig
2+ semmle-extractor-options: --load-sources-from-project:${testdir}/../../../../../resources/stubs/_frameworks/Microsoft.NETCore.App/Microsoft.NETCore.App.csproj
3+ semmle-extractor-options: ${testdir}/../../../../../resources/stubs/System.Web.cs
You can’t perform that action at this time.
0 commit comments