Skip to content

Commit

Permalink
Removed Support For .NET 6; Added Support For .NET 9 (#100)
Browse files Browse the repository at this point in the history
* Removed support for .NET 6 and 7;
Updated csproj version numbers throughout;
Upgraded NuGet packages used in Tests project;
Rebuilt Example project using .NET 9;
Updated Readme, NuGet specific Readme, changelog, and documentation files.

* Ran dotnet-format on codebase

* Upped .NET SDK version in GitHub workflows

* Updated .NET SDK version in GitHub workflows to v9

* Added locked mode to .NET restore action in Github workflows

* Added RestorePackagesWithLockFile to all csproj's to enhance OpenSSF Score and pin dependencies

* Added project.lock.json files

* Excluded packages.lock.json from NuGet package command
  • Loading branch information
jamie-taylor-rjj authored Nov 20, 2024
1 parent 1f3a692 commit 62367f4
Show file tree
Hide file tree
Showing 18 changed files with 529 additions and 167 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '9.0.x'

- name: Install dependencies
run: dotnet restore
run: dotnet restore --locked-mode

- name: Build
run: dotnet build --configuration Release --no-restore
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '9.0.x'

- name: Install dependencies
run: dotnet restore
run: dotnet restore --locked-mode

- name: Build
run: dotnet build --configuration Release --no-restore
Expand Down
37 changes: 16 additions & 21 deletions OwaspHeaders.Core.Example/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
using Microsoft.AspNetCore.Mvc;

namespace OwaspHeaders.Core.Example.Controllers;

[ApiController]
[Route("/")]
public class HomeController : ControllerBase
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

[HttpGet(Name = "/")]
public IEnumerable<string> Get()
{
return HttpContext.Response.Headers.Select(h => h.ToString()).ToArray();
}
}
using Microsoft.AspNetCore.Mvc;

namespace OwaspHeaders.Core.Example.Controllers;

[ApiController]
[Route("/")]
public class HomeController(ILogger<HomeController> logger) : ControllerBase
{
private readonly ILogger<HomeController> _logger = logger;

[HttpGet(Name = "/")]
public IEnumerable<string> Get()
{
return HttpContext.Response.Headers.Select(h => h.ToString()).ToArray();
}
}
34 changes: 19 additions & 15 deletions OwaspHeaders.Core.Example/OwaspHeaders.Core.Example.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="ClacksMiddlware" Version="2.0.2" />
<ProjectReference Include="..\src\OwaspHeaders.Core.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\OwaspHeaders.Core.csproj" />
</ItemGroup>

</Project>
58 changes: 29 additions & 29 deletions OwaspHeaders.Core.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
using OwaspHeaders.Core.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.UseSecureHeadersMiddleware();

app.MapControllers();

app.Run();
using OwaspHeaders.Core.Extensions;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.UseSecureHeadersMiddleware();

app.MapControllers();

