< Summary

Information
Class: DotnetFuzzing.Fuzzers.SslStreamClientHelloFuzzer
Assembly: DotnetFuzzing
File(s): D:\runner\runtime\src\libraries\Fuzzing\DotnetFuzzing\Fuzzers\SslStreamClientHelloFuzzer.cs
Line coverage
88%
Covered lines: 23
Uncovered lines: 3
Coverable lines: 26
Total lines: 48
Line coverage: 88.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
FuzzTarget(...)100%1195.83%

File(s)

D:\runner\runtime\src\libraries\Fuzzing\DotnetFuzzing\Fuzzers\SslStreamClientHelloFuzzer.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System.Buffers;
 5using System.Net.Security;
 6using System.Security.Authentication;
 7
 8namespace DotnetFuzzing.Fuzzers
 9{
 10    internal sealed class SslStreamClientHelloFuzzer : IFuzzer
 11    {
 012        public string[] TargetAssemblies => ["System.Net.Security"];
 13
 014        public string[] TargetCoreLibPrefixes => [];
 15
 16        public void FuzzTarget(ReadOnlySpan<byte> bytes)
 3817        {
 3818            byte[] buffer = ArrayPool<byte>.Shared.Rent(bytes.Length);
 19            try
 3820            {
 3821                bytes.CopyTo(buffer);
 3822                using MemoryStream ms = new MemoryStream(buffer, 0, bytes.Length);
 3823                using SslStream sslStream = new SslStream(ms);
 3824                sslStream.AuthenticateAsServerAsync((stream, clientHelloInfo, b, token) =>
 225                {
 3826                    // This callback should be called when ClientHello is
 3827                    // received, Since we don't parse any other TLS messages,
 3828                    // we can terminate the handshake here. Fuzzing the rest of
 3829                    // the handshake would fuzz the platform TLS implementation
 3830                    // which is not instrumented and is out of scope for this
 3831                    // fuzzer.
 232                    throw new MyCustomException();
 3833                }, null).GetAwaiter().GetResult();
 034            }
 3835            catch (Exception ex) when (ex is AuthenticationException or IOException or MyCustomException)
 3836            {
 3837            }
 38            finally
 3839            {
 3840                ArrayPool<byte>.Shared.Return(buffer);
 3841            }
 3842        }
 43
 44        internal class MyCustomException : Exception
 45        {
 46        }
 47    }
 48}