Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/release/7.0' into merge-intern…
Browse files Browse the repository at this point in the history
…al/release/7.0
  • Loading branch information
mmitche committed Nov 14, 2022
2 parents 1c11d81 + 462405a commit ac8b3b0
Show file tree
Hide file tree
Showing 20 changed files with 2,185 additions and 57 deletions.
6 changes: 3 additions & 3 deletions .azure/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -489,13 +489,13 @@ stages:
$(_InternalRuntimeDownloadArgs)
displayName: Run build.sh
- script: git clean -xfd src/**/obj/;
./dockerbuild.sh bionic --ci --nobl --arch x64 --build-installers --no-build-deps --no-build-nodejs
./dockerbuild.sh bionic --ci --nobl --arch x64 --build-installers --no-build-deps --no-build-nodejs --init-nuget
-p:OnlyPackPlatformSpecificPackages=true -p:BuildRuntimeArchive=false -p:LinuxInstallerType=deb
$(_BuildArgs)
$(_InternalRuntimeDownloadArgs)
displayName: Build Debian installers
- script: git clean -xfd src/**/obj/;
./dockerbuild.sh rhel --ci --nobl --arch x64 --build-installers --no-build-deps --no-build-nodejs
./dockerbuild.sh rhel --ci --nobl --arch x64 --build-installers --no-build-deps --no-build-nodejs --init-nuget
-p:OnlyPackPlatformSpecificPackages=true -p:BuildRuntimeArchive=false -p:LinuxInstallerType=rpm
-p:AssetManifestFileName=aspnetcore-Linux_x64.xml
$(_BuildArgs)
Expand Down Expand Up @@ -568,7 +568,7 @@ stages:
$(_InternalRuntimeDownloadArgs)
displayName: Run build.sh
- script: git clean -xfd src/**/obj/;
./dockerbuild.sh rhel --ci --nobl --arch arm64 --build-installers --no-build-deps --no-build-nodejs
./dockerbuild.sh rhel --ci --nobl --arch arm64 --build-installers --no-build-deps --no-build-nodejs --init-nuget
-p:OnlyPackPlatformSpecificPackages=true -p:BuildRuntimeArchive=false -p:LinuxInstallerType=rpm
-p:AssetManifestFileName=aspnetcore-Linux_arm64.xml
$(_BuildArgs)
Expand Down
8 changes: 0 additions & 8 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,8 @@
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-efcore -->
<add key="darc-int-dotnet-efcore-baac22d" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-efcore-baac22d8/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-efcore -->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-int-dotnet-runtime-d099f07" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-d099f075/nuget/v3/index.json" />
<add key="darc-int-dotnet-runtime-d099f07-4" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-d099f075-4/nuget/v3/index.json" />
<add key="darc-int-dotnet-runtime-d099f07-3" value="https://pkgs.dev.azure.com/dnceng/internal/_packaging/darc-int-dotnet-runtime-d099f075-3/nuget/v3/index.json" />
<!-- End: Package sources from dotnet-runtime -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
<add key="dotnet-eng" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json" />
Expand All @@ -28,12 +24,8 @@
<clear />
<!--Begin: Package sources managed by Dependency Flow automation. Do not edit the sources below.-->
<!-- Begin: Package sources from dotnet-efcore -->
<add key="darc-int-dotnet-efcore-baac22d" value="true" />
<!-- End: Package sources from dotnet-efcore -->
<!-- Begin: Package sources from dotnet-runtime -->
<add key="darc-int-dotnet-runtime-d099f07-3" value="true" />
<add key="darc-int-dotnet-runtime-d099f07-4" value="true" />
<add key="darc-int-dotnet-runtime-d099f07" value="true" />
<!-- End: Package sources from dotnet-runtime -->
<!--End: Package sources managed by Dependency Flow automation. Do not edit the sources above.-->
</disabledPackageSources>
Expand Down
16 changes: 8 additions & 8 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -302,22 +302,22 @@
<Uri>https://dev.azure.com/dnceng/internal/_git/dotnet-runtime</Uri>
<Sha>d099f075e45d2aa6007a22b71b45a08758559f80</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.22558.4">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="7.0.0-beta.22561.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3f3c360819c5c092d0e4505a67dfe59a33fba557</Sha>
<Sha>f36ea231c234560514ede4c2747897a737ced28f</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="7.0.0-beta.22558.4">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Installers" Version="7.0.0-beta.22561.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3f3c360819c5c092d0e4505a67dfe59a33fba557</Sha>
<Sha>f36ea231c234560514ede4c2747897a737ced28f</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="7.0.0-beta.22558.4">
<Dependency Name="Microsoft.DotNet.Build.Tasks.Templating" Version="7.0.0-beta.22561.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3f3c360819c5c092d0e4505a67dfe59a33fba557</Sha>
<Sha>f36ea231c234560514ede4c2747897a737ced28f</Sha>
</Dependency>
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="7.0.0-beta.22558.4">
<Dependency Name="Microsoft.DotNet.Helix.Sdk" Version="7.0.0-beta.22561.2">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>3f3c360819c5c092d0e4505a67dfe59a33fba557</Sha>
<Sha>f36ea231c234560514ede4c2747897a737ced28f</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
4 changes: 2 additions & 2 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@
<MicrosoftEntityFrameworkCoreVersion>7.0.1</MicrosoftEntityFrameworkCoreVersion>
<MicrosoftEntityFrameworkCoreDesignVersion>7.0.1</MicrosoftEntityFrameworkCoreDesignVersion>
<!-- Packages from dotnet/arcade -->
<MicrosoftDotNetBuildTasksInstallersVersion>7.0.0-beta.22558.4</MicrosoftDotNetBuildTasksInstallersVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>7.0.0-beta.22558.4</MicrosoftDotNetBuildTasksTemplatingVersion>
<MicrosoftDotNetBuildTasksInstallersVersion>7.0.0-beta.22561.2</MicrosoftDotNetBuildTasksInstallersVersion>
<MicrosoftDotNetBuildTasksTemplatingVersion>7.0.0-beta.22561.2</MicrosoftDotNetBuildTasksTemplatingVersion>
<!-- Packages from dotnet/source-build-externals -->
<MicrosoftSourceBuildIntermediatesourcebuildexternalsVersion>7.0.0-alpha.1.22505.1</MicrosoftSourceBuildIntermediatesourcebuildexternalsVersion>
<!-- Packages from dotnet/xdt -->
Expand Down
30 changes: 30 additions & 0 deletions eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ target_arch='x64'
configuration=''
runtime_source_feed=''
runtime_source_feed_key=''
init_nuget=false

