Add fuzzing infra
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Emby.Server.Implementations">
|
||||
<HintPath>Emby.Server.Implementations.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpFuzz" Version="1.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
32
fuzz/Emby.Server.Implementations.Fuzz/Program.cs
Normal file
32
fuzz/Emby.Server.Implementations.Fuzz/Program.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using Emby.Server.Implementations.Library;
|
||||
using SharpFuzz;
|
||||
|
||||
namespace Emby.Server.Implementations.Fuzz
|
||||
{
|
||||
public static class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
switch (args[0])
|
||||
{
|
||||
case "PathExtensions.TryReplaceSubPath": Run(PathExtensions_TryReplaceSubPath); return;
|
||||
default: throw new ArgumentException($"Unknown fuzzing function: {args[0]}");
|
||||
}
|
||||
}
|
||||
|
||||
private static void Run(Action<string> action) => Fuzzer.OutOfProcess.Run(action);
|
||||
|
||||
private static void PathExtensions_TryReplaceSubPath(string data)
|
||||
{
|
||||
// Stupid, but it worked
|
||||
var parts = data.Split(':');
|
||||
if (parts.Length != 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = PathExtensions.TryReplaceSubPath(parts[0], parts[1], parts[2], out _);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
/fuzz/Emby.Server.Implementations.Fuzz/Testcases/PathExtensions.TryReplaceSubPath/test1.txt/:/home/bond/dev/jellyfin/:/srv/jellyfin/
|
||||
11
fuzz/Emby.Server.Implementations.Fuzz/fuzz.sh
Executable file
11
fuzz/Emby.Server.Implementations.Fuzz/fuzz.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
dotnet build -c Release ../../Emby.Server.Implementations/Emby.Server.Implementations.csproj --output bin
|
||||
sharpfuzz bin/Emby.Server.Implementations.dll
|
||||
cp bin/Emby.Server.Implementations.dll .
|
||||
|
||||
dotnet build
|
||||
mkdir -p Findings
|
||||
AFL_SKIP_BIN_CHECK=1 afl-fuzz -i "Testcases/$1" -o "Findings/$1" -t 5000 -m 10240 dotnet bin/Debug/net5.0/Emby.Server.Implementations.Fuzz.dll "$1"
|
||||
Reference in New Issue
Block a user