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 1212 */
1313
1414import csharp
15- private import DataFlow
16- import semmle.code.csharp.frameworks.system.Web
1715import CorsMisconfigurationLib
1816
1917/**
Original file line number Diff line number Diff line change 1212 */
1313
1414import csharp
15- private import DataFlow
16- import semmle.code.csharp.frameworks.system.Web
1715import CorsMisconfigurationLib
1816
19- /**
20- * Holds if credentials are allowed
21- */
17+ /** A call to `CorsPolicyBuilder.AllowCredentials`. */
2218class AllowsCredentials extends MethodCall {
2319 AllowsCredentials ( ) {
2420 this .getTarget ( )
Original file line number Diff line number Diff line change 33using System ;
44using Microsoft . Extensions . DependencyInjection ;
55
6+ public class Startup {
7+ public void ConfigureServices ( string [ ] args ) {
8+ var builder = WebApplication . CreateBuilder ( args ) ;
9+ var MyAllowSpecificOrigins = "_myAllowSpecificOrigins" ;
610
11+ builder . Services . AddCors ( options => {
12+ options . AddPolicy ( MyAllowSpecificOrigins ,
13+ policy => {
14+ policy . SetIsOriginAllowed ( test => true ) . AllowCredentials ( ) . AllowAnyHeader ( ) . AllowAnyMethod ( ) ;
15+ } ) ;
16+ } ) ;
717
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 ( ) ;
1419
20+ app . MapGet ( "/" , ( ) => "Hello World!" ) ;
21+ app . UseCors ( MyAllowSpecificOrigins ) ;
1522
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+ }
3425}
You can’t perform that action at this time.
0 commit comments