if [ "$(uname)" = "Darwin" ]; then
target_os_name='osx'
Expand Down Expand Up @@ -82,6 +83,8 @@ Options:
--runtime-source-feed Additional feed that can be used when downloading .NET runtimes and SDKs
--runtime-source-feed-key Key for feed that can be used when downloading .NET runtimes and SDKs
--init-nuget Run nuget --version.
Description:
This build script installs required tools and runs an MSBuild command on this repository
This script can be used to invoke various targets, such as targets to produce packages
Expand Down Expand Up @@ -208,6 +211,9 @@ while [[ $# -gt 0 ]]; do
-ci)
ci=true
;;
-init-nuget)
init_nuget=true
;;
-binarylog|-bl)
binary_log=true
;;
Expand Down Expand Up @@ -359,6 +365,30 @@ export MSBUILDDEBUGPATH="$log_dir"
_tmp_restore=$restore
restore=true

if [[ "$init_nuget" == true ]]; then
InitializeBuildTool

function RunBuildTool {
"$_InitializeBuildTool" "$@" || {
local exit_code=$?
# We should not Write-PipelineTaskError here because that message shows up in the build summary
# The build already logged an error, that's the reason it failed. Producing an error here only adds noise.
echo "Build failed with exit code $exit_code. Check errors above."
if [[ "$ci" == "true" ]]; then
Write-PipelineSetResult -result "Failed" -message "nuget execution failed."
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
ExitWithExitCode 0
else
ExitWithExitCode $exit_code
fi
}
}

echo 'Running dotnet nuget --version (issue: https://github.com/NuGet/Home/issues/12159#issuecomment-1278360511)'
RunBuildTool "nuget" "--version"
fi

InitializeToolset

restore=$_tmp_restore=
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"msbuild-sdks": {
"Yarn.MSBuild": "1.22.10",
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22558.4",
"Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22558.4"
"Microsoft.DotNet.Arcade.Sdk": "7.0.0-beta.22561.2",
"Microsoft.DotNet.Helix.Sdk": "7.0.0-beta.22561.2"
}
}
105 changes: 86 additions & 19 deletions src/Servers/HttpSys/src/RequestProcessing/Request.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,106 @@ internal Request(RequestContext requestContext)

