Skip to content

Commit a4fb0e0

Browse files
committed
Added tests
1 parent e165fc7 commit a4fb0e0

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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();
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/CWE-942/CorsMisconfiguration.ql
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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+

0 commit comments

Comments
 (0)