mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-15 08:23:28 -03:00
Add SqliteItemRepository.ItemImageInfoFromValueString as a fuzzing
target and add test cases
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../MediaBrowser.Controller/MediaBrowser.Controller.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoFixture" Version="4.17.0" />
|
||||
<PackageReference Include="AutoFixture.AutoMoq" Version="4.17.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="SharpFuzz" Version="1.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
using System;
|
||||
using AutoFixture;
|
||||
using AutoFixture.AutoMoq;
|
||||
using Emby.Server.Implementations.Data;
|
||||
using Emby.Server.Implementations.Library;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Moq;
|
||||
using SharpFuzz;
|
||||
|
||||
namespace Emby.Server.Implementations.Fuzz
|
||||
@@ -11,6 +18,7 @@ namespace Emby.Server.Implementations.Fuzz
|
||||
switch (args[0])
|
||||
{
|
||||
case "PathExtensions.TryReplaceSubPath": Run(PathExtensions_TryReplaceSubPath); return;
|
||||
case "SqliteItemRepository.ItemImageInfoFromValueString": Run(SqliteItemRepository_ItemImageInfoFromValueString); return;
|
||||
default: throw new ArgumentException($"Unknown fuzzing function: {args[0]}");
|
||||
}
|
||||
}
|
||||
@@ -28,5 +36,27 @@ namespace Emby.Server.Implementations.Fuzz
|
||||
|
||||
_ = PathExtensions.TryReplaceSubPath(parts[0], parts[1], parts[2], out _);
|
||||
}
|
||||
|
||||
private static void SqliteItemRepository_ItemImageInfoFromValueString(string data)
|
||||
{
|
||||
var sqliteItemRepository = MockSqliteItemRepository();
|
||||
sqliteItemRepository.ItemImageInfoFromValueString(data);
|
||||
}
|
||||
|
||||
private static SqliteItemRepository MockSqliteItemRepository()
|
||||
{
|
||||
const string VirtualMetaDataPath = "%MetadataPath%";
|
||||
const string MetaDataPath = "/meta/data/path";
|
||||
|
||||
var appHost = new Mock<IServerApplicationHost>();
|
||||
appHost.Setup(x => x.ExpandVirtualPath(It.IsAny<string>()))
|
||||
.Returns((string x) => x.Replace(VirtualMetaDataPath, MetaDataPath, StringComparison.Ordinal));
|
||||
appHost.Setup(x => x.ReverseVirtualPath(It.IsAny<string>()))
|
||||
.Returns((string x) => x.Replace(MetaDataPath, VirtualMetaDataPath, StringComparison.Ordinal));
|
||||
|
||||
IFixture fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
|
||||
fixture.Inject(appHost);
|
||||
return fixture.Create<SqliteItemRepository>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
/mnt/series/Family Guy/Season 1/Family Guy - S01E01-thumb.jpg*637452096478512963*Primary*1920*1080*WjQbtJtSO8nhNZ%L_Io#R/oaS6o}-;adXAoIn7j[%hW9s:WGw[nN
|
||||
Reference in New Issue
Block a user