File tree 1 file changed +14
-6
lines changed
csharp/ql/src/Security Features/CWE-352
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,21 @@ import semmle.code.csharp.frameworks.system.Web
16
16
import semmle.code.csharp.frameworks.system.web.Helpers
17
17
import semmle.code.csharp.frameworks.system.web.Mvc
18
18
19
+ private Method getAValidatingMethod ( ) {
20
+ result = any ( AntiForgeryClass a ) .getValidateMethod ( )
21
+ or
22
+ result .calls ( getAValidatingMethod ( ) )
23
+ }
24
+
19
25
/** An `AuthorizationFilter` that calls the `AntiForgery.Validate` method. */
20
26
class AntiForgeryAuthorizationFilter extends AuthorizationFilter {
21
- AntiForgeryAuthorizationFilter ( ) {
22
- this .getOnAuthorizationMethod ( ) .calls * ( any ( AntiForgeryClass a ) .getValidateMethod ( ) )
23
- }
27
+ AntiForgeryAuthorizationFilter ( ) { this .getOnAuthorizationMethod ( ) = getAValidatingMethod ( ) }
28
+ }
29
+
30
+ private Method getAStartedMethod ( ) {
31
+ result = any ( WebApplication wa ) .getApplication_StartMethod ( )
32
+ or
33
+ getAStartedMethod ( ) .calls ( result )
24
34
}
25
35
26
36
/**
@@ -34,9 +44,7 @@ predicate hasGlobalAntiForgeryFilter() {
34
44
// The filter is an antiforgery filter
35
45
addGlobalFilter .getArgumentForName ( "filter" ) .getType ( ) instanceof AntiForgeryAuthorizationFilter and
36
46
// The filter is added by the Application_Start() method
37
- any ( WebApplication wa )
38
- .getApplication_StartMethod ( )
39
- .calls * ( addGlobalFilter .getEnclosingCallable ( ) )
47
+ getAStartedMethod ( ) = addGlobalFilter .getEnclosingCallable ( )
40
48
)
41
49
}
42
50
You can’t perform that action at this time.
0 commit comments