app.Run();
72 changes: 41 additions & 31 deletions OwaspHeaders.Core.Example/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:24885",
"sslPort": 44362
}
},
"profiles": {
"example": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7001;http://localhost:5265",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:39531",
"sslPort": 44308
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5231",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7090;http://localhost:5231",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
16 changes: 8 additions & 8 deletions OwaspHeaders.Core.Example/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
18 changes: 9 additions & 9 deletions OwaspHeaders.Core.Example/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
119 changes: 119 additions & 0 deletions OwaspHeaders.Core.Example/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
{
"version": 1,
"dependencies": {
"net8.0": {
"Microsoft.AspNetCore.OpenApi": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "P1mkNhZ3IwU3phNLIUkgqVXb1exnooTalIYwpSON3oKKkcRtACDgS4WpO+xnwFw4KzV0bmgkUqB3acXxIefvvg==",
"dependencies": {
"Microsoft.OpenApi": "1.4.3"
}
},
"Swashbuckle.AspNetCore": {
"type": "Direct",
"requested": "[6.4.0, )",
"resolved": "6.4.0",
"contentHash": "eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==",
"dependencies": {
"Microsoft.Extensions.ApiDescription.Server": "6.0.5",
"Swashbuckle.AspNetCore.Swagger": "6.4.0",
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0",
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0"
}
},
"Microsoft.Extensions.ApiDescription.Server": {
"type": "Transitive",
"resolved": "6.0.5",
"contentHash": "Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw=="
},
"Microsoft.OpenApi": {
"type": "Transitive",
"resolved": "1.4.3",
"contentHash": "rURwggB+QZYcSVbDr7HSdhw/FELvMlriW10OeOzjPT7pstefMo7IThhtNtDudxbXhW+lj0NfX72Ka5EDsG8x6w=="
},
"Swashbuckle.AspNetCore.Swagger": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==",
"dependencies": {
"Microsoft.OpenApi": "1.2.3"
}
},
"Swashbuckle.AspNetCore.SwaggerGen": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==",
"dependencies": {
"Swashbuckle.AspNetCore.Swagger": "6.4.0"
}
},
"Swashbuckle.AspNetCore.SwaggerUI": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ=="
},
"owaspheaders.core": {
"type": "Project"
}
},
"net9.0": {
"Microsoft.AspNetCore.OpenApi": {
"type": "Direct",
"requested": "[7.0.0, )",
"resolved": "7.0.0",
"contentHash": "P1mkNhZ3IwU3phNLIUkgqVXb1exnooTalIYwpSON3oKKkcRtACDgS4WpO+xnwFw4KzV0bmgkUqB3acXxIefvvg==",
"dependencies": {
"Microsoft.OpenApi": "1.4.3"
}
},
"Swashbuckle.AspNetCore": {
"type": "Direct",
"requested": "[6.4.0, )",
"resolved": "6.4.0",
"contentHash": "eUBr4TW0up6oKDA5Xwkul289uqSMgY0xGN4pnbOIBqCcN9VKGGaPvHX3vWaG/hvocfGDP+MGzMA0bBBKz2fkmQ==",
"dependencies": {
"Microsoft.Extensions.ApiDescription.Server": "6.0.5",
"Swashbuckle.AspNetCore.Swagger": "6.4.0",
"Swashbuckle.AspNetCore.SwaggerGen": "6.4.0",
"Swashbuckle.AspNetCore.SwaggerUI": "6.4.0"
}
},
"Microsoft.Extensions.ApiDescription.Server": {
"type": "Transitive",
"resolved": "6.0.5",
"contentHash": "Ckb5EDBUNJdFWyajfXzUIMRkhf52fHZOQuuZg/oiu8y7zDCVwD0iHhew6MnThjHmevanpxL3f5ci2TtHQEN6bw=="
},
"Microsoft.OpenApi": {
"type": "Transitive",
"resolved": "1.4.3",
"contentHash": "rURwggB+QZYcSVbDr7HSdhw/FELvMlriW10OeOzjPT7pstefMo7IThhtNtDudxbXhW+lj0NfX72Ka5EDsG8x6w=="
},
"Swashbuckle.AspNetCore.Swagger": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "nl4SBgGM+cmthUcpwO/w1lUjevdDHAqRvfUoe4Xp/Uvuzt9mzGUwyFCqa3ODBAcZYBiFoKvrYwz0rabslJvSmQ==",
"dependencies": {
"Microsoft.OpenApi": "1.2.3"
}
},
"Swashbuckle.AspNetCore.SwaggerGen": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "lXhcUBVqKrPFAQF7e/ZeDfb5PMgE8n5t6L5B6/BQSpiwxgHzmBcx8Msu42zLYFTvR5PIqE9Q9lZvSQAcwCxJjw==",
"dependencies": {
"Swashbuckle.AspNetCore.Swagger": "6.4.0"
}
},
"Swashbuckle.AspNetCore.SwaggerUI": {
"type": "Transitive",
"resolved": "6.4.0",
"contentHash": "1Hh3atb3pi8c+v7n4/3N80Jj8RvLOXgWxzix6w3OZhB7zBGRwsy7FWr4e3hwgPweSBpwfElqj4V4nkjYabH9nQ=="
},
"owaspheaders.core": {
"type": "Project"
}
}
}
}
Loading

0 comments on commit 62367f4

Please sign in to comment.