Skip to content

Commit

Permalink
Merge pull request #9455 from NuGet/dev
Browse files Browse the repository at this point in the history
[ReleasePrep][2023.04.05]RI of dev into main
  • Loading branch information
advay26 committed Apr 7, 2023
2 parents 3f644cb + 10e5890 commit 0931f8b
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 42 deletions.
19 changes: 14 additions & 5 deletions src/NuGetGallery.Core/Infrastructure/TableErrorLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public override string Log(Error error)
return pos.ToString(CultureInfo.InvariantCulture);
}

private void Obfuscate(Error error)
public static void Obfuscate(Error error)
{
error.User = string.Empty;
if (error.Form != null)
Expand Down Expand Up @@ -218,10 +218,19 @@ private void Obfuscate(Error error)

error.ServerVariables["HTTP_X_NUGET_APIKEY"] = string.Empty;

var forwardedIps = error.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(',');
var obfuscatedIps = forwardedIps.Select(Obfuscator.ObfuscateIp);

error.ServerVariables["HTTP_X_FORWARDED_FOR"] = string.Join(",", obfuscatedIps);
var forwardedIps = error.ServerVariables["HTTP_X_FORWARDED_FOR"]?
.Split(',')
.Select(x => x.Trim())
.Where(x => x.Length > 0)
.ToList();
if (forwardedIps != null)
{
var obfuscatedIps = string.Join(",", forwardedIps.Select(Obfuscator.ObfuscateIp));
if (!string.IsNullOrWhiteSpace(obfuscatedIps))
{
error.ServerVariables["HTTP_X_FORWARDED_FOR"] = obfuscatedIps;
}
}
}
}
}
4 changes: 2 additions & 2 deletions src/NuGetGallery/App_Code/ViewHelpers.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,8 @@ var hlp = new AccordionHelper(name, formModelStatePrefix, expanded, page);
</div>
if (!disabled)
{
<div class="panel panel-default panel-collapse collapse @(expanded ? "in" : string.Empty)"
aria-expanded="@(expanded ? "true" : "false")" id="@id-container">
<div aria-controls="panel-body" class="panel panel-default panel-collapse collapse @(expanded ? "in" : string.Empty)"
id="@id-container">
<div class="panel-body">
@content(MvcHtmlString.Empty)
</div>
Expand Down
1 change: 0 additions & 1 deletion src/NuGetGallery/Scripts/gallery/page-list-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ $(function() {
'use strict';

$(".reserved-indicator").each(window.nuget.setPopovers);
$(".framework-filter-info-icon").each(window.nuget.setPopovers);

const searchForm = document.forms.search;
const allFrameworks = document.querySelectorAll('.framework');
Expand Down
9 changes: 0 additions & 9 deletions src/NuGetGallery/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/NuGetGallery/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,4 @@ The {1} Team</value>
<data name="ForgotPassword_Disabled_Error" xml:space="preserve">
<value>Forgot password is disabled.</value>
</data>
<data name="FrameworkFilterInformation_Tooltip" xml:space="preserve">
<value>Filters packages based on the target frameworks included in the NuGet Package.</value>
</data>
</root>
2 changes: 1 addition & 1 deletion src/NuGetGallery/ViewModels/PackageListViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ public PackageListViewModel(

public Dictionary<string, FrameworkFilterHelper.FrameworkFilterGroup> FrameworkFilters = FrameworkFilterHelper.FrameworkFilters;

public string TargetFrameworkInformationLink = "https://learn.microsoft.com/en-us/dotnet/standard/frameworks";
public string FrameworksFilteringInformationLink = "https://learn.microsoft.com/nuget/consume-packages/finding-and-choosing-packages#advanced-filtering-and-sorting";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,7 @@
<!-- /ko -->
</div>
</div>
<div class="col-xs-2 col-sm-2 col-sm-push-3 member-column text-right">
<!-- ko if: IsCurrentUser || @(Model.CanManageMemberships ? "true" : "false") -->
<div>
<span>
<button class="btn-link" data-bind="click: DeleteMember, attr: { 'aria-label': 'Delete Member' }">
<i class="ms-Icon ms-Icon--Cancel" aria-hidden="true"></i>
</button>
</span>
</div>
<!-- /ko -->
</div>
<div class="col-xs-12 col-sm-3 col-sm-pull-2 member-column">
<div class="col-xs-8 col-sm-3 member-column">
<div>
@if (Model.CanManageMemberships)
{
Expand All @@ -93,6 +82,17 @@
}
</div>
</div>
<div class="col-xs-4 col-sm-2 member-column text-right">
<!-- ko if: IsCurrentUser || @(Model.CanManageMemberships ? "true" : "false") -->
<div>
<span>
<button class="btn-link" data-bind="click: DeleteMember, attr: { 'aria-label': 'Delete Member' }">
<i class="ms-Icon ms-Icon--Cancel" aria-hidden="true"></i>
</button>
</span>
</div>
<!-- /ko -->
</div>
</div>
</div>
</div>
Expand Down
6 changes: 2 additions & 4 deletions src/NuGetGallery/Views/Shared/ListPackages.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@
<fieldset id="frameworkfilters">
<legend>
Frameworks
<a href="@(Model.TargetFrameworkInformationLink)" title="Frameworks filter information">
<i class="framework-filter-info-icon ms-Icon ms-Icon--Info" tabindex="0"
data-content="@Strings.FrameworkFilterInformation_Tooltip"
alt="@Strings.FrameworkFilterInformation_Tooltip"></i>
<a href="@(Model.FrameworksFilteringInformationLink)" title="Filters packages based on the target frameworks included in the NuGet Package. Click here to learn more.">
<i class="framework-filter-info-icon ms-Icon ms-Icon--Info"></i>
</a>
</legend>
@foreach (var framework in Model.FrameworkFilters.Values)
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Views/Shared/_ListPackage.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
@Model.ShortDescription
@if (Model.IsDescriptionTruncated)
{
@Html.RouteLink("More information", RouteName.DisplayPackage, new { Model.Id, Model.Version })
@Html.RouteLink("More information", RouteName.DisplayPackage, new { Model.Id, Model.Version }, new { @title = "More information about " + Model.Id + " package." })
}
</div>
</div>
Expand Down
5 changes: 2 additions & 3 deletions src/NuGetGallery/Views/Users/ApiKeys.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@

<div class="row">
<div class="col-sm-12 form-group">
<b id="select-scopes" class="ms-fontSize-xl">Select Scopes</b>
<br />
<h4 id="select-scopes" class="ms-fontSize-xl"><b>Select Scopes</b></h4>
<span class="has-error">
<span class="help-block" data-bind="text: ScopesError" aria-live="polite" role="alert"></span>
</span>
Expand Down Expand Up @@ -394,7 +393,7 @@
<!-- /ko -->
<div class="row">
<div class="col-sm-12">
<b class="ms-fontSize-xl">Select Packages</b>
<h4 class="ms-fontSize-xl"><b>Select Packages</b></h4>
<p>
To select which packages to associate with a key, use a glob pattern, select
individual packages, or both.
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/Views/Users/Organizations.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Url,
CurrentUser,
false,
@<text>Organizations&nbsp;<span aria-hidden="true" class="ms-font-xl organizations-divider">|</span>&nbsp;<a href="@Url.AddOrganization()"><span aria-hidden="true" class="ms-font-m ms-Icon ms-Icon--Add"></span>&nbsp;Add new</a></text>)
@<text>Organizations&nbsp;<span aria-hidden="true" class="ms-font-xl organizations-divider">|</span>&nbsp;<a href="@Url.AddOrganization()" title="Add new organization."><span aria-hidden="true" class="ms-font-m ms-Icon ms-Icon--Add"></span>&nbsp;Add new</a></text>)
</div>
</div>
<hr class="breadcrumb-divider"/>
Expand Down
48 changes: 48 additions & 0 deletions tests/NuGetGallery.Core.Facts/Infrastructure/TableErrorLogFacts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Linq;
using Elmah;
using Xunit;

namespace NuGetGallery.Infrastructure
{
public class TableErrorLogFacts
{
public class TheObfuscateMethod
{
[Fact]
public void HandlesMissingForwardedHeader()
{
// Arrange
var error = new Error();

// Act
TableErrorLog.Obfuscate(error);

// Assert
Assert.DoesNotContain("HTTP_X_FORWARDED_FOR", error.ServerVariables.Keys.Cast<string>());
}

[Theory]
[InlineData("", "")]
[InlineData(",", ",")]
[InlineData(" ", " ")]
[InlineData("127.0.0.1", "127.0.0.0")]
[InlineData("127.1.2.3,127.1.2.4", "127.1.2.0,127.1.2.0")]
[InlineData("127.1.2.3 , 127.1.2.4", "127.1.2.0,127.1.2.0")]
public void ObfuscatesForwardedHeader(string input, string expected)
{
// Arrange
var error = new Error();
error.ServerVariables["HTTP_X_FORWARDED_FOR"] = input;

// Act
TableErrorLog.Obfuscate(error);

// Assert
Assert.Equal(expected, error.ServerVariables["HTTP_X_FORWARDED_FOR"]);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<Compile Include="Infrastructure\Mail\Messages\SymbolPackageValidationFailedMessageFacts.cs" />
<Compile Include="Infrastructure\Mail\Messages\SymbolPackageValidationTakingTooLongMessageFacts.cs" />
<Compile Include="Infrastructure\Mail\TestMessageServiceConfiguration.cs" />
<Compile Include="Infrastructure\TableErrorLogFacts.cs" />
<Compile Include="Packaging\ManifestValidatorFacts.cs" />
<Compile Include="Packaging\PackageIdValidatorTest.cs" />
<Compile Include="Packaging\PackageMetadataFacts.cs" />
Expand Down

0 comments on commit 0931f8b

Please sign in to comment.