Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
dotnet-version: 10.x.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-dev-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
dotnet-version: 10.x.x

- name: Restore dependencies
run: dotnet restore
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.x.x
dotnet-version: 10.x.x

- name: Restore dependencies
run: dotnet restore
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS base
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY ["SS14.MapServer/SS14.MapServer.csproj", "SS14.MapServer/"]
RUN dotnet restore "SS14.MapServer/SS14.MapServer.csproj"
Expand Down
12 changes: 6 additions & 6 deletions SS14.MapServer.Tests/SS14.MapServer.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand All @@ -10,14 +10,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.7.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.2.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.12.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PackageReference Include="coverlet.collector" Version="10.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions SS14.MapServer/Controllers/GitHubWebhookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public async Task<IActionResult> Post()

var cloneUrl = pushEvent.Repository?.CloneUrl ?? string.Empty;
if (cloneUrl != string.Empty && !_gitConfiguration.RepositoryUrl.Equals(cloneUrl))
return new BadRequestObjectResult($"Instance not configured for repository: {pushEvent.Repository.CloneUrl}");
return new BadRequestObjectResult($"Instance not configured for repository: {pushEvent.Repository?.CloneUrl}");

switch (eventName)
{
Expand Down Expand Up @@ -319,7 +319,7 @@ private string GetGridImageUrl(Guid mapGuid, int gridId)
/// </summary>
public sealed class PatchedPushEventPayload : PushEventPayload
{
public string Before { get; private set; }
public new string Before { get; private set; }
public string After { get; private set; }
public new string Ref { get; private set; }
}
12 changes: 9 additions & 3 deletions SS14.MapServer/Helpers/MapFromDataParameterFilter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace SS14.MapServer.Helpers;
Expand All @@ -12,12 +12,18 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)
if (methodName != "PostMap" && methodName != "PutMap")
return;

if (operation.RequestBody?.Content is null)
return;
if(!operation.RequestBody.Content.TryGetValue("multipart/form-data", out var type))
return;

if(type.Schema?.Properties is null)
return;
if(!type.Schema.Properties.TryGetValue("images", out var imagesParameter))
return;

if (type.Encoding is null)
return;
if(!type.Encoding.TryGetValue("images", out var imageEncoding))
return;

Expand All @@ -32,13 +38,13 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)

var mapParameter = new OpenApiSchema
{
Type = "string"
Type = JsonSchemaType.String
};

type.Schema.Properties.Clear();
type.Schema.Properties.Add("images", imagesParameter);
type.Schema.Properties.Add("map", mapParameter);

type.Schema.Required.Clear();
type.Schema?.Required?.Clear();
}
}
2 changes: 1 addition & 1 deletion SS14.MapServer/Jobs/ProcessTiledImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public async Task Execute(IJobExecutionContext context)
{
var dataMap = context.JobDetail.JobDataMap;

if (dataMap.Get(ProcessOptionsKey) is not ProcessingOptions options)
if (dataMap[ProcessOptionsKey] is not ProcessingOptions options)
throw new JobExecutionException($"Job data value with key ${ProcessOptionsKey} and type ProcessingOptions is missing");

var tiles = await _processingService.TileImage(
Expand Down
8 changes: 4 additions & 4 deletions SS14.MapServer/Models/DTOs/MapRendererData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace SS14.MapServer.Models.DTOs;

public sealed class MapRendererData
{
public string Id {get; set;}
public required string Id {get; set;}
[Required, JsonProperty("Name")]
public string DisplayName {get; set;}
public required string DisplayName {get; set;}
[JsonProperty("Attributions")]
public string? Attribution {get; set;}
[Required]
public List<GridData> Grids {get;} = new();
public List<ParallaxLayer> ParallaxLayers {get; set;}
}
public required List<ParallaxLayer> ParallaxLayers {get; set;}
}
2 changes: 1 addition & 1 deletion SS14.MapServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Npgsql;
using Quartz;
using Quartz.AspNetCore;
Expand Down
36 changes: 18 additions & 18 deletions SS14.MapServer/SS14.MapServer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand All @@ -10,30 +10,30 @@

<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.15" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="JetBrains.Annotations" Version="2025.2.4" />
<PackageReference Include="JsonModelBinder" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.6">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="9.0.3" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="9.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.6" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.6" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="10.0.6" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="10.0.6" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="10.0.2" />
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
<PackageReference Include="Npgsql" Version="10.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
<PackageReference Include="Octokit" Version="14.0.0" />
<PackageReference Include="Quartz.AspNetCore" Version="3.14.0" />
<PackageReference Include="Sentry.AspNetCore" Version="5.5.0" />
<PackageReference Include="Sentry.Serilog" Version="5.5.0" />
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.7" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="8.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="8.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.3" />
<PackageReference Include="Quartz.AspNetCore" Version="3.18.0" />
<PackageReference Include="Sentry.AspNetCore" Version="6.4.0" />
<PackageReference Include="Sentry.Serilog" Version="6.4.0" />
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.7" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.6" />
</ItemGroup>

<ItemGroup>
Expand Down
28 changes: 11 additions & 17 deletions SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace SS14.MapServer.Security;
Expand All @@ -14,24 +14,18 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context)

if (allowsAnonymousAccess)
return;

operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" });
operation.Responses.Add("403", new OpenApiResponse { Description = "Forbidden" });

var apiKeyScheme = new OpenApiSecurityScheme
{
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = ApiKeyHandler.Name }
};
operation.Responses?.Add("401", new OpenApiResponse { Description = "Unauthorized" });
operation.Responses?.Add("403", new OpenApiResponse { Description = "Forbidden" });

operation.Security = new List<OpenApiSecurityRequirement>
{
new()
var apiKeyScheme = new OpenApiSecuritySchemeReference(ApiKeyHandler.Name, context.Document);

operation.Security =
[
new OpenApiSecurityRequirement
{
[ apiKeyScheme ] = new List<string>
{
"API"
}
[apiKeyScheme] = ["API"]
}
};
];
}
}
}
2 changes: 1 addition & 1 deletion SS14.MapServer/Services/FileManagementService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private Task<int> InternalCleanBuildDirectories()
file.Delete();
filesCounter++;
}
catch (Exception e)
catch (Exception)
{
// Ignore
}
Expand Down
4 changes: 2 additions & 2 deletions SS14.MapServer/Services/MapService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void DeleteFile(string path)
{
File.Delete(path);
}
catch (Exception _)
catch (Exception)
{
// Best effort deletion
}
Expand All @@ -56,7 +56,7 @@ private void DeleteDirectory(string path)
{
Directory.Delete(path, true);
}
catch (Exception _)
catch (Exception)
{
// Best effort deletion
}
Expand Down