aboutsummaryrefslogtreecommitdiff
path: root/fuzz/Jellyfin.Server.Fuzz/Program.cs
blob: e47286c13161bc8bcd28109a8e3c7c33b69dbe69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using System;
using System.Collections.Generic;
using Jellyfin.Server.Middleware;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
using SharpFuzz;

namespace Emby.Server.Implementations.Fuzz
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            switch (args[0])
            {
                case "UrlDecodeQueryFeature": Run(UrlDecodeQueryFeature); return;
                default: throw new ArgumentException($"Unknown fuzzing function: {args[0]}");
            }
        }

        private static void Run(Action<string> action) => Fuzzer.OutOfProcess.Run(action);

        private static void UrlDecodeQueryFeature(string data)
        {
            var dict = new Dictionary<string, StringValues>
            {
                { data, StringValues.Empty }
            };
            _ = new UrlDecodeQueryFeature(new QueryFeature(new QueryCollection(dict)));
        }
    }
}