File tree Expand file tree Collapse file tree 4 files changed +63
-0
lines changed
csharp/ql/test/experimental/CWE-942 Expand file tree Collapse file tree 4 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ using Microsoft.AspNetCore.Builder;
2+ using Microsoft.AspNetCore.Mvc;
3+ using System;
4+
5+
6+ public class Startup
7+ {
8+ public void ConfigureServices(IServiceCollection services)
9+ {
10+ var builder = WebApplication.CreateBuilder(args);
11+ var MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
12+
13+
14+ builder.Services.AddCors(options =>
15+ {
16+ options.AddPolicy(MyAllowSpecificOrigins,
17+ policy =>
18+ {
19+ policy.SetIsOriginAllowed(test => true).AllowCredentials().AllowAnyHeader().AllowAnyMethod();
20+ });
21+ });
22+
23+ var app = builder.Build();
24+
25+
26+
27+ app.MapGet("/", () => "Hello World!");
28+ app.UseCors(MyAllowSpecificOrigins);
29+
30+ app.Run();
31+ }
32+ }
Original file line number Diff line number Diff line change 1+ using Microsoft . AspNetCore . Builder ;
2+ using Microsoft . AspNetCore . Mvc ;
3+ using System ;
4+
5+ var builder = WebApplication . CreateBuilder ( args ) ;
6+ var MyAllowSpecificOrigins = "_myAllowSpecificOrigins" ;
7+
8+
9+ builder . Services . AddCors ( options =>
10+ {
11+ options . AddPolicy ( MyAllowSpecificOrigins ,
12+ policy =>
13+ {
14+ policy . SetIsOriginAllowed ( test => true ) . AllowCredentials ( ) . AllowAnyHeader ( ) . AllowAnyMethod ( ) ;
15+ } ) ;
16+ } ) ;
17+
18+ var app = builder . Build ( ) ;
19+
20+
21+
22+ app . MapGet ( "/" , ( ) => "Hello World!" ) ;
23+ app . UseCors ( MyAllowSpecificOrigins ) ;
24+
25+ app . Run ( ) ;
Original file line number Diff line number Diff line change 1+ experimental/CWE-942/CorsMisconfiguration.ql
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: --load-sources-from-project:../../resources/stubs/_frameworks/Microsoft.AspNetCore.App/Microsoft.AspNetCore.App.csproj
4+ semmle-extractor-options: --load-sources-from-project:../../resources/stubs/Microsoft.Extensions.DependencyInjection.Abstractions/6.0.0/Microsoft.Extensions.DependencyInjection.Abstractions.csproj
5+
You can’t perform that action at this time.
0 commit comments