PathBase = string.Empty;
Path = originalPath;
var prefix = requestContext.Server.Options.UrlPrefixes.GetPrefix((int)requestContext.UrlContext);

// 'OPTIONS * HTTP/1.1'
if (KnownMethod == HttpApiTypes.HTTP_VERB.HttpVerbOPTIONS && string.Equals(RawUrl, "*", StringComparison.Ordinal))
{
PathBase = string.Empty;
Path = string.Empty;
}
else
// Prefix may be null if the requested has been transfered to our queue
else if (prefix is not null)
{
var prefix = requestContext.Server.Options.UrlPrefixes.GetPrefix((int)requestContext.UrlContext);
// Prefix may be null if the requested has been transfered to our queue
if (!(prefix is null))
var pathBase = prefix.PathWithoutTrailingSlash;

// url: /base/path, prefix: /base/, base: /base, path: /path
// url: /, prefix: /, base: , path: /
if (originalPath.Equals(pathBase, StringComparison.Ordinal))
{
if (originalPath.Length == prefix.PathWithoutTrailingSlash.Length)
{
// They matched exactly except for the trailing slash.
PathBase = originalPath;
Path = string.Empty;
}
else
{
// url: /base/path, prefix: /base/, base: /base, path: /path
// url: /, prefix: /, base: , path: /
PathBase = originalPath.Substring(0, prefix.PathWithoutTrailingSlash.Length); // Preserve the user input casing
Path = originalPath.Substring(prefix.PathWithoutTrailingSlash.Length);
}
// Exact match, no need to preserve the casing
PathBase = pathBase;
Path = string.Empty;
}
else if (requestContext.Server.Options.UrlPrefixes.TryMatchLongestPrefix(IsHttps, cookedUrl.GetHost()!, originalPath, out var pathBase, out var path))
else if (originalPath.Equals(pathBase, StringComparison.OrdinalIgnoreCase))
{
// Preserve the user input casing
PathBase = originalPath;
Path = string.Empty;
}
else if (originalPath.StartsWith(prefix.Path, StringComparison.Ordinal))
{
// Exact match, no need to preserve the casing
PathBase = pathBase;
Path = path;
Path = originalPath[pathBase.Length..];
}
else if (originalPath.StartsWith(prefix.Path, StringComparison.OrdinalIgnoreCase))
{
// Preserve the user input casing
PathBase = originalPath[..pathBase.Length];
Path = originalPath[pathBase.Length..];
}
else
{
// Http.Sys path base matching is based on the cooked url which applies some non-standard normalizations that we don't use
// like collapsing duplicate slashes "//", converting '\' to '/', and un-escaping "%2F" to '/'. Find the right split and
// ignore the normalizations.
var originalOffset = 0;
var baseOffset = 0;
while (originalOffset < originalPath.Length && baseOffset < pathBase.Length)
{
var baseValue = pathBase[baseOffset];
var offsetValue = originalPath[originalOffset];
if (baseValue == offsetValue
|| char.ToUpperInvariant(baseValue) == char.ToUpperInvariant(offsetValue))
{
// case-insensitive match, continue
originalOffset++;
baseOffset++;
}
else if (baseValue == '/' && offsetValue == '\\')
{
// Http.Sys considers these equivalent
originalOffset++;
baseOffset++;
}
else if (baseValue == '/' && originalPath.AsSpan(originalOffset).StartsWith("%2F", StringComparison.OrdinalIgnoreCase))
{
// Http.Sys un-escapes this
originalOffset += 3;
baseOffset++;
}
else if (baseOffset > 0 && pathBase[baseOffset - 1] == '/'
&& (offsetValue == '/' || offsetValue == '\\'))
{
// Duplicate slash, skip
originalOffset++;
}
else if (baseOffset > 0 && pathBase[baseOffset - 1] == '/'
&& originalPath.AsSpan(originalOffset).StartsWith("%2F", StringComparison.OrdinalIgnoreCase))
{
// Duplicate slash equivalent, skip
originalOffset += 3;
}
else
{
// Mismatch, fall back
// The failing test case here is "/base/call//../bat//path1//path2", reduced to "/base/call/bat//path1//path2",
// where http.sys collapses "//" before "../", but we do "../" first. We've lost the context that there were dot segments,
// or duplicate slashes, how do we figure out that "call/" can be eliminated?
originalOffset = 0;
break;
}
}
PathBase = originalPath[..originalOffset];
Path = originalPath[originalOffset..];
}
}
else if (requestContext.Server.Options.UrlPrefixes.TryMatchLongestPrefix(IsHttps, cookedUrl.GetHost()!, originalPath, out var pathBase, out var path))
{
PathBase = pathBase;
Path = path;
}

