Current libraries: the database, media, sanitizer, mail and sign-in libraries are on their latest versions
Build / Build (push) Successful in 35s
Build / Build (push) Successful in 35s
- MongoDB.Entities 26, FFMpegCore 6, HtmlSanitizer 11, Serilog's MongoDB sink 8, OpenIddict 7.8, MailKit 4.18.2, Markdig 1.6, Swashbuckle 10.3, QRCoder 1.8.1 and the .NET 10.0.14 sign-in library; the build uses SDK 10.0.403. The two packages with known vulnerabilities in the old set are gone. - Stored records are read and written exactly as before: ids keep their form, personas and groups still get ids that carry their published day, and an older version can still read what this one writes. - Videos are probed, transcoded and given a poster frame as before. - Federated posts are cleaned exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
This commit is contained in:
1 parent
739a1603ca
commit
8a1e4e419b
9 files changed
+88
-26
No files matched your search
@@ -601,7 +601,7 @@ namespace PrivaPub.Domain.Media
|
||||
await _processing.WaitAsync(token);
|
||||
try
|
||||
{
|
||||
var probe = await FFProbe.AnalyseAsync(input, default, token, "-protocol_whitelist file");
|
||||
var probe = await FFProbe.AnalyseAsync(input, customArguments: "-protocol_whitelist file", cancellationToken: token);
|
||||
if (probe.Duration > TimeSpan.FromSeconds(options.MaxSeconds))
|
||||
return MediaOutcome.Fail(StatusCodes.Status422UnprocessableEntity, "Validation failed: The file is too long");
|
||||
var video = attachment.ContentType.StartsWith("video/", StringComparison.Ordinal) ? probe.PrimaryVideoStream : default;
|
||||
@@ -614,7 +614,7 @@ namespace PrivaPub.Domain.Media
|
||||
if (video == default)
|
||||
arguments = "-map 0:a:0 -vn -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "m4a" ? " -movflags +faststart" : string.Empty);
|
||||
else if (video.CodecName is "h264" or "vp8" or "vp9" or "av1" && (long)video.Width * video.Height <= options.MaxVideoPixels
|
||||
&& video.FrameRate <= options.MaxFrameRate + 0.5)
|
||||
&& video.RealFrameRate <= options.MaxFrameRate + 0.5)
|
||||
arguments = "-map 0:v:0 -map 0:a:0? -dn -sn -map_metadata -1 -map_chapters -1 -c copy" + (extension == "mp4" ? " -movflags +faststart" : string.Empty);
|
||||
else
|
||||
{
|
||||
@@ -631,13 +631,15 @@ namespace PrivaPub.Domain.Media
|
||||
.CancellableThrough(token)
|
||||
.ProcessAsynchronously();
|
||||
|
||||
var made = await FFProbe.AnalyseAsync(output, default, token, "-protocol_whitelist file");
|
||||
var made = await FFProbe.AnalyseAsync(output, customArguments: "-protocol_whitelist file", cancellationToken: token);
|
||||
byte[] poster = default;
|
||||
if (video != default)
|
||||
{
|
||||
attachment.Width = made.PrimaryVideoStream?.Width;
|
||||
attachment.Height = made.PrimaryVideoStream?.Height;
|
||||
await FFMpeg.SnapshotAsync(output, frame, captureTime: TimeSpan.FromSeconds(Math.Min(1, made.Duration.TotalSeconds / 2)), cancellationToken: token);
|
||||
await FFMpeg.Snapshot(made, frame, captureTime: TimeSpan.FromSeconds(Math.Min(1, made.Duration.TotalSeconds / 2)))
|
||||
.CancellableThrough(token)
|
||||
.ProcessAsynchronously();
|
||||
var still = ProcessImage(await File.ReadAllBytesAsync(frame, token), 640, options.PreviewSide);
|
||||
poster = still.Preview;
|
||||
attachment.Blurhash = still.Blurhash;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization;
|
||||
using MongoDB.Entities;
|
||||
|
||||
namespace PrivaPub.Infrastructure.Data
|
||||
{
|
||||
public interface IOwnId
|
||||
{
|
||||
string NewId();
|
||||
}
|
||||
|
||||
public static class EntityIds
|
||||
{
|
||||
static readonly Lock Gate = new();
|
||||
|
||||
public static void Register()
|
||||
{
|
||||
lock (Gate)
|
||||
{
|
||||
if (BsonClassMap.IsClassMapRegistered(typeof(Entity)))
|
||||
{
|
||||
if (BsonClassMap.LookupClassMap(typeof(Entity)).IdMemberMap?.IdGenerator is Generator)
|
||||
return;
|
||||
|
||||
throw new InvalidOperationException(
|
||||
"The BSON map of Entity was built before EntityIds.Register(), so IDs would not be stored as they always were. Register them before anything touches a stored record.");
|
||||
}
|
||||
|
||||
BsonClassMap.RegisterClassMap<Entity>(map =>
|
||||
{
|
||||
map.AutoMap();
|
||||
map.SetIgnoreExtraElements(true);
|
||||
var id = map.MapIdProperty(entity => entity.ID);
|
||||
((IBsonMemberMapAttribute)new AsObjectIdAttribute()).Apply(id);
|
||||
id.SetIdGenerator(new Generator());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Generator : IIdGenerator
|
||||
{
|
||||
public object GenerateId(object container, object document)
|
||||
=> document is IOwnId own ? own.NewId() : ObjectId.GenerateNewId().ToString();
|
||||
|
||||
public bool IsEmpty(object id)
|
||||
=> string.IsNullOrEmpty(id as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
using MongoDB.Entities;
|
||||
|
||||
using PrivaPub.Infrastructure.Data;
|
||||
using PrivaPub.Infrastructure.Ids;
|
||||
|
||||
namespace PrivaPub.Models.Group
|
||||
{
|
||||
public class Group : Entity
|
||||
public class Group : Entity, IOwnId
|
||||
{
|
||||
public string UserName { get; set; }//preferredUsername
|
||||
public string Name { get; set; }//name
|
||||
@@ -35,7 +36,7 @@ namespace PrivaPub.Models.Group
|
||||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime? DeletionAt { get; set; }
|
||||
|
||||
public override object GenerateNewID() => PrivacyIds.ForDay(PublishedOn);
|
||||
public string NewId() => PrivacyIds.ForDay(PublishedOn);
|
||||
}
|
||||
|
||||
public class GroupMember
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using MongoDB.Entities;
|
||||
|
||||
using PrivaPub.Infrastructure.Data;
|
||||
using PrivaPub.Infrastructure.Ids;
|
||||
|
||||
namespace PrivaPub.Models.User
|
||||
{
|
||||
public class Avatar : Entity
|
||||
public class Avatar : Entity, IOwnId
|
||||
{
|
||||
public string Url { get; set; }//url
|
||||
public string Name { get; set; }//name
|
||||
@@ -40,7 +41,7 @@ namespace PrivaPub.Models.User
|
||||
public DateTime? BannedAt { get; set; }
|
||||
public DateTime? DeletionAt { get; set; }
|
||||
|
||||
public override object GenerateNewID() => PrivacyIds.ForDay(PublishedOn);
|
||||
public string NewId() => PrivacyIds.ForDay(PublishedOn);
|
||||
}
|
||||
|
||||
public class ForeignAvatar : Entity
|
||||
|
||||
+11
-11
@@ -8,22 +8,22 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />
|
||||
<PackageReference Include="FFMpegCore" Version="5.5.0" />
|
||||
<PackageReference Include="HtmlSanitizer" Version="9.2.1039" />
|
||||
<PackageReference Include="MailKit" Version="4.18.0" />
|
||||
<PackageReference Include="Markdig" Version="1.4.0" />
|
||||
<PackageReference Include="FFMpegCore" Version="6.0.0" />
|
||||
<PackageReference Include="HtmlSanitizer" Version="11.0.26" />
|
||||
<PackageReference Include="MailKit" Version="4.18.2" />
|
||||
<PackageReference Include="Markdig" Version="1.6.0" />
|
||||
<PackageReference Include="MaxMind.Db" Version="5.2.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.9" />
|
||||
<PackageReference Include="MongoDB.Entities" Version="25.1.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.14" />
|
||||
<PackageReference Include="MongoDB.Entities" Version="26.0.0" />
|
||||
<PackageReference Include="NetVips" Version="3.2.0" />
|
||||
<PackageReference Include="NetVips.Native.linux-x64" Version="8.18.7" />
|
||||
<PackageReference Include="OpenIddict.AspNetCore" Version="7.7.1" />
|
||||
<PackageReference Include="OpenIddict.MongoDb" Version="7.7.1" />
|
||||
<PackageReference Include="OpenIddict.AspNetCore" Version="7.8.0" />
|
||||
<PackageReference Include="OpenIddict.MongoDb" Version="7.8.0" />
|
||||
<PackageReference Include="Otp.NET" Version="1.4.1" />
|
||||
<PackageReference Include="QRCoder" Version="1.8.0" />
|
||||
<PackageReference Include="QRCoder" Version="1.8.1" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.MongoDB" Version="7.3.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.2.3" />
|
||||
<PackageReference Include="Serilog.Sinks.MongoDB" Version="8.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -90,6 +90,7 @@ try
|
||||
try
|
||||
{
|
||||
BsonSerializer.TryRegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
|
||||
EntityIds.Register();
|
||||
var mongoSettings = builder.Configuration.GetSection(nameof(MongoSettings)).Get<MongoSettings>();
|
||||
await DB.InitAsync(mongoSettings.Database, MongoClientSettings.FromConnectionString(mongoSettings.ConnectionString));
|
||||
EntityMaps.Warm();
|
||||
|
||||
Reference in new issue
Block a user