File tree Expand file tree Collapse file tree 3 files changed +16
-31
lines changed
test/experimental/CWE-942 Expand file tree Collapse file tree 3 files changed +16
-31
lines changed Original file line number Diff line number Diff line change 12
12
*/
13
13
14
14
import csharp
15
- private import DataFlow
16
- import semmle.code.csharp.frameworks.system.Web
17
15
import CorsMisconfigurationLib
18
16
19
17
/**
Original file line number Diff line number Diff line change 12
12
*/
13
13
14
14
import csharp
15
- private import DataFlow
16
- import semmle.code.csharp.frameworks.system.Web
17
15
import CorsMisconfigurationLib
18
16
19
- /**
20
- * Holds if credentials are allowed
21
- */
17
+ /** A call to `CorsPolicyBuilder.AllowCredentials`. */
22
18
class AllowsCredentials extends MethodCall {
23
19
AllowsCredentials ( ) {
24
20
this .getTarget ( )
Original file line number Diff line number Diff line change 3
3
using System ;
4
4
using Microsoft . Extensions . DependencyInjection ;
5
5
6
+ public class Startup {
7
+ public void ConfigureServices ( string [ ] args ) {
8
+ var builder = WebApplication . CreateBuilder ( args ) ;
9
+ var MyAllowSpecificOrigins = "_myAllowSpecificOrigins" ;
6
10
11
+ builder . Services . AddCors ( options => {
12
+ options . AddPolicy ( MyAllowSpecificOrigins ,
13
+ policy => {
14
+ policy . SetIsOriginAllowed ( test => true ) . AllowCredentials ( ) . AllowAnyHeader ( ) . AllowAnyMethod ( ) ;
15
+ } ) ;
16
+ } ) ;
7
17
8
- public class Startup
9
- {
10
- public void ConfigureServices ( string [ ] args )
11
- {
12
- var builder = WebApplication . CreateBuilder ( args ) ;
13
- var MyAllowSpecificOrigins = "_myAllowSpecificOrigins" ;
18
+ var app = builder . Build ( ) ;
14
19
20
+ app . MapGet ( "/" , ( ) => "Hello World!" ) ;
21
+ app . UseCors ( MyAllowSpecificOrigins ) ;
15
22
16
- builder . Services . AddCors ( options =>
17
- {
18
- options . AddPolicy ( MyAllowSpecificOrigins ,
19
- policy =>
20
- {
21
- policy . SetIsOriginAllowed ( test => true ) . AllowCredentials ( ) . AllowAnyHeader ( ) . AllowAnyMethod ( ) ;
22
- } ) ;
23
- } ) ;
24
-
25
- var app = builder . Build ( ) ;
26
-
27
-
28
-
29
- app . MapGet ( "/" , ( ) => "Hello World!" ) ;
30
- app . UseCors ( MyAllowSpecificOrigins ) ;
31
-
32
- app . Run ( ) ;
33
- }
23
+ app . Run ( ) ;
24
+ }
34
25
}
You can’t perform that action at this time.
0 commit comments