ProtocolVersion = RequestContext.GetVersion();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
Expand Down Expand Up @@ -138,6 +138,42 @@ public async Task Request_OverlongUTF8Path(string requestPath, string expectedPa
}
}

[ConditionalTheory]
[InlineData("/", "/", "", "/")]
[InlineData("/base", "/base", "/base", "")]
[InlineData("/base", "/baSe", "/baSe", "")]
[InlineData("/base", "/base/path", "/base", "/path")]
[InlineData("/base", "///base/path1/path2", "///base", "/path1/path2")]
[InlineData("/base/ball", @"/baSe\ball//path1//path2", @"/baSe\ball", "//path1//path2")]
[InlineData("/base/ball", @"/base%2fball//path1//path2", @"/base%2fball", "//path1//path2")]
[InlineData("/base/ball", @"/base%2Fball//path1//path2", @"/base%2Fball", "//path1//path2")]
[InlineData("/base/ball", @"/base%5cball//path1//path2", @"/base\ball", "//path1//path2")]
[InlineData("/base/ball", @"/base%5Cball//path1//path2", @"/base\ball", "//path1//path2")]
[InlineData("/base/ball", "///baSe//ball//path1//path2", "///baSe//ball", "//path1//path2")]
[InlineData("/base/ball", @"/base/\ball//path1//path2", @"/base/\ball", "//path1//path2")]
[InlineData("/base/ball", @"/base/%2fball//path1//path2", @"/base/%2fball", "//path1//path2")]
[InlineData("/base/ball", @"/base/%2Fball//path1//path2", @"/base/%2Fball", "//path1//path2")]
[InlineData("/base/ball", @"/base/%5cball//path1//path2", @"/base/\ball", "//path1//path2")]
[InlineData("/base/ball", @"/base/%5Cball//path1//path2", @"/base/\ball", "//path1//path2")]
[InlineData("/base/ball", @"/base/call/../ball//path1//path2", @"/base/ball", "//path1//path2")]
// The results should be "/base/ball", "//path1//path2", but Http.Sys collapses the "//" before the "../"
// and we don't have a good way of emulating that.
[InlineData("/base/ball", @"/base/call//../ball//path1//path2", @"", "/base/call/ball//path1//path2")]
[InlineData("/base/ball", @"/base/call/.%2e/ball//path1//path2", @"/base/ball", "//path1//path2")]
[InlineData("/base/ball", @"/base/call/.%2E/ball//path1//path2", @"/base/ball", "//path1//path2")]
public async Task Request_WithPathBase(string pathBase, string requestPath, string expectedPathBase, string expectedPath)
{
using var server = Utilities.CreateHttpServerReturnRoot(pathBase, out var root);
var responseTask = SendSocketRequestAsync(root, requestPath);
var context = await server.AcceptAsync(Utilities.DefaultTimeout).Before(responseTask);
Assert.Equal(expectedPathBase, context.Request.PathBase);
Assert.Equal(expectedPath, context.Request.Path);
context.Dispose();

var response = await responseTask;
Assert.Equal("200", response.Substring(9));
}

private async Task<string> SendSocketRequestAsync(string address, string path, string method = "GET")
{
var uri = new Uri(address);
Expand Down
1 change: 1 addition & 0 deletions src/Servers/HttpSys/test/FunctionalTests/RequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public async Task Request_FieldsCanBeSetToNull_Set()
[InlineData("/base path/", "/base%20path/sub%20path", "/base path", "/sub path")]
[InlineData("/base葉path/", "/base%E8%91%89path/sub%E8%91%89path", "/base葉path", "/sub葉path")]
[InlineData("/basepath/", "/basepath/sub%2Fpath", "/basepath", "/sub%2Fpath")]
[InlineData("/base", "///base/path1/path2", "///base", "/path1/path2")]
public async Task Request_PathSplitting(string pathBase, string requestPath, string expectedPathBase, string expectedPath)
{
string root;
Expand Down
Loading

0 comments on commit ac8b3b0

Please sign in to comment.