Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a467c79
Add HTTP dotnettestcli transport
Evangelink Jul 22, 2026
1af0d20
Address HTTP transport review feedback
Evangelink Jul 22, 2026
56e353d
Merge origin/main and resolve PR conflicts
Copilot Jul 23, 2026
f269f7d
Harden HTTP transport diagnostics
Evangelink Jul 23, 2026
315e0f1
Close HTTP transport cancellation gaps
Evangelink Jul 23, 2026
b364346
Make HTTP transport tests deterministic
Evangelink Jul 23, 2026
410a2c7
Redact all sensitive option values
Evangelink Jul 23, 2026
2d20ea6
Redact excess inline option values
Evangelink Jul 23, 2026
040233d
Redact malformed HTTP transport arguments
Evangelink Jul 23, 2026
d5d720a
Make response cancellation terminal
Evangelink Jul 23, 2026
5c1d5de
Validate HTTP transport option dependencies
Evangelink Jul 23, 2026
c928130
Avoid redirect configuration on WASI
Evangelink Jul 23, 2026
9b71119
Close remaining diagnostic leaks
Evangelink Jul 23, 2026
df4ebb2
Make failed HTTP requests terminal
Evangelink Jul 23, 2026
caad62e
Validate explicit pipe transport dependency
Evangelink Jul 23, 2026
d8862c1
Redact expanded response-file arguments
Evangelink Jul 23, 2026
3ff029b
Redact sensitive response-file errors
Evangelink Jul 23, 2026
94e0b13
Redact whitespace-prefixed sensitive options
Evangelink Jul 23, 2026
4b2ed23
Declare response-file helper overload
Evangelink Jul 23, 2026
e2fbf0d
Sanitize response-file access errors
Evangelink Jul 23, 2026
eae0231
Redact relaunched process diagnostics
Evangelink Jul 23, 2026
7cd0694
Redact malformed response-file paths
Evangelink Jul 23, 2026
f4ce182
Merge branch 'main' into dev/amauryleve/http-dotnettestcli-transport
Evangelink Jul 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
194 changes: 154 additions & 40 deletions docs/mstest-runner-protocol/004-protocol-dotnet-test-pipe.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS
static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload<T>(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action<System.IO.Stream!, T>! writeItem) -> void
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken, int maximumFrameSize = 2147483647) -> System.Threading.Tasks.Task<object?>!
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<object?>!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS
static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload<T>(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action<System.IO.Stream!, T>! writeItem) -> void
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken, int maximumFrameSize = 2147483647) -> System.Threading.Tasks.Task<object?>!
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<object?>!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteExecutionS
static Microsoft.Testing.Platform.IPC.Serializers.BaseSerializer.WriteListPayload<T>(System.IO.Stream! stream, ushort fieldId, T[]? list, System.Action<System.IO.Stream!, T>! writeItem) -> void
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Expected = 10 -> ushort
const Microsoft.Testing.Platform.IPC.FailedTestResultMessageFieldsId.Actual = 11 -> ushort
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken, int maximumFrameSize = 2147483647) -> System.Threading.Tasks.Task<object?>!
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<object?>!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ Microsoft.Testing.Extensions.MergeOutputFileHelper
static Microsoft.Testing.Extensions.MergeOutputFileHelper.BuildCaseFoldedProbePath(string! directory, string! probeFileName) -> string!
static Microsoft.Testing.Extensions.MergeOutputFileHelper.EnsureOutputDoesNotAliasInput(System.Collections.Generic.IReadOnlyList<string!>! inputPaths, string! outputPath) -> void
static Microsoft.Testing.Extensions.MergeOutputFileHelper.WriteViaTemporarySiblingAsync(string! outputPath, System.Func<string!, System.Threading.Tasks.Task!>! writeToTempAsync) -> System.Threading.Tasks.Task!
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Stream! stream, System.Threading.CancellationToken cancellationToken, int maximumFrameSize = 2147483647) -> System.Threading.Tasks.Task<object?>!
Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Stream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.ReadNextMessageAsync(System.IO.Pipes.PipeStream! stream, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<object?>!
*REMOVED*Microsoft.Testing.Platform.IPC.NamedPipeConnectionBase.WriteMessageAsync(System.IO.Pipes.PipeStream! stream, Microsoft.Testing.Platform.IPC.INamedPipeSerializer! serializer, object! message, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task!
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private static async Task LogInformationAsync(

string moduleName = testApplicationModuleInfo.GetDisplayName();
await logger.LogInformationAsync($"Test module: {moduleName}").ConfigureAwait(false);
await logger.LogInformationAsync($"Command line arguments: '{(args.Length == 0 ? string.Empty : args.Aggregate((a, b) => $"{a} {b}"))}'").ConfigureAwait(false);
await logger.LogInformationAsync($"Command line arguments: '{CommandLineArgumentsRedactor.Redact(args)}'").ConfigureAwait(false);
Comment thread
Evangelink marked this conversation as resolved.
Resolved
Comment thread
Evangelink marked this conversation as resolved.
Resolved

StringBuilder machineInfo = new();
#pragma warning disable RS0030 // Do not use banned APIs
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

namespace Microsoft.Testing.Platform.CommandLine;

internal static class CommandLineArgumentsRedactor
{
private const string RedactedPlaceholder = "***REDACTED***";

public static string Redact(string[] args)
=> string.Join(" ", RedactArguments(args));

public static string RedactArgument(string[] args, int index)
=> RedactArguments(args)[index];

private static string[] RedactArguments(string[] args)
{
if (args.Length == 0)
{
return [];
}

string[] redacted = new string[args.Length];
bool redactNextValue = false;
bool sanitizeNextEndpoint = false;
bool sensitiveValueConsumed = false;

for (int i = 0; i < args.Length; i++)
{
string arg = args[i];
if (TryParseOption(arg, out string? prefix, out string? name, out string? delimiter, out string? inlineValue))
{
bool isToken = IsTokenOption(name);
bool isEndpoint = IsEndpointOption(name);
if (isToken)
{
redacted[i] = inlineValue is null
? arg
: $"{prefix}{name}{delimiter}{RedactedPlaceholder}";
redactNextValue = true;
sanitizeNextEndpoint = false;
sensitiveValueConsumed = inlineValue is not null;
}
else if (isEndpoint)
{
redacted[i] = inlineValue is null
? arg
: $"{prefix}{name}{delimiter}{SanitizeEndpoint(inlineValue)}";
sanitizeNextEndpoint = true;
redactNextValue = false;
sensitiveValueConsumed = inlineValue is not null;
}
else if (redactNextValue && !sensitiveValueConsumed)
{
redacted[i] = RedactedPlaceholder;
redactNextValue = false;
sanitizeNextEndpoint = false;
sensitiveValueConsumed = false;
}
else if (sanitizeNextEndpoint && !sensitiveValueConsumed)
{
redacted[i] = SanitizeEndpoint(arg);
redactNextValue = false;
sanitizeNextEndpoint = false;
sensitiveValueConsumed = false;
}
else
{
redacted[i] = arg;
redactNextValue = false;
sanitizeNextEndpoint = false;
sensitiveValueConsumed = false;
}

continue;
}

if (redactNextValue)
{
redacted[i] = RedactedPlaceholder;
sensitiveValueConsumed = true;
}
else if (sanitizeNextEndpoint)
{
redacted[i] = SanitizeEndpoint(arg);
sensitiveValueConsumed = true;
}
else
{
redacted[i] = arg;
}
}

return redacted;
}

private static bool TryParseOption(
string arg,
[NotNullWhen(true)] out string? prefix,
[NotNullWhen(true)] out string? name,
out string? delimiter,
out string? inlineValue)
{
prefix = null;
name = null;
delimiter = null;
inlineValue = null;

int optionStart = 0;
while (optionStart < arg.Length && char.IsWhiteSpace(arg[optionStart]))
{
optionStart++;
}

int prefixLength = 0;
while (optionStart + prefixLength < arg.Length && arg[optionStart + prefixLength] == '-')
{
prefixLength++;
}

bool hasLeadingWhitespace = optionStart > 0;
bool isValidPrefix = !hasLeadingWhitespace && prefixLength is 1 or 2;
bool isMalformedPrefix = hasLeadingWhitespace || prefixLength >= 3;
if ((!isValidPrefix && !isMalformedPrefix) || optionStart + prefixLength == arg.Length)
{
return false;
}

prefix = arg[..(optionStart + prefixLength)];
string withoutPrefix = arg[(optionStart + prefixLength)..];
int delimiterIndex = withoutPrefix.IndexOfAny(['=', ':']);
if (delimiterIndex == -1)
{
name = withoutPrefix;
}
else
{
name = withoutPrefix[..delimiterIndex];
delimiter = withoutPrefix[delimiterIndex].ToString();
inlineValue = withoutPrefix[(delimiterIndex + 1)..];
}

if (!isMalformedPrefix || IsTokenOption(name) || IsEndpointOption(name))
{
return true;
}

prefix = null;
name = null;
delimiter = null;
inlineValue = null;
return false;
}

private static bool IsTokenOption(string name)
=> PlatformCommandLineProvider.DotNetTestHttpTokenOptionKey.Equals(name, StringComparison.OrdinalIgnoreCase);

private static bool IsEndpointOption(string name)
=> PlatformCommandLineProvider.DotNetTestHttpEndpointOptionKey.Equals(name, StringComparison.OrdinalIgnoreCase);

private static string SanitizeEndpoint(string endpoint)
=> Uri.TryCreate(endpoint, UriKind.Absolute, out Uri? uri)
&& uri.Scheme is "http" or "https"
&& RoslynString.IsNullOrEmpty(uri.UserInfo)
? uri.GetLeftPart(UriPartial.Authority)
: RedactedPlaceholder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal CommandLineParseResult(string? toolName, IReadOnlyList<CommandLineParse
ToolName = toolName;
Options = options;
Errors = errors;
CommandLine = string.Join(" ", arguments);
CommandLine = CommandLineArgumentsRedactor.Redact([.. arguments]);
Comment thread
Evangelink marked this conversation as resolved.
Resolved
}

/// <summary>
Expand Down
30 changes: 24 additions & 6 deletions src/Platform/Microsoft.Testing.Platform/CommandLine/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ private static CommandLineParseResult Parse(List<string> args, IEnvironment envi
{
string? currentArg = args[i];

if (currentArg.StartsWith("@", StringComparison.Ordinal) && ResponseFileHelper.TryReadResponseFile(currentArg.Substring(1), errors, out string[]? newArguments))
if (currentArg.StartsWith("@", StringComparison.Ordinal))
{
args.InsertRange(i + 1, newArguments);
continue;
string responseFilePath = currentArg.Substring(1);
string redactedResponseFileArgument = CommandLineArgumentsRedactor.RedactArgument([.. args], i);
string diagnosticPath = redactedResponseFileArgument.StartsWith("@", StringComparison.Ordinal)
? redactedResponseFileArgument.Substring(1)
: redactedResponseFileArgument;
if (ResponseFileHelper.TryReadResponseFile(responseFilePath, diagnosticPath, errors, out string[]? newArguments))
{
args.InsertRange(i + 1, newArguments);
continue;
}
}

// If it's the first argument and it doesn't start with - then it's the tool name
Expand Down Expand Up @@ -80,7 +88,11 @@ private static CommandLineParseResult Parse(List<string> args, IEnvironment envi
{
if (currentOption is null)
{
errors.Add(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserUnexpectedArgument, args[i]));
errors.Add(
string.Format(
CultureInfo.InvariantCulture,
PlatformResources.CommandLineParserUnexpectedArgument,
CommandLineArgumentsRedactor.RedactArgument([.. args], i)));
}
else
{
Expand Down Expand Up @@ -125,9 +137,15 @@ static bool TryUnescape(string input, string? option, IEnvironment environment,
{
if (input.IndexOf('\'', 1, input.Length - 2) != -1)
{
const string redactedPlaceholder = "***REDACTED***";
string displayInput =
PlatformCommandLineProvider.DotNetTestHttpTokenOptionKey.Equals(option, StringComparison.OrdinalIgnoreCase)
|| PlatformCommandLineProvider.DotNetTestHttpEndpointOptionKey.Equals(option, StringComparison.OrdinalIgnoreCase)
? redactedPlaceholder
: input;
error = option is null
? string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserUnexpectedSingleQuoteInArgument, input)
: string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserUnexpectedSingleQuoteInArgumentForOption, input, option);
? string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserUnexpectedSingleQuoteInArgument, displayInput)
: string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserUnexpectedSingleQuoteInArgumentForOption, displayInput, option);
return false;
}

Expand Down
Loading
Loading