mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
[PM-5052] Upgrade to .NET 8 (#3461)
* Upgrade to .NET 8 * Linting * Clean up old JSON deserialization code * More .NET 8-oriented linting * Light feedback * Get rid of old test we don't know the root issue for * Fix a new test * Remove now-unnecessary Renovate constraint * Use Any() * Somehow a 6.0 tooling config we don't need snuck back in * Space out properties that always change per release * Bump a few core packages since the last update
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -67,14 +67,14 @@ public class AzureQueueMailHostedService : IHostedService
|
||||
|
||||
if (root.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
foreach (var mailQueueMessage in root.ToObject<List<MailQueueMessage>>())
|
||||
foreach (var mailQueueMessage in root.Deserialize<List<MailQueueMessage>>())
|
||||
{
|
||||
await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage);
|
||||
}
|
||||
}
|
||||
else if (root.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
var mailQueueMessage = root.ToObject<MailQueueMessage>();
|
||||
var mailQueueMessage = root.Deserialize<MailQueueMessage>();
|
||||
await _mailService.SendEnqueuedMailMessageAsync(mailQueueMessage);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class OrganizationConnectionRequestModel<T> : OrganizationConnectionReque
|
||||
|
||||
try
|
||||
{
|
||||
ParsedConfig = model.Config.ToObject<T>(JsonHelpers.IgnoreCase);
|
||||
ParsedConfig = model.Config.Deserialize<T>(JsonHelpers.IgnoreCase);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -59,7 +59,7 @@ public class CreateOrganizationDomainCommand : ICreateOrganizationDomainCommand
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError("Error verifying Organization domain.", e);
|
||||
_logger.LogError(e, "Error verifying Organization domain.");
|
||||
}
|
||||
|
||||
organizationDomain.SetNextRunDate(_globalSettings.DomainVerification.VerificationInterval);
|
||||
|
@ -88,7 +88,7 @@ public class ValidateSponsorshipCommand : CancelSponsorshipCommand, IValidateSpo
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.LogError("Error sending Family sponsorship removed email.", e);
|
||||
_logger.LogError(e, "Error sending Family sponsorship removed email.");
|
||||
}
|
||||
}
|
||||
await base.DeleteSponsorshipAsync(sponsorship);
|
||||
|
@ -45,18 +45,6 @@ public static class JsonHelpers
|
||||
};
|
||||
}
|
||||
|
||||
[Obsolete("This is built into .NET 6, it SHOULD be removed when we upgrade")]
|
||||
public static T ToObject<T>(this JsonElement element, JsonSerializerOptions options = null)
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(element.GetRawText(), options ?? Default);
|
||||
}
|
||||
|
||||
[Obsolete("This is built into .NET 6, it SHOULD be removed when we upgrade")]
|
||||
public static T ToObject<T>(this JsonDocument document, JsonSerializerOptions options = null)
|
||||
{
|
||||
return JsonSerializer.Deserialize<T>(document.RootElement.GetRawText(), options ?? default);
|
||||
}
|
||||
|
||||
public static T DeserializeOrNew<T>(string json, JsonSerializerOptions options = null)
|
||||
where T : new()
|
||||
{
|
||||
|
@ -15,13 +15,13 @@ public sealed class SecurityHeadersMiddleware
|
||||
public Task Invoke(HttpContext context)
|
||||
{
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
|
||||
context.Response.Headers.Add("x-frame-options", new StringValues("SAMEORIGIN"));
|
||||
context.Response.Headers.Append("x-frame-options", new StringValues("SAMEORIGIN"));
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection
|
||||
context.Response.Headers.Add("x-xss-protection", new StringValues("1; mode=block"));
|
||||
context.Response.Headers.Append("x-xss-protection", new StringValues("1; mode=block"));
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
|
||||
context.Response.Headers.Add("x-content-type-options", new StringValues("nosniff"));
|
||||
context.Response.Headers.Append("x-content-type-options", new StringValues("nosniff"));
|
||||
|
||||
return _next(context);
|
||||
}
|
||||
|
@ -18,21 +18,4 @@ public static class SpanExtensions
|
||||
rest = input[++splitIndex..];
|
||||
return true;
|
||||
}
|
||||
|
||||
// Replace with the implementation from .NET 8 when we upgrade
|
||||
// Ref: https://github.com/dotnet/runtime/issues/59466
|
||||
public static int Count<T>(this ReadOnlySpan<T> span, T value)
|
||||
where T : IEquatable<T>
|
||||
{
|
||||
var count = 0;
|
||||
int pos;
|
||||
|
||||
while ((pos = span.IndexOf(value)) >= 0)
|
||||
{
|
||||
span = span[++pos..];
|
||||
count++;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -104,13 +104,13 @@ public class AzureQueueHostedService : IHostedService, IDisposable
|
||||
var root = jsonDocument.RootElement;
|
||||
if (root.ValueKind == JsonValueKind.Array)
|
||||
{
|
||||
var indexedEntities = root.ToObject<List<EventMessage>>()
|
||||
var indexedEntities = root.Deserialize<List<EventMessage>>()
|
||||
.SelectMany(e => EventTableEntity.IndexEvent(e));
|
||||
events.AddRange(indexedEntities);
|
||||
}
|
||||
else if (root.ValueKind == JsonValueKind.Object)
|
||||
{
|
||||
var eventMessage = root.ToObject<EventMessage>();
|
||||
var eventMessage = root.Deserialize<EventMessage>();
|
||||
events.AddRange(EventTableEntity.IndexEvent(eventMessage));
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
@ -1,11 +1,11 @@
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0
|
||||
|
||||
LABEL com.bitwarden.product="bitwarden"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
curl \
|
||||
gosu \
|
||||
curl \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV ASPNETCORE_URLS http://+:5000
|
||||
|
Reference in New Issue
Block a user