author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
455,744 | 23.09.2019 18:33:09 | 25,200 | efce75868e12408d999a4bc33cb0c1c1bec405fa | IconUrl deprecation message.
* IconUrl deprecation message.
Tests. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<DependentUpon>201906262145129_EmbeddedIconFlag.cs</DependentUpon>\n</Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n+ <Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\IconUrlTemplateProcessor.cs\" />\n<Compile Include=\"Services\\IIconUrlTemplateProcessor.cs\" />\n<Compile Include=\"Services\\IIconUrlProvider.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"new_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"diff": "using NuGetGallery.Diagnostics;\nusing NuGetGallery.Helpers;\nusing NuGetGallery.Packaging;\n+using NuGetGallery.Services;\nnamespace NuGetGallery\n{\n@@ -148,7 +149,7 @@ public class PackageUploadService : IPackageUploadService\nreturn result;\n}\n- result = await CheckIconMetadataAsync(nuGetPackage, currentUser);\n+ result = await CheckIconMetadataAsync(nuGetPackage, warnings, currentUser);\nif (result != null)\n{\n//_telemetryService.TrackIconValidationFailure();\n@@ -341,18 +342,22 @@ private async Task<PackageValidationResult> CheckLicenseMetadataAsync(PackageArc\nreturn null;\n}\n- private async Task<PackageValidationResult> CheckIconMetadataAsync(PackageArchiveReader nuGetPackage, User user)\n+ private async Task<PackageValidationResult> CheckIconMetadataAsync(PackageArchiveReader nuGetPackage, List<IValidationMessage> warnings, User user)\n{\nvar nuspecReader = GetNuspecReader(nuGetPackage);\n-\nvar iconElement = nuspecReader.IconElement;\n+ var embeddedIconsEnabled = _featureFlagService.AreEmbeddedIconsEnabled(user);\nif (iconElement == null)\n{\n+ if (embeddedIconsEnabled && nuspecReader.GetIconUrl() != null)\n+ {\n+ warnings.Add(new IconUrlDeprecationValidationMessage());\n+ }\nreturn null;\n}\n- if (!_featureFlagService.AreEmbeddedIconsEnabled(user))\n+ if (!embeddedIconsEnabled)\n{\nreturn PackageValidationResult.Invalid(Strings.UploadPackage_EmbeddedIconNotAccepted);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.Designer.cs",
"new_path": "src/NuGetGallery/Strings.Designer.cs",
"diff": "@@ -2355,7 +2355,7 @@ public class Strings {\n}\n/// <summary>\n- /// Looks up a localized string similar to <licenseUrl> element will be deprecated, please consider switching to specifying the license in the package..\n+ /// Looks up a localized string similar to The <licenseUrl> element is deprecated. Consider using the <license> element instead..\n/// </summary>\npublic static string UploadPackage_DeprecatingLicenseUrl {\nget {\n@@ -2426,6 +2426,15 @@ public class Strings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to The <iconUrl> element is deprecated. Consider using the <icon> element instead..\n+ /// </summary>\n+ public static string UploadPackage_IconUrlDeprecated {\n+ get {\n+ return ResourceManager.GetString(\"UploadPackage_IconUrlDeprecated\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to This package ID has been reserved. Please request access to upload to this reserved namespace from the owner of the reserved prefix, or re-upload the package with a different ID..\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.resx",
"new_path": "src/NuGetGallery/Strings.resx",
"diff": "@@ -1006,7 +1006,7 @@ The {1} Team</value>\n<value>Unknown error!</value>\n</data>\n<data name=\"UploadPackage_DeprecatingLicenseUrl\" xml:space=\"preserve\">\n- <value><licenseUrl> element will be deprecated, please consider switching to specifying the license in the package.</value>\n+ <value>The <licenseUrl> element is deprecated. Consider using the <license> element instead.</value>\n</data>\n<data name=\"UploadPackage_DeprecationUrlUsage\" xml:space=\"preserve\">\n<value>The license deprecation URL must be used in conjunction with specifying the license in the package.</value>\n@@ -1150,4 +1150,7 @@ The {1} Team</value>\n<data name=\"SiteAdminNotLoggedInWithRequiredTenant\" xml:space=\"preserve\">\n<value>The site admins are required to sign in with the '{0}' tenant only.</value>\n</data>\n+ <data name=\"UploadPackage_IconUrlDeprecated\" xml:space=\"preserve\">\n+ <value>The <iconUrl> element is deprecated. Consider using the <icon> element instead.</value>\n+ </data>\n</root>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"diff": "@@ -554,7 +554,7 @@ public async Task HandlesLegacyLicenseUrlPackageAccordingToSettings(bool blockLe\nAssert.Equal(PackageValidationResultType.Accepted, result.Type);\nAssert.Null(result.Message);\nAssert.Single(result.Warnings);\n- Assert.StartsWith(\"<licenseUrl> element will be deprecated, please consider switching to specifying the license in the package.\", result.Warnings[0].PlainTextMessage);\n+ Assert.StartsWith(\"The <licenseUrl> element is deprecated. Consider using the <license> element instead.\", result.Warnings[0].PlainTextMessage);\nAssert.IsType<LicenseUrlDeprecationValidationMessage>(result.Warnings[0]);\n}\n}\n@@ -1141,6 +1141,53 @@ public async Task AcceptsPackagesWithEmbeddedIconForFlightedUsers()\nAssert.Empty(result.Warnings);\n}\n+ [Fact]\n+ public async Task WarnsAboutPackagesWithIconUrlForFlightedUsers()\n+ {\n+ _nuGetPackage = GeneratePackageWithUserContent(\n+ iconUrl: new Uri(\"https://nuget.test/icon\"),\n+ iconFilename: null,\n+ licenseExpression: \"MIT\",\n+ licenseUrl: new Uri(\"https://licenses.nuget.org/MIT\"));\n+ _featureFlagService\n+ .Setup(ffs => ffs.AreEmbeddedIconsEnabled(_currentUser))\n+ .Returns(true);\n+\n+ var result = await _target.ValidateBeforeGeneratePackageAsync(\n+ _nuGetPackage.Object,\n+ GetPackageMetadata(_nuGetPackage),\n+ _currentUser);\n+\n+ Assert.Equal(PackageValidationResultType.Accepted, result.Type);\n+ Assert.Null(result.Message);\n+ var warning = Assert.Single(result.Warnings);\n+ Assert.IsType<IconUrlDeprecationValidationMessage>(warning);\n+ Assert.StartsWith(\"The <iconUrl> element is deprecated. Consider using the <icon> element instead.\", warning.PlainTextMessage);\n+ Assert.StartsWith(\"The <iconUrl> element is deprecated. Consider using the <icon> element instead.\", warning.RawHtmlMessage);\n+ }\n+\n+ [Fact]\n+ public async Task DoesntWarnAboutPackagesWithIconUrl()\n+ {\n+ _nuGetPackage = GeneratePackageWithUserContent(\n+ iconUrl: new Uri(\"https://nuget.test/icon\"),\n+ iconFilename: null,\n+ licenseExpression: \"MIT\",\n+ licenseUrl: new Uri(\"https://licenses.nuget.org/MIT\"));\n+ _featureFlagService\n+ .Setup(ffs => ffs.AreEmbeddedIconsEnabled(_currentUser))\n+ .Returns(false);\n+\n+ var result = await _target.ValidateBeforeGeneratePackageAsync(\n+ _nuGetPackage.Object,\n+ GetPackageMetadata(_nuGetPackage),\n+ _currentUser);\n+\n+ Assert.Equal(PackageValidationResultType.Accepted, result.Type);\n+ Assert.Null(result.Message);\n+ Assert.Empty(result.Warnings);\n+ }\n+\n[Theory]\n[InlineData(\"<icon><something/></icon>\")]\n[InlineData(\"<icon><something>icon.png</something></icon>\")]\n@@ -2218,6 +2265,7 @@ public FactsBase()\nbool isSigned = true,\nint? desiredTotalEntryCount = null,\nFunc<string> getCustomNuspecNodes = null,\n+ Uri iconUrl = null,\nUri licenseUrl = null,\nstring licenseExpression = null,\nstring licenseFilename = null,\n@@ -2232,6 +2280,7 @@ public FactsBase()\nisSigned: isSigned,\ndesiredTotalEntryCount: desiredTotalEntryCount,\ngetCustomNuspecNodes: getCustomNuspecNodes,\n+ iconUrl: iconUrl,\nlicenseUrl: licenseUrl,\nlicenseExpression: licenseExpression,\nlicenseFilename: licenseFilename,\n@@ -2249,6 +2298,7 @@ public FactsBase()\nbool isSigned = true,\nint? desiredTotalEntryCount = null,\nFunc<string> getCustomNuspecNodes = null,\n+ Uri iconUrl = null,\nUri licenseUrl = null,\nstring licenseExpression = null,\nstring licenseFilename = null,\n@@ -2265,6 +2315,7 @@ public FactsBase()\ndesiredTotalEntryCount: desiredTotalEntryCount,\ngetCustomNuspecNodes: getCustomNuspecNodes,\nlicenseUrl: licenseUrl,\n+ iconUrl: iconUrl,\nlicenseExpression: licenseExpression,\nlicenseFilename: licenseFilename,\nlicenseFileContents: GetBinaryLicenseFileContents(licenseFileBinaryContents, licenseFileContents),\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | IconUrl deprecation message. (#7556)
* IconUrl deprecation message.
Tests. |
455,759 | 26.09.2019 08:48:40 | -7,200 | d199584d61d92757081f2f4be3fe39d6aa65860d | Upgrade to AppInsights v2.10 | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.AspNet.Mvc\">\n<Version>5.2.3</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.Agent.Intercept\">\n- <Version>2.0.7</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.DependencyCollector\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.PerfCounterCollector\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights.TraceListener\">\n<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights.Web\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.WindowsServer\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.AspNet.DynamicData.EFProvider\">\n<Version>6.0.0</Version>\n<PackageReference Include=\"System.Diagnostics.Debug\">\n<Version>4.3.0</Version>\n</PackageReference>\n- <PackageReference Include=\"System.Diagnostics.DiagnosticSource\">\n- <Version>4.3.0</Version>\n- </PackageReference>\n<PackageReference Include=\"System.Linq.Expressions\">\n<Version>4.3.0</Version>\n</PackageReference>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"diff": "@@ -24,19 +24,23 @@ public void Initialize(ITelemetry telemetry)\n// cannot be used since it will fail if the key already exists.\n// https://github.com/microsoft/ApplicationInsights-dotnet-server/issues/977\n+ // We need to cast to ISupportProperties to avoid using the deprecated telemetry.Context.Properties API.\n+ // https://github.com/Microsoft/ApplicationInsights-Home/issues/300\n+ var itemTelemetry = (ISupportProperties)telemetry;\n+\n// ClientVersion is available for NuGet clients starting version 4.1.0-~4.5.0\n// Was deprecated and replaced by Protocol version\n- telemetry.Context.Properties[TelemetryService.ClientVersion]\n+ itemTelemetry.Properties[TelemetryService.ClientVersion]\n= httpContext.Request.Headers[ServicesConstants.ClientVersionHeaderName];\n- telemetry.Context.Properties[TelemetryService.ProtocolVersion]\n+ itemTelemetry.Properties[TelemetryService.ProtocolVersion]\n= httpContext.Request.Headers[ServicesConstants.NuGetProtocolHeaderName];\n- telemetry.Context.Properties[TelemetryService.ClientInformation]\n+ itemTelemetry.Properties[TelemetryService.ClientInformation]\n= httpContext.GetClientInformation();\n// Is the user authenticated or this is an anonymous request?\n- telemetry.Context.Properties[TelemetryService.IsAuthenticated]\n+ itemTelemetry.Properties[TelemetryService.IsAuthenticated]\n= httpContext.Request.IsAuthenticated.ToString();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/DeploymentIdTelemetryEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/DeploymentIdTelemetryEnricher.cs",
"diff": "using System;\nusing Microsoft.ApplicationInsights.Channel;\n+using Microsoft.ApplicationInsights.DataContracts;\nusing Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n@@ -34,13 +35,23 @@ public class DeploymentIdTelemetryEnricher : ITelemetryInitializer\npublic void Initialize(ITelemetry telemetry)\n{\nif (telemetry == null\n- || DeploymentId == null\n- || telemetry.Context.Properties.ContainsKey(PropertyKey))\n+ || DeploymentId == null)\n{\nreturn;\n}\n- telemetry.Context.Properties.Add(PropertyKey, DeploymentId);\n+ var itemTelemetry = telemetry as ISupportProperties;\n+ if (itemTelemetry == null)\n+ {\n+ return;\n+ }\n+\n+ if (itemTelemetry.Properties.ContainsKey(PropertyKey))\n+ {\n+ return;\n+ }\n+\n+ itemTelemetry.Properties.Add(PropertyKey, DeploymentId);\n}\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"Microsoft.ApplicationInsights\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-2.3.0.0\" newVersion=\"2.3.0.0\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-2.10.0.0\" newVersion=\"2.10.0.0\"/>\n</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"EntityFramework\" publicKeyToken=\"B77A5C561934E089\" culture=\"neutral\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Telemetry/ClientInformationTelemetryEnricherTests.cs",
"new_path": "tests/NuGetGallery.Facts/Telemetry/ClientInformationTelemetryEnricherTests.cs",
"diff": "@@ -37,7 +37,9 @@ public void EnrichesOnlyRequestsTelemetry(Type telemetryType)\n{\n// Arrange\nvar telemetry = (ITelemetry)telemetryType.GetConstructor(new Type[] { }).Invoke(new object[] { });\n- telemetry.Context.Properties.Add(\"Test\", \"blala\");\n+\n+ var itemTelemetry = telemetry as ISupportProperties;\n+ itemTelemetry.Properties.Add(\"Test\", \"blala\");\nvar headers = new NameValueCollection\n{\n@@ -54,11 +56,11 @@ public void EnrichesOnlyRequestsTelemetry(Type telemetryType)\n// Assert\nif (telemetry is RequestTelemetry)\n{\n- Assert.Equal(5, telemetry.Context.Properties.Count);\n+ Assert.Equal(5, itemTelemetry.Properties.Count);\n}\nelse\n{\n- Assert.Equal(1, telemetry.Context.Properties.Count);\n+ Assert.Equal(1, itemTelemetry.Properties.Count);\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Upgrade to AppInsights v2.10 (#7499) |
455,736 | 23.09.2019 09:13:51 | 25,200 | a37e81fa365671b7aeac77620b47f521d11d271f | Batch sign the binaries
Progress on | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "-nuget.exe\n*.ide\n*.results.xml\n@@ -26,10 +25,9 @@ x64/\n# Files created and used by our build scripts\nbuild/\ntools/\n-.nuget/CredentialProviderBundle.zip\n-.nuget/CredentialProvider.VSS.exe\n-.nuget/EULA_Microsoft Visual Studio Team Services Credential Provider.docx\n-.nuget/ThirdPartyNotices.txt\n+.nuget/credprovider\n+.nuget/.marker.v*\n+nuget.exe\nAssemblyInfo.g.cs\ntests/Scripts/Config-*.json\n"
},
{
"change_type": "MODIFY",
"old_path": "build.ps1",
"new_path": "build.ps1",
"diff": "@@ -10,7 +10,7 @@ param (\n[string]$PackageSuffix,\n[string]$Branch,\n[string]$CommitSHA,\n- [string]$BuildBranch = '1f60ff35a3cebf1a0c5fb631d2534fd5b4a11edc'\n+ [string]$BuildBranch = 'd298565f387e93995a179ef8ae6838f1be37904f'\n)\nSet-StrictMode -Version 1.0\n@@ -98,6 +98,11 @@ Invoke-BuildStep 'Building solution' {\n} `\n-ev +BuildErrors\n+Invoke-BuildStep 'Signing the binaries' {\n+ Sign-Binaries -Configuration $Configuration -BuildNumber $BuildNumber -MSBuildVersion \"15\" `\n+} `\n+-ev +BuildErrors\n+\nInvoke-BuildStep 'Creating artifacts' { `\nNew-ProjectPackage (Join-Path $PSScriptRoot \"src\\NuGetGallery.Core\\NuGetGallery.Core.csproj\") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion -PackageId \"NuGetGallery.Core$PackageSuffix\"\nNew-ProjectPackage (Join-Path $PSScriptRoot \"src\\NuGet.Services.Entities\\NuGet.Services.Entities.csproj\") -Configuration $Configuration -Symbols -BuildNumber $BuildNumber -Version $SemanticVersion\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "sign.thirdparty.props",
"diff": "+<?xml version=\"1.0\" encoding=\"utf-8\"?>\n+<Project ToolsVersion=\"14.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n+ <ItemGroup>\n+ <ThirdPartyBinaries Include=\"AnglicanGeek.MarkdownMailer.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.Extensions.DependencyInjection.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.Integration.Mvc.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.Integration.Mvc.Owin.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.Integration.Owin.dll\" />\n+ <ThirdPartyBinaries Include=\"Autofac.Integration.WebApi.dll\" />\n+ <ThirdPartyBinaries Include=\"CommonMark.dll\" />\n+ <ThirdPartyBinaries Include=\"CsvHelper.dll\" />\n+ <ThirdPartyBinaries Include=\"Dapper.StrongName.dll\" />\n+ <ThirdPartyBinaries Include=\"DynamicData.EFCodeFirstProvider.dll\" />\n+ <ThirdPartyBinaries Include=\"Elmah.dll\" />\n+ <ThirdPartyBinaries Include=\"ICSharpCode.SharpZipLib.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Analyzers.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Core.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.FastVectorHighlighter.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Highlighter.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Memory.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Queries.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Regex.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.SimpleFacetedSearch.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Snowball.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.SpellChecker.dll\" />\n+ <ThirdPartyBinaries Include=\"Lucene.Net.dll\" />\n+ <ThirdPartyBinaries Include=\"Markdig.dll\" />\n+ <ThirdPartyBinaries Include=\"MarkdownSharp.dll\" />\n+ <ThirdPartyBinaries Include=\"Microsoft.ApplicationServer.Caching.Client.dll\" />\n+ <ThirdPartyBinaries Include=\"Microsoft.ApplicationServer.Caching.Core.dll\" />\n+ <ThirdPartyBinaries Include=\"Microsoft.AspNet.WebApi.MessageHandlers.Compression.dll\" />\n+ <ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.dll\" />\n+ <ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.NetStd.dll\" />\n+ <ThirdPartyBinaries Include=\"Newtonsoft.Json.dll\" />\n+ <ThirdPartyBinaries Include=\"Polly.dll\" />\n+ <ThirdPartyBinaries Include=\"Polly.Extensions.Http.dll\" />\n+ <ThirdPartyBinaries Include=\"QueryInterceptor.dll\" />\n+ <ThirdPartyBinaries Include=\"RouteMagic.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.Enrichers.Environment.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.Enrichers.Process.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.Extensions.Logging.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.Sinks.ApplicationInsights.dll\" />\n+ <ThirdPartyBinaries Include=\"Serilog.Sinks.ColoredConsole.dll\" />\n+ <ThirdPartyBinaries Include=\"SerilogTraceListener.dll\" />\n+ <ThirdPartyBinaries Include=\"WebActivator.dll\" />\n+ <ThirdPartyBinaries Include=\"WebActivatorEx.dll\" />\n+ <ThirdPartyBinaries Include=\"WebApi.OutputCache.Core.dll\" />\n+ <ThirdPartyBinaries Include=\"WebApi.OutputCache.V2.dll\" />\n+ <ThirdPartyBinaries Include=\"WebBackgrounder.dll\" />\n+ <ThirdPartyBinaries Include=\"WebBackgrounder.EntityFramework.dll\" />\n+ </ItemGroup>\n+</Project>\n+\n"
},
{
"change_type": "DELETE",
"old_path": "sign.thirdparty.targets",
"new_path": null,
"diff": "-\n-<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n- <ItemGroup>\n- <SignFilesDependsOn Include=\"EnumerateThirdPartyBinariesToSign\" />\n- </ItemGroup>\n- <Target Name=\"EnumerateThirdPartyBinariesToSign\" AfterTargets=\"AfterBuild\" Condition=\"'$(SignType)' != 'none'\">\n- <ItemGroup>\n- <ThirdPartyBinaries Include=\"AnglicanGeek.MarkdownMailer.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.Extensions.DependencyInjection.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.Integration.Mvc.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.Integration.Mvc.Owin.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.Integration.Owin.dll\" />\n- <ThirdPartyBinaries Include=\"Autofac.Integration.WebApi.dll\" />\n- <ThirdPartyBinaries Include=\"CommonMark.dll\" />\n- <ThirdPartyBinaries Include=\"CsvHelper.dll\" />\n- <ThirdPartyBinaries Include=\"Dapper.StrongName.dll\" />\n- <ThirdPartyBinaries Include=\"DynamicData.EFCodeFirstProvider.dll\" />\n- <ThirdPartyBinaries Include=\"Elmah.dll\" />\n- <ThirdPartyBinaries Include=\"ICSharpCode.SharpZipLib.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Analyzers.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Core.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.FastVectorHighlighter.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Highlighter.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Memory.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Queries.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Regex.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.SimpleFacetedSearch.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.Snowball.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.Contrib.SpellChecker.dll\" />\n- <ThirdPartyBinaries Include=\"Lucene.Net.dll\" />\n- <ThirdPartyBinaries Include=\"Markdig.dll\" />\n- <ThirdPartyBinaries Include=\"MarkdownSharp.dll\" />\n- <ThirdPartyBinaries Include=\"Microsoft.ApplicationServer.Caching.Client.dll\" />\n- <ThirdPartyBinaries Include=\"Microsoft.ApplicationServer.Caching.Core.dll\" />\n- <ThirdPartyBinaries Include=\"Microsoft.AspNet.WebApi.MessageHandlers.Compression.dll\" />\n- <ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.dll\" />\n- <ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.NetStd.dll\" />\n- <ThirdPartyBinaries Include=\"Newtonsoft.Json.dll\" />\n- <ThirdPartyBinaries Include=\"Polly.dll\" />\n- <ThirdPartyBinaries Include=\"Polly.Extensions.Http.dll\" />\n- <ThirdPartyBinaries Include=\"QueryInterceptor.dll\" />\n- <ThirdPartyBinaries Include=\"RouteMagic.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.Enrichers.Environment.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.Enrichers.Process.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.Extensions.Logging.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.Sinks.ApplicationInsights.dll\" />\n- <ThirdPartyBinaries Include=\"Serilog.Sinks.ColoredConsole.dll\" />\n- <ThirdPartyBinaries Include=\"SerilogTraceListener.dll\" />\n- <ThirdPartyBinaries Include=\"WebActivator.dll\" />\n- <ThirdPartyBinaries Include=\"WebActivatorEx.dll\" />\n- <ThirdPartyBinaries Include=\"WebApi.OutputCache.Core.dll\" />\n- <ThirdPartyBinaries Include=\"WebApi.OutputCache.V2.dll\" />\n- <ThirdPartyBinaries Include=\"WebBackgrounder.dll\" />\n- <ThirdPartyBinaries Include=\"WebBackgrounder.EntityFramework.dll\" />\n- </ItemGroup>\n- <ItemGroup>\n- <FilesToSign Include=\"$(OutDir)%(ThirdPartyBinaries.Identity)\" Condition=\"Exists('$(OutDir)%(ThirdPartyBinaries.Identity)')\">\n- <Authenticode>3PartySHA2</Authenticode>\n- </FilesToSign>\n- </ItemGroup>\n- <Message Text=\"Files to sign:%0A@(FilesToSign, '%0A')\" Importance=\"High\" />\n- </Target>\n-</Project>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Batch sign the binaries (#7581)
Progress on https://github.com/NuGet/Engineering/issues/1821 |
455,759 | 02.10.2019 19:05:29 | -7,200 | 872e05f3958a4fb1a2551ca0e52bbd691b77404d | Fix AI request telemetry | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ApplicationInsights.config",
"new_path": "src/NuGetGallery/ApplicationInsights.config",
"diff": "Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.\n-->\n- <TelemetryProcessors>\n- <Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector\"/>\n- </TelemetryProcessors>\n<TelemetryInitializers>\n<Add Type=\"Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer\"/>\n-->\n</Add>\n<Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AppServicesHeartbeatTelemetryModule, Microsoft.AI.WindowsServer\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AzureInstanceMetadataTelemetryModule, Microsoft.AI.WindowsServer\">\n+ <!--\n+ Remove individual fields collected here by adding them to the ApplicationInsighs.HeartbeatProvider\n+ with the following syntax:\n+\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights\">\n+ <ExcludedHeartbeatProperties>\n+ <Add>osType</Add>\n+ <Add>location</Add>\n+ <Add>name</Add>\n+ <Add>offer</Add>\n+ <Add>platformFaultDomain</Add>\n+ <Add>platformUpdateDomain</Add>\n+ <Add>publisher</Add>\n+ <Add>sku</Add>\n+ <Add>version</Add>\n+ <Add>vmId</Add>\n+ <Add>vmSize</Add>\n+ <Add>subscriptionId</Add>\n+ <Add>resourceGroupName</Add>\n+ <Add>placementGroupId</Add>\n+ <Add>tags</Add>\n+ <Add>vmScaleSetName</Add>\n+ </ExcludedHeartbeatProperties>\n+ </Add>\n+\n+ NOTE: exclusions will be lost upon upgrade.\n+ -->\n+ </Add>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer\"/>\nNOTE: handler configuration will be lost upon NuGet upgrade.\n-->\n- <Add>System.Web.Handlers.TransferRequestHandler</Add>\n<Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>\n<Add>System.Web.StaticFileHandler</Add>\n<Add>System.Web.Handlers.AssemblyResourceLoader</Add>\n</Handlers>\n</Add>\n<Add Type=\"Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web\"/>\n</TelemetryModules>\n+ <ApplicationIdProvider Type=\"Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights\"/>\n+ <TelemetrySinks>\n+ <Add Name=\"default\">\n+ <TelemetryProcessors>\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights\"/>\n+ </TelemetryProcessors>\n<TelemetryChannel Type=\"Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel\"/>\n+ </Add>\n+ </TelemetrySinks>\n<!--\nLearn more about Application Insights configuration with ApplicationInsights.config here:\nhttp://go.microsoft.com/fwlink/?LinkID=513840\nNote: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.\n- --></ApplicationInsights>\n\\ No newline at end of file\n+ -->\n+</ApplicationInsights>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<add name=\"ErrorFilter\" type=\"Elmah.ErrorFilterModule, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=57eac04b2e0f138e, processorArchitecture=MSIL\" preCondition=\"managedHandler\"/>\n<add name=\"AsyncFileUpload\" type=\"NuGetGallery.AsyncFileUpload.AsyncFileUploadModule, NuGetGallery.Services\" preCondition=\"managedHandler\"/>\n<remove name=\"RoleManager\"/>\n+ <remove name=\"TelemetryCorrelationHttpModule\" />\n+ <add name=\"TelemetryCorrelationHttpModule\" type=\"Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation\" preCondition=\"integratedMode,managedHandler\" />\n<remove name=\"ApplicationInsightsWebTracking\"/>\n<add name=\"ApplicationInsightsWebTracking\" type=\"Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web\" preCondition=\"managedHandler\"/>\n</modules>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix AI request telemetry (#7599) |
455,759 | 02.10.2019 19:06:22 | -7,200 | 665c759cd739252134c654e920c1ac6a5aecff72 | Re-align AppInsights with dev branch | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.AspNet.Mvc\">\n<Version>5.2.3</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ApplicationInsights.config",
"new_path": "src/NuGetGallery/ApplicationInsights.config",
"diff": "Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.\n-->\n- <TelemetryProcessors>\n- <Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector\"/>\n- </TelemetryProcessors>\n<TelemetryInitializers>\n<Add Type=\"Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer\"/>\n-->\n</Add>\n<Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AppServicesHeartbeatTelemetryModule, Microsoft.AI.WindowsServer\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.WindowsServer.AzureInstanceMetadataTelemetryModule, Microsoft.AI.WindowsServer\">\n+ <!--\n+ Remove individual fields collected here by adding them to the ApplicationInsighs.HeartbeatProvider\n+ with the following syntax:\n+\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights\">\n+ <ExcludedHeartbeatProperties>\n+ <Add>osType</Add>\n+ <Add>location</Add>\n+ <Add>name</Add>\n+ <Add>offer</Add>\n+ <Add>platformFaultDomain</Add>\n+ <Add>platformUpdateDomain</Add>\n+ <Add>publisher</Add>\n+ <Add>sku</Add>\n+ <Add>version</Add>\n+ <Add>vmId</Add>\n+ <Add>vmSize</Add>\n+ <Add>subscriptionId</Add>\n+ <Add>resourceGroupName</Add>\n+ <Add>placementGroupId</Add>\n+ <Add>tags</Add>\n+ <Add>vmScaleSetName</Add>\n+ </ExcludedHeartbeatProperties>\n+ </Add>\n+\n+ NOTE: exclusions will be lost upon upgrade.\n+ -->\n+ </Add>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer\"/>\n<Add Type=\"Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer\"/>\nNOTE: handler configuration will be lost upon NuGet upgrade.\n-->\n- <Add>System.Web.Handlers.TransferRequestHandler</Add>\n<Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>\n<Add>System.Web.StaticFileHandler</Add>\n<Add>System.Web.Handlers.AssemblyResourceLoader</Add>\n</Handlers>\n</Add>\n<Add Type=\"Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.Web.AspNetDiagnosticTelemetryModule, Microsoft.AI.Web\"/>\n</TelemetryModules>\n+ <ApplicationIdProvider Type=\"Microsoft.ApplicationInsights.Extensibility.Implementation.ApplicationId.ApplicationInsightsApplicationIdProvider, Microsoft.ApplicationInsights\"/>\n+ <TelemetrySinks>\n+ <Add Name=\"default\">\n+ <TelemetryProcessors>\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector\"/>\n+ <Add Type=\"Microsoft.ApplicationInsights.Extensibility.AutocollectedMetricsExtractor, Microsoft.ApplicationInsights\"/>\n+ </TelemetryProcessors>\n<TelemetryChannel Type=\"Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel\"/>\n+ </Add>\n+ </TelemetrySinks>\n<!--\nLearn more about Application Insights configuration with ApplicationInsights.config here:\nhttp://go.microsoft.com/fwlink/?LinkID=513840\nNote: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.\n- --></ApplicationInsights>\n\\ No newline at end of file\n+ -->\n+</ApplicationInsights>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.Agent.Intercept\">\n- <Version>2.0.7</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.DependencyCollector\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.PerfCounterCollector\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights.TraceListener\">\n<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.ApplicationInsights.Web\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.WindowsServer\">\n- <Version>2.3.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel\">\n- <Version>2.3.0</Version>\n+ <Version>2.10.0</Version>\n</PackageReference>\n<PackageReference Include=\"Microsoft.AspNet.DynamicData.EFProvider\">\n<Version>6.0.0</Version>\n<PackageReference Include=\"System.Diagnostics.Debug\">\n<Version>4.3.0</Version>\n</PackageReference>\n- <PackageReference Include=\"System.Diagnostics.DiagnosticSource\">\n- <Version>4.3.0</Version>\n- </PackageReference>\n<PackageReference Include=\"System.Linq.Expressions\">\n<Version>4.3.0</Version>\n</PackageReference>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"diff": "@@ -24,19 +24,23 @@ public void Initialize(ITelemetry telemetry)\n// cannot be used since it will fail if the key already exists.\n// https://github.com/microsoft/ApplicationInsights-dotnet-server/issues/977\n+ // We need to cast to ISupportProperties to avoid using the deprecated telemetry.Context.Properties API.\n+ // https://github.com/Microsoft/ApplicationInsights-Home/issues/300\n+ var itemTelemetry = (ISupportProperties)telemetry;\n+\n// ClientVersion is available for NuGet clients starting version 4.1.0-~4.5.0\n// Was deprecated and replaced by Protocol version\n- telemetry.Context.Properties[TelemetryService.ClientVersion]\n+ itemTelemetry.Properties[TelemetryService.ClientVersion]\n= httpContext.Request.Headers[ServicesConstants.ClientVersionHeaderName];\n- telemetry.Context.Properties[TelemetryService.ProtocolVersion]\n+ itemTelemetry.Properties[TelemetryService.ProtocolVersion]\n= httpContext.Request.Headers[ServicesConstants.NuGetProtocolHeaderName];\n- telemetry.Context.Properties[TelemetryService.ClientInformation]\n+ itemTelemetry.Properties[TelemetryService.ClientInformation]\n= httpContext.GetClientInformation();\n// Is the user authenticated or this is an anonymous request?\n- telemetry.Context.Properties[TelemetryService.IsAuthenticated]\n+ itemTelemetry.Properties[TelemetryService.IsAuthenticated]\n= httpContext.Request.IsAuthenticated.ToString();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/DeploymentIdTelemetryEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/DeploymentIdTelemetryEnricher.cs",
"diff": "using System;\nusing Microsoft.ApplicationInsights.Channel;\n+using Microsoft.ApplicationInsights.DataContracts;\nusing Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n@@ -34,13 +35,23 @@ public class DeploymentIdTelemetryEnricher : ITelemetryInitializer\npublic void Initialize(ITelemetry telemetry)\n{\nif (telemetry == null\n- || DeploymentId == null\n- || telemetry.Context.Properties.ContainsKey(PropertyKey))\n+ || DeploymentId == null)\n{\nreturn;\n}\n- telemetry.Context.Properties.Add(PropertyKey, DeploymentId);\n+ var itemTelemetry = telemetry as ISupportProperties;\n+ if (itemTelemetry == null)\n+ {\n+ return;\n+ }\n+\n+ if (itemTelemetry.Properties.ContainsKey(PropertyKey))\n+ {\n+ return;\n+ }\n+\n+ itemTelemetry.Properties.Add(PropertyKey, DeploymentId);\n}\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<add name=\"ErrorFilter\" type=\"Elmah.ErrorFilterModule, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=57eac04b2e0f138e, processorArchitecture=MSIL\" preCondition=\"managedHandler\"/>\n<add name=\"AsyncFileUpload\" type=\"NuGetGallery.AsyncFileUpload.AsyncFileUploadModule, NuGetGallery.Services\" preCondition=\"managedHandler\"/>\n<remove name=\"RoleManager\"/>\n+ <remove name=\"TelemetryCorrelationHttpModule\" />\n+ <add name=\"TelemetryCorrelationHttpModule\" type=\"Microsoft.AspNet.TelemetryCorrelation.TelemetryCorrelationHttpModule, Microsoft.AspNet.TelemetryCorrelation\" preCondition=\"integratedMode,managedHandler\" />\n<remove name=\"ApplicationInsightsWebTracking\"/>\n<add name=\"ApplicationInsightsWebTracking\" type=\"Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web\" preCondition=\"managedHandler\"/>\n</modules>\n</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"Microsoft.ApplicationInsights\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-2.3.0.0\" newVersion=\"2.3.0.0\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-2.10.0.0\" newVersion=\"2.10.0.0\"/>\n</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"EntityFramework\" publicKeyToken=\"B77A5C561934E089\" culture=\"neutral\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Telemetry/ClientInformationTelemetryEnricherTests.cs",
"new_path": "tests/NuGetGallery.Facts/Telemetry/ClientInformationTelemetryEnricherTests.cs",
"diff": "@@ -37,7 +37,9 @@ public void EnrichesOnlyRequestsTelemetry(Type telemetryType)\n{\n// Arrange\nvar telemetry = (ITelemetry)telemetryType.GetConstructor(new Type[] { }).Invoke(new object[] { });\n- telemetry.Context.Properties.Add(\"Test\", \"blala\");\n+\n+ var itemTelemetry = telemetry as ISupportProperties;\n+ itemTelemetry.Properties.Add(\"Test\", \"blala\");\nvar headers = new NameValueCollection\n{\n@@ -54,11 +56,11 @@ public void EnrichesOnlyRequestsTelemetry(Type telemetryType)\n// Assert\nif (telemetry is RequestTelemetry)\n{\n- Assert.Equal(5, telemetry.Context.Properties.Count);\n+ Assert.Equal(5, itemTelemetry.Properties.Count);\n}\nelse\n{\n- Assert.Equal(1, telemetry.Context.Properties.Count);\n+ Assert.Equal(1, itemTelemetry.Properties.Count);\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Re-align AppInsights with dev branch (#7600) |
455,759 | 03.10.2019 09:56:35 | -7,200 | d5699f170ca2c28110fae4b82420e995ca974ea7 | Handle RequestTelemetry.Url == null (AI intermediate requests) | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/ClientTelemetryPIIProcessor.cs",
"new_path": "src/NuGetGallery/Telemetry/ClientTelemetryPIIProcessor.cs",
"diff": "@@ -28,13 +28,20 @@ public void Process(ITelemetry item)\nprivate void ModifyItem(ITelemetry item)\n{\nvar requestTelemetryItem = item as RequestTelemetry;\n- if(requestTelemetryItem != null)\n+\n+ // In some cases, Application Insights reports an intermediate request as a workaround\n+ // when AI lost correlation context and has to restore it.\n+ // Hence, RequestTelemetry.Url may be null.\n+ // See https://github.com/microsoft/ApplicationInsights-dotnet-server/pull/898\n+ // and https://docs.microsoft.com/en-us/dotnet/api/microsoft.applicationinsights.datacontracts.requesttelemetry.url\n+ if (requestTelemetryItem != null && requestTelemetryItem.Url != null)\n{\nvar route = GetCurrentRoute();\nif (route == null)\n{\nreturn;\n}\n+\nrequestTelemetryItem.Url = RouteExtensions.ObfuscateUrlQuery(requestTelemetryItem.Url, RouteExtensions.ObfuscatedReturnUrlMetadata);\n// Removes the first /\nvar requestPath = requestTelemetryItem.Url.AbsolutePath.TrimStart('/');\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Telemetry/ClientTelemetryPIIProcessorTests.cs",
"new_path": "tests/NuGetGallery.Facts/Telemetry/ClientTelemetryPIIProcessorTests.cs",
"diff": "@@ -37,6 +37,20 @@ public void NullTelemetryItemDoesNotThrow()\npiiProcessor.Process(null);\n}\n+ [Fact]\n+ public void NullRequestTelemetryUrlDoesNotThrow()\n+ {\n+ // Arange\n+ var piiProcessor = CreatePIIProcessor();\n+ var requestTelemetry = new RequestTelemetry\n+ {\n+ Url = null\n+ };\n+\n+ // Act\n+ piiProcessor.Process(requestTelemetry);\n+ }\n+\n[Theory]\n[MemberData(nameof(PIIUrlDataGenerator))]\npublic void UrlIsUpdatedOnPIIAction(string routePath, string inputUrl, string expectedOutputUrl)\n@@ -132,7 +146,8 @@ private List<string> GetPIIOperationsFromRoute()\n{\nRoute webRoute = r as Route;\nreturn webRoute != null ? IsPIIUrl(webRoute.Url.ToString()) : false;\n- }).Select((r) => {\n+ }).Select((r) =>\n+ {\nvar dd = ((Route)r).Defaults;\nreturn $\"{dd[\"controller\"]}/{dd[\"action\"]}\";\n}).Distinct().ToList();\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Handle RequestTelemetry.Url == null (AI intermediate requests) (#7603) |
455,770 | 04.10.2019 10:50:27 | 25,200 | 8a1b7356e4d1b3c4db831f38587db1eb99b996b0 | Replacing enum StorageType with static class of constants by the same name. | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/Configuration/GalleryConfiguration.cs",
"new_path": "src/AccountDeleter/Configuration/GalleryConfiguration.cs",
"diff": "@@ -48,7 +48,7 @@ public string SiteRoot\npublic bool FeedOnlyMode { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic string FileStorageDirectory { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic string Brand { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n- public StorageType StorageType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n+ public string StorageType { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic Uri SmtpUri { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic string SqlConnectionString { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic string SqlConnectionStringSupportRequest { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"diff": "@@ -134,8 +134,8 @@ public class AppConfiguration : IAppConfiguration\n/// <summary>\n/// Gets the storage mechanism used by this instance of the gallery\n/// </summary>\n- [DefaultValue(StorageType.NotSpecified)]\n- public StorageType StorageType { get; set; }\n+ [DefaultValue(NuGetGallery.Configuration.StorageType.NotSpecified)]\n+ public string StorageType { get; set; }\n/// <summary>\n/// Gets the URI of the SMTP host to use. Or null if SMTP is not being used\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"diff": "@@ -158,7 +158,7 @@ public interface IAppConfiguration : IMessageServiceConfiguration\n/// <summary>\n/// Gets the storage mechanism used by this instance of the gallery\n/// </summary>\n- StorageType StorageType { get; set; }\n+ string StorageType { get; set; }\n/// <summary>\n/// Gets the URI of the SMTP host to use. Or null if SMTP is not being used. Use <see cref=\"NuGetGallery.Configuration.SmtpUri\"/> to parse it\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Models/StorageType.cs",
"new_path": "src/NuGetGallery.Services/Models/StorageType.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nnamespace NuGetGallery.Configuration\n{\n- public enum StorageType\n+ public static class StorageType\n{\n- NotSpecified = 0,\n- FileSystem,\n- AzureStorage\n+ public const string NotSpecified = \"\";\n+ public const string FileSystem = \"FileSystem\";\n+ public const string AzureStorage = \"AzureStorage\";\n}\n}\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Replacing enum StorageType with static class of constants by the same name. (#7602) |
455,747 | 05.10.2019 23:41:29 | 25,200 | 5c21a41506ea6e088eb4742b8b58047e5b94b819 | [Hotfix] Fix AAD login issues for some tenants. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs",
"new_path": "src/NuGetGallery.Services/Authentication/Providers/AzureActiveDirectoryV2/AzureActiveDirectoryV2Authenticator.cs",
"diff": "@@ -184,9 +184,11 @@ public override IdentityInformation GetIdentityInformation(ClaimsIdentity claims\nvar nameClaim = claimsIdentity.FindFirst(V2Claims.Name);\nvar emailClaim = claimsIdentity.FindFirst(V2Claims.EmailAddress);\n+ var preferredUsernameClaim = claimsIdentity.FindFirst(V2Claims.PreferredUsername);\n+ emailClaim = emailClaim ?? preferredUsernameClaim;\nif (emailClaim == null)\n{\n- throw new ArgumentException($\"External Authentication is missing required claim: '{V2Claims.EmailAddress}'\");\n+ throw new ArgumentException($\"External Authentication is missing required claims: '{V2Claims.EmailAddress}' and '{V2Claims.PreferredUsername}\");\n}\nvar acrClaim = claimsIdentity.FindFirst(V2Claims.ACR);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Authentication/Providers/CommonAuth/AzureActiveDirectoryV2AuthenticatorFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Authentication/Providers/CommonAuth/AzureActiveDirectoryV2AuthenticatorFacts.cs",
"diff": "@@ -150,7 +150,7 @@ public void MissingNameClaimDoesNotThrow()\n}\n[Fact]\n- public void ThrowsForMissingEmailClaim()\n+ public void ThrowsForMissingEmailAndPreferredUsernameClaim()\n{\n// Arrange\nvar authenticator = new AzureActiveDirectoryV2Authenticator();\n@@ -165,6 +165,49 @@ public void ThrowsForMissingEmailClaim()\nAssert.Throws<ArgumentException>(() => authenticator.GetIdentityInformation(claimsIdentity));\n}\n+ [Fact]\n+ public void DoesNotThrowForMissingEmailClaimIfPreferredUsernameClaimIsPresent()\n+ {\n+ // Arrange\n+ var authenticator = new AzureActiveDirectoryV2Authenticator();\n+ var claimsIdentity = new ClaimsIdentity(new[] {\n+ TestData.Issuer,\n+ TestData.TenantId,\n+ TestData.Identifier,\n+ TestData.Name,\n+ TestData.PreferredUsername\n+ });\n+\n+ // Act\n+ var result = authenticator.GetIdentityInformation(claimsIdentity);\n+\n+ // Assert\n+ Assert.NotNull(result);\n+ Assert.Equal(TestData.PreferredUsername.Value, result.Email);\n+ }\n+\n+ [Fact]\n+ public void EmailClaimIsPreferredOverPreferredUsernameClaime()\n+ {\n+ // Arrange\n+ var authenticator = new AzureActiveDirectoryV2Authenticator();\n+ var claimsIdentity = new ClaimsIdentity(new[] {\n+ TestData.Issuer,\n+ TestData.TenantId,\n+ TestData.Identifier,\n+ TestData.Name,\n+ TestData.Email,\n+ TestData.PreferredUsername\n+ });\n+\n+ // Act\n+ var result = authenticator.GetIdentityInformation(claimsIdentity);\n+\n+ // Assert\n+ Assert.NotNull(result);\n+ Assert.Equal(TestData.Email.Value, result.Email);\n+ }\n+\n[Fact]\npublic void ReturnsAuthInformationForCorrectClaims()\n{\n@@ -220,6 +263,7 @@ private static class TestData\npublic static Claim Name = new Claim(AzureActiveDirectoryV2Authenticator.V2Claims.Name, \"bloog\", ClaimValueTypes.String, Authority);\npublic static Claim TenantId = new Claim(AzureActiveDirectoryV2Authenticator.V2Claims.TenantId, TEST_TENANT_ID, ClaimValueTypes.String, Authority);\npublic static Claim Email = new Claim(AzureActiveDirectoryV2Authenticator.V2Claims.EmailAddress, \"[email protected]\", ClaimValueTypes.String, Authority);\n+ public static Claim PreferredUsername = new Claim(AzureActiveDirectoryV2Authenticator.V2Claims.PreferredUsername, \"[email protected]\", ClaimValueTypes.String, Authority);\npublic static ClaimsIdentity GetIdentity()\n{\n@@ -228,7 +272,8 @@ public static ClaimsIdentity GetIdentity()\nTenantId,\nIdentifier,\nName,\n- Email\n+ Email,\n+ PreferredUsername\n});\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [Hotfix] Fix AAD login issues for some tenants. (#7606) |
455,744 | 08.10.2019 10:56:58 | 25,200 | dc1cad435f5dec2fb5f53c6fb204e004ac8e8c54 | Fix for iconUrl deprecation message appearing for packages without any icon. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"new_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"diff": "@@ -350,7 +350,7 @@ private async Task<PackageValidationResult> CheckIconMetadataAsync(PackageArchiv\nif (iconElement == null)\n{\n- if (embeddedIconsEnabled && nuspecReader.GetIconUrl() != null)\n+ if (embeddedIconsEnabled && !string.IsNullOrWhiteSpace(nuspecReader.GetIconUrl()))\n{\nwarnings.Add(new IconUrlDeprecationValidationMessage());\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"diff": "@@ -1166,6 +1166,28 @@ public async Task WarnsAboutPackagesWithIconUrlForFlightedUsers()\nAssert.StartsWith(\"The <iconUrl> element is deprecated. Consider using the <icon> element instead.\", warning.RawHtmlMessage);\n}\n+ [Fact]\n+ public async Task DoesntWarnAboutPackagesWithNoIconForFlightedUsers()\n+ {\n+ _nuGetPackage = GeneratePackageWithUserContent(\n+ iconUrl: null,\n+ iconFilename: null,\n+ licenseExpression: \"MIT\",\n+ licenseUrl: new Uri(\"https://licenses.nuget.org/MIT\"));\n+ _featureFlagService\n+ .Setup(ffs => ffs.AreEmbeddedIconsEnabled(_currentUser))\n+ .Returns(true);\n+\n+ var result = await _target.ValidateBeforeGeneratePackageAsync(\n+ _nuGetPackage.Object,\n+ GetPackageMetadata(_nuGetPackage),\n+ _currentUser);\n+\n+ Assert.Equal(PackageValidationResultType.Accepted, result.Type);\n+ Assert.Null(result.Message);\n+ Assert.Empty(result.Warnings);\n+ }\n+\n[Fact]\npublic async Task DoesntWarnAboutPackagesWithIconUrl()\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix for iconUrl deprecation message appearing for packages without any icon. (#7608) |
455,736 | 09.10.2019 16:32:07 | 25,200 | b93ae1ce43fa2f190cf8e4cc61f5b18cbf008a65 | Display instead of for user certificates
Address | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -324,6 +324,10 @@ img.reserved-indicator-icon {\n.breadcrumb-menu h1 {\nmargin-top: 0px;\n}\n+.page-account-settings .small-fingerprint,\n+.page-manage-organizations .small-fingerprint {\n+ font-size: 75%;\n+}\n.modal-backdrop.in {\nopacity: 0.8 !important;\nposition: fixed;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/base.less",
"new_path": "src/Bootstrap/less/theme/base.less",
"diff": "@@ -404,3 +404,9 @@ img.reserved-indicator-icon {\nmargin-top: 0px;\n}\n}\n+\n+.page-account-settings, .page-manage-organizations {\n+ .small-fingerprint {\n+ font-size: 75%;\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/Certificate.cs",
"new_path": "src/NuGet.Services.Entities/Certificate.cs",
"diff": "@@ -18,6 +18,7 @@ public class Certificate : IEntity\n/// <summary>\n/// Gets or sets the SHA-1 thumbprint of the certificate.\n/// </summary>\n+ [Obsolete(\"This property should not be used since SHA-1 usage is avoided in NuGetGallery.\")]\npublic string Sha1Thumbprint { get; set; }\n/// <summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Helpers/ViewModelExtensions/ListPackageItemViewModelFactory.cs",
"new_path": "src/NuGetGallery/Helpers/ViewModelExtensions/ListPackageItemViewModelFactory.cs",
"diff": "@@ -55,7 +55,7 @@ private ListPackageItemViewModel SetupInternal(ListPackageItemViewModel viewMode\n{\nvar owners = package.PackageRegistration?.Owners ?? Enumerable.Empty<User>();\nvar signerUsernames = owners.Where(owner => owner.UserCertificates.Any(uc => uc.CertificateKey == package.CertificateKey)).Select(owner => owner.Username).ToList();\n- viewModel.UpdateSignatureInformation(signerUsernames, package.Certificate.Sha1Thumbprint);\n+ viewModel.UpdateSignatureInformation(signerUsernames, package.Certificate.Thumbprint);\n}\nreturn viewModel;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/CertificateService.cs",
"new_path": "src/NuGetGallery/Services/CertificateService.cs",
"diff": "@@ -59,7 +59,9 @@ public async Task<Certificate> AddCertificateAsync(HttpPostedFileBase file)\ncertificate = new Certificate()\n{\n+#pragma warning disable CS0618 // Only set the SHA1 thumbprint, for backwards compatibility. Never read it.\nSha1Thumbprint = certificateFile.Sha1Thumbprint,\n+#pragma warning restore CS0618\nThumbprint = certificateFile.Sha256Thumbprint,\nUserCertificates = new List<UserCertificate>()\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/ListCertificateItemViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/ListCertificateItemViewModel.cs",
"diff": "@@ -15,7 +15,7 @@ public sealed class ListCertificateItemViewModel\n/// </summary>\nprivate const int AbbreviationLength = 36;\n- public string Sha1Thumbprint { get; }\n+ public string Thumbprint { get; }\npublic bool HasInfo { get; }\npublic bool IsExpired { get; }\npublic string ExpirationDisplay { get; }\n@@ -34,7 +34,7 @@ public ListCertificateItemViewModel(Certificate certificate, string deleteUrl)\nthrow new ArgumentNullException(nameof(certificate));\n}\n- Sha1Thumbprint = certificate.Sha1Thumbprint;\n+ Thumbprint = certificate.Thumbprint;\nHasInfo = certificate.Expiration.HasValue;\nif (certificate.Expiration.HasValue)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/ListPackageItemViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/ListPackageItemViewModel.cs",
"diff": "@@ -16,7 +16,7 @@ public class ListPackageItemViewModel : PackageViewModel\nprivate string _signatureInformation;\nprivate IReadOnlyCollection<string> _signerUsernames;\n- private string _sha1Thumbprint;\n+ private string _thumbprint;\npublic string Authors { get; set; }\npublic IReadOnlyCollection<BasicUserViewModel> Owners { get; set; }\n@@ -64,15 +64,15 @@ public void SetShortDescriptionFrom(string fullDescription)\nIsDescriptionTruncated = wasTruncated;\n}\n- public void UpdateSignatureInformation(IReadOnlyCollection<string> signerUsernames, string sha1Thumbprint)\n+ public void UpdateSignatureInformation(IReadOnlyCollection<string> signerUsernames, string thumbprint)\n{\n- if ((signerUsernames == null && sha1Thumbprint != null) || (signerUsernames != null && sha1Thumbprint == null))\n+ if ((signerUsernames == null && thumbprint != null) || (signerUsernames != null && thumbprint == null))\n{\n- throw new ArgumentException($\"{nameof(signerUsernames)} and {nameof(sha1Thumbprint)} arguments must either be both null or both non-null.\");\n+ throw new ArgumentException($\"{nameof(signerUsernames)} and {nameof(thumbprint)} arguments must either be both null or both non-null.\");\n}\n_signerUsernames = signerUsernames;\n- _sha1Thumbprint = sha1Thumbprint;\n+ _thumbprint = thumbprint;\n_signatureInformation = null;\n}\n@@ -107,7 +107,7 @@ private string GetSignerInformation()\nbuilder.Append($\" and {_signerUsernames.Last()}'s\");\n}\n- builder.Append($\" certificate ({_sha1Thumbprint})\");\n+ builder.Append($\" certificate ({_thumbprint})\");\nreturn builder.ToString();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Shared/_AccountCertificates.cshtml",
"new_path": "src/NuGetGallery/Views/Shared/_AccountCertificates.cshtml",
"diff": "<table class=\"table\" role=\"list\">\n<thead>\n<tr class=\"manage-certificate-headings\">\n- <th>Fingerprint</th>\n+ <th>Fingerprint (SHA-256)</th>\n<th>Subject</th>\n<th>Expiration</th>\n<th>Issuer</th>\n</thead>\n<tbody data-bind=\"foreach: $data.certificates\">\n<tr class=\"manage-certificate-listing\" role=\"listitem\">\n- <td data-bind=\"text: Sha1Thumbprint\"></td>\n+ <td><samp class=\"small-fingerprint\" data-bind=\"text: Thumbprint\"></samp></td>\n<td data-bind=\"text: ShortSubject, attr: { title: Subject }\"></td>\n<td data-bind=\"text: ExpirationDisplay, attr: {\ntitle: IsExpired ? 'This certificate\\'s expiration date is in the past. Future packages signed with this certificate will fail validation. Upload a renewed certificate to enable signed package uploads.' : ExpirationIso,\n</tr>\n</tbody>\n</table>\n+\n+ <p>\n+ The SHA-256 fingerprint can be found by calculating the SHA-256 hash of the DER encoded\n+ certificate file (.cer). The fingerprint should be hex-encoded. This can be done with a variety\n+ of tools.\n+ </p>\n+ <p>\n+ <b>PowerShell:</b> <samp>Get-FileHash -Algorithm SHA256 .\\my-public-certificate.cer</samp>\n+ <br />\n+ <b>nuget.exe:</b> <samp>nuget.exe verify -Signatures .\\my-signed-package.1.0.0.nupkg</samp>\n+ </p>\n</div>\n</div>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/OrganizationsControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/OrganizationsControllerFacts.cs",
"diff": "@@ -1816,7 +1816,6 @@ public TheGetCertificateAction()\n_certificate = new Certificate()\n{\nKey = 3,\n- Sha1Thumbprint = \"c\",\nThumbprint = \"d\"\n};\n@@ -1936,7 +1935,7 @@ public void GetCertificate_WhenOrganizationHasCertificate_ReturnsOK(bool multiFa\nAssert.True(viewModel.CanDelete);\nAssert.Equal($\"/organization/{_organization.Username}/certificates/{_certificate.Thumbprint}\", viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -1960,7 +1959,7 @@ public void GetCertificate_WhenOrganizationHasCertificateAndCurrentUserIsOrganiz\nAssert.False(viewModel.CanDelete);\nAssert.Null(viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -1995,7 +1994,6 @@ public TheGetCertificatesAction()\n_certificate = new Certificate()\n{\nKey = 3,\n- Sha1Thumbprint = \"c\",\nThumbprint = \"d\"\n};\n@@ -2102,7 +2100,7 @@ public void GetCertificates_WhenOrganizationHasCertificate_ForAllValidClaims_Ret\nAssert.True(viewModel.CanDelete);\nAssert.Equal($\"/organization/{_organization.Username}/certificates/{_certificate.Thumbprint}\", viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -2126,7 +2124,7 @@ public void GetCertificates_WhenOrganizationHasCertificateAndCurrentUserIsOrgani\nAssert.False(viewModel.CanDelete);\nAssert.Null(viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -2165,7 +2163,6 @@ public TheAddCertificateAction()\n_certificate = new Certificate()\n{\nKey = 3,\n- Sha1Thumbprint = \"c\",\nThumbprint = \"d\"\n};\n@@ -2354,7 +2351,6 @@ public TheDeleteCertificateAction()\n_certificate = new Certificate()\n{\nKey = 3,\n- Sha1Thumbprint = \"c\",\nThumbprint = \"d\"\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/UsersControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/UsersControllerFacts.cs",
"diff": "@@ -3292,7 +3292,6 @@ public TheGetCertificateAction()\n_certificate = new Certificate()\n{\nKey = 2,\n- Sha1Thumbprint = \"b\",\nThumbprint = \"c\"\n};\n}\n@@ -3354,7 +3353,7 @@ public void GetCertificate_WhenCurrentUserHasCertificate_ReturnsOK()\nAssert.True(viewModel.CanDelete);\nAssert.Equal($\"/account/certificates/{_certificate.Thumbprint}\", viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -3381,7 +3380,6 @@ public TheGetCertificatesAction()\n_certificate = new Certificate()\n{\nKey = 2,\n- Sha1Thumbprint = \"b\",\nThumbprint = \"c\"\n};\n}\n@@ -3430,7 +3428,7 @@ public void GetCertificates_WhenCurrentUserHasCertificate_ReturnsOK()\nAssert.True(viewModel.CanDelete);\nAssert.Equal($\"/account/certificates/{_certificate.Thumbprint}\", viewModel.DeleteUrl);\n- Assert.Equal(_certificate.Sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(_certificate.Thumbprint, viewModel.Thumbprint);\nAssert.Equal(JsonRequestBehavior.AllowGet, response.JsonRequestBehavior);\nAssert.Equal((int)HttpStatusCode.OK, _controller.Response.StatusCode);\n@@ -3461,7 +3459,6 @@ public TheAddCertificateAction()\n_certificate = new Certificate()\n{\nKey = 2,\n- Sha1Thumbprint = \"b\",\nThumbprint = \"c\"\n};\n}\n@@ -3589,7 +3586,6 @@ public TheDeleteCertificateAction()\n_certificate = new Certificate()\n{\nKey = 2,\n- Sha1Thumbprint = \"b\",\nThumbprint = \"c\"\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/CertificateServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/CertificateServiceFacts.cs",
"diff": "@@ -51,7 +51,9 @@ public CertificateServiceFacts()\n_certificate = new Certificate()\n{\nKey = 1,\n+#pragma warning disable CS0618 // Set the value for minimal testing.\nSha1Thumbprint = _sha1Thumbprint,\n+#pragma warning restore CS0618\nThumbprint = _sha256Thumbprint,\nUserCertificates = new List<UserCertificate>()\n};\n@@ -202,9 +204,7 @@ public async Task AddCertificateAsync_WhenCertificateDoesNotAlreadyExistInEntiti\n.Returns(new EnumerableQuery<Certificate>(Array.Empty<Certificate>()));\n_certificateRepository.Setup(\nx => x.InsertOnCommit(\n- It.Is<Certificate>(certificate =>\n- certificate.Sha1Thumbprint == _sha1Thumbprint &&\n- certificate.Thumbprint == _sha256Thumbprint)));\n+ It.Is<Certificate>(certificate => certificate.Thumbprint == _sha256Thumbprint)));\n_certificateRepository.Setup(x => x.CommitChangesAsync())\n.Returns(Task.CompletedTask);\n_fileStorageService.Setup(\n@@ -231,7 +231,9 @@ public async Task AddCertificateAsync_WhenCertificateDoesNotAlreadyExistInEntiti\nvar certificate = await service.AddCertificateAsync(file);\nAssert.NotNull(certificate);\n+#pragma warning disable CS0618 // Assert the value is set properly, but we will never read it.\nAssert.Equal(_sha1Thumbprint, certificate.Sha1Thumbprint);\n+#pragma warning restore CS0618\nAssert.Equal(_sha256Thumbprint, certificate.Thumbprint);\n}\n@@ -255,7 +257,6 @@ public async Task AddCertificateAsync_WhenCertificateAlreadyExistsInEntitiesCont\nAssert.NotNull(certificate);\nAssert.Equal(1, certificate.Key);\n- Assert.Equal(_sha1Thumbprint, certificate.Sha1Thumbprint);\nAssert.Equal(_sha256Thumbprint, certificate.Thumbprint);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/ViewModels/ListCertificateItemViewModelFacts.cs",
"new_path": "tests/NuGetGallery.Facts/ViewModels/ListCertificateItemViewModelFacts.cs",
"diff": "@@ -22,12 +22,12 @@ public void Constructor_WhenCertificateIsNull_Throws()\n[InlineData(\"a\", \"b\")]\n[InlineData(\"c\", null)]\n[InlineData(\"d\", \"\")]\n- public void Constructor_InitializesProperties(string sha1Thumbprint, string deleteUrl)\n+ public void Constructor_InitializesProperties(string thumbprint, string deleteUrl)\n{\n- var certificate = new Certificate() { Sha1Thumbprint = sha1Thumbprint };\n+ var certificate = new Certificate() { Thumbprint = thumbprint };\nvar viewModel = new ListCertificateItemViewModel(certificate, deleteUrl);\n- Assert.Equal(sha1Thumbprint, viewModel.Sha1Thumbprint);\n+ Assert.Equal(thumbprint, viewModel.Thumbprint);\nAssert.Equal(deleteUrl, viewModel.DeleteUrl);\nAssert.Equal(!string.IsNullOrEmpty(deleteUrl), viewModel.CanDelete);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/ViewModels/ListPackageItemViewModelFacts.cs",
"new_path": "tests/NuGetGallery.Facts/ViewModels/ListPackageItemViewModelFacts.cs",
"diff": "@@ -253,7 +253,6 @@ public SignerInformation()\n{\nKey = 4,\nThumbprint = \"D\",\n- Sha1Thumbprint = \"E\"\n};\n_packageRegistration = new PackageRegistration()\n@@ -301,7 +300,7 @@ public void WhenPackageCertificateIsNotNullAndNoOwners_ReturnsString()\nviewModel.CanDisplayPrivateMetadata = true;\n- Assert.Equal(\"Signed with certificate (E)\", viewModel.SignatureInformation);\n+ Assert.Equal(\"Signed with certificate (D)\", viewModel.SignatureInformation);\n}\n[Fact]\n@@ -315,7 +314,7 @@ public void WhenPackageCertificateIsNotNullAndOneSigner_ReturnsString()\nvar viewModel = CreateListPackageItemViewModel(_package, _user1);\nAssert.True(viewModel.CanDisplayPrivateMetadata);\n- Assert.Equal(\"Signed with A's certificate (E)\", viewModel.SignatureInformation);\n+ Assert.Equal(\"Signed with A's certificate (D)\", viewModel.SignatureInformation);\n}\n[Fact]\n@@ -331,7 +330,7 @@ public void WhenPackageCertificateIsNotNullAndTwoSigners_ReturnsString()\nvar viewModel = CreateListPackageItemViewModel(_package, _user1);\nAssert.True(viewModel.CanDisplayPrivateMetadata);\n- Assert.Equal(\"Signed with A and B's certificate (E)\", viewModel.SignatureInformation);\n+ Assert.Equal(\"Signed with A and B's certificate (D)\", viewModel.SignatureInformation);\n}\n[Fact]\n@@ -349,7 +348,7 @@ public void WhenPackageCertificateIsNotNullAndThreeSigners_ReturnsString()\nvar viewModel = CreateListPackageItemViewModel(_package, _user1);\nAssert.True(viewModel.CanDisplayPrivateMetadata);\n- Assert.Equal(\"Signed with A, B, and C's certificate (E)\", viewModel.SignatureInformation);\n+ Assert.Equal(\"Signed with A, B, and C's certificate (D)\", viewModel.SignatureInformation);\n}\nprivate void ActivateCertificate(User user)\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Display SHA-256 instead of SHA-1 for user certificates (#7614)
Address https://github.com/NuGet/Engineering/issues/2758 |
455,776 | 11.10.2019 15:43:42 | 25,200 | 6a035d5bc11c70ef48dd97d15e6b6d6b8add43cd | Add nuget.org and nugettest.org to the HTTP URL rewrite list | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Extensions/UriExtensions.cs",
"new_path": "src/NuGetGallery.Services/Extensions/UriExtensions.cs",
"diff": "@@ -38,7 +38,11 @@ public static bool IsGitProtocol(this Uri uri)\npublic static bool IsDomainWithHttpsSupport(this Uri uri)\n{\n- return IsGitHubUri(uri) || IsGitHubPagerUri(uri) || IsCodeplexUri(uri) || IsMicrosoftUri(uri);\n+ return IsGitHubUri(uri) ||\n+ IsGitHubPagerUri(uri) ||\n+ IsCodeplexUri(uri) ||\n+ IsMicrosoftUri(uri) ||\n+ IsNuGetUri(uri);\n}\npublic static bool IsGitHubUri(this Uri uri)\n@@ -67,6 +71,12 @@ private static bool IsMicrosoftUri(this Uri uri)\nstring.Equals(uri.Authority, \"www.mono-project.com\", StringComparison.OrdinalIgnoreCase);\n}\n+ private static bool IsNuGetUri(this Uri uri)\n+ {\n+ return uri.IsInDomain(\"nuget.org\") ||\n+ uri.IsInDomain(\"nugettest.org\");\n+ }\n+\nprivate static bool IsInDomain(this Uri uri, string domain)\n{\nreturn uri.Authority.EndsWith(\".\" + domain, StringComparison.OrdinalIgnoreCase) ||\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Helpers/HtmlExtensionsFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Helpers/HtmlExtensionsFacts.cs",
"diff": "@@ -62,23 +62,25 @@ public void EncodesHtml()\n[Theory]\n[InlineData(\"My site is https://www.nuget.org.\", \"My site is <a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>.\")]\n[InlineData(\"My site is https://www.nuget.org!\", \"My site is <a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>!\")]\n- [InlineData(\"My site is http://www.nuget.org\", \"My site is <a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>\")]\n- [InlineData(\"My site is http://www.nuget.org/sub/path/\", \"My site is <a href=\\\"http://www.nuget.org/sub/path/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/sub/path/</a>\")]\n+ [InlineData(\"My site is http://www.nuget.org\", \"My site is <a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>\")]\n+ [InlineData(\"My site is http://www.nuget.org/sub/path/\", \"My site is <a href=\\\"https://www.nuget.org/sub/path/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/sub/path/</a>\")]\n[InlineData(\"My site is https://www.nuget.org/packages.\", \"My site is <a href=\\\"https://www.nuget.org/packages\\\" rel=\\\"nofollow\\\">https://www.nuget.org/packages</a>.\")]\n- [InlineData(\"My site is http://www.nuget.org/?foo&bar=2#a\", \"My site is <a href=\\\"http://www.nuget.org/?foo&bar=2#a\\\" rel=\\\"nofollow\\\">http://www.nuget.org/?foo&bar=2#a</a>\")]\n- [InlineData(\"My site is http://www.nuget.org/?foo[]=a\", \"My site is <a href=\\\"http://www.nuget.org/?foo\\\" rel=\\\"nofollow\\\">http://www.nuget.org/?foo</a>[]=a\")]\n+ [InlineData(\"My site is http://www.nuget.org/?foo&bar=2#a\", \"My site is <a href=\\\"https://www.nuget.org/?foo&bar=2#a\\\" rel=\\\"nofollow\\\">https://www.nuget.org/?foo&bar=2#a</a>\")]\n+ [InlineData(\"My site is http://www.nuget.org/?foo[]=a\", \"My site is <a href=\\\"https://www.nuget.org/?foo\\\" rel=\\\"nofollow\\\">https://www.nuget.org/?foo</a>[]=a\")]\n[InlineData(\"http://a.com http://b.com\", \"<a href=\\\"http://a.com/\\\" rel=\\\"nofollow\\\">http://a.com/</a> <a href=\\\"http://b.com/\\\" rel=\\\"nofollow\\\">http://b.com/</a>\")]\n- [InlineData(\"http://www.nuget.org/ is my site.\", \"<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a> is my site.\")]\n- [InlineData(\"\\\"http://www.nuget.org/\\\" is my site.\", \""<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>" is my site.\")]\n- [InlineData(\"\\'http://www.nuget.org/\\' is my site.\", \"'<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>' is my site.\")]\n- [InlineData(\"http://www.nuget.org, is my site.\", \"<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>, is my site.\")]\n- [InlineData(\"(http://www.nuget.org) is my site.\", \"(<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>) is my site.\")]\n- [InlineData(\"http://www.nuget.org; is my site.\", \"<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>; is my site.\")]\n- [InlineData(\"http://www.nuget.org- is my site.\", \"<a href=\\\"http://www.nuget.org/\\\" rel=\\\"nofollow\\\">http://www.nuget.org/</a>- is my site.\")]\n+ [InlineData(\"http://www.nuget.org/ is my site.\", \"<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a> is my site.\")]\n+ [InlineData(\"\\\"http://www.nuget.org/\\\" is my site.\", \""<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>" is my site.\")]\n+ [InlineData(\"\\'http://www.nuget.org/\\' is my site.\", \"'<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>' is my site.\")]\n+ [InlineData(\"http://www.nuget.org, is my site.\", \"<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>, is my site.\")]\n+ [InlineData(\"(http://www.nuget.org) is my site.\", \"(<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>) is my site.\")]\n+ [InlineData(\"http://www.nuget.org; is my site.\", \"<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>; is my site.\")]\n+ [InlineData(\"http://www.nuget.org- is my site.\", \"<a href=\\\"https://www.nuget.org/\\\" rel=\\\"nofollow\\\">https://www.nuget.org/</a>- is my site.\")]\n[InlineData(\"http://www.github.com/nuget is my site.\", \"<a href=\\\"https://www.github.com/nuget\\\" rel=\\\"nofollow\\\">https://www.github.com/nuget</a> is my site.\")]\n[InlineData(\"My site is http://www.asp.net best site ever!\", \"My site is <a href=\\\"https://www.asp.net/\\\" rel=\\\"nofollow\\\">https://www.asp.net/</a> best site ever!\")]\n[InlineData(\"My site is http:////github.com bad url\", \"My site is http:////github.com bad url\")]\n[InlineData(\"Im using github pages! http://mypage.github.com/stuff.\", \"Im using github pages! <a href=\\\"https://mypage.github.com/stuff\\\" rel=\\\"nofollow\\\">https://mypage.github.com/stuff</a>.\")]\n+ [InlineData(\"My site is https://www.nugettest.org!\", \"My site is <a href=\\\"https://www.nugettest.org/\\\" rel=\\\"nofollow\\\">https://www.nugettest.org/</a>!\")]\n+ [InlineData(\"My site is http://www.nugettest.org\", \"My site is <a href=\\\"https://www.nugettest.org/\\\" rel=\\\"nofollow\\\">https://www.nugettest.org/</a>\")]\npublic void ConvertsUrlsToLinks(string input, string expected)\n{\n// Arrange\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Helpers/PackageHelperTests.cs",
"new_path": "tests/NuGetGallery.Facts/Helpers/PackageHelperTests.cs",
"diff": "@@ -26,10 +26,14 @@ public void ShouldRenderUrlTests(string url, bool secureOnly, bool shouldRender)\n}\n[Theory]\n- [InlineData(\"http://nuget.org/\", false, \"http://nuget.org/\", true)]\n+ [InlineData(\"http://nuget.org/\", false, \"https://nuget.org/\", true)]\n[InlineData(\"http://nuget.org/\", true, \"https://nuget.org/\", true)]\n[InlineData(\"https://nuget.org/\", false, \"https://nuget.org/\", true)]\n[InlineData(\"https://nuget.org/\", true, \"https://nuget.org/\", true)]\n+ [InlineData(\"http://nugettest.org/\", false, \"https://nugettest.org/\", true)]\n+ [InlineData(\"http://nugettest.org/\", true, \"https://nugettest.org/\", true)]\n+ [InlineData(\"https://nugettest.org/\", false, \"https://nugettest.org/\", true)]\n+ [InlineData(\"https://nugettest.org/\", true, \"https://nugettest.org/\", true)]\n[InlineData(\"http://www.github.com/\", false, \"https://www.github.com/\", true)]\n[InlineData(\"http://www.github.com/\", true, \"https://www.github.com/\", true)]\n[InlineData(\"https://www.github.com/\", false, \"https://www.github.com/\", true)]\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add nuget.org and nugettest.org to the HTTP URL rewrite list (#7624) |
455,759 | 02.10.2019 15:12:07 | -7,200 | e39061bd73dbb945d609ab5c4076d14f3e4b2613 | Add heartbeats support | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n- <PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.1.0-master-2602271</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.55.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.55.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.55.0</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.ServiceBus\">\n- <Version>2.55.0</Version>\n- </PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.1.0-dev-2759568</Version>\n+ <Version>4.2.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<Version>1.1.2</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.1.0-master-2758883</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.55.0</Version>\n+ <Version>4.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.1.0-master-2602271</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.55.0</Version>\n+ <Version>4.2.0</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "<EmbeddedResource Include=\"Infrastructure\\MigrateUserToOrganization.sql\" />\n</ItemGroup>\n<ItemGroup>\n- <PackageReference Include=\"NuGet.Services.Entities\">\n- <Version>2.55.0</Version>\n- </PackageReference>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"diff": "@@ -193,6 +193,11 @@ public class AppConfiguration : IAppConfiguration\n/// </summary>\npublic double AppInsightsSamplingPercentage { get; set; }\n+ /// <summary>\n+ /// Gets the Application Insights heartbeat interval in seconds associated with this deployment.\n+ /// </summary>\n+ public int AppInsightsHeartbeatIntervalSeconds { get; set; }\n+\n/// <summary>\n/// Gets the protocol-independent site root\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"diff": "@@ -205,6 +205,11 @@ public interface IAppConfiguration : IMessageServiceConfiguration\n/// </summary>\ndouble AppInsightsSamplingPercentage { get; set; }\n+ /// <summary>\n+ /// Gets the Application Insights heartbeat interval in seconds associated with this deployment.\n+ /// </summary>\n+ int AppInsightsHeartbeatIntervalSeconds { get; set; }\n+\n/// <summary>\n/// Gets the protocol-independent site root\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using Autofac.Core;\nusing Autofac.Extensions.DependencyInjection;\nusing Elmah;\n-using Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Http;\nusing Microsoft.Extensions.Logging;\n@@ -98,7 +97,20 @@ protected override void Load(ContainerBuilder builder)\nvar instrumentationKey = configuration.Current.AppInsightsInstrumentationKey;\nif (!string.IsNullOrEmpty(instrumentationKey))\n{\n- TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey;\n+ var heartbeatIntervalSeconds = configuration.Current.AppInsightsHeartbeatIntervalSeconds;\n+\n+ if (heartbeatIntervalSeconds > 0)\n+ {\n+ // Configure instrumentation key, heartbeat interval,\n+ // and register NuGet.Services.Logging.TelemetryContextInitializer.\n+ ApplicationInsights.Initialize(instrumentationKey, TimeSpan.FromSeconds(heartbeatIntervalSeconds));\n+ }\n+ else\n+ {\n+ // Configure instrumentation key,\n+ // and register NuGet.Services.Logging.TelemetryContextInitializer.\n+ ApplicationInsights.Initialize(instrumentationKey);\n+ }\n}\nvar loggerConfiguration = LoggingSetup.CreateDefaultLoggerConfiguration(withConsoleLogger: false);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"new_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"diff": "@@ -79,7 +79,20 @@ public static void Configuration(IAppBuilder app)\nvar instrumentationKey = config.Current.AppInsightsInstrumentationKey;\nif (!string.IsNullOrEmpty(instrumentationKey))\n{\n- TelemetryConfiguration.Active.InstrumentationKey = instrumentationKey;\n+ var heartbeatIntervalSeconds = config.Current.AppInsightsHeartbeatIntervalSeconds;\n+\n+ if (heartbeatIntervalSeconds > 0)\n+ {\n+ // Configure instrumentation key, heartbeat interval,\n+ // and register NuGet.Services.Logging.TelemetryContextInitializer.\n+ ApplicationInsights.Initialize(instrumentationKey, TimeSpan.FromSeconds(heartbeatIntervalSeconds));\n+ }\n+ else\n+ {\n+ // Configure instrumentation key,\n+ // and register NuGet.Services.Logging.TelemetryContextInitializer.\n+ ApplicationInsights.Initialize(instrumentationKey);\n+ }\n// Add enrichers\nTelemetryConfiguration.Active.TelemetryInitializers.Add(new DeploymentIdTelemetryEnricher());\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.55.0</Version>\n+ <Version>2.57.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<add key=\"Gallery.AppInsightsInstrumentationKey\" value=\"\"/>\n<!-- Set this if you have a Application Insights instrumentation key to use for your gallery deployment and want to apply sampling -->\n<add key=\"Gallery.AppInsightsSamplingPercentage\" value=\"100\"/>\n+ <!-- Set this if you have a Application Insights instrumentation key to use for your gallery deployment and want to configure heartbeat interval -->\n+ <add key=\"Gallery.AppInsightsHeartbeatIntervalSeconds\" value=\"60\"/>\n<!-- Set this if you have a Facebook App ID you want to use for the Like button -->\n<add key=\"Gallery.GoogleAnalyticsPropertyId\" value=\"\"/>\n<!-- Set this if you have a Google Analytics property for the site -->\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add heartbeats support |
455,737 | 21.10.2019 13:10:30 | 25,200 | 279a68b4e6f7b6adb30f6561f05553153f0da9ee | Update to real jobs.common packages | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-ryuyu-update-extensions-3142787</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-ryuyu-update-extensions-3142787</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n<Version>2.58.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-ryuyu-update-extensions-3142787</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Configuration\">\n<Version>2.58.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Update to real jobs.common packages (#7636) |
455,736 | 21.10.2019 09:40:33 | 25,200 | b83e497a96278ee508f6a8b9078a35b9f5a3c344 | Add better messaging when SxS page is disabled
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/ExperimentsController.cs",
"new_path": "src/NuGetGallery/Controllers/ExperimentsController.cs",
"diff": "@@ -27,7 +27,7 @@ public async Task<ActionResult> SearchSideBySide(string q = null)\nvar currentUser = GetCurrentUser();\nif (!_featureFlagService.IsSearchSideBySideEnabled(currentUser))\n{\n- return new HttpNotFoundResult();\n+ return View(new SearchSideBySideViewModel { IsDisabled = true });\n}\nvar viewModel = await _searchSideBySideService.SearchAsync(q, currentUser);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/SearchSideBySideViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/SearchSideBySideViewModel.cs",
"diff": "@@ -15,6 +15,8 @@ public class SearchSideBySideViewModel\npublic const string CommentsLabel = \"Comments:\";\npublic const string EmailLabel = \"Email (optional, provide only if you want us to be able to follow up):\";\n+ public bool IsDisabled { get; set; }\n+\npublic string SearchTerm { get; set; } = string.Empty;\npublic bool OldSuccess { get; set; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Experiments/SearchSideBySide.cshtml",
"new_path": "src/NuGetGallery/Views/Experiments/SearchSideBySide.cshtml",
"diff": "<section role=\"main\" class=\"main-container page-search-sxs\">\n<div class=\"container\">\n+ @if (Model.IsDisabled)\n+ {\n+ <div class=\"row\">\n+ <div class=\"col-xs-offset-3 col-xs-6 text-center\">\n+ @ViewHelpers.AlertWarning(\n+ @<text>\n+ The side-by-side search page is now <b>closed</b>.\n+ <br /><br />\n+ Thank you for trying out the side-by-side preview. The new and improved NuGet search\n+ is now <a href=\"@Url.PackageList()\">live</a>! For details about the initial release, check out the\n+ <a href=\"https://devblogs.microsoft.com/nuget/new-and-improved-nuget-search/\">blog post</a>.\n+ The old search results are no longer available.\n+ <br /><br />\n+ Keep an eye on <a href=\"https://twitter.com/nuget\">Twitter</a> to hear about future search\n+ improvements that you can try out.\n+ </text>)\n+ </div>\n+ </div>\n+ }\n+ else\n+ {\n<div class=\"row\">\n<div class=\"col-xs-12\">\n<h1>Step 1: enter a search query</h1>\n</div>\n</div>\n- @if (!string.IsNullOrWhiteSpace(Model.SearchTerm))\n+ if (!string.IsNullOrWhiteSpace(Model.SearchTerm))\n{\n<div class=\"row\">\n<div class=\"col-xs-12\">\[email protected](@<text>Some of the search results could not be loaded. Please try again later.</text>)\n}\n}\n+ }\n</div>\n</section>\n@section bottomScripts {\[email protected](this)\n+ @if (!Model.IsDisabled)\n+ {\n<script type=\"text/javascript\">\n@if (!string.IsNullOrWhiteSpace(Model.SearchTerm))\n{\n})\n</script>\n}\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ExperimentsControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ExperimentsControllerFacts.cs",
"diff": "@@ -32,13 +32,18 @@ public async Task CallsDependencies()\n[Fact]\npublic async Task ReturnsViewResult()\n{\n+ SearchSideBySideService\n+ .Setup(x => x.SearchAsync(It.IsAny<string>(), It.IsAny<User>()))\n+ .ReturnsAsync(() => ViewModel);\n+\nvar result = await Target.SearchSideBySide(SearchTerm);\n- Assert.IsType<ViewResult>(result);\n+ var model = ResultAssert.IsView<SearchSideBySideViewModel>(result);\n+ Assert.Same(ViewModel, model);\n}\n[Fact]\n- public async Task ReturnsNotFoundWhenFeatureFlagIsDisabled()\n+ public async Task ReturnsIsDisabledWhenFeatureFlagIsDisabled()\n{\nFeatureFlagService\n.Setup(x => x.IsSearchSideBySideEnabled(It.IsAny<User>()))\n@@ -46,7 +51,8 @@ public async Task ReturnsNotFoundWhenFeatureFlagIsDisabled()\nvar result = await Target.SearchSideBySide(SearchTerm);\n- Assert.IsType<HttpNotFoundResult>(result);\n+ var model = ResultAssert.IsView<SearchSideBySideViewModel>(result);\n+ Assert.True(model.IsDisabled);\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add better messaging when SxS page is disabled (#7639)
Address https://github.com/NuGet/NuGetGallery/issues/7638 |
455,747 | 28.10.2019 17:06:28 | 25,200 | 02795c60dca8d450234e6aaa29519f57e3861cc4 | [MSA] Audit the external credential for attempted login in Gallery | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Auditing/AuditedUserAction.cs",
"new_path": "src/NuGetGallery.Core/Auditing/AuditedUserAction.cs",
"diff": "@@ -23,6 +23,7 @@ public enum AuditedUserAction\nRemoveOrganizationMember,\nUpdateOrganizationMember,\nEnabledMultiFactorAuthentication,\n- DisabledMultiFactorAuthentication\n+ DisabledMultiFactorAuthentication,\n+ ExternalLoginAttempt,\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Auditing/CredentialAuditRecord.cs",
"new_path": "src/NuGetGallery.Core/Auditing/CredentialAuditRecord.cs",
"diff": "@@ -18,6 +18,7 @@ public class CredentialAuditRecord\npublic DateTime Created { get; }\npublic DateTime? Expires { get; }\npublic DateTime? LastUsed { get; }\n+ public string TenantId { get; }\npublic CredentialAuditRecord(Credential credential, bool removed)\n{\n@@ -30,9 +31,14 @@ public CredentialAuditRecord(Credential credential, bool removed)\nType = credential.Type;\nDescription = credential.Description;\nIdentity = credential.Identity;\n+ TenantId = credential.TenantId;\n- // Track the value for credentials that are definitely revocable (API Key, etc.) and have been removed\n- if (removed)\n+ // Track the value for credentials that are external (object id) or definitely revocable (API Key, etc.) and have been removed\n+ if (credential.IsExternal())\n+ {\n+ Value = credential.Value;\n+ }\n+ else if (removed)\n{\nif (Type == null)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Authentication/AuthenticationService.cs",
"new_path": "src/NuGetGallery.Services/Authentication/AuthenticationService.cs",
"diff": "@@ -675,6 +675,12 @@ public virtual async Task<AuthenticateExternalLoginResult> AuthenticateExternalL\n// Authenticate!\nif (result.Credential != null)\n{\n+ // We want to audit the received credential from external authentication. We use the UserAuditRecord\n+ // for easier logging, since it actually needs a `User`, instead we use a dummy user because at this point\n+ // we do not have the actual user context since this request has not yet been authenticated.\n+ await Auditing.SaveAuditRecordAsync(new UserAuditRecord(\n+ new User(\"NonExistentDummyAuditUser\"), AuditedUserAction.ExternalLoginAttempt, result.Credential));\n+\nresult.Authentication = await Authenticate(result.Credential);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Auditing/AuditedUserActionTests.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Auditing/AuditedUserActionTests.cs",
"diff": "@@ -30,7 +30,8 @@ public void Definition_HasNotChanged()\n\"RemoveOrganizationMember\",\n\"UpdateOrganizationMember\",\n\"EnabledMultiFactorAuthentication\",\n- \"DisabledMultiFactorAuthentication\"\n+ \"DisabledMultiFactorAuthentication\",\n+ \"ExternalLoginAttempt\"\n};\nVerify(typeof(AuditedUserAction), expectedNames);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Auditing/CredentialAuditRecordTests.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Auditing/CredentialAuditRecordTests.cs",
"diff": "@@ -51,6 +51,17 @@ public void Constructor_NonRemovalOfNonPasswordDoesNotSetsValue()\nAssert.Null(record.Value);\n}\n+ [Theory]\n+ [InlineData(CredentialTypes.External.MicrosoftAccount)]\n+ [InlineData(CredentialTypes.External.AzureActiveDirectoryAccount)]\n+ public void Constructor_ExternalCredentialSetsValue(string externalType)\n+ {\n+ var credential = new Credential(type: externalType, value: \"b\");\n+ var record = new CredentialAuditRecord(credential, removed: false);\n+\n+ Assert.Equal(\"b\", record.Value);\n+ }\n+\n[Fact]\npublic void Constructor_NonRemovalOfPasswordDoesNotSetValue()\n{\n@@ -72,6 +83,7 @@ public void Constructor_SetsProperties()\nDescription = \"a\",\nExpires = expires,\nIdentity = \"b\",\n+ TenantId = \"c\",\nKey = 1,\nLastUsed = lastUsed,\nScopes = new List<Scope>() { new Scope(subject: \"c\", allowedAction: \"d\") },\n@@ -84,6 +96,7 @@ public void Constructor_SetsProperties()\nAssert.Equal(\"a\", record.Description);\nAssert.Equal(expires, record.Expires);\nAssert.Equal(\"b\", record.Identity);\n+ Assert.Equal(\"c\", record.TenantId);\nAssert.Equal(1, record.Key);\nAssert.Equal(lastUsed, record.LastUsed);\nAssert.Single(record.Scopes);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [MSA] Audit the external credential for attempted login in Gallery (#7645) |
455,776 | 31.10.2019 09:30:07 | 25,200 | 13fd9d31bc96767df1ef3bbd710148883e84383d | Add vulnerabilities entities | [
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/Constants.cs",
"new_path": "src/NuGet.Services.Entities/Constants.cs",
"diff": "@@ -7,5 +7,6 @@ public static class Constants\n{\npublic const string AdminRoleName = \"Admins\";\npublic const int MaxPackageIdLength = 128;\n+ public const int MaxPackageVersionLength = 64;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"new_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"diff": "<Compile Include=\"PackageRegistration.cs\" />\n<Compile Include=\"PackageStatus.cs\" />\n<Compile Include=\"PackageType.cs\" />\n+ <Compile Include=\"PackageVulnerability.cs\" />\n+ <Compile Include=\"PackageVulnerabilitySeverity.cs\" />\n<Compile Include=\"Properties\\AssemblyInfo.cs\" />\n<Compile Include=\"ReservedNamespace.cs\" />\n<Compile Include=\"Role.cs\" />\n<Compile Include=\"User.cs\" />\n<Compile Include=\"UserCertificate.cs\" />\n<Compile Include=\"UserSecurityPolicy.cs\" />\n+ <Compile Include=\"VulnerablePackageVersionRange.cs\" />\n</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"EntityFramework\">\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/Package.cs",
"new_path": "src/NuGet.Services.Entities/Package.cs",
"diff": "@@ -24,6 +24,7 @@ public Package()\nSymbolPackages = new HashSet<SymbolPackage>();\nDeprecations = new HashSet<PackageDeprecation>();\nAlternativeOf = new HashSet<PackageDeprecation>();\n+ Vulnerabilities = new HashSet<VulnerablePackageVersionRange>();\nListed = true;\n}\n#pragma warning restore 618\n@@ -175,7 +176,7 @@ public bool HasReadMe\n/// <summary>\n/// Gets or sets the version listed in the manifest for this package, which MAY NOT conform to NuGet's use of SemVer\n/// </summary>\n- [StringLength(64)]\n+ [StringLength(Constants.MaxPackageVersionLength)]\n[Required]\npublic string Version { get; set; }\n@@ -275,6 +276,11 @@ public bool HasReadMe\n/// </summary>\npublic virtual ICollection<PackageDeprecation> AlternativeOf { get; set; }\n+ /// <summary>\n+ /// Gets or sets the list of vulnerabilites that this package has.\n+ /// </summary>\n+ public ICollection<VulnerablePackageVersionRange> Vulnerabilities { get; set; }\n+\n/// <summary>\n/// A flag that indicates that the package metadata had an embedded icon specified.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"diff": "@@ -67,6 +67,8 @@ public EntitiesContext(DbConnection connection, bool readOnly)\npublic DbSet<Certificate> Certificates { get; set; }\npublic DbSet<UserCertificate> UserCertificates { get; set; }\npublic DbSet<SymbolPackage> SymbolPackages { get; set; }\n+ public DbSet<PackageVulnerability> Vulnerabilities { get; set; }\n+ public DbSet<VulnerablePackageVersionRange> VulnerableRanges { get; set; }\n/// <summary>\n/// User or organization accounts.\n@@ -449,6 +451,25 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)\n.WithMany()\n.HasForeignKey(d => d.DeprecatedByUserKey)\n.WillCascadeOnDelete(false);\n+\n+ modelBuilder.Entity<PackageVulnerability>()\n+ .HasKey(v => v.Key)\n+ .HasMany(v => v.AffectedRanges)\n+ .WithRequired(pv => pv.Vulnerability)\n+ .HasForeignKey(pv => pv.VulnerabilityKey);\n+\n+ modelBuilder.Entity<PackageVulnerability>()\n+ .HasIndex(v => v.GitHubDatabaseKey)\n+ .IsUnique();\n+\n+ modelBuilder.Entity<VulnerablePackageVersionRange>()\n+ .HasKey(pv => pv.Key)\n+ .HasMany(pv => pv.Packages)\n+ .WithMany(p => p.Vulnerabilities);\n+\n+ modelBuilder.Entity<VulnerablePackageVersionRange>()\n+ .HasIndex(pv => new { pv.VulnerabilityKey, pv.PackageId, pv.PackageVersionRange })\n+ .IsUnique();\n}\n#pragma warning restore 618\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/IEntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/IEntitiesContext.cs",
"diff": "@@ -19,6 +19,8 @@ public interface IEntitiesContext : IReadOnlyEntitiesContext\nDbSet<ReservedNamespace> ReservedNamespaces { get; set; }\nDbSet<UserCertificate> UserCertificates { get; set; }\nDbSet<SymbolPackage> SymbolPackages { get; set; }\n+ DbSet<PackageVulnerability> Vulnerabilities { get; set; }\n+ DbSet<VulnerablePackageVersionRange> VulnerableRanges { get; set; }\nTask<int> SaveChangesAsync();\nvoid DeleteOnCommit<T>(T entity) where T : class;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/NuGetGallery/Migrations/201910291956170_AddPackageVulnerabilities.Designer.cs",
"diff": "+// <auto-generated />\n+namespace NuGetGallery.Migrations\n+{\n+ using System.CodeDom.Compiler;\n+ using System.Data.Entity.Migrations;\n+ using System.Data.Entity.Migrations.Infrastructure;\n+ using System.Resources;\n+\n+ [GeneratedCode(\"EntityFramework.Migrations\", \"6.2.0-61023\")]\n+ public sealed partial class AddPackageVulnerabilities : IMigrationMetadata\n+ {\n+ private readonly ResourceManager Resources = new ResourceManager(typeof(AddPackageVulnerabilities));\n+\n+ string IMigrationMetadata.Id\n+ {\n+ get { return \"201910291956170_AddPackageVulnerabilities\"; }\n+ }\n+\n+ string IMigrationMetadata.Source\n+ {\n+ get { return null; }\n+ }\n+\n+ string IMigrationMetadata.Target\n+ {\n+ get { return Resources.GetString(\"Target\"); }\n+ }\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/NuGetGallery/Migrations/201910291956170_AddPackageVulnerabilities.cs",
"diff": "+namespace NuGetGallery.Migrations\n+{\n+ using System;\n+ using System.Data.Entity.Migrations;\n+\n+ public partial class AddPackageVulnerabilities : DbMigration\n+ {\n+ public override void Up()\n+ {\n+ CreateTable(\n+ \"dbo.VulnerablePackageVersionRanges\",\n+ c => new\n+ {\n+ Key = c.Int(nullable: false, identity: true),\n+ VulnerabilityKey = c.Int(nullable: false),\n+ PackageId = c.String(nullable: false, maxLength: 128),\n+ PackageVersionRange = c.String(nullable: false, maxLength: 132),\n+ })\n+ .PrimaryKey(t => t.Key)\n+ .ForeignKey(\"dbo.PackageVulnerabilities\", t => t.VulnerabilityKey, cascadeDelete: true)\n+ .Index(t => new { t.VulnerabilityKey, t.PackageId, t.PackageVersionRange }, unique: true);\n+\n+ CreateTable(\n+ \"dbo.PackageVulnerabilities\",\n+ c => new\n+ {\n+ Key = c.Int(nullable: false, identity: true),\n+ GitHubDatabaseKey = c.Int(nullable: false),\n+ ReferenceUrl = c.String(),\n+ Severity = c.Int(nullable: false),\n+ })\n+ .PrimaryKey(t => t.Key)\n+ .Index(t => t.GitHubDatabaseKey, unique: true);\n+\n+ CreateTable(\n+ \"dbo.VulnerablePackageVersionRangePackages\",\n+ c => new\n+ {\n+ VulnerablePackageVersionRange_Key = c.Int(nullable: false),\n+ Package_Key = c.Int(nullable: false),\n+ })\n+ .PrimaryKey(t => new { t.VulnerablePackageVersionRange_Key, t.Package_Key })\n+ .ForeignKey(\"dbo.VulnerablePackageVersionRanges\", t => t.VulnerablePackageVersionRange_Key, cascadeDelete: true)\n+ .ForeignKey(\"dbo.Packages\", t => t.Package_Key, cascadeDelete: true)\n+ .Index(t => t.VulnerablePackageVersionRange_Key)\n+ .Index(t => t.Package_Key);\n+\n+ }\n+\n+ public override void Down()\n+ {\n+ DropForeignKey(\"dbo.VulnerablePackageVersionRanges\", \"VulnerabilityKey\", \"dbo.PackageVulnerabilities\");\n+ DropForeignKey(\"dbo.VulnerablePackageVersionRangePackages\", \"Package_Key\", \"dbo.Packages\");\n+ DropForeignKey(\"dbo.VulnerablePackageVersionRangePackages\", \"VulnerablePackageVersionRange_Key\", \"dbo.VulnerablePackageVersionRanges\");\n+ DropIndex(\"dbo.VulnerablePackageVersionRangePackages\", new[] { \"Package_Key\" });\n+ DropIndex(\"dbo.VulnerablePackageVersionRangePackages\", new[] { \"VulnerablePackageVersionRange_Key\" });\n+ DropIndex(\"dbo.PackageVulnerabilities\", new[] { \"GitHubDatabaseKey\" });\n+ DropIndex(\"dbo.VulnerablePackageVersionRanges\", new[] { \"VulnerabilityKey\", \"PackageId\", \"PackageVersionRange\" });\n+ DropTable(\"dbo.VulnerablePackageVersionRangePackages\");\n+ DropTable(\"dbo.PackageVulnerabilities\");\n+ DropTable(\"dbo.VulnerablePackageVersionRanges\");\n+ }\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Migrations\\201906262145129_EmbeddedIconFlag.Designer.cs\">\n<DependentUpon>201906262145129_EmbeddedIconFlag.cs</DependentUpon>\n</Compile>\n+ <Compile Include=\"Migrations\\201910291956170_AddPackageVulnerabilities.cs\" />\n+ <Compile Include=\"Migrations\\201910291956170_AddPackageVulnerabilities.Designer.cs\">\n+ <DependentUpon>201910291956170_AddPackageVulnerabilities.cs</DependentUpon>\n+ </Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n<Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\GravatarProxyResult.cs\" />\n<EmbeddedResource Include=\"Migrations\\201906262145129_EmbeddedIconFlag.resx\">\n<DependentUpon>201906262145129_EmbeddedIconFlag.cs</DependentUpon>\n</EmbeddedResource>\n+ <EmbeddedResource Include=\"Migrations\\201910291956170_AddPackageVulnerabilities.resx\">\n+ <DependentUpon>201910291956170_AddPackageVulnerabilities.cs</DependentUpon>\n+ </EmbeddedResource>\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1packages.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1search.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv2getupdates.json\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/TestUtils/FakeEntitiesContext.cs",
"new_path": "tests/NuGetGallery.Facts/TestUtils/FakeEntitiesContext.cs",
"diff": "@@ -162,6 +162,30 @@ public DbSet<SymbolPackage> SymbolPackages\n}\n}\n+ public DbSet<PackageVulnerability> Vulnerabilities\n+ {\n+ get\n+ {\n+ return Set<PackageVulnerability>();\n+ }\n+ set\n+ {\n+ throw new NotSupportedException();\n+ }\n+ }\n+\n+ public DbSet<VulnerablePackageVersionRange> VulnerableRanges\n+ {\n+ get\n+ {\n+ return Set<VulnerablePackageVersionRange>();\n+ }\n+ set\n+ {\n+ throw new NotSupportedException();\n+ }\n+ }\n+\npublic Task<int> SaveChangesAsync()\n{\n_areChangesSaved = true;\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add vulnerabilities entities (#7660) |
455,776 | 31.10.2019 10:43:45 | 25,200 | c4752b82e50924bc9d8053c56ede0a58a4a3da97 | Add PackageVulnerabilityService | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Compile Include=\"PackageManagement\\IPackageOwnershipManagementService.cs\" />\n<Compile Include=\"PackageManagement\\IPackageService.cs\" />\n<Compile Include=\"PackageManagement\\IPackageUpdateService.cs\" />\n+ <Compile Include=\"PackageManagement\\IPackageVulnerabilityService.cs\" />\n<Compile Include=\"PackageManagement\\IReservedNamespaceService.cs\" />\n<Compile Include=\"PackageManagement\\PackageDeleteDecision.cs\" />\n<Compile Include=\"PackageManagement\\PackageHelper.cs\" />\n<Compile Include=\"PackageManagement\\PackageOwnerRequestService.cs\" />\n<Compile Include=\"PackageManagement\\PackageOwnershipManagementService.cs\" />\n<Compile Include=\"PackageManagement\\PackageService.cs\" />\n+ <Compile Include=\"PackageManagement\\PackageVulnerabilityService.cs\" />\n<Compile Include=\"PackageManagement\\ReservedNamespaceService.cs\" />\n<Compile Include=\"Permissions\\ActionRequiringAccountPermissions.cs\" />\n<Compile Include=\"Permissions\\ActionRequiringEntityPermissions.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/IPackageUpdateService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/IPackageUpdateService.cs",
"diff": "@@ -28,9 +28,6 @@ public interface IPackageUpdateService\n/// <summary>\n/// Marks the packages in <paramref name=\"packages\"/> as updated.\n/// </summary>\n- /// <param name=\"packages\">\n- /// The packages to mark as updated. All packages must have the same <see cref=\"PackageRegistration\"/>.\n- /// </param>\n/// <param name=\"updateIndex\">If true, <see cref=\"IIndexingService.UpdatePackage(Package)\"/> will be called.</param>\nTask UpdatePackagesAsync(IReadOnlyList<Package> packages, bool updateIndex = true);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageUpdateService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageUpdateService.cs",
"diff": "@@ -120,17 +120,16 @@ public async Task UpdatePackagesAsync(IReadOnlyList<Package> packages, bool upda\nthrow new ArgumentException(nameof(packages));\n}\n- if (packages.Select(p => p.PackageRegistrationKey).Distinct().Count() > 1)\n- {\n- throw new ArgumentException(\"All packages to update must have the same ID.\", nameof(packages));\n- }\n-\nawait UpdatePackagesInBulkAsync(packages.Select(p => p.Key).ToList());\nif (updateIndex)\n{\n- // The indexing service will find the latest version of the package to index--it doesn't matter what package we pass in.\n- _indexingService.UpdatePackage(packages.First());\n+ // The indexing service will find the latest version of a package to index--it doesn't matter what package we pass in.\n+ // We do, however, need to pass in a single package for each registration to ensure that each package is indexed.\n+ foreach (var package in packages.GroupBy(p => p.PackageRegistration).Select(g => g.First()))\n+ {\n+ _indexingService.UpdatePackage(package);\n+ }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"new_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"diff": "<Compile Include=\"Services\\IconUrlTemplateProcessorFacts.cs\" />\n<Compile Include=\"Services\\PackageDeprecationManagementServiceFacts.cs\" />\n<Compile Include=\"Services\\PackageDeprecationServiceFacts.cs\" />\n+ <Compile Include=\"Services\\PackageVulnerabilityServiceFacts.cs\" />\n<Compile Include=\"Services\\SearchSideBySideServiceFacts.cs\" />\n<Compile Include=\"Services\\PackageUpdateServiceFacts.cs\" />\n<Compile Include=\"Services\\StatusServiceFacts.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageUpdateServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageUpdateServiceFacts.cs",
"diff": "@@ -183,15 +183,14 @@ public async Task EmitsTelemetry()\npublic class TheUpdatePackagesAsyncMethod : TestContainer\n{\nprivate readonly Mock<IEntitiesContext> _mockEntitiesContext;\n- private readonly Mock<IPackageService> _mockPackageService;\nprivate readonly Mock<IDatabase> _mockDatabase;\n+ private readonly Mock<IIndexingService> _mockIndexingService;\npublic TheUpdatePackagesAsyncMethod()\n{\n- _mockEntitiesContext = GetMock<IEntitiesContext>();\n- _mockPackageService = GetMock<IPackageService>();\n-\n+ _mockIndexingService = GetMock<IIndexingService>();\n_mockDatabase = GetMock<IDatabase>();\n+ _mockEntitiesContext = GetMock<IEntitiesContext>();\n_mockEntitiesContext\n.Setup(x => x.GetDatabase())\n.Returns(_mockDatabase.Object)\n@@ -244,6 +243,20 @@ public async Task SuccessfullyUpdatesPackages(PackageLatestState latestState, bo\nawait SetupAndInvokeMethod(packages, true);\n_mockDatabase.Verify();\n+ _mockIndexingService.Verify();\n+ }\n+\n+ [Theory]\n+ [MemberData(nameof(PackageCombinations_Data))]\n+ public async Task SuccessfullyUpdatesPackagesWithMultipleRegistrations(PackageLatestState latestState, bool listed)\n+ {\n+ var firstPackages = GetPackagesForTest(latestState, listed, 0);\n+ var secondPackages = GetPackagesForTest(latestState, listed, 1);\n+ var allPackages = firstPackages.Concat(secondPackages).ToList();\n+ await SetupAndInvokeMethod(allPackages, true);\n+\n+ _mockDatabase.Verify();\n+ _mockIndexingService.Verify();\n}\nprivate Task SetupAndInvokeMethod(IReadOnlyList<Package> packages, bool sqlQuerySucceeds)\n@@ -268,15 +281,22 @@ private Task SetupAndInvokeMethod(IReadOnlyList<Package> packages, bool sqlQuery\n.Returns(Task.FromResult(sqlQuerySucceeds ? packages.Count() * 2 : 0))\n.Verifiable();\n+ foreach (var registration in packages.Select(p => p.PackageRegistration).Distinct())\n+ {\n+ _mockIndexingService\n+ .Setup(x => x.UpdatePackage(It.Is<Package>(p => p.PackageRegistration == registration)))\n+ .Verifiable();\n+ }\n+\nreturn Get<PackageUpdateService>()\n.UpdatePackagesAsync(packages);\n}\n- private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState, bool listed)\n+ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState, bool listed, int number = 0)\n{\nvar registration = new PackageRegistration\n{\n- Id = \"updatePackagesAsyncTest\"\n+ Id = \"updatePackagesAsyncTest\" + number\n};\nPackage unselectedPackage;\n@@ -284,7 +304,7 @@ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState\n{\nunselectedPackage = new Package\n{\n- Key = 1,\n+ Key = 1 + number * 100,\nVersion = \"3.0.0\",\nPackageRegistration = registration,\nIsLatest = true,\n@@ -298,7 +318,7 @@ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState\n{\nunselectedPackage = new Package\n{\n- Key = 1,\n+ Key = 1 + number * 100,\nVersion = \"1.0.0\",\nPackageRegistration = registration,\nIsLatest = false,\n@@ -313,7 +333,7 @@ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState\nvar selectedListedPackage = new Package\n{\n- Key = 2,\n+ Key = 2 + number * 100,\nVersion = \"2.0.0\",\nPackageRegistration = registration,\nListed = true\n@@ -323,7 +343,7 @@ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState\nvar selectedUnlistedPackage = new Package\n{\n- Key = 3,\n+ Key = 3 + number * 100,\nVersion = \"2.1.0\",\nPackageRegistration = registration,\nListed = false\n@@ -333,7 +353,7 @@ private IReadOnlyList<Package> GetPackagesForTest(PackageLatestState latestState\nvar selectedMaybeLatestPackage = new Package\n{\n- Key = 4,\n+ Key = 4 + number * 100,\nVersion = \"2.5.0\",\nPackageRegistration = registration,\nListed = listed\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add PackageVulnerabilityService (#7661) |
455,736 | 01.11.2019 14:22:02 | 25,200 | 7300656b7ef3953572687f4edce02fcccf34d57f | Add storage abstractions for list and snapshots | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "<Compile Include=\"NuGetVersionExtensions.cs\" />\n<Compile Include=\"SemVerLevelKey.cs\" />\n<Compile Include=\"Services\\AccessConditionWrapper.cs\" />\n+ <Compile Include=\"Services\\BlobResultSegmentWrapper.cs\" />\n<Compile Include=\"Services\\CloudBlobClientWrapper.cs\" />\n<Compile Include=\"Services\\CloudBlobContainerWrapper.cs\" />\n<Compile Include=\"Services\\CloudBlobCoreFileStorageService.cs\" />\n<Compile Include=\"Services\\ICloudBlobContainerInformationProvider.cs\" />\n<Compile Include=\"Services\\IContentFileMetadataService.cs\" />\n<Compile Include=\"Services\\ICoreLicenseFileService.cs\" />\n+ <Compile Include=\"Services\\ISimpleBlobResultSegment.cs\" />\n<Compile Include=\"Services\\IStringTemplateProcessor.cs\" />\n<Compile Include=\"Services\\PackageAlreadyExistsException.cs\" />\n<Compile Include=\"Services\\FileAlreadyExistsException.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Services/CloudBlobWrapper.cs",
"new_path": "src/NuGetGallery.Core/Services/CloudBlobWrapper.cs",
"diff": "using System.Net;\nusing System.Threading;\nusing System.Threading.Tasks;\n+using Markdig.Extensions.Tables;\nusing Microsoft.WindowsAzure.Storage;\nusing Microsoft.WindowsAzure.Storage.Blob;\nusing Microsoft.WindowsAzure.Storage.RetryPolicies;\n@@ -24,6 +25,7 @@ public class CloudBlobWrapper : ISimpleCloudBlob\npublic string Name => _blob.Name;\npublic DateTime LastModifiedUtc => _blob.Properties.LastModified?.UtcDateTime ?? DateTime.MinValue;\npublic string ETag => _blob.Properties.ETag;\n+ public bool IsSnapshot => _blob.IsSnapshot;\npublic CloudBlobWrapper(CloudBlockBlob blob)\n{\n@@ -94,6 +96,11 @@ public async Task<bool> ExistsAsync()\nreturn await _blob.ExistsAsync();\n}\n+ public async Task SnapshotAsync(CancellationToken token)\n+ {\n+ await _blob.SnapshotAsync(token);\n+ }\n+\npublic async Task SetPropertiesAsync()\n{\nawait _blob.SetPropertiesAsync();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Services/ISimpleCloudBlob.cs",
"new_path": "src/NuGetGallery.Core/Services/ISimpleCloudBlob.cs",
"diff": "@@ -20,6 +20,7 @@ public interface ISimpleCloudBlob\nstring Name { get; }\nDateTime LastModifiedUtc { get; }\nstring ETag { get; }\n+ bool IsSnapshot { get; }\nTask<Stream> OpenReadAsync(AccessCondition accessCondition);\nTask<Stream> OpenWriteAsync(AccessCondition accessCondition);\n@@ -64,5 +65,7 @@ public interface ISimpleCloudBlob\nTimeSpan serverTimeout,\nTimeSpan maxExecutionTime,\nCancellationToken cancellationToken);\n+\n+ Task SnapshotAsync(CancellationToken token);\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Services/CloudBlobCoreFileStorageServiceIntegrationTests.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Services/CloudBlobCoreFileStorageServiceIntegrationTests.cs",
"diff": "@@ -62,6 +62,91 @@ public CloudBlobCoreFileStorageServiceIntegrationTests(BlobStorageFixture fixtur\n_targetB = new CloudBlobCoreFileStorageService(_clientB, Mock.Of<IDiagnosticsService>(), folderInformationProvider);\n}\n+ [BlobStorageFact]\n+ public async Task EnumeratesBlobs()\n+ {\n+ // Arrange\n+ var folderName = CoreConstants.Folders.ValidationFolderName;\n+ var blobAName = $\"{_prefixA}/a.txt\";\n+ var blobBName = $\"{_prefixA}/b.txt\";\n+ var blobCName = $\"{_prefixA}/c.txt\";\n+ await _targetA.SaveFileAsync(folderName, blobAName, new MemoryStream(Encoding.UTF8.GetBytes(\"A\")));\n+ await _targetA.SaveFileAsync(folderName, blobCName, new MemoryStream(Encoding.UTF8.GetBytes(\"C\")));\n+ await _targetA.SaveFileAsync(folderName, blobBName, new MemoryStream(Encoding.UTF8.GetBytes(\"B\")));\n+\n+ var container = _clientA.GetContainerReference(folderName);\n+\n+ // Act\n+ var segmentA = await container.ListBlobsSegmentedAsync(\n+ _prefixA,\n+ useFlatBlobListing: true,\n+ blobListingDetails: BlobListingDetails.None,\n+ maxResults: 2,\n+ blobContinuationToken: null,\n+ options: null,\n+ operationContext: null,\n+ cancellationToken: CancellationToken.None);\n+ var segmentB = await container.ListBlobsSegmentedAsync(\n+ _prefixA,\n+ useFlatBlobListing: true,\n+ blobListingDetails: BlobListingDetails.None,\n+ maxResults: 2,\n+ blobContinuationToken: segmentA.ContinuationToken,\n+ options: null,\n+ operationContext: null,\n+ cancellationToken: CancellationToken.None);\n+\n+ // Assert\n+ Assert.Equal(2, segmentA.Results.Count);\n+ Assert.Equal(blobAName, segmentA.Results[0].Name);\n+ Assert.Equal(blobBName, segmentA.Results[1].Name);\n+ Assert.Equal(blobCName, Assert.Single(segmentB.Results).Name);\n+ }\n+\n+ [BlobStorageFact]\n+ public async Task EnumeratesSnapshots()\n+ {\n+ // Arrange\n+ var folderName = CoreConstants.Folders.ValidationFolderName;\n+ var blobAName = $\"{_prefixA}/a.txt\";\n+ var blobBName = $\"{_prefixA}/b.txt\";\n+ await _targetA.SaveFileAsync(folderName, blobAName, new MemoryStream(Encoding.UTF8.GetBytes(\"A\")));\n+ await _targetA.SaveFileAsync(folderName, blobBName, new MemoryStream(Encoding.UTF8.GetBytes(\"B\")));\n+\n+ var container = _clientA.GetContainerReference(folderName);\n+ var blobA = container.GetBlobReference(blobAName);\n+ await blobA.SnapshotAsync(CancellationToken.None);\n+\n+ // Act\n+ var segmentA = await container.ListBlobsSegmentedAsync(\n+ _prefixA,\n+ useFlatBlobListing: true,\n+ blobListingDetails: BlobListingDetails.Snapshots,\n+ maxResults: 2,\n+ blobContinuationToken: null,\n+ options: null,\n+ operationContext: null,\n+ cancellationToken: CancellationToken.None);\n+ var segmentB = await container.ListBlobsSegmentedAsync(\n+ _prefixA,\n+ useFlatBlobListing: true,\n+ blobListingDetails: BlobListingDetails.Snapshots,\n+ maxResults: 2,\n+ blobContinuationToken: segmentA.ContinuationToken,\n+ options: null,\n+ operationContext: null,\n+ cancellationToken: CancellationToken.None);\n+\n+ // Assert\n+ Assert.Equal(2, segmentA.Results.Count);\n+ Assert.Equal(blobAName, segmentA.Results[0].Name);\n+ Assert.True(segmentA.Results[0].IsSnapshot);\n+ Assert.Equal(blobAName, segmentA.Results[1].Name);\n+ Assert.False(segmentA.Results[1].IsSnapshot);\n+ Assert.Equal(blobBName, Assert.Single(segmentB.Results).Name);\n+ Assert.False(segmentB.Results[0].IsSnapshot);\n+ }\n+\n[BlobStorageFact]\npublic async Task AllowsDefaultRequestOptionsToBeSet()\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/TestUtils/BlobStorageFixture.cs",
"new_path": "tests/NuGetGallery.Core.Facts/TestUtils/BlobStorageFixture.cs",
"diff": "@@ -81,7 +81,7 @@ private void DeleteTestBlobs(string connectionString)\nforeach (var blob in blobs.OfType<CloudBlockBlob>())\n{\n- blob.DeleteIfExists();\n+ blob.DeleteIfExists(DeleteSnapshotsOption.IncludeSnapshots);\n}\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add storage abstractions for list and snapshots (#7670) |
455,776 | 04.11.2019 15:22:40 | 28,800 | d1f5ae0a8cf07754bfcf159c3e7cdb7f95f19d19 | Fix nuspec for GitHubVulnerabilities2Db | [
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.nuspec",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.nuspec",
"diff": "<copyright>Copyright .NET Foundation</copyright>\n</metadata>\n<files>\n- <file src=\"bin\\$configuration$\\*.*\" target=\"bin\"/>\n+ <file src=\"bin\\$configuration$\\**\\*.*\" target=\"bin\"/>\n<file src=\"Scripts\\Functions.ps1\" />\n<file src=\"Scripts\\PreDeploy.ps1\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix nuspec for GitHubVulnerabilities2Db (#7673) |
455,776 | 06.11.2019 11:12:23 | 28,800 | 08f8ecf2f76cffbdac4a1d581d5b2a1e9fa922d5 | Manage Package page forms should link back to the Manage page | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/ManageDeprecationJsonApiController.cs",
"new_path": "src/NuGetGallery/Controllers/ManageDeprecationJsonApiController.cs",
"diff": "@@ -53,6 +53,13 @@ public virtual JsonResult GetAlternatePackageVersions(string id)\nreturn Json(error.Status, new { error = error.Message });\n}\n+ var packagePluralString = request.Versions.Count() > 1 ? \"packages have\" : \"package has\";\n+ var deprecatedString = request.IsLegacy || request.HasCriticalBugs || request.IsOther\n+ ? \"deprecated\" : \"undeprecated\";\n+ TempData[\"Message\"] =\n+ $\"Your {packagePluralString} been {deprecatedString}. \" +\n+ $\"It may take several hours for this change to propagate through our system.\";\n+\nreturn Json(HttpStatusCode.OK);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -1905,8 +1905,39 @@ public virtual ActionResult Edit(string id, string version)\n[ValidateAntiForgeryToken]\npublic virtual async Task<ActionResult> UpdateListed(string id, string version, bool? listed)\n{\n- // Edit does exactly the same thing that Delete used to do... REUSE ALL THE CODE!\n- return await Edit(id, version, listed, Url.Package);\n+ var package = _packageService.FindPackageByIdAndVersionStrict(id, version);\n+ if (package == null)\n+ {\n+ return HttpNotFound();\n+ }\n+\n+ if (ActionsRequiringPermissions.EditPackage.CheckPermissionsOnBehalfOfAnyAccount(GetCurrentUser(), package) != PermissionsCheckResult.Allowed)\n+ {\n+ return HttpForbidden();\n+ }\n+\n+ if (package.PackageRegistration.IsLocked)\n+ {\n+ return new HttpStatusCodeResult(403, string.Format(CultureInfo.CurrentCulture, Strings.PackageIsLocked, package.PackageRegistration.Id));\n+ }\n+\n+ string action;\n+ if (!(listed ?? false))\n+ {\n+ action = \"unlisted\";\n+ await _packageUpdateService.MarkPackageUnlistedAsync(package);\n+ }\n+ else\n+ {\n+ action = \"listed\";\n+ await _packageUpdateService.MarkPackageListedAsync(package);\n+ }\n+ TempData[\"Message\"] = string.Format(\n+ CultureInfo.CurrentCulture,\n+ \"The package has been {0}. It may take several hours for this change to propagate through our system.\",\n+ action);\n+\n+ return Redirect(Url.ManagePackage(new TrivialPackageVersionModel(package)));\n}\n[UIAuthorize]\n@@ -1969,9 +2000,11 @@ public virtual async Task<JsonResult> Edit(string id, string version, VerifyPack\n}\n}\n+ TempData[\"Message\"] = \"Your package's documentation has been updated.\";\n+\nreturn Json(new\n{\n- location = returnUrl ?? Url.Package(id, version)\n+ location = returnUrl ?? Url.ManagePackage(new TrivialPackageVersionModel(id, version))\n});\n}\n@@ -2129,43 +2162,6 @@ private Task SendAddPackageOwnerNotificationAsync(PackageRegistration package, U\nreturn Task.WhenAll(tasks);\n}\n- internal virtual async Task<ActionResult> Edit(string id, string version, bool? listed, Func<Package, bool, string> urlFactory)\n- {\n- var package = _packageService.FindPackageByIdAndVersionStrict(id, version);\n- if (package == null)\n- {\n- return HttpNotFound();\n- }\n-\n- if (ActionsRequiringPermissions.EditPackage.CheckPermissionsOnBehalfOfAnyAccount(GetCurrentUser(), package) != PermissionsCheckResult.Allowed)\n- {\n- return HttpForbidden();\n- }\n-\n- if (package.PackageRegistration.IsLocked)\n- {\n- return new HttpStatusCodeResult(403, string.Format(CultureInfo.CurrentCulture, Strings.PackageIsLocked, package.PackageRegistration.Id));\n- }\n-\n- string action;\n- if (!(listed ?? false))\n- {\n- action = \"unlisted\";\n- await _packageUpdateService.MarkPackageUnlistedAsync(package);\n- }\n- else\n- {\n- action = \"listed\";\n- await _packageUpdateService.MarkPackageListedAsync(package);\n- }\n- TempData[\"Message\"] = string.Format(\n- CultureInfo.CurrentCulture,\n- \"The package has been {0}. It may take several hours for this change to propagate through our system.\",\n- action);\n-\n- return Redirect(urlFactory(package, /*relativeUrl:*/ true));\n- }\n-\n[UIAuthorize]\n[HttpPost]\n[RequiresAccountConfirmation(\"upload a package\")]\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"diff": "// Set up owners section\nvar packageId = \"@Model.Id\";\nvar isUserAnAdmin = \"@Model.IsCurrentUserAnAdmin\";\n- var packageUrl = \"@Url.Package(Model.Id)\";\n+ var packageUrl = \"@Url.ManagePackage(new TrivialPackageVersionModel(Model.Id, Model.Version))\";\nvar getPackageOwnersUrl = \"@Url.GetPackageOwners()\";\nvar addPackageOwnerUrl = \"@Url.AddPackageOwner()\";\nvar removePackageOwnerUrl = \"@Url.RemovePackageOwner()\";\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ManageDeprecationJsonApiControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ManageDeprecationJsonApiControllerFacts.cs",
"diff": "@@ -47,7 +47,7 @@ public class TheDeprecateMethod : TestContainer\nMemberDataHelper.Combine(\nEnumerable\n.Repeat(\n- MemberDataHelper.BooleanDataSet(), 4)\n+ MemberDataHelper.BooleanDataSet(), 5)\n.ToArray());\n[Theory]\n@@ -56,11 +56,12 @@ public class TheDeprecateMethod : TestContainer\nbool isLegacy,\nbool hasCriticalBugs,\nbool isOther,\n+ bool multipleVersions,\nbool success)\n{\n// Arrange\nvar id = \"Crested.Gecko\";\n- var versions = new[] { \"1.0.0\", \"2.0.0\" };\n+ var versions = multipleVersions ? new[] { \"1.0.0\", \"2.0.0\" } : new[] { \"1.0.0\" };\nvar alternateId = \"alt.Id\";\nvar alternateVersion = \"3.0.0\";\nvar customMessage = \"custom\";\n@@ -105,34 +106,44 @@ public class TheDeprecateMethod : TestContainer\n// Assert\nif (success)\n{\n- AssertSuccessResponse(controller);\n+ AssertResponseStatusCode(controller, HttpStatusCode.OK);\n+ string expectedString;\n+ if (isLegacy || hasCriticalBugs || isOther)\n+ {\n+ if (multipleVersions)\n+ {\n+ expectedString = \"Your packages have been deprecated.\";\n}\nelse\n{\n- AssertErrorResponse(controller, result, errorStatus, errorMessage);\n+ expectedString = \"Your package has been deprecated.\";\n+ }\n+ }\n+ else\n+ {\n+ if (multipleVersions)\n+ {\n+ expectedString = \"Your packages have been undeprecated.\";\n+ }\n+ else\n+ {\n+ expectedString = \"Your package has been undeprecated.\";\n}\n-\n- deprecationService.Verify();\n}\n- private static void AssertErrorResponse(\n- ManageDeprecationJsonApiController controller,\n- JsonResult result,\n- HttpStatusCode code,\n- string error)\n+ Assert.StartsWith(expectedString, controller.TempData[\"Message\"] as string);\n+ }\n+ else\n{\n- AssertResponseStatusCode(controller, code);\n+ AssertResponseStatusCode(controller, errorStatus);\n// Using JObject to get the property from the result easily.\n// Alternatively we could use reflection, but this is easier, and makes sense as the response is intended to be JSON anyway.\nvar jObject = JObject.FromObject(result.Data);\n- Assert.Equal(error, jObject[\"error\"].Value<string>());\n+ Assert.Equal(errorMessage, jObject[\"error\"].Value<string>());\n}\n- private static void AssertSuccessResponse(\n- ManageDeprecationJsonApiController controller)\n- {\n- AssertResponseStatusCode(controller, HttpStatusCode.OK);\n+ deprecationService.Verify();\n}\nprivate static void AssertResponseStatusCode(\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"diff": "@@ -3519,6 +3519,29 @@ public async Task WhenPackageRegistrationIsLockedReturns403()\npublic class TheUpdateListedMethod : TestContainer\n{\n+ [Theory]\n+ [InlineData(false)]\n+ [InlineData(true)]\n+ public async Task Returns404IfNotFound(bool listed)\n+ {\n+ // Arrange\n+ var packageService = new Mock<IPackageService>(MockBehavior.Strict);\n+ packageService.Setup(svc => svc.FindPackageByIdAndVersionStrict(\"Foo\", \"1.0\"))\n+ .Returns((Package)null);\n+ // Note: this Mock must be strict because it guarantees that MarkPackageListedAsync is not called!\n+\n+ var controller = CreateController(\n+ GetConfigurationService(),\n+ packageService: packageService);\n+ controller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n+\n+ // Act\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", listed);\n+\n+ // Assert\n+ Assert.IsType<HttpNotFoundResult>(result);\n+ }\n+\npublic static IEnumerable<object[]> NotOwner_Data\n{\nget\n@@ -3562,7 +3585,7 @@ public async Task Returns403IfNotOwner(User currentUser, User owner)\ncontroller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n// Act\n- var result = await controller.Edit(\"Foo\", \"1.0\", listed: false, urlFactory: (pkg, relativeUrl) => @\"~\\Bar.cshtml\");\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", false);\n// Assert\nAssert.IsType<HttpStatusCodeResult>(result);\n@@ -3627,15 +3650,17 @@ public async Task UpdatesUnlistedIfSelected(User currentUser, User owner)\nGetConfigurationService(),\npackageService: packageService);\ncontroller.SetCurrentUser(currentUser);\n- controller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n+ TestUtility.SetupUrlHelperForUrlGeneration(controller);\n// Act\n- var result = await controller.Edit(\"Foo\", \"1.0\", listed: false, urlFactory: (pkg, relativeUrl) => @\"~\\Bar.cshtml\");\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", false);\n// Assert\npackageService.Verify();\nAssert.IsType<RedirectResult>(result);\n- Assert.Equal(@\"~\\Bar.cshtml\", ((RedirectResult)result).Url);\n+ Assert.Equal(\n+ \"The package has been unlisted. It may take several hours for this change to propagate through our system.\",\n+ controller.TempData[\"Message\"]);\n}\n[Theory]\n@@ -3647,6 +3672,7 @@ public async Task UpdatesUnlistedIfNotSelected(User currentUser, User owner)\n{\nPackageRegistration = new PackageRegistration { Id = \"Foo\" },\nVersion = \"1.0\",\n+ NormalizedVersion = \"1.0.0\",\nListed = true\n};\npackage.PackageRegistration.Owners.Add(owner);\n@@ -3664,15 +3690,17 @@ public async Task UpdatesUnlistedIfNotSelected(User currentUser, User owner)\nGetConfigurationService(),\npackageService: packageService);\ncontroller.SetCurrentUser(currentUser);\n- controller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n+ TestUtility.SetupUrlHelperForUrlGeneration(controller);\n// Act\n- var result = await controller.Edit(\"Foo\", \"1.0\", listed: true, urlFactory: (pkg, relativeUrl) => @\"~\\Bar.cshtml\");\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", true);\n// Assert\npackageService.Verify();\nAssert.IsType<RedirectResult>(result);\n- Assert.Equal(@\"~\\Bar.cshtml\", ((RedirectResult)result).Url);\n+ Assert.Equal(\n+ \"The package has been listed. It may take several hours for this change to propagate through our system.\",\n+ controller.TempData[\"Message\"]);\n}\n[Fact]\n@@ -3701,7 +3729,7 @@ public async Task WhenPackageRegistrationIsLockedReturns403()\ncontroller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n// Act\n- var result = await controller.Edit(\"Foo\", \"1.0\", listed: true, urlFactory: (pkg, relativeUrl) => @\"~\\Bar.cshtml\");\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", true);\n// Assert\nResultAssert.IsStatusCode(result, HttpStatusCode.Forbidden);\n@@ -3834,7 +3862,7 @@ public async Task Returns403IfNotOwner(User currentUser, User owner)\ncontroller.Url = new UrlHelper(new RequestContext(), new RouteCollection());\n// Act\n- var result = await controller.Edit(\"Foo\", \"1.0\", listed: false, urlFactory: (pkg, relativeUrl) => @\"~\\Bar.cshtml\");\n+ var result = await controller.UpdateListed(\"Foo\", \"1.0\", false);\n// Assert\nAssert.IsType<HttpStatusCodeResult>(result);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Manage Package page forms should link back to the Manage page (#7678) |
455,776 | 11.11.2019 12:45:58 | 28,800 | e9ab0ddc8332bef25fbca8817454ec6d4c036bca | Newly pushed packages that are vulnerable should be marked vulnerable on upload/push | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"diff": "@@ -467,6 +467,9 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)\n.HasMany(pv => pv.Packages)\n.WithMany(p => p.Vulnerabilities);\n+ modelBuilder.Entity<VulnerablePackageVersionRange>()\n+ .HasIndex(pv => pv.PackageId);\n+\nmodelBuilder.Entity<VulnerablePackageVersionRange>()\n.HasIndex(pv => new { pv.VulnerabilityKey, pv.PackageId, pv.PackageVersionRange })\n.IsUnique();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/IPackageVulnerabilityService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/IPackageVulnerabilityService.cs",
"diff": "@@ -8,6 +8,14 @@ namespace NuGetGallery\n{\npublic interface IPackageVulnerabilityService\n{\n+ /// <summary>\n+ /// Adds any <see cref=\"VulnerablePackageVersionRange\"/>s to <see cref=\"Package.Vulnerabilities\"/> that it is a part of.\n+ /// </summary>\n+ /// <remarks>\n+ /// Does not commit changes. The caller is expected to commit any changes separately.\n+ /// </remarks>\n+ void ApplyExistingVulnerabilitiesToPackage(Package package);\n+\n/// <summary>\n/// If we don't currently have <paramref name=\"vulnerability\"/> in our database, adds it and its <see cref=\"PackageVulnerability.AffectedRanges\"/>.\n/// If we do, updates the existing entity.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageVulnerabilityService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageVulnerabilityService.cs",
"diff": "@@ -28,6 +28,29 @@ public class PackageVulnerabilityService : IPackageVulnerabilityService\n_logger = logger ?? throw new ArgumentNullException(nameof(logger));\n}\n+ public void ApplyExistingVulnerabilitiesToPackage(Package package)\n+ {\n+ if (package == null)\n+ {\n+ throw new ArgumentNullException(nameof(package));\n+ }\n+\n+ var version = NuGetVersion.Parse(package.NormalizedVersion);\n+ var possibleRanges = _entitiesContext.VulnerableRanges\n+ .Where(r => r.PackageId == package.Id)\n+ .ToList();\n+\n+ foreach (var possibleRange in possibleRanges)\n+ {\n+ var versionRange = VersionRange.Parse(possibleRange.PackageVersionRange);\n+ if (versionRange.Satisfies(version))\n+ {\n+ package.Vulnerabilities.Add(possibleRange);\n+ possibleRange.Packages.Add(package);\n+ }\n+ }\n+ }\n+\npublic async Task UpdateVulnerabilityAsync(PackageVulnerability vulnerability, bool withdrawn)\n{\nif (vulnerability == null)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "@@ -423,6 +423,10 @@ protected override void Load(ContainerBuilder builder)\n.As<IIconUrlTemplateProcessor>()\n.InstancePerLifetimeScope();\n+ builder.RegisterType<PackageVulnerabilityService>()\n+ .As<IPackageVulnerabilityService>()\n+ .InstancePerLifetimeScope();\n+\nservices.AddHttpClient();\nservices.AddScoped<IGravatarProxyService, GravatarProxyService>();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Migrations\\201910291956170_AddPackageVulnerabilities.Designer.cs\">\n<DependentUpon>201910291956170_AddPackageVulnerabilities.cs</DependentUpon>\n</Compile>\n+ <Compile Include=\"Migrations\\201911072143480_AddVulnerablePackageVersionRangeIdIndex.cs\" />\n+ <Compile Include=\"Migrations\\201911072143480_AddVulnerablePackageVersionRangeIdIndex.designer.cs\">\n+ <DependentUpon>201911072143480_AddVulnerablePackageVersionRangeIdIndex.cs</DependentUpon>\n+ </Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n<Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\GravatarProxyResult.cs\" />\n<EmbeddedResource Include=\"Migrations\\201910291956170_AddPackageVulnerabilities.resx\">\n<DependentUpon>201910291956170_AddPackageVulnerabilities.cs</DependentUpon>\n</EmbeddedResource>\n+ <EmbeddedResource Include=\"Migrations\\201911072143480_AddVulnerablePackageVersionRangeIdIndex.resx\">\n+ <DependentUpon>201911072143480_AddVulnerablePackageVersionRangeIdIndex.cs</DependentUpon>\n+ </EmbeddedResource>\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1packages.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1search.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv2getupdates.json\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"new_path": "src/NuGetGallery/Services/PackageUploadService.cs",
"diff": "using NuGet.Packaging;\nusing NuGet.Packaging.Licenses;\nusing NuGet.Services.Entities;\n-using NuGet.Services.Validation;\nusing NuGet.Versioning;\nusing NuGetGallery.Configuration;\nusing NuGetGallery.Diagnostics;\nusing NuGetGallery.Helpers;\nusing NuGetGallery.Packaging;\n-using NuGetGallery.Services;\nnamespace NuGetGallery\n{\n@@ -72,6 +70,7 @@ public class PackageUploadService : IPackageUploadService\nprivate readonly ICoreLicenseFileService _coreLicenseFileService;\nprivate readonly IDiagnosticsSource _trace;\nprivate readonly IFeatureFlagService _featureFlagService;\n+ private readonly IPackageVulnerabilityService _vulnerabilityService;\npublic PackageUploadService(\nIPackageService packageService,\n@@ -84,7 +83,8 @@ public class PackageUploadService : IPackageUploadService\nITelemetryService telemetryService,\nICoreLicenseFileService coreLicenseFileService,\nIDiagnosticsService diagnosticsService,\n- IFeatureFlagService featureFlagService)\n+ IFeatureFlagService featureFlagService,\n+ IPackageVulnerabilityService vulnerabilityService)\n{\n_packageService = packageService ?? throw new ArgumentNullException(nameof(packageService));\n_packageFileService = packageFileService ?? throw new ArgumentNullException(nameof(packageFileService));\n@@ -101,6 +101,7 @@ public class PackageUploadService : IPackageUploadService\n}\n_trace = diagnosticsService.GetSource(nameof(PackageUploadService));\n_featureFlagService = featureFlagService ?? throw new ArgumentNullException(nameof(featureFlagService));\n+ _vulnerabilityService = vulnerabilityService ?? throw new ArgumentNullException(nameof(vulnerabilityService));\n}\npublic async Task<PackageValidationResult> ValidateBeforeGeneratePackageAsync(\n@@ -794,6 +795,8 @@ private PackageValidationResult CheckRepositoryMetadata(PackageMetadata packageM\n}\n}\n+ _vulnerabilityService.ApplyExistingVulnerabilitiesToPackage(package);\n+\nreturn package;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageUploadServiceFacts.cs",
"diff": "@@ -33,7 +33,8 @@ public class PackageUploadServiceFacts\nMock<IPackageService> packageService = null,\nMock<IReservedNamespaceService> reservedNamespaceService = null,\nMock<IValidationService> validationService = null,\n- Mock<IAppConfiguration> config = null)\n+ Mock<IAppConfiguration> config = null,\n+ Mock<IPackageVulnerabilityService> vulnerabilityService = null)\n{\npackageService = packageService ?? new Mock<IPackageService>();\n@@ -63,6 +64,11 @@ public class PackageUploadServiceFacts\n.Returns(new ReservedNamespace[0]);\n}\n+ if (vulnerabilityService == null)\n+ {\n+ vulnerabilityService = new Mock<IPackageVulnerabilityService>();\n+ }\n+\nvalidationService = validationService ?? new Mock<IValidationService>();\nconfig = config ?? new Mock<IAppConfiguration>();\nvar diagnosticsService = new Mock<IDiagnosticsService>();\n@@ -81,7 +87,8 @@ public class PackageUploadServiceFacts\nMock.Of<ITelemetryService>(),\nMock.Of<ICoreLicenseFileService>(),\ndiagnosticsService.Object,\n- Mock.Of<IFeatureFlagService>());\n+ Mock.Of<IFeatureFlagService>(),\n+ vulnerabilityService.Object);\nreturn packageUploadService.Object;\n}\n@@ -94,16 +101,30 @@ public async Task WillCallCreatePackageAsyncCorrectly()\nvar key = 0;\nvar packageService = new Mock<IPackageService>();\npackageService.Setup(x => x.FindPackageRegistrationById(It.IsAny<string>())).Returns((PackageRegistration)null);\n+ var vulnerabilityService = new Mock<IPackageVulnerabilityService>();\nvar id = \"Microsoft.Aspnet.Mvc\";\n- var packageUploadService = CreateService(packageService);\n+ var packageUploadService = CreateService(packageService, vulnerabilityService: vulnerabilityService);\nvar nugetPackage = PackageServiceUtility.CreateNuGetPackage(id: id);\nvar owner = new User { Key = key++, Username = \"owner\" };\nvar currentUser = new User { Key = key++, Username = \"user\" };\n- var package = await packageUploadService.GeneratePackageAsync(id, nugetPackage.Object, new PackageStreamMetadata(), owner, currentUser);\n+ var package = await packageUploadService.GeneratePackageAsync(\n+ id, nugetPackage.Object, new PackageStreamMetadata(), owner, currentUser);\n+\n+ packageService.Verify(\n+ x => x.CreatePackageAsync(\n+ It.IsAny<PackageArchiveReader>(),\n+ It.IsAny<PackageStreamMetadata>(),\n+ owner,\n+ currentUser,\n+ false),\n+ Times.Once);\n+\n+ vulnerabilityService.Verify(\n+ x => x.ApplyExistingVulnerabilitiesToPackage(package),\n+ Times.Once);\n- packageService.Verify(x => x.CreatePackageAsync(It.IsAny<PackageArchiveReader>(), It.IsAny<PackageStreamMetadata>(), owner, currentUser, false), Times.Once);\nAssert.False(package.PackageRegistration.IsVerified);\n}\n@@ -135,11 +156,19 @@ public async Task WillMarkPackageRegistrationVerifiedFlagCorrectly(bool shouldMa\n.Setup(r => r.GetReservedNamespacesForId(It.IsAny<string>()))\n.Returns(testNamespaces.ToList().AsReadOnly());\n- var packageUploadService = CreateService(reservedNamespaceService: reservedNamespaceService);\n+ var vulnerabilityService = new Mock<IPackageVulnerabilityService>();\n+\n+ var packageUploadService = CreateService(\n+ reservedNamespaceService: reservedNamespaceService,\n+ vulnerabilityService: vulnerabilityService);\nvar nugetPackage = PackageServiceUtility.CreateNuGetPackage(id: id);\nvar package = await packageUploadService.GeneratePackageAsync(id, nugetPackage.Object, new PackageStreamMetadata(), firstUser, firstUser);\n+ vulnerabilityService.Verify(\n+ x => x.ApplyExistingVulnerabilitiesToPackage(package),\n+ Times.Once);\n+\nAssert.Equal(shouldMarkIdVerified, package.PackageRegistration.IsVerified);\n}\n@@ -169,11 +198,19 @@ public async Task WillMarkPackageRegistrationNotVerifiedIfIdMatchesNonOwnedShare\n.Setup(r => r.GetReservedNamespacesForId(It.IsAny<string>()))\n.Returns(testNamespaces.ToList().AsReadOnly());\n- var packageUploadService = CreateService(reservedNamespaceService: reservedNamespaceService);\n+ var vulnerabilityService = new Mock<IPackageVulnerabilityService>();\n+\n+ var packageUploadService = CreateService(\n+ reservedNamespaceService: reservedNamespaceService,\n+ vulnerabilityService: vulnerabilityService);\nvar nugetPackage = PackageServiceUtility.CreateNuGetPackage(id: id);\nvar package = await packageUploadService.GeneratePackageAsync(id, nugetPackage.Object, new PackageStreamMetadata(), lastUser, lastUser);\n+ vulnerabilityService.Verify(\n+ x => x.ApplyExistingVulnerabilitiesToPackage(package),\n+ Times.Once);\n+\nAssert.False(package.PackageRegistration.IsVerified);\n}\n}\n@@ -2202,6 +2239,7 @@ public abstract class FactsBase\nprotected readonly Mock<ITelemetryService> _telemetryService;\nprotected readonly Mock<ICoreLicenseFileService> _licenseFileService;\nprotected readonly Mock<IDiagnosticsService> _diagnosticsService;\n+ protected readonly Mock<IPackageVulnerabilityService> _vulnerabilityService;\nprotected Package _package;\nprotected Stream _packageFile;\nprotected ArgumentException _unexpectedException;\n@@ -2249,6 +2287,8 @@ public FactsBase()\n.Setup(ffs => ffs.AreEmbeddedIconsEnabled(It.IsAny<User>()))\n.Returns(false);\n+ _vulnerabilityService = new Mock<IPackageVulnerabilityService>();\n+\n_target = new PackageUploadService(\n_packageService.Object,\n_packageFileService.Object,\n@@ -2260,7 +2300,8 @@ public FactsBase()\n_telemetryService.Object,\n_licenseFileService.Object,\n_diagnosticsService.Object,\n- _featureFlagService.Object);\n+ _featureFlagService.Object,\n+ _vulnerabilityService.Object);\n}\nprotected static Mock<TestPackageReader> GeneratePackage(\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageVulnerabilityServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageVulnerabilityServiceFacts.cs",
"diff": "@@ -15,6 +15,59 @@ namespace NuGetGallery.Services\n{\npublic class PackageVulnerabilityServiceFacts\n{\n+ public class TheApplyExistingVulnerabilitiesToPackageMethod : MethodFacts\n+ {\n+ [Fact]\n+ public void IfNull_ThrowsArgumentNullException()\n+ {\n+ Assert.Throws<ArgumentNullException>(() => Service.ApplyExistingVulnerabilitiesToPackage(null));\n+ }\n+\n+ [Fact]\n+ public void AppliesCorrectVulnerabilities()\n+ {\n+ // Arrange\n+ var registration = new PackageRegistration\n+ {\n+ Id = \"id\"\n+ };\n+\n+ var package = new Package\n+ {\n+ PackageRegistration = registration,\n+ NormalizedVersion = \"1.0.0\"\n+ };\n+\n+ var wrongIdRange = new VulnerablePackageVersionRange\n+ {\n+ PackageId = \"wrongId\",\n+ PackageVersionRange = \"(,)\"\n+ };\n+\n+ var satisfiedRange = new VulnerablePackageVersionRange\n+ {\n+ PackageId = registration.Id,\n+ PackageVersionRange = \"[1.0.0, )\"\n+ };\n+\n+ var unsatisfiedRange = new VulnerablePackageVersionRange\n+ {\n+ PackageId = registration.Id,\n+ PackageVersionRange = \"(, 1.0.0)\"\n+ };\n+\n+ Context.VulnerableRanges.AddRange(\n+ new[] { wrongIdRange, satisfiedRange, unsatisfiedRange });\n+\n+ // Act\n+ Service.ApplyExistingVulnerabilitiesToPackage(package);\n+\n+ // Assert\n+ Assert.Single(package.Vulnerabilities, satisfiedRange);\n+ Assert.Single(satisfiedRange.Packages, package);\n+ }\n+ }\n+\npublic class TheUpdateVulnerabilityMethod : MethodFacts\n{\n[Theory]\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Newly pushed packages that are vulnerable should be marked vulnerable on upload/push (#7679) |
455,776 | 12.11.2019 13:57:30 | 28,800 | e89c40983f0617f8dc9133c93a9b9779533e5dc5 | Allow admins to see users' MFA setting on profile page | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/UserProfileModel.cs",
"new_path": "src/NuGetGallery/ViewModels/UserProfileModel.cs",
"diff": "@@ -16,6 +16,7 @@ public UserProfileModel(User user, User currentUser, List<ListPackageItemViewMod\nUsername = user.Username;\nEmailAddress = user.EmailAddress;\nUnconfirmedEmailAddress = user.UnconfirmedEmailAddress;\n+ HasEnabledMultiFactorAuthentication = user.EnableMultiFactorAuthentication;\nAllPackages = allPackages;\nTotalPackages = allPackages.Count;\nPackagePage = pageIndex;\n@@ -41,6 +42,7 @@ public UserProfileModel(User user, User currentUser, List<ListPackageItemViewMod\npublic string Username { get; private set; }\npublic string EmailAddress { get; private set; }\npublic string UnconfirmedEmailAddress { get; set; }\n+ public bool HasEnabledMultiFactorAuthentication { get; set; }\npublic ICollection<ListPackageItemViewModel> AllPackages { get; private set; }\npublic ICollection<ListPackageItemViewModel> PagedPackages { get; private set; }\npublic long TotalPackageDownloadCount { get; private set; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/Profiles.cshtml",
"new_path": "src/NuGetGallery/Views/Users/Profiles.cshtml",
"diff": "<dt>Unconfirmed Email Address:</dt>\n<dd>@Model.UnconfirmedEmailAddress</dd>\n}\n+ <dt>Multi-factor Authentication:</dt>\n+ <dd>@(Model.HasEnabledMultiFactorAuthentication ? \"Enabled\" : \"Disabled\")</dd>\n</dl>\n</div>\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Allow admins to see users' MFA setting on profile page (#7692) |
455,776 | 14.11.2019 16:31:41 | 28,800 | 7d1f3ca6badc4445868ad74785f50abbf8e2e469 | Ingest first patched version of security vulnerabilities from the GitHub API | [
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.3.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"MicroBuild.Core\">\n<Version>0.3.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryBuilder.cs",
"new_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryBuilder.cs",
"diff": "@@ -58,6 +58,9 @@ private string CreateVulnerabilitiesConnectionQuery(string edgeCursor = null)\npackage {\nname\n}\n+ firstPatchedVersion {\n+ identifier\n+ }\nvulnerableVersionRange\nupdatedAt\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GraphQL/SecurityVulnerability.cs",
"new_path": "src/GitHubVulnerabilities2Db/GraphQL/SecurityVulnerability.cs",
"diff": "@@ -12,6 +12,7 @@ public class SecurityVulnerability : INode\n{\npublic SecurityVulnerabilityPackage Package { get; set; }\npublic string VulnerableVersionRange { get; set; }\n+ public SecurityVulnerabilityPackageVersion FirstPatchedVersion { get; set; }\npublic DateTimeOffset UpdatedAt { get; set; }\npublic SecurityAdvisory Advisory { get; set; }\n}\n@@ -23,4 +24,12 @@ public class SecurityVulnerabilityPackage\n{\npublic string Name { get; set; }\n}\n+\n+ /// <summary>\n+ /// https://developer.github.com/v4/object/securityadvisorypackageversion/\n+ /// </summary>\n+ public class SecurityVulnerabilityPackageVersion\n+ {\n+ public string Identifier { get; set; }\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"new_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"diff": "@@ -59,7 +59,8 @@ private VulnerablePackageVersionRange FromVulnerability(PackageVulnerability vul\n{\nVulnerability = vulnerability,\nPackageId = securityVulnerability.Package.Name,\n- PackageVersionRange = _gitHubVersionRangeParser.ToNuGetVersionRange(securityVulnerability.VulnerableVersionRange).ToNormalizedString()\n+ PackageVersionRange = _gitHubVersionRangeParser.ToNuGetVersionRange(securityVulnerability.VulnerableVersionRange).ToNormalizedString(),\n+ FirstPatchedPackageVersion = securityVulnerability.FirstPatchedVersion?.Identifier\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.3.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"MicroBuild.Core\">\n<Version>0.3.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"new_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.2.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"MicroBuild.Core\">\n<Version>0.3.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/VulnerablePackageVersionRange.cs",
"new_path": "src/NuGet.Services.Entities/VulnerablePackageVersionRange.cs",
"diff": "@@ -42,6 +42,9 @@ public VulnerablePackageVersionRange()\n[Required]\npublic string PackageVersionRange { get; set; }\n+ [StringLength(Constants.MaxPackageVersionLength)]\n+ public string FirstPatchedPackageVersion { get; set; }\n+\n/// <summary>\n/// The set of packages that is vulnerable.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "<Version>1.2.2</Version>\n</PackageReference>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.2.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"MicroBuild.Core\">\n<Version>0.3.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.2.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"MicroBuild.Core\">\n<Version>0.3.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageVulnerabilityService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageVulnerabilityService.cs",
"diff": "@@ -196,8 +196,38 @@ private bool UpdatePackageVulnerabilityMetadata(PackageVulnerability vulnerabili\nprivate void UpdateRangesOfPackageVulnerability(PackageVulnerability vulnerability, PackageVulnerability existingVulnerability, HashSet<Package> packagesToUpdate)\n{\n- // Any new ranges in the updated vulnerability need to be added to the database.\nvar rangeComparer = new RangeForSameVulnerabilityEqualityComparer();\n+ // Check for updates in the existing version ranges of this vulnerability.\n+ foreach (var existingRange in existingVulnerability.AffectedRanges.ToList())\n+ {\n+ var updatedRange = vulnerability.AffectedRanges\n+ .SingleOrDefault(r => rangeComparer.Equals(existingRange, r));\n+\n+ if (updatedRange == null)\n+ {\n+ // Any ranges that are missing from the updated vulnerability need to be removed.\n+ _logger.LogInformation(\n+ \"ID {VulnerablePackageId} and version range {VulnerablePackageVersionRange} is no longer vulnerable to vulnerability with GitHub key {GitHubDatabaseKey}\",\n+ existingRange.PackageId,\n+ existingRange.PackageVersionRange,\n+ vulnerability.GitHubDatabaseKey);\n+\n+ _entitiesContext.VulnerableRanges.Remove(existingRange);\n+ existingVulnerability.AffectedRanges.Remove(existingRange);\n+ packagesToUpdate.UnionWith(existingRange.Packages);\n+ }\n+ else\n+ {\n+ // Any range that had its first patched version updated needs to be updated.\n+ if (existingRange.FirstPatchedPackageVersion != updatedRange.FirstPatchedPackageVersion)\n+ {\n+ existingRange.FirstPatchedPackageVersion = updatedRange.FirstPatchedPackageVersion;\n+ packagesToUpdate.UnionWith(existingRange.Packages);\n+ }\n+ }\n+ }\n+\n+ // Any new ranges in the updated vulnerability need to be added to the database.\nvar newRanges = vulnerability.AffectedRanges\n.Except(existingVulnerability.AffectedRanges, rangeComparer)\n.ToList();\n@@ -214,23 +244,6 @@ private void UpdateRangesOfPackageVulnerability(PackageVulnerability vulnerabili\nexistingVulnerability.AffectedRanges.Add(newRange);\nProcessNewVulnerabilityRange(newRange, packagesToUpdate);\n}\n-\n- // Any ranges that are missing from the updated vulnerability need to be removed.\n- var missingRanges = existingVulnerability.AffectedRanges\n- .Except(vulnerability.AffectedRanges, rangeComparer)\n- .ToList();\n- _entitiesContext.VulnerableRanges.RemoveRange(missingRanges);\n- foreach (var missingRange in missingRanges)\n- {\n- _logger.LogInformation(\n- \"ID {VulnerablePackageId} and version range {VulnerablePackageVersionRange} is no longer vulnerable to vulnerability with GitHub key {GitHubDatabaseKey}\",\n- missingRange.PackageId,\n- missingRange.PackageVersionRange,\n- vulnerability.GitHubDatabaseKey);\n-\n- existingVulnerability.AffectedRanges.Remove(missingRange);\n- packagesToUpdate.UnionWith(missingRange.Packages);\n- }\n}\n/// <summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Migrations\\201911072143480_AddVulnerablePackageVersionRangeIdIndex.designer.cs\">\n<DependentUpon>201911072143480_AddVulnerablePackageVersionRangeIdIndex.cs</DependentUpon>\n</Compile>\n+ <Compile Include=\"Migrations\\201911132341290_AddVulnerablePackageVersionRangeFirstPatchedVersion.cs\" />\n+ <Compile Include=\"Migrations\\201911132341290_AddVulnerablePackageVersionRangeFirstPatchedVersion.designer.cs\">\n+ <DependentUpon>201911132341290_AddVulnerablePackageVersionRangeFirstPatchedVersion.cs</DependentUpon>\n+ </Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n<Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\GravatarProxyResult.cs\" />\n<EmbeddedResource Include=\"Migrations\\201911072143480_AddVulnerablePackageVersionRangeIdIndex.resx\">\n<DependentUpon>201911072143480_AddVulnerablePackageVersionRangeIdIndex.cs</DependentUpon>\n</EmbeddedResource>\n+ <EmbeddedResource Include=\"Migrations\\201911132341290_AddVulnerablePackageVersionRangeFirstPatchedVersion.resx\">\n+ <DependentUpon>201911132341290_AddVulnerablePackageVersionRangeFirstPatchedVersion.cs</DependentUpon>\n+ </EmbeddedResource>\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1packages.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1search.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv2getupdates.json\" />\n<Version>1.2.2</Version>\n</PackageReference>\n<PackageReference Include=\"EntityFramework\">\n- <Version>6.2.0</Version>\n+ <Version>6.4.0-preview3-19553-01</Version>\n</PackageReference>\n<PackageReference Include=\"Knockout.Mapping\">\n<Version>2.4.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"new_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"diff": "@@ -65,15 +65,19 @@ public async Task IngestsAdvisoryWithoutVulnerability(bool withdrawn)\n}\n[Theory]\n- [InlineData(false)]\n- [InlineData(true)]\n- public async Task IngestsAdvisory(bool withdrawn)\n+ [InlineData(false, false)]\n+ [InlineData(true, false)]\n+ [InlineData(false, true)]\n+ [InlineData(true, true)]\n+ public async Task IngestsAdvisory(bool withdrawn, bool vulnerabilityHasFirstPatchedVersion)\n{\n// Arrange\nvar securityVulnerability = new SecurityVulnerability\n{\nPackage = new SecurityVulnerabilityPackage { Name = \"crested.gecko\" },\n- VulnerableVersionRange = \"homeOnTheRange\"\n+ VulnerableVersionRange = \"homeOnTheRange\",\n+ FirstPatchedVersion = vulnerabilityHasFirstPatchedVersion\n+ ? new SecurityVulnerabilityPackageVersion { Identifier = \"1.2.3\" } : null\n};\nvar advisory = new SecurityAdvisory\n@@ -110,9 +114,10 @@ public async Task IngestsAdvisory(bool withdrawn)\nAssert.Equal(PackageVulnerabilitySeverity.Critical, vulnerability.Severity);\nAssert.Equal(advisory.References.Single().Url, vulnerability.ReferenceUrl);\n- var packageVulnerability = vulnerability.AffectedRanges.Single();\n- Assert.Equal(securityVulnerability.Package.Name, packageVulnerability.PackageId);\n- Assert.Equal(versionRange.ToNormalizedString(), packageVulnerability.PackageVersionRange);\n+ var range = vulnerability.AffectedRanges.Single();\n+ Assert.Equal(securityVulnerability.Package.Name, range.PackageId);\n+ Assert.Equal(versionRange.ToNormalizedString(), range.PackageVersionRange);\n+ Assert.Equal(securityVulnerability.FirstPatchedVersion?.Identifier, range.FirstPatchedPackageVersion);\n})\n.Returns(Task.CompletedTask)\n.Verifiable();\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageVulnerabilityServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageVulnerabilityServiceFacts.cs",
"diff": "@@ -350,6 +350,38 @@ public async Task WithExistingVulnerability_NotWithdrawn_NoRanges_RemovesAndUnma\nexpectedPackagesToUpdate.Add(existingVulnerablePackage);\n}\n+ // If an existing vulnerable range is updated, its packages should be updated.\n+ var existingVulnerablePackageWithUpdatedRange = new Package\n+ {\n+ PackageRegistration = registration,\n+ NormalizedVersion = \"0.0.9\"\n+ };\n+\n+ var existingVulnerablePackageVersionWithUpdatedRange = NuGetVersion.Parse(existingVulnerablePackageWithUpdatedRange.NormalizedVersion);\n+ var existingRangeWithUpdatedRange = new VulnerablePackageVersionRange\n+ {\n+ Vulnerability = existingVulnerability,\n+ PackageId = id,\n+ PackageVersionRange = new VersionRange(existingVulnerablePackageVersionWithUpdatedRange, true, existingVulnerablePackageVersionWithUpdatedRange, true).ToNormalizedString()\n+ };\n+\n+ Context.VulnerableRanges.Add(existingRangeWithUpdatedRange);\n+ existingRangeWithUpdatedRange.Packages.Add(existingVulnerablePackageWithUpdatedRange);\n+ existingVulnerability.AffectedRanges.Add(existingRangeWithUpdatedRange);\n+\n+ var updatedExistingRange = new VulnerablePackageVersionRange\n+ {\n+ Vulnerability = existingRangeWithUpdatedRange.Vulnerability,\n+ PackageId = existingRangeWithUpdatedRange.PackageId,\n+ PackageVersionRange = existingRangeWithUpdatedRange.PackageVersionRange,\n+ FirstPatchedPackageVersion = \"1.0.0\"\n+ };\n+\n+ vulnerability.AffectedRanges.Add(updatedExistingRange);\n+\n+ expectedVulnerablePackages.Add(existingVulnerablePackageWithUpdatedRange);\n+ expectedPackagesToUpdate.Add(existingVulnerablePackageWithUpdatedRange);\n+\n// If a package vulnerability is missing from the new vulnerability, it should be removed.\nvar existingMissingVulnerablePackage = new Package\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Ingest first patched version of security vulnerabilities from the GitHub API (#7686) |
455,736 | 19.11.2019 14:19:04 | 28,800 | 9a2d0bef771a0dbd11fe454cad3399f2c4527aac | Use ef6.exe instead of migrate.exe
This addresses a breaking change introduced in 6.3.0 which eliminates migrate.exe and replaces it with ef6.exe.
Discover the version from the .csproj instead of hard-coding it.
Fix some "Nuget" cases and made them "NuGet".
Address
Migration details available here: | [
{
"change_type": "MODIFY",
"old_path": "test.ps1",
"new_path": "test.ps1",
"diff": "@@ -38,6 +38,9 @@ Function Run-Tests {\n& $xUnitExe (Join-Path $PSScriptRoot $Test) -xml \"Results.$TestCount.xml\"\n$TestCount++\n}\n+\n+ Write-Host \"Ensuring the EntityFramework version can be discovered.\"\n+ . (Join-Path $PSScriptRoot \"tools\\Update-Databases.ps1\") -MigrationTargets @(\"FakeMigrationTarget\")\n}\nWrite-Host (\"`r`n\" * 3)\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/Setup-DevEnvironment.ps1",
"new_path": "tools/Setup-DevEnvironment.ps1",
"diff": "@@ -119,6 +119,6 @@ Invoke-Netsh http add sslcert hostnameport=\"$(Get-SiteHttpsHost)\" certhash=\"$($s\nWrite-Host \"[DONE] Setting SSL Certificate\" -ForegroundColor Cyan\nWrite-Host \"[BEGIN] Running Migrations\" -ForegroundColor Cyan\n-& \"$ScriptRoot\\Update-Databases.ps1\" -MigrationTargets NugetGallery,NugetGallerySupportRequest -NugetGallerySitePath $SitePhysicalPath\n+& \"$ScriptRoot\\Update-Databases.ps1\" -MigrationTargets NuGetGallery,NuGetGallerySupportRequest -NuGetGallerySitePath $SitePhysicalPath\nWrite-Host \"[DONE] Running Migrations\" -ForegroundColor Cyan\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tools/Update-Databases.ps1",
"new_path": "tools/Update-Databases.ps1",
"diff": "param(\n[parameter(Mandatory=$true)]\n[string[]] $MigrationTargets,\n- [string] $NugetGallerySitePath)\n+ [string] $NuGetGallerySitePath)\n-function Initialize-MigrateExe() {\n+function Initialize-EF6Exe() {\n[string] $migrateDirectory = [System.IO.Path]::Combine($PSScriptRoot, '__temp_migrate_directory_' + [guid]::NewGuid().ToString(\"N\") )\n- [string] $efDirectory = \"$env:userprofile\\.nuget\\packages\\EntityFramework\\6.1.3\"\n- [string] $migrate = ([System.IO.Path]::Combine($migrateDirectory, 'migrate.exe'))\n+ [string] $efDirectory = $null\n+ [string] $ef6 = ([System.IO.Path]::Combine($migrateDirectory, 'ef6.exe'))\nif (-not (New-Item -ItemType Directory -Path $migrateDirectory -Force).Exists) {\nthrow 'migrate directory could not be created.'\n}\n+ if (!$efDirectory) {\n+ # Read the current version of EntityFramework from NuGetGallery.csproj so that we can find the tools.\n+ $csprojPath = Join-Path $PSScriptRoot \"..\\src\\NuGetGallery\\NuGetGallery.csproj\"\n+ [xml]$csproj = Get-Content $csprojPath\n+ $efPackageReference = Select-Xml -Xml $csproj -XPath \"//*[local-name()='PackageReference']\" `\n+ | Where-Object { $_.Node.Attributes[\"Include\"].Value -eq \"EntityFramework\" }\n+ $efVersion = $efPackageReference.Node.Version\n+ Write-Host \"Using EntityFramework version $efVersion.\"\n+ $efDirectory = \"$env:userprofile\\.nuget\\packages\\EntityFramework\\$efVersion\"\n+ }\n+\nCopy-Item `\n-Path `\n- ([System.IO.Path]::Combine($efDirectory, 'tools\\migrate.exe')), `\n+ ([System.IO.Path]::Combine($efDirectory, 'tools\\net45\\win-x86\\ef6.exe')), `\n([System.IO.Path]::Combine($efDirectory, 'lib\\net45\\*.dll')) `\n-Destination $migrateDirectory `\n-Force\n- if (-not (Test-Path -Path $migrate)) {\n- throw 'migrate.exe could not be provisioned.'\n+ if (-not (Test-Path -Path $ef6)) {\n+ throw 'ef6.exe could not be provisioned.'\n}\nreturn $migrateDirectory\n}\n-function Update-NugetDatabases([string] $MigrateExePath, [string] $NugetGallerySitePath, [string[]] $MigrationTargets) {\n- [string] $binariesPath = [System.IO.Path]::Combine($NugetGallerySitePath, 'bin')\n- [string] $webConfigPath = [System.IO.Path]::Combine($NugetGallerySitePath, 'web.config')\n- if ($MigrationTargets.Contains('NugetGallery')) {\n- Write-Host 'Updating Nuget Gallery database...'\n- & $MigrateExePath \"NuGetGallery.dll\" MigrationsConfiguration \"NuGetGallery.Core.dll\" \"/startUpDirectory:$binariesPath\" \"/startUpConfigurationFile:$webConfigPath\"\n+function Update-NuGetDatabases([string] $EF6ExePath, [string] $NuGetGallerySitePath, [string[]] $MigrationTargets) {\n+ [string] $binariesPath = [System.IO.Path]::Combine($NuGetGallerySitePath, 'bin')\n+ [string] $webConfigPath = [System.IO.Path]::Combine($NuGetGallerySitePath, 'web.config')\n+ if ($MigrationTargets.Contains('NuGetGallery')) {\n+ Write-Host 'Updating NuGet Gallery database...'\n+ & $EF6ExePath database update --assembly (Join-Path $binariesPath \"NuGetGallery.dll\") --migrations-config MigrationsConfiguration --config $webConfigPath\n}\n- if ($MigrationTargets.Contains('NugetGallerySupportRequest')) {\n- Write-Host 'Updating Nuget Gallery Support request database...'\n- & $MigrateExePath \"NuGetGallery.dll\" SupportRequestMigrationsConfiguration \"NuGetGallery.dll\" \"/startUpDirectory:$binariesPath\" \"/startUpConfigurationFile:$webConfigPath\"\n+ if ($MigrationTargets.Contains('NuGetGallerySupportRequest')) {\n+ Write-Host 'Updating NuGet Gallery Support request database...'\n+ & $EF6ExePath database update --assembly (Join-Path $binariesPath \"NuGetGallery.dll\") --migrations-config SupportRequestMigrationsConfiguration --config $webConfigPath\n}\nWrite-Host 'Update Complete!'\n}\n-[string] $migrateExeDirectory = $null\n+[string] $ef6ExeDirectory = $null\ntry {\n- if ([string]::IsNullOrWhiteSpace($NugetGallerySitePath)) {\n- $NugetGallerySitePath = [System.IO.Path]::Combine($Script:PSScriptRoot, '..', 'src\\NugetGallery')\n- Write-Host 'NugetGallerySitePath was not provided.'\n- Write-Host \"We will attempt to use $NugetGallerySitePath\"\n+ if ([string]::IsNullOrWhiteSpace($NuGetGallerySitePath)) {\n+ $NuGetGallerySitePath = [System.IO.Path]::Combine($Script:PSScriptRoot, '..', 'src\\NuGetGallery')\n+ Write-Host 'NuGetGallerySitePath was not provided.'\n+ Write-Host \"We will attempt to use $NuGetGallerySitePath\"\n}\n- $migrateExeDirectory = Initialize-MigrateExe\n+ $ef6ExeDirectory = Initialize-EF6Exe\n- Update-NugetDatabases `\n- -MigrateExePath ([System.IO.Path]::Combine($migrateExeDirectory, 'migrate.exe')) `\n- -NugetGallerySitePath $NugetGallerySitePath `\n+ Update-NuGetDatabases `\n+ -EF6ExePath ([System.IO.Path]::Combine($ef6ExeDirectory, 'ef6.exe')) `\n+ -NuGetGallerySitePath $NuGetGallerySitePath `\n-MigrationTargets $MigrationTargets\n}\nfinally {\n- if ($migrateExeDirectory -ne $null -and (Test-Path -Path $migrateExeDirectory -PathType Container)) {\n- Remove-Item -Path $migrateExeDirectory -Recurse -Force\n+ if ($ef6ExeDirectory -ne $null -and (Test-Path -Path $ef6ExeDirectory -PathType Container)) {\n+ Remove-Item -Path $ef6ExeDirectory -Recurse -Force\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Use ef6.exe instead of migrate.exe (#7711)
This addresses a breaking change introduced in 6.3.0 which eliminates migrate.exe and replaces it with ef6.exe.
Discover the version from the .csproj instead of hard-coding it.
Fix some "Nuget" cases and made them "NuGet".
Address https://github.com/NuGet/NuGetGallery/issues/7699
Migration details available here: https://github.com/aspnet/EntityFramework.Docs/issues/1740#issuecomment-557204757 |
455,744 | 22.11.2019 15:38:45 | 28,800 | c87374c7a07037fa3a29273e4024310c38508f53 | Dropped the `DiagnosticMonitorTraceListener` usage. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"new_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"diff": "using System.Web.Routing;\nusing System.Web.UI;\nusing Elmah;\n-using Microsoft.WindowsAzure.Diagnostics;\nusing Microsoft.WindowsAzure.ServiceRuntime;\nusing NuGetGallery;\nusing NuGetGallery.Configuration;\n@@ -47,18 +46,6 @@ public static void PreStart()\nViewEngines.Engines.Clear();\nViewEngines.Engines.Add(CreateViewEngine());\n-\n- try\n- {\n- if (RoleEnvironment.IsAvailable)\n- {\n- CloudPreStart();\n- }\n- }\n- catch\n- {\n- // Azure SDK not available!\n- }\n}\npublic static void PostStart()\n@@ -110,11 +97,6 @@ private static RazorViewEngine CreateViewEngine()\nreturn ret;\n}\n- private static void CloudPreStart()\n- {\n- Trace.Listeners.Add(new DiagnosticMonitorTraceListener());\n- }\n-\nprivate static void BundlingPostStart()\n{\n// Add primary style bundle\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Dropped the `DiagnosticMonitorTraceListener` usage. (#7709) |
455,736 | 03.12.2019 11:43:07 | 28,800 | a79a30b3804b741b49ec70131bd1d9d63e8cb5d8 | Removed unused TrustedHttpsCertificates since it is no longer used | [
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.FunctionalTests.Core/GalleryConfiguration.cs",
"new_path": "tests/NuGetGallery.FunctionalTests.Core/GalleryConfiguration.cs",
"diff": "@@ -25,8 +25,6 @@ public class GalleryConfiguration\n[JsonProperty]\npublic string EmailServerHost { get; private set; }\n[JsonProperty]\n- public IEnumerable<string> TrustedHttpsCertificates { get; private set; }\n- [JsonProperty]\npublic bool DefaultSecurityPoliciesEnforced { get; private set; }\n[JsonProperty]\npublic bool TestPackageLock { get; private set; }\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Removed unused TrustedHttpsCertificates since it is no longer used (#7724) |
455,736 | 04.12.2019 09:46:22 | 28,800 | e7ebfbd44f93eff3a6aab7a871f33a1c63950381 | Fix null reference exception when GitHub usage is not yet initialized
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"new_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"diff": "@@ -23,6 +23,7 @@ public ContentObjectService(IContentService contentService)\nCertificatesConfiguration = new CertificatesConfiguration();\nSymbolsConfiguration = new SymbolsConfiguration();\nTyposquattingConfiguration = new TyposquattingConfiguration();\n+ GitHubUsageConfiguration = new GitHubUsageConfiguration(Array.Empty<RepositoryInformation>());\nABTestConfiguration = new ABTestConfiguration();\nODataCacheConfiguration = new ODataCacheConfiguration();\n}\n@@ -56,7 +57,6 @@ public async Task Refresh()\nvar reposCache =\nawait Refresh<IReadOnlyCollection<RepositoryInformation>>(ServicesConstants.ContentNames.NuGetPackagesGitHubDependencies) ??\nArray.Empty<RepositoryInformation>();\n-\nGitHubUsageConfiguration = new GitHubUsageConfiguration(reposCache);\nABTestConfiguration =\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/ContentObjectServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/ContentObjectServiceFacts.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n+using System.Reflection;\nusing System.Threading.Tasks;\nusing System.Web;\nusing Moq;\n@@ -13,6 +14,22 @@ namespace NuGetGallery.Services\n{\npublic class ContentObjectServiceFacts\n{\n+ public class TheConstructor : TestContainer\n+ {\n+ [Fact]\n+ public void InitializesAllPublicProperties()\n+ {\n+ // Arrange\n+ var service = new ContentObjectService(new Mock<IContentService>().Object);\n+ var properties = service\n+ .GetType()\n+ .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty);\n+\n+ // Act & Assert\n+ Assert.All(properties, p => Assert.NotNull(p.GetGetMethod().Invoke(service, null)));\n+ }\n+ }\n+\npublic class TheRefreshMethod : TestContainer\n{\n[Fact]\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix null reference exception when GitHub usage is not yet initialized (#7727)
Address https://github.com/NuGet/NuGetGallery/issues/7726 |
455,736 | 04.12.2019 11:27:22 | 28,800 | 39b34b916b505f4eb662dc78fb63bd2c99f9a0c7 | Only check "is indexed" for a day
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -51,6 +51,11 @@ public partial class PackagesController\n/// </remarks>\ninternal const int MaxAllowedLicenseLengthForDisplaying = 1024 * 1024; // 1 MB\n+ /// <summary>\n+ /// Only perform the \"is indexed\" check for a short time after the package was lasted edited or created.\n+ /// </summary>\n+ private static readonly TimeSpan IsIndexedCheckUntil = TimeSpan.FromDays(1);\n+\nprivate static readonly IReadOnlyList<ReportPackageReason> ReportAbuseReasons = new[]\n{\nReportPackageReason.ViolatesALicenseIOwn,\n@@ -855,6 +860,18 @@ public virtual async Task<ActionResult> DisplayPackage(string id, string version\nvar searchService = _searchServiceFactory.GetService();\nvar externalSearchService = searchService as ExternalSearchService;\nif (searchService.ContainsAllVersions && externalSearchService != null)\n+ {\n+ // A package can be re-indexed when it is created or edited. Determine the latest of these times.\n+ var sinceLatestUpsert = package.Created;\n+ if (package.LastEdited.HasValue && package.LastEdited > sinceLatestUpsert)\n+ {\n+ sinceLatestUpsert = package.LastEdited.Value;\n+ }\n+\n+ // If a package has not been created or edited in quite a while, save the cache memory and search\n+ // service load by not checking the indexed status.\n+ var isIndexedCheckUntil = sinceLatestUpsert + IsIndexedCheckUntil;\n+ if (DateTime.UtcNow < isIndexedCheckUntil)\n{\nvar isIndexedCacheKey = $\"IsIndexed_{package.PackageRegistration.Id}_{package.Version}\";\nvar isIndexed = HttpContext.Cache.Get(isIndexedCacheKey) as bool?;\n@@ -877,7 +894,7 @@ public virtual async Task<ActionResult> DisplayPackage(string id, string version\nisIndexed = results.Hits > 0;\n- var expiration = Cache.NoAbsoluteExpiration;\n+ var expiration = isIndexedCheckUntil;\nif (!isIndexed.Value)\n{\nexpiration = DateTime.UtcNow.Add(TimeSpan.FromSeconds(30));\n@@ -893,6 +910,7 @@ public virtual async Task<ActionResult> DisplayPackage(string id, string version\nmodel.IsIndexed = isIndexed;\n}\n+ }\nViewBag.FacebookAppID = _config.FacebookAppId;\nreturn View(model);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"diff": "using NuGetGallery.Infrastructure;\nusing NuGetGallery.Infrastructure.Mail.Messages;\nusing NuGetGallery.Infrastructure.Mail.Requests;\n+using NuGetGallery.Infrastructure.Search;\nusing NuGetGallery.Packaging;\nusing NuGetGallery.Security;\nusing Xunit;\n@@ -372,6 +373,67 @@ public async Task RedirectsToUploadPageAfterDelete()\npublic class TheDisplayPackageMethod\n: TestContainer\n{\n+ public static IEnumerable<object[]> PackageIsIndexedTestData => new[]\n+ {\n+ new object[] { DateTime.UtcNow, null, 1 },\n+ new object[] { DateTime.UtcNow.AddDays(-1), DateTime.UtcNow, 1 },\n+ new object[] { DateTime.UtcNow, DateTime.UtcNow.AddDays(-1), 1 },\n+ new object[] { DateTime.UtcNow.AddDays(-1), DateTime.UtcNow.AddDays(-1), 0 },\n+ new object[] { DateTime.UtcNow.AddDays(-1), null, 0 },\n+ };\n+\n+ [Theory]\n+ [MemberData(nameof(PackageIsIndexedTestData))]\n+ public async Task IsIndexCheckOnlyHappensForRecentlyChangedPackages(DateTime created, DateTime? lastEdited, int searchTimes)\n+ {\n+ // Arrange\n+ var id = \"Test\" + Guid.NewGuid().ToString();\n+ var packageService = new Mock<IPackageService>();\n+ var diagnosticsService = new Mock<IDiagnosticsService>();\n+ var searchClient = new Mock<ISearchClient>();\n+ var searchService = new Mock<ExternalSearchService>(diagnosticsService.Object, searchClient.Object)\n+ {\n+ CallBase = true,\n+ };\n+ var httpContext = new Mock<HttpContextBase>();\n+ httpContext.Setup(c => c.Cache).Returns(new Cache());\n+ var controller = CreateController(\n+ GetConfigurationService(),\n+ packageService: packageService,\n+ searchService: searchService.As<ISearchService>(),\n+ httpContext: httpContext);\n+ controller.SetCurrentUser(TestUtility.FakeUser);\n+\n+ searchService\n+ .Setup(x => x.RawSearch(It.IsAny<SearchFilter>()))\n+ .ReturnsAsync(() => new SearchResults(0, indexTimestampUtc: null));\n+\n+ var package = new Package\n+ {\n+ PackageRegistration = new PackageRegistration()\n+ {\n+ Id = id,\n+ Owners = new List<User>(),\n+ },\n+ Created = created,\n+ LastEdited = lastEdited,\n+ Version = \"2.0.0\",\n+ NormalizedVersion = \"2.0.0\",\n+ };\n+\n+ packageService\n+ .Setup(p => p.FilterExactPackage(It.IsAny<IReadOnlyCollection<Package>>(), It.IsAny<string>()))\n+ .Returns(package);\n+\n+ // Act\n+ var result = await controller.DisplayPackage(package.Id, package.Version);\n+\n+ // Assert\n+ var model = ResultAssert.IsView<DisplayPackageViewModel>(result);\n+ Assert.Equal(id, model.Id);\n+ searchService.Verify(x => x.RawSearch(It.IsAny<SearchFilter>()), Times.Exactly(searchTimes));\n+ }\n+\n[Fact]\npublic async Task GivenANonNormalizedVersionIt302sToTheNormalizedVersion()\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Only check "is indexed" for a day (#7729)
Address https://github.com/NuGet/NuGetGallery/issues/7716 |
455,736 | 05.12.2019 09:26:40 | 28,800 | ecc99ffe85d74269fcdceb956d247615cb199639 | [Hotfix] Align NuGet.Jobs and ServerCommon dependencies to 2.60.0 | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-dev-3159955</Version>\n+ <Version>4.3.0-dev-3297551</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3159955</Version>\n+ <Version>4.3.0-dev-3297551</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3159955</Version>\n+ <Version>4.3.0-dev-3297551</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3159955</Version>\n- </PackageReference>\n- <PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.59.0</Version>\n+ <Version>4.3.0-dev-3297551</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.59.0</Version>\n+ <Version>2.60.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [Hotfix] Align NuGet.Jobs and ServerCommon dependencies to 2.60.0 (#7731) |
455,736 | 09.12.2019 12:24:47 | 28,800 | c60db2f15660de0b9a9339d574897069556da345 | [Hotfix] Revert to ServerCommon 2.58.0
Address | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-dev-3297551</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3297551</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3297551</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3297551</Version>\n+ <Version>4.3.0-dev-3159955</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"new_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"diff": "@@ -96,10 +96,6 @@ public static void Configuration(IAppBuilder app)\n// Add enrichers\nTelemetryConfiguration.Active.TelemetryInitializers.Add(new DeploymentIdTelemetryEnricher());\n- if (config.Current.DeploymentLabel != null)\n- {\n- TelemetryConfiguration.Active.TelemetryInitializers.Add(new DeploymentLabelEnricher(config.Current.DeploymentLabel));\n- }\nTelemetryConfiguration.Active.TelemetryInitializers.Add(new ClientInformationTelemetryEnricher());\nvar telemetryProcessorChainBuilder = TelemetryConfiguration.Active.TelemetryProcessorChainBuilder;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.60.0</Version>\n+ <Version>2.58.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [Hotfix] Revert to ServerCommon 2.58.0 (#7750)
Address https://github.com/NuGet/NuGetGallery/issues/7747 |
455,747 | 10.12.2019 12:30:25 | 28,800 | 3bcb7d001019b10a1f83513afaec1bf3d52de027 | [MSA] Redirect to home page for enabling 2FA | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"new_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"diff": "@@ -612,7 +612,7 @@ public virtual async Task<ActionResult> LinkExternalAccount(string returnUrl, st\nif (!currentUser.EnableMultiFactorAuthentication\n&& CredentialTypes.IsMicrosoftAccount(result.Credential.Type))\n{\n- TempData[\"AskUserToEnable2FA\"] = true;\n+ TempData[GalleryConstants.AskUserToEnable2FA] = true;\n}\nreturn SafeRedirect(returnUrl);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Filters/UiAuthorizeAttribute.cs",
"new_path": "src/NuGetGallery/Filters/UiAuthorizeAttribute.cs",
"diff": "@@ -19,9 +19,12 @@ public UIAuthorizeAttribute(bool allowDiscontinuedLogins = false)\npublic override void OnAuthorization(AuthorizationContext filterContext)\n{\n- // If the user has a discontinued login claim, redirect them to the homepage\n+ // If the user has a discontinued login claim or should enable 2FA, redirect them to the homepage\nvar identity = filterContext.HttpContext.User.Identity as ClaimsIdentity;\n- if (!AllowDiscontinuedLogins && ClaimsExtensions.HasDiscontinuedLoginClaims(identity))\n+ var askUserToEnable2FA = filterContext.Controller?.TempData?.ContainsKey(GalleryConstants.AskUserToEnable2FA);\n+\n+ if ((!AllowDiscontinuedLogins && ClaimsExtensions.HasDiscontinuedLoginClaims(identity))\n+ || (askUserToEnable2FA.HasValue && askUserToEnable2FA.Value))\n{\nfilterContext.Result = new RedirectToRouteResult(\nnew RouteValueDictionary(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/GalleryConstants.cs",
"new_path": "src/NuGetGallery/GalleryConstants.cs",
"diff": "@@ -45,6 +45,7 @@ public static class GalleryConstants\npublic static readonly string ReturnUrlViewDataKey = \"ReturnUrl\";\npublic static readonly string ReturnUrlMessageViewDataKey = \"ReturnUrlMessage\";\npublic const string AbsoluteLatestUrlString = \"absoluteLatest\";\n+ public const string AskUserToEnable2FA = \"AskUserToEnable2FA\";\npublic const string UrlValidationRegEx = @\"(https?):\\/\\/[^ \"\"]+$\";\npublic const string UrlValidationErrorMessage = \"This doesn't appear to be a valid HTTP/HTTPS URL\";\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/AuthenticationControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/AuthenticationControllerFacts.cs",
"diff": "@@ -1731,7 +1731,7 @@ public async Task ShouldAskToEnableMultiFactorSettingForMicrosoftAccounts(string\nuserServiceMock.Verify(x => x.ChangeMultiFactorAuthentication(authUser.User, true, It.IsAny<string>()), Times.Never());\nif (shouldAskToEnable2FA)\n{\n- Assert.Equal(true, controller.TempData[\"AskUserToEnable2FA\"]);\n+ Assert.Equal(true, controller.TempData[GalleryConstants.AskUserToEnable2FA]);\n}\nResultAssert.IsSafeRedirectTo(result, returnUrl);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Filters/UiAuthorizeAttributeFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Filters/UiAuthorizeAttributeFacts.cs",
"diff": "@@ -126,6 +126,42 @@ public void RedirectsToHomepageForAuthenticatedUserWithDiscontinuedLogin(string\nAssert.Contains(new KeyValuePair<string, object>(\"action\", \"Home\"), redirectResult.RouteValues);\n}\n+ [Theory]\n+ [InlineData(true)]\n+ [InlineData(false)]\n+ public void RedirectsToHomepageOnlyWith2FAMarker(bool shouldEnable2FA)\n+ {\n+ var tempData = new TempDataDictionary();\n+ if (shouldEnable2FA)\n+ {\n+ tempData.Add(GalleryConstants.AskUserToEnable2FA, true);\n+ }\n+\n+ var context = BuildAuthorizationContext(\n+ BuildClaimsIdentity(\n+ AuthenticationTypes.External,\n+ authenticated: true,\n+ hasDiscontinuedLoginClaim: false).Object).Object;\n+ context.Controller.TempData = tempData;\n+ var attribute = new UIAuthorizeAttribute();\n+\n+ // Act\n+ attribute.OnAuthorization(context);\n+\n+ // Assert\n+ var redirectResult = context.Result as RedirectToRouteResult;\n+ if (shouldEnable2FA)\n+ {\n+ Assert.NotNull(redirectResult);\n+ Assert.Contains(new KeyValuePair<string, object>(\"controller\", \"Pages\"), redirectResult.RouteValues);\n+ Assert.Contains(new KeyValuePair<string, object>(\"action\", \"Home\"), redirectResult.RouteValues);\n+ }\n+ else\n+ {\n+ Assert.Null(redirectResult);\n+ }\n+ }\n+\nprivate static Mock<ClaimsIdentity> BuildClaimsIdentity(string authType, bool authenticated, bool hasDiscontinuedLoginClaim)\n{\nvar mockIdentity = new Mock<ClaimsIdentity>();\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [MSA] Redirect to home page for enabling 2FA (#7758) |
455,759 | 03.12.2019 12:10:57 | -3,600 | 6ae47ca94e83cee9907e8314bbf79f4fe844c171 | Guard against unexpected data integrity violation from GH API. | [
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"new_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"diff": "@@ -28,6 +28,13 @@ public async Task IngestAsync(IReadOnlyList<SecurityAdvisory> advisories)\n{\nforeach (var advisory in advisories)\n{\n+ if (!advisory.References.Any())\n+ {\n+ // This should not happen, but we should guard against it anyway to avoid data integrity issues.\n+ // Ignore advisories that don't have any reference.\n+ continue;\n+ }\n+\nvar vulnerabilityTuple = FromAdvisory(advisory);\nvar vulnerability = vulnerabilityTuple.Item1;\nvar wasWithdrawn = vulnerabilityTuple.Item2;\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Guard against unexpected data integrity violation from GH API. |
455,736 | 18.12.2019 14:02:04 | 28,800 | 8377465d9ad05c907b1f9e5f17ad4a8096587ca4 | Fix two package type related bugs
Clear previous package types during reflow:
Reject invalid package type names: | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/CoreStrings.Designer.cs",
"new_path": "src/NuGetGallery.Core/CoreStrings.Designer.cs",
"diff": "@@ -19,7 +19,7 @@ namespace NuGetGallery {\n// class via a tool like ResGen or Visual Studio.\n// To add or remove a member, edit your .ResX file then rerun ResGen\n// with the /str option, or rebuild your VS project.\n- [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"15.0.0.0\")]\n+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute(\"System.Resources.Tools.StronglyTypedResourceBuilder\", \"16.0.0.0\")]\n[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\n[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]\npublic class CoreStrings {\n@@ -222,6 +222,15 @@ public class CoreStrings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to The package manifest contains an invalid package type name: '{0}'.\n+ /// </summary>\n+ public static string Manifest_InvalidPackageTypeName {\n+ get {\n+ return ResourceManager.GetString(\"Manifest_InvalidPackageTypeName\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to The package manifest contains an invalid Target Framework: '{0}'.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/CoreStrings.resx",
"new_path": "src/NuGetGallery.Core/CoreStrings.resx",
"diff": "<data name=\"CertificateThumbprintHashAlgorithmChanged\" xml:space=\"preserve\">\n<value>The thumbprint is expected to be a SHA-256 thumbprint, which is exactly 64 characters in length. Did the hash algorithm change?</value>\n</data>\n+ <data name=\"Manifest_InvalidPackageTypeName\" xml:space=\"preserve\">\n+ <value>The package manifest contains an invalid package type name: '{0}'</value>\n+ <comment>{0} is the package type name.</comment>\n+ </data>\n</root>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Packaging/PackageMetadata.cs",
"new_path": "src/NuGetGallery.Core/Packaging/PackageMetadata.cs",
"diff": "@@ -255,6 +255,17 @@ public static PackageMetadata FromNuspecReader(NuspecReader nuspecReader, bool s\n}\n}\n+ // Reject invalid package types.\n+ foreach (var packageType in nuspecReader.GetPackageTypes())\n+ {\n+ if (!NuGet.Packaging.PackageIdValidator.IsValidPackageId(packageType.Name))\n+ {\n+ throw new PackagingException(string.Format(\n+ CoreStrings.Manifest_InvalidPackageTypeName,\n+ packageType.Name));\n+ }\n+ }\n+\nreturn new PackageMetadata(\nnuspecReader.GetMetadata().ToDictionary(kvp => kvp.Key, kvp => kvp.Value),\nnuspecReader.GetDependencyGroups(useStrictVersionCheck: strict),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/ReflowPackageService.cs",
"new_path": "src/NuGetGallery/Services/ReflowPackageService.cs",
"diff": "@@ -64,6 +64,7 @@ public async Task<Package> ReflowAsync(string id, string version)\nClearSupportedFrameworks(package);\nClearAuthors(package);\nClearDependencies(package);\n+ ClearPackageTypes(package);\n// 4) Reflow the package\nvar listed = package.Listed;\n@@ -125,5 +126,14 @@ private void ClearDependencies(Package package)\n}\npackage.Dependencies.Clear();\n}\n+\n+ private void ClearPackageTypes(Package package)\n+ {\n+ foreach (var packageType in package.PackageTypes.ToList())\n+ {\n+ _entitiesContext.Set<PackageType>().Remove(packageType);\n+ }\n+ package.PackageTypes.Clear();\n+ }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Packaging/PackageMetadataFacts.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Packaging/PackageMetadataFacts.cs",
"diff": "@@ -90,6 +90,44 @@ public void RejectsEmptyBooleanValue(string name)\nAssert.Equal($\"The package manifest contains an invalid boolean value for metadata element: '{name}'. The value should be 'true' or 'false'.\", ex.Message);\n}\n+ [Theory]\n+ [InlineData(\"Bad package type\")]\n+ [InlineData(\"Bad--packageType\")]\n+ [InlineData(\"Bad..packageType\")]\n+ [InlineData(\"Bad!!packageType\")]\n+ public void RejectsInvalidPackageTypeName(string name)\n+ {\n+ // Arrange\n+ var packageStream = CreateTestPackageStreamWithPackageTypes(\"Dependency\", name);\n+ var nupkg = new PackageArchiveReader(packageStream, leaveStreamOpen: false);\n+ var nuspec = nupkg.GetNuspecReader();\n+\n+ // Act & Assert\n+ var ex = Assert.Throws<PackagingException>(() => PackageMetadata.FromNuspecReader(nuspec, strict: false));\n+ Assert.Equal($\"The package manifest contains an invalid package type name: '{name}'\", ex.Message);\n+ }\n+\n+ [Theory]\n+ [InlineData(\"goodpackagetype\")]\n+ [InlineData(\"GoodPackageType\")]\n+ [InlineData(\" GoodPackageType \")]\n+ [InlineData(\"good__packageType\")]\n+ public void RejectsValidPackageTypeName(string name)\n+ {\n+ // Arrange\n+ var packageStream = CreateTestPackageStreamWithPackageTypes(name);\n+ var nupkg = new PackageArchiveReader(packageStream, leaveStreamOpen: false);\n+ var nuspec = nupkg.GetNuspecReader();\n+\n+ // Act\n+ var metadata = PackageMetadata.FromNuspecReader(nuspec, strict: false);\n+\n+ // Assert\n+ var packageType = Assert.Single(metadata.GetPackageTypes());\n+ Assert.Equal(name.Trim(), packageType.Name);\n+ Assert.Equal(new Version(0, 0), packageType.Version);\n+ }\n+\n[Theory]\n[MemberData(nameof(RestrictedNameAndValueData))]\npublic void RejectsRestrictedElementNames(string name, string value)\n@@ -429,6 +467,24 @@ private static Stream CreateTestPackageStreamWithDuplicateEmptyAndNonEmptyMetada\n</package>\");\n}\n+ private static Stream CreateTestPackageStreamWithPackageTypes(params string[] packageTypes)\n+ {\n+ var packageTypeElements = packageTypes\n+ .Select(x => $\"<packageType name=\\\"{x}\\\" />\")\n+ .ToList();\n+\n+ return CreateTestPackageStream($@\"<?xml version=\"\"1.0\"\"?>\n+ <package xmlns=\"\"http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd\"\">\n+ <metadata>\n+ <id>TestPackage</id>\n+ <version>0.0.0.1</version>\n+ <packageTypes>\n+ {string.Join(string.Empty, packageTypeElements)}\n+ </packageTypes>\n+ </metadata>\n+ </package>\");\n+ }\n+\nprivate static Stream CreateTestPackageStream(string nuspec)\n{\nvar packageStream = new MemoryStream();\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/ReflowPackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/ReflowPackageServiceFacts.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n+using System.Collections.Generic;\nusing System.IO;\nusing System.IO.Compression;\nusing System.Threading.Tasks;\n@@ -119,10 +120,11 @@ public async Task RetrievesOriginalPackageMetadata()\n}\n[Fact]\n- public async Task RemovesOriginalFrameworks_Authors_Dependencies()\n+ public async Task RemovesOriginalChildEntities()\n{\n// Arrange\nvar package = PackageServiceUtility.CreateTestPackage();\n+ package.PackageTypes = new List<PackageType> { new PackageType { Name = \"Dependency\", Version = \"0.0\" } };\nvar packageService = SetupPackageService(package);\nvar entitiesContext = SetupEntitiesContext();\n@@ -393,6 +395,10 @@ private static Mock<IEntitiesContext> SetupEntitiesContext()\n.Setup(s => s.Set<PackageDependency>().Remove(It.IsAny<PackageDependency>()))\n.Verifiable();\n+ entitiesContext\n+ .Setup(s => s.Set<PackageType>().Remove(It.IsAny<PackageType>()))\n+ .Verifiable();\n+\nreturn entitiesContext;\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix two package type related bugs (#7782)
Clear previous package types during reflow: https://github.com/NuGet/NuGetGallery/issues/7780
Reject invalid package type names: https://github.com/NuGet/NuGetGallery/issues/7766 |
455,756 | 30.12.2019 11:28:21 | 28,800 | f4e8334447bc3816a06dbb76cf7a834ce95e2dff | Fix typo of emails | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Infrastructure/Mail/Messages/CredentialRevokedMessage.cs",
"new_path": "src/NuGetGallery.Core/Infrastructure/Mail/Messages/CredentialRevokedMessage.cs",
"diff": "@@ -52,7 +52,7 @@ protected override string GetMarkdownBody()\n{\nvar body = @\"Hi {0},\n-This is your friendly NuGet security bot! It appears that an API key {1}assoicated with your account was posted at {2}. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\n+This is your friendly NuGet security bot! It appears that an API key {1}associated with your account was posted at {2}. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\nYour key was found here: <{3}>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Infrastructure/Mail/Messages/CredentialRevokedMessageFacts.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Infrastructure/Mail/Messages/CredentialRevokedMessageFacts.cs",
"diff": "@@ -180,7 +180,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedMarkdownBodyWithCredentialDescription =\n@\"Hi requestingUser,\n-This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\n+This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\nYour key was found here: <TestLeakedUrl>\n@@ -201,7 +201,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedPlainTextBodyWithCredentialDescription =\n@\"Hi requestingUser,\n-This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\n+This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\nYour key was found here: <TestLeakedUrl>\n@@ -222,7 +222,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedHtmlBodyWithCredentialDescription =\n\"<p>Hi requestingUser,</p>\\n\" +\n-\"<p>This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.</p>\\n\" +\n+\"<p>This is your friendly NuGet security bot! It appears that an API key 'TestApiKey' associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.</p>\\n\" +\n\"<p>Your key was found here: <TestLeakedUrl></p>\\n\" +\n\"<p>In the future, please be mindful of accidentally posting your API keys publicly!</p>\\n\" +\n\"<p>You can regenerate this key or create a new one on the <a href=\\\"TestManageApiKeyUrl\\\">Manage API Keys</a> page.</p>\\n\" +\n@@ -239,7 +239,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedMarkdownBodyWithNullCredentialDescription =\n@\"Hi requestingUser,\n-This is your friendly NuGet security bot! It appears that an API key assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\n+This is your friendly NuGet security bot! It appears that an API key associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\nYour key was found here: <TestLeakedUrl>\n@@ -260,7 +260,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedPlainTextBodyWithNullCredentialDescription =\n@\"Hi requestingUser,\n-This is your friendly NuGet security bot! It appears that an API key assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\n+This is your friendly NuGet security bot! It appears that an API key associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.\nYour key was found here: <TestLeakedUrl>\n@@ -281,7 +281,7 @@ private static CredentialRevokedMessage CreateMessage(Credential credential)\nprivate const string _expectedHtmlBodyWithNullCredentialDescription =\n\"<p>Hi requestingUser,</p>\\n\" +\n-\"<p>This is your friendly NuGet security bot! It appears that an API key assoicated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.</p>\\n\" +\n+\"<p>This is your friendly NuGet security bot! It appears that an API key associated with your account was posted at TestRevocationSource. As a precautionary measure, we have revoked this key to protect your account and packages. Please review your packages for any unauthorized activity.</p>\\n\" +\n\"<p>Your key was found here: <TestLeakedUrl></p>\\n\" +\n\"<p>In the future, please be mindful of accidentally posting your API keys publicly!</p>\\n\" +\n\"<p>You can regenerate this key or create a new one on the <a href=\\\"TestManageApiKeyUrl\\\">Manage API Keys</a> page.</p>\\n\" +\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix typo of emails (#7793) |
455,781 | 08.01.2020 14:50:29 | 28,800 | 70bd1cccab34386e4831986d400298f652d66319 | use Json.Encode to avoid js injection | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"diff": "// Set up documentation section\nvar readMeModel = {\n\"Versions\": @Html.Raw(JsonConvert.SerializeObject(Model.VersionReadMeStateDictionary)),\n- \"Edit\": @Html.Raw(JsonConvert.SerializeObject(Model.ReadMe))\n+ \"Edit\": @Html.Raw(Json.Encode(Model.ReadMe))\n};\nvar readMeModelVersion = readMeModel.Versions['@Model.Version'];\nif (readMeModelVersion) {\n- readMeModelVersion.readMe = @Html.Raw(JsonConvert.SerializeObject(Model.ReadMe));\n+ readMeModelVersion.readMe = @Html.Raw(Json.Encode(Model.ReadMe));\n}\nEditReadMeManager.init(\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | use Json.Encode to avoid js injection |
455,744 | 08.01.2020 17:07:16 | 28,800 | 5267c95ee808fb5633f0f0569cb082401ca33378 | Build extensions targets file for build pipelines. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "</PropertyGroup>\n<Import Project=\"$(SignPath)\\sign.targets\" Condition=\"Exists('$(SignPath)\\sign.targets')\" />\n<Import Project=\"$(SignPath)\\sign.microbuild.targets\" Condition=\"Exists('$(SignPath)\\sign.microbuild.targets')\" />\n+ <Import Project=\"$(NuGetBuildExtensions)\" Condition=\"'$(NuGetBuildExtensions)' != '' And Exists('$(NuGetBuildExtensions)')\" />\n<Import Project=\"$(VSToolsPath)\\WebApplications\\Microsoft.WebApplication.targets\" Condition=\"'$(VSToolsPath)' != ''\" />\n<Import Project=\"$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v10.0\\WebApplications\\Microsoft.WebApplication.targets\" Condition=\"false\" />\n<Target Name=\"MvcBuildViews\" AfterTargets=\"AfterBuild\" Condition=\"'$(MvcBuildViews)'=='true'\">\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Build extensions targets file for build pipelines. (#7770) |
455,744 | 09.01.2020 15:02:15 | 28,800 | 6dc57effd8c2cd3c63014284c3db958ff201e983 | Functional test script update to wait for the service to start up after the deployment | [
{
"change_type": "MODIFY",
"old_path": "tests/Scripts/RunTestScripts.ps1",
"new_path": "tests/Scripts/RunTestScripts.ps1",
"diff": "@@ -13,6 +13,56 @@ Write-Host $fullDivider\n$failedTests = New-Object System.Collections.ArrayList\n+Function Wait-ForServiceStart($MaxWaitSeconds) {\n+ $configurationFile = $env:ConfigurationFilePath\n+ if ($null -eq $configurationFile) {\n+ Write-Error \"Configuration file path environment variable is not specified\"\n+ return $false;\n+ }\n+ if (-not (Test-Path $configurationFile)) {\n+ Write-Error \"Missing configuration file: $configurationFile\"\n+ return $false\n+ }\n+ $configuration = Get-Content $configurationFile | ConvertFrom-Json;\n+ if ($null -eq $configuration.Slot) {\n+ Write-Error \"`\"Slot`\" property was not found in the test configuration object: $configurationFile\"\n+ return $false\n+ }\n+ $baseUrlPropertyName = if ($configuration.Slot -eq \"staging\") { \"StagingBaseUrl\" } else { \"ProductionBaseUrl\" }\n+ if ($null -eq $configuration.$baseUrlPropertyName) {\n+ Write-Error \"`\"$($baseUrlPropertyName)`\" property was not found in the test configuration object: $configurationFile\"\n+ return $false\n+ }\n+\n+ $galleryUrl = $configuration.$baseUrlPropertyName\n+ $response = $null\n+ Write-Host \"$(Get-Date -Format s) Sleeping before querying the service\";\n+ Start-Sleep -Seconds 120\n+ Write-Host \"$(Get-Date -Format s) Waiting until service ($galleryUrl) responds with non-502\"\n+ $start = Get-Date\n+ $maxWait = New-TimeSpan -Seconds $MaxWaitSeconds\n+ do\n+ {\n+ if ($null -ne $response) {\n+ Start-Sleep -Seconds 5\n+ }\n+ $response = try { Invoke-WebRequest -Uri $galleryUrl -Method Get -UseBasicParsing } catch [System.Net.WebException] {$_.Exception.Response}\n+ if ($response.StatusCode -eq 502) {\n+ $elapsed = (Get-Date) - $start\n+ if ($elapsed -ge $maxWait) {\n+ Write-Error \"$(Get-Date -Format s) Service start timeout expired\"\n+ return $false\n+ } else {\n+ Write-Host \"$(Get-Date -Format s) Still waiting for the service to stop responding with 502 after $elapsed\"\n+ }\n+ } else {\n+ Write-Host \"$(Get-Date -Format s) Got a $($response.StatusCode) response\";\n+ }\n+ } while($response.StatusCode -eq 502)\n+\n+ return $true;\n+}\n+\nFunction Output-Job {\n[CmdletBinding()]\nparam(\n@@ -41,6 +91,11 @@ Function Output-Job {\nRemove-Job $job | Out-Host\n}\n+$serviceAvailable = Wait-ForServiceStart -MaxWaitSeconds 300\n+if (-not $serviceAvailable) {\n+ exit 1;\n+}\n+\n$finished = $false\n$TestCategoriesArray = $TestCategories.Split(';')\nWrite-Host \"Testing $($TestCategoriesArray -join \", \")\"\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Functional test script update to wait for the service to start up after the deployment (#7799) |
455,744 | 09.01.2020 16:24:50 | 28,800 | c59ced8e63dba5fb645b4e53a131bd65eafe95e5 | Minor app service related changes | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"new_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"diff": "using System.ComponentModel;\nusing System.ComponentModel.DataAnnotations;\nusing System.Configuration;\n+using System.Diagnostics;\nusing System.Globalization;\nusing System.Linq;\nusing System.Threading.Tasks;\n@@ -23,7 +24,7 @@ public class ConfigurationService : IGalleryConfigurationService\nprotected const string ServiceBusPrefix = \"AzureServiceBus.\";\nprotected const string PackageDeletePrefix = \"PackageDelete.\";\n- private bool _notInCloud;\n+ private bool _notInCloudService;\nprivate readonly Lazy<string> _httpSiteRootThunk;\nprivate readonly Lazy<string> _httpsSiteRootThunk;\nprivate readonly Lazy<IAppConfiguration> _lazyAppConfiguration;\n@@ -131,7 +132,7 @@ public string ReadRawSetting(string settingName)\n{\nstring value;\n- value = GetCloudSetting(settingName);\n+ value = GetCloudServiceSetting(settingName);\nif (value == \"null\")\n{\n@@ -171,10 +172,10 @@ private async Task<IPackageDeleteConfiguration> ResolvePackageDelete()\nreturn await ResolveConfigObject(new PackageDeleteConfiguration(), PackageDeletePrefix);\n}\n- protected virtual string GetCloudSetting(string settingName)\n+ protected virtual string GetCloudServiceSetting(string settingName)\n{\n// Short-circuit if we've already determined we're not in the cloud\n- if (_notInCloud)\n+ if (_notInCloudService)\n{\nreturn null;\n}\n@@ -188,13 +189,13 @@ protected virtual string GetCloudSetting(string settingName)\n}\nelse\n{\n- _notInCloud = true;\n+ _notInCloudService = true;\n}\n}\ncatch (TypeInitializationException)\n{\n// Not in the role environment...\n- _notInCloud = true; // Skip future checks to save perf\n+ _notInCloudService = true; // Skip future checks to save perf\n}\ncatch (Exception)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using NuGetGallery.Cookies;\nusing NuGetGallery.Diagnostics;\nusing NuGetGallery.Features;\n+using NuGetGallery.Helpers;\nusing NuGetGallery.Infrastructure;\nusing NuGetGallery.Infrastructure.Authentication;\nusing NuGetGallery.Infrastructure.Lucene;\n@@ -1362,15 +1363,7 @@ private static void ConfigureForAzureStorage(ContainerBuilder builder, IGalleryC\nprivate static IAuditingService GetAuditingServiceForAzureStorage(ContainerBuilder builder, IGalleryConfigurationService configuration)\n{\n- string instanceId;\n- try\n- {\n- instanceId = RoleEnvironment.CurrentRoleInstance.Id;\n- }\n- catch\n- {\n- instanceId = Environment.MachineName;\n- }\n+ string instanceId = HostMachine.Name;\nvar localIp = AuditActor.GetLocalIpAddressAsync().Result;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "</rule>\n</rules>\n</rewrite>\n+ <applicationInitialization>\n+ <add initializationPage=\"/\"/>\n+ <add initializationPage=\"/api/health-probe\"/>\n+ </applicationInitialization>\n</system.webServer>\n<system.serviceModel>\n<serviceHostingEnvironment aspNetCompatibilityEnabled=\"true\" multipleSiteBindingsEnabled=\"true\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/App_Start/ConfigurationServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/App_Start/ConfigurationServiceFacts.cs",
"diff": "@@ -121,7 +121,7 @@ protected override ConnectionStringSettings GetConnectionString(string settingNa\nreturn new ConnectionStringSettings(ConnectionStringStub, ConnectionStringStub);\n}\n- protected override string GetCloudSetting(string settingName)\n+ protected override string GetCloudServiceSetting(string settingName)\n{\nreturn CloudSettingStub;\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Minor app service related changes (#7803) |
455,747 | 14.01.2020 12:13:11 | 28,800 | 5d2380b2f2d9d35418074f2db2d98e9c1b27e2b0 | Add ussc preview to functional tests validation | [
{
"change_type": "MODIFY",
"old_path": "tests/Scripts/Import-Configuration.ps1",
"new_path": "tests/Scripts/Import-Configuration.ps1",
"diff": "@@ -7,7 +7,7 @@ param (\n[Parameter(Mandatory=$true)][string]$Branch = \"master\",\n[Parameter(Mandatory=$true)][ValidateSet(\"production\", \"staging\")][string]$Slot = \"production\",\n[Parameter(Mandatory=$true)][ValidateSet(\"Dev\", \"Int\", \"Prod\")][string]$Environment,\n- [Parameter(Mandatory=$true)][ValidateSet(\"USNC\", \"USSC\", \"USNC-PREVIEW\")][string]$Region\n+ [Parameter(Mandatory=$true)][ValidateSet(\"USNC\", \"USSC\", \"USNC-PREVIEW\", \"USSC-PREVIEW\")][string]$Region\n)\nWrite-Host \"Importing configuration for Gallery Functional tests on $Environment $Region\"\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add ussc preview to functional tests validation (#7804) |
455,759 | 16.01.2020 10:00:21 | -3,600 | c676fb6df6f76bb714832fd815bf23981623d45e | Upgrade ServerCommon and NuGet.Jobs dependencies to latest | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-dev-3341672</Version>\n+ <Version>4.3.0-dev-3383587</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3341672</Version>\n+ <Version>4.3.0-dev-3383587</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3341672</Version>\n+ <Version>4.3.0-dev-3383587</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3341672</Version>\n+ <Version>4.3.0-dev-3383587</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.64.0</Version>\n+ <Version>2.66.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Upgrade ServerCommon and NuGet.Jobs dependencies to latest (#7807) |
455,772 | 21.01.2020 19:24:53 | 18,000 | 8680f654ec6f9264929648a7fa01f4daf3af7fd4 | Reject packages with duplicate dependency groups | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageHelper.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageHelper.cs",
"diff": "@@ -171,6 +171,12 @@ public static void ValidateNuGetPackageMetadata(PackageMetadata packageMetadata)\n{\nthrow new EntityException(ServicesStrings.NuGetPackagePropertyTooLong, \"Dependencies\", Int16.MaxValue);\n}\n+\n+ // Verify there are no duplicate dependency groups\n+ if (packageDependencies.Select(pd => pd.TargetFramework).Distinct().Count() != packageDependencies.Count)\n+ {\n+ throw new EntityException(ServicesStrings.NuGetPackageDuplicateDependencyGroup);\n+ }\n}\n// Validate repository metadata\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesStrings.Designer.cs",
"new_path": "src/NuGetGallery.Services/ServicesStrings.Designer.cs",
"diff": "@@ -1246,6 +1246,15 @@ public class ServicesStrings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to A nuget package may not contain multiple dependency groups with the same target framework..\n+ /// </summary>\n+ public static string NuGetPackageDuplicateDependencyGroup {\n+ get {\n+ return ResourceManager.GetString(\"NuGetPackageDuplicateDependencyGroup\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to A nuget package's ID and version properties combined may not be more than {0} characters long..\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesStrings.resx",
"new_path": "src/NuGetGallery.Services/ServicesStrings.resx",
"diff": "@@ -1130,4 +1130,7 @@ The {1} Team</value>\n<data name=\"RevokeCredential_UnrevocableApiKeyCredential\" xml:space=\"preserve\">\n<value>The API key credential with Key '{0}' is not revocable.</value>\n</data>\n+ <data name=\"NuGetPackageDuplicateDependencyGroup\" xml:space=\"preserve\">\n+ <value>A nuget package may not contain multiple dependency groups with the same target framework.</value>\n+ </data>\n</root>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Helpers/PackageHelperTests.cs",
"new_path": "tests/NuGetGallery.Facts/Helpers/PackageHelperTests.cs",
"diff": "using System.Collections.Generic;\nusing System.Linq;\n+using NuGet.Frameworks;\nusing NuGet.Packaging;\nusing NuGet.Services.Entities;\n+using NuGet.Versioning;\nusing NuGetGallery.Packaging;\nusing Xunit;\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"diff": "@@ -651,6 +651,41 @@ private async Task WillThrowIfThePackageDependencyIdIsLongerThanMaxPackageIdLeng\nAssert.Equal(String.Format(Strings.NuGetPackagePropertyTooLong, \"Dependency.Id\", NuGet.Services.Entities.Constants.MaxPackageIdLength), ex.Message);\n}\n+ [Fact]\n+ private async Task WillThrowIfThePackageContainsDuplicateDependencyGroups()\n+ {\n+ var service = CreateService();\n+\n+ var duplicateDependencyGroup = new PackageDependencyGroup(\n+ new NuGetFramework(\"net40\"),\n+ new[]\n+ {\n+ new NuGet.Packaging.Core.PackageDependency(\n+ \"dependency\",\n+ VersionRange.Parse(\"[1.0.0, 2.0.0)\")),\n+ });\n+\n+ var packageDependencyGroups = new[]\n+ {\n+ duplicateDependencyGroup,\n+ new PackageDependencyGroup(\n+ new NuGetFramework(\"net35\"),\n+ new[]\n+ {\n+ new NuGet.Packaging.Core.PackageDependency(\n+ \"dependency\",\n+ VersionRange.Parse(\"[1.0]\"))\n+ }),\n+ duplicateDependencyGroup\n+ };\n+\n+ var nugetPackage = PackageServiceUtility.CreateNuGetPackage(packageDependencyGroups: packageDependencyGroups);\n+\n+ var ex = await Assert.ThrowsAsync<InvalidPackageException>(async () => await service.CreatePackageAsync(nugetPackage.Object, new PackageStreamMetadata(), owner: null, currentUser: null, isVerified: false));\n+\n+ Assert.Equal(ServicesStrings.NuGetPackageDuplicateDependencyGroup, ex.Message);\n+ }\n+\n[Fact]\nprivate async Task WillThrowIfThePackageDependencyVersionSpecIsLongerThan256()\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Reject packages with duplicate dependency groups (#7814) |
455,736 | 05.02.2020 17:06:46 | 28,800 | b876c52811035c4d4712e5058f71dd860b00c176 | Block versions that NuGet pack does not allow
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/CoreStrings.Designer.cs",
"new_path": "src/NuGetGallery.Core/CoreStrings.Designer.cs",
"diff": "@@ -195,6 +195,15 @@ public class CoreStrings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to The package manifest contains an invalid Dependency Version Range: '{0}'.\n+ /// </summary>\n+ public static string Manifest_InvalidDependencyVersionRange {\n+ get {\n+ return ResourceManager.GetString(\"Manifest_InvalidDependencyVersionRange\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to The package manifest contains an invalid ID: '{0}'.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/CoreStrings.resx",
"new_path": "src/NuGetGallery.Core/CoreStrings.resx",
"diff": "<value>The package manifest contains an invalid package type name: '{0}'</value>\n<comment>{0} is the package type name.</comment>\n</data>\n+ <data name=\"Manifest_InvalidDependencyVersionRange\" xml:space=\"preserve\">\n+ <value>The package manifest contains an invalid Dependency Version Range: '{0}'</value>\n+ <comment>{0} is the original dependency version range string.</comment>\n+ </data>\n</root>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Packaging/ManifestValidator.cs",
"new_path": "src/NuGetGallery.Core/Packaging/ManifestValidator.cs",
"diff": "@@ -145,6 +145,14 @@ private static IEnumerable<ValidationResult> ValidateCore(PackageMetadata packag\n}\n// Versions\n+ if (dependency.VersionRange.IsFloating)\n+ {\n+ yield return new ValidationResult(String.Format(\n+ CultureInfo.CurrentCulture,\n+ CoreStrings.Manifest_InvalidDependencyVersionRange,\n+ dependency.VersionRange.OriginalString));\n+ }\n+\nif (dependency.VersionRange.MinVersion != null)\n{\nvar versionRangeValidationResult =\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Core.Facts/Packaging/ManifestValidatorFacts.cs",
"new_path": "tests/NuGetGallery.Core.Facts/Packaging/ManifestValidatorFacts.cs",
"diff": "@@ -350,6 +350,20 @@ public class ManifestValidatorFacts\n</metadata>\n</package>\";\n+ private const string NuspecDependencyWithVersionRangeFormat = @\"<?xml version=\"\"1.0\"\"?>\n+ <package xmlns=\"\"http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd\"\">\n+ <metadata>\n+ <id>packageA</id>\n+ <version>1.0.1-alpha</version>\n+ <description>package A description.</description>\n+ <dependencies>\n+ <group targetFramework=\"\"net40\"\">\n+ <dependency id=\"\"SomeDependency\"\" version=\"\"{0}\"\" />\n+ </group>\n+ </dependencies>\n+ </metadata>\n+ </package>\";\n+\n[Fact]\npublic void ReturnsErrorIfIdNotPresent()\n{\n@@ -498,6 +512,22 @@ public void ReturnsErrorIfDependencySetContainsDuplicateDependency()\nAssert.Equal(new[] { String.Format(CoreStrings.Manifest_DuplicateDependency, \"net40\", \"SomeDependency\") }, GetErrors(nuspecStream));\n}\n+ [Theory]\n+ [InlineData(\"*\")]\n+ [InlineData(\"1.*\")]\n+ [InlineData(\"1.0.*\")]\n+ [InlineData(\"1.0.0.*\")]\n+ [InlineData(\"1.0.0-beta*\")]\n+ [InlineData(\"1.0.0-beta-*\")]\n+ [InlineData(\"1.0.0-beta.*\")]\n+ public void ReturnsErrorIfDependencyHasInvalidVersionRange(string versionRange)\n+ {\n+ var nuspec = string.Format(NuspecDependencyWithVersionRangeFormat, versionRange);\n+ var nuspecStream = CreateNuspecStream(nuspec);\n+\n+ Assert.Equal(new[] { string.Format(CoreStrings.Manifest_InvalidDependencyVersionRange, versionRange) }, GetErrors(nuspecStream));\n+ }\n+\n[Fact]\npublic void NoErrorIfFrameworkAssemblyReferenceContainsEmptyTargetFramework()\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Block versions that NuGet pack does not allow (#7838)
Address https://github.com/NuGet/NuGetGallery/issues/4973 |
455,736 | 05.02.2020 14:15:30 | 28,800 | 0799e8cd4a3769388b5eb0dd40ba72da10c51efc | Remove the SemVer 2.0.0 warnings from push and display packages
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesStrings.Designer.cs",
"new_path": "src/NuGetGallery.Services/ServicesStrings.Designer.cs",
"diff": "@@ -2958,15 +2958,6 @@ public class ServicesStrings {\n}\n}\n- /// <summary>\n- /// Looks up a localized string similar to This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3 and above. For more information, see https://go.microsoft.com/fwlink/?linkid=852248..\n- /// </summary>\n- public static string WarningSemVer2PackagePushed {\n- get {\n- return ResourceManager.GetString(\"WarningSemVer2PackagePushed\", resourceCulture);\n- }\n- }\n-\n/// <summary>\n/// Looks up a localized string similar to Yes.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesStrings.resx",
"new_path": "src/NuGetGallery.Services/ServicesStrings.resx",
"diff": "@@ -487,9 +487,6 @@ For more information, please contact '{2}'.</value>\n<data name=\"AzureActiveDirectory_RegisterMessage\" xml:space=\"preserve\">\n<value>Register with Azure Active Directory</value>\n</data>\n- <data name=\"WarningSemVer2PackagePushed\" xml:space=\"preserve\">\n- <value>This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3 and above. For more information, see https://go.microsoft.com/fwlink/?linkid=852248.</value>\n- </data>\n<data name=\"ReservedNamespace_InvalidCharactersInNamespace\" xml:space=\"preserve\">\n<value>The namespace '{0}' contains invalid characters. Examples of valid namespaces include 'MyNamespace', 'MyNamespace.' or 'MyNamespace-' etc.</value>\n</data>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Code/ViewHelpers.cshtml",
"new_path": "src/NuGetGallery/App_Code/ViewHelpers.cshtml",
"diff": "@Alert(htmlContent, \"danger\", \"ErrorBadge\", isAlertRole)\n}\n-@helper AlertIsSemVer2Package(bool hasSemVer2Version, bool hasSemVer2Dependency)\n-{\n- string warningHeader = null;\n- if (hasSemVer2Version)\n- {\n- warningHeader = \"This package has a SemVer 2.0.0 package version.\";\n- }\n- else if (hasSemVer2Dependency)\n- {\n- warningHeader = \"This package is considered a SemVer 2.0.0 package as it has a package dependency on SemVer 2.0.0 package(s).\";\n- }\n-\n- if (warningHeader != null)\n- {\n- @AlertWarning(\n- @<text>\n- @warningHeader<br />\n- <em>\n- This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual\n- Studio 2017 (version 15.3) and above or NuGet client 4.3.0 and above.\n- <a href=\"https://go.microsoft.com/fwlink/?linkid=852248\" alt=\"Read more\">Read more</a><br />\n- </em>\n- </text>\n- )\n- }\n-}\n-\n@helper AlertPasswordDeprecation()\n{\n@AlertWarning(\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/ApiController.cs",
"new_path": "src/NuGetGallery/Controllers/ApiController.cs",
"diff": "@@ -764,10 +764,6 @@ private async Task<ActionResult> CreatePackageInternal()\nvar warnings = new List<IValidationMessage>();\nwarnings.AddRange(beforeValidationResult.Warnings);\nwarnings.AddRange(afterValidationResult.Warnings);\n- if (package.SemVerLevelKey == SemVerLevelKey.SemVer2)\n- {\n- warnings.Add(new PlainTextOnlyValidationMessage(Strings.WarningSemVer2PackagePushed));\n- }\nreturn new HttpStatusCodeWithServerWarningResult(HttpStatusCode.Created, warnings);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Helpers/ViewModelExtensions/DisplayPackageViewModelFactory.cs",
"new_path": "src/NuGetGallery/Helpers/ViewModelExtensions/DisplayPackageViewModelFactory.cs",
"diff": "@@ -59,11 +59,6 @@ public DisplayPackageViewModelFactory(IIconUrlProvider iconUrlProvider)\nvar dependencies = package.Dependencies.ToList();\nviewModel.Dependencies = new DependencySetsViewModel(dependencies);\n- viewModel.HasSemVer2Version = viewModel.NuGetVersion.IsSemVer2;\n- viewModel.HasSemVer2Dependency = dependencies\n- .Where(pd => !string.IsNullOrEmpty(pd.VersionSpec))\n- .Select(pd => VersionRange.Parse(pd.VersionSpec))\n- .Any(p => (p.HasUpperBound && p.MaxVersion.IsSemVer2) || (p.HasLowerBound && p.MinVersion.IsSemVer2));\nvar packageHistory = allVersions\n.OrderByDescending(p => new NuGetVersion(p.Version))\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Helpers/ViewModelExtensions/PackageViewModelFactory.cs",
"new_path": "src/NuGetGallery/Helpers/ViewModelExtensions/PackageViewModelFactory.cs",
"diff": "@@ -34,7 +34,6 @@ public PackageViewModel Setup(PackageViewModel viewModel, Package package)\n}\nviewModel.FullVersion = NuGetVersionFormatter.ToFullString(package.Version);\n- viewModel.IsSemVer2 = package.SemVerLevelKey == SemVerLevelKey.SemVer2;\nviewModel.Id = package.PackageRegistration.Id;\nviewModel.Version = String.IsNullOrEmpty(package.NormalizedVersion) ?\n@@ -44,9 +43,7 @@ public PackageViewModel Setup(PackageViewModel viewModel, Package package)\nviewModel.Description = package.Description;\nviewModel.ReleaseNotes = package.ReleaseNotes;\nviewModel.IconUrl = _iconUrlProvider.GetIconUrlString(package);\n- viewModel.LatestVersion = package.IsLatest;\nviewModel.LatestVersionSemVer2 = package.IsLatestSemVer2;\n- viewModel.LatestStableVersion = package.IsLatestStable;\nviewModel.LatestStableVersionSemVer2 = package.IsLatestStableSemVer2;\nviewModel.DevelopmentDependency = package.DevelopmentDependency;\nviewModel.LastUpdated = package.Published;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/RequestModels/VerifyPackageRequest.cs",
"new_path": "src/NuGetGallery/RequestModels/VerifyPackageRequest.cs",
"diff": "@@ -21,10 +21,6 @@ public VerifyPackageRequest(PackageMetadata packageMetadata, IEnumerable<User> p\nId = packageMetadata.Id;\nVersion = packageMetadata.Version.ToFullStringSafe();\nOriginalVersion = packageMetadata.Version.OriginalVersion;\n- HasSemVer2Version = packageMetadata.Version.IsSemVer2;\n- HasSemVer2Dependency = packageMetadata.GetDependencyGroups().Any(d => d.Packages.Any(\n- p => (p.VersionRange.HasUpperBound && p.VersionRange.MaxVersion.IsSemVer2)\n- || (p.VersionRange.HasLowerBound && p.VersionRange.MinVersion.IsSemVer2)));\n// Verifiable fields\nLanguage = packageMetadata.Language;\n@@ -92,10 +88,6 @@ public VerifyPackageRequest(PackageMetadata packageMetadata, IEnumerable<User> p\n/// </summary>\npublic IReadOnlyCollection<string> PossibleOwners { get; set; }\n- public bool IsSemVer2 => HasSemVer2Version || HasSemVer2Dependency;\n- public bool HasSemVer2Version { get; set; }\n- public bool HasSemVer2Dependency { get; set; }\n-\n// Editable server-state\npublic bool Listed { get; set; }\npublic EditPackageVersionReadMeRequest Edit { get; set; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.Designer.cs",
"new_path": "src/NuGetGallery/Strings.Designer.cs",
"diff": "@@ -3021,15 +3021,6 @@ public class Strings {\n}\n}\n- /// <summary>\n- /// Looks up a localized string similar to This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3 and above. For more information, see https://go.microsoft.com/fwlink/?linkid=852248..\n- /// </summary>\n- public static string WarningSemVer2PackagePushed {\n- get {\n- return ResourceManager.GetString(\"WarningSemVer2PackagePushed\", resourceCulture);\n- }\n- }\n-\n/// <summary>\n/// Looks up a localized string similar to Yes.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.resx",
"new_path": "src/NuGetGallery/Strings.resx",
"diff": "@@ -487,9 +487,6 @@ For more information, please contact '{2}'.</value>\n<data name=\"AzureActiveDirectory_RegisterMessage\" xml:space=\"preserve\">\n<value>Register with Azure Active Directory</value>\n</data>\n- <data name=\"WarningSemVer2PackagePushed\" xml:space=\"preserve\">\n- <value>This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual Studio 2017 (version 15.3) and above or NuGet client 4.3 and above. For more information, see https://go.microsoft.com/fwlink/?linkid=852248.</value>\n- </data>\n<data name=\"ReservedNamespace_InvalidCharactersInNamespace\" xml:space=\"preserve\">\n<value>The namespace '{0}' contains invalid characters. Examples of valid namespaces include 'MyNamespace', 'MyNamespace.' or 'MyNamespace-' etc.</value>\n</data>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/DisplayPackageViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/DisplayPackageViewModel.cs",
"diff": "@@ -29,8 +29,6 @@ public class DisplayPackageViewModel : ListPackageItemViewModel\npublic SymbolPackage LatestSymbolsPackage { get; set; }\npublic SymbolPackage LatestAvailableSymbolsPackage { get; set; }\n- public bool HasSemVer2Version { get; set; }\n- public bool HasSemVer2Dependency { get; set; }\npublic bool IsDotnetToolPackageType { get; set; }\npublic bool IsDotnetNewTemplatePackageType { get; set; }\npublic bool IsAtomFeedEnabled { get; set; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/ListPackageItemViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/ListPackageItemViewModel.cs",
"diff": "@@ -44,8 +44,7 @@ public bool UseVersion\n{\n// only use the version in URLs when necessary. This would happen when the latest version is not the\n// same as the latest stable version.\n- return !(!IsSemVer2 && LatestVersion && LatestStableVersion)\n- && !(IsSemVer2 && LatestStableVersionSemVer2 && LatestVersionSemVer2);\n+ return !(LatestStableVersionSemVer2 && LatestVersionSemVer2);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/PackageViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/PackageViewModel.cs",
"diff": "@@ -11,8 +11,6 @@ public class PackageViewModel : IPackageVersionModel\npublic string ReleaseNotes { get; set; }\npublic string IconUrl { get; set; }\npublic DateTime LastUpdated { get; set; }\n- public bool LatestVersion { get; set; }\n- public bool LatestStableVersion { get; set; }\npublic bool LatestVersionSemVer2 { get; set; }\npublic bool LatestStableVersionSemVer2 { get; set; }\npublic bool DevelopmentDependency { get; set; }\n@@ -27,7 +25,6 @@ public class PackageViewModel : IPackageVersionModel\npublic string Id { get; set; }\npublic string Version { get; set; }\npublic string FullVersion { get; set; }\n- public bool IsSemVer2 { get; set; }\npublic PackageStatusSummary PackageStatusSummary { get; set; }\npublic bool IsCurrent(IPackageVersionModel current)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"diff": ")\n}\n- @if (Model.IsSemVer2)\n- {\n- @ViewHelpers.AlertIsSemVer2Package(Model.HasSemVer2Version, Model.HasSemVer2Dependency)\n- }\n-\n@if (Model.CanDisplayPrivateMetadata && showSymbolsPackageStatus)\n{\nif (Model.LatestSymbolsPackage.StatusKey == PackageStatus.Validating)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/_VerifyMetadata.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/_VerifyMetadata.cshtml",
"diff": "<!-- /ko -->\n<!-- /ko -->\n</div>\n-\n- <!-- ko if: $data.IsSemVer2 -->\n- @ViewHelpers.AlertWarning(@<text>\n- <!-- ko if: $data.HasSemVer2Version -->\n- This package has a SemVer 2.0.0 package version.<br />\n- <!-- /ko -->\n- <!-- ko if: !$data.HasSemVer2Version && $data.HasSemVer2Dependency -->\n- This package is considered a SemVer 2.0.0 package as it has a package dependency on SemVer 2.0.0 package(s).<br />\n- <!-- /ko -->\n- <em>\n- This package will only be available to download with SemVer 2.0.0 compatible NuGet clients, such as Visual\n- Studio 2017 (version 15.3) and above or NuGet client 4.3.0 and above.\n- <a href=\"https://go.microsoft.com/fwlink/?linkid=852248\" alt=\"Read more\">Read more</a><br />\n- </em>\n- </text>)\n- <!-- /ko -->\n</div>\n</script>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs",
"new_path": "tests/NuGetGallery.Facts/ViewModels/DisplayPackageViewModelFacts.cs",
"diff": "@@ -549,85 +549,6 @@ public void HasNewerReleaseDoesNotConsiderUnlistedVersions()\nAssert.False(hasNewerRelease);\n}\n- [Theory]\n- [InlineData(null)]\n- [InlineData(\"\")]\n- public void HasSemVer2DependencyIsFalseWhenInvalidDependencyVersionRange(string versionSpec)\n- {\n- // Arrange\n- var package = CreateTestPackage(\"1.0.0\", dependencyVersion: versionSpec);\n-\n- // Act\n- var viewModel = CreateDisplayPackageViewModel(package, currentUser: null, packageKeyToDeprecation: null, readmeHtml: null);\n-\n- // Assert\n- Assert.False(viewModel.HasSemVer2Dependency);\n- }\n-\n- [Theory]\n- [InlineData(\"2.0.0-alpha.1\")]\n- [InlineData(\"2.0.0+metadata\")]\n- [InlineData(\"2.0.0-alpha+metadata\")]\n- public void HasSemVer2DependencyWhenSemVer2DependencyVersionSpec(string versionSpec)\n- {\n- // Arrange\n- var package = CreateTestPackage(\"1.0.0\", dependencyVersion: versionSpec);\n-\n- // Act\n- var viewModel = CreateDisplayPackageViewModel(package, currentUser: null, packageKeyToDeprecation: null, readmeHtml: null);\n-\n- // Assert\n- Assert.True(viewModel.HasSemVer2Dependency);\n- }\n-\n- [Theory]\n- [InlineData(\"2.0.0-alpha\")]\n- [InlineData(\"2.0.0\")]\n- [InlineData(\"2.0.0.0\")]\n- public void HasSemVer2DependencyIsFalseWhenNonSemVer2DependencyVersionSpec(string versionSpec)\n- {\n- // Arrange\n- var package = CreateTestPackage(\"1.0.0\", dependencyVersion: versionSpec);\n-\n- // Act\n- var viewModel = CreateDisplayPackageViewModel(package, currentUser: null, packageKeyToDeprecation: null, readmeHtml: null);\n-\n- // Assert\n- Assert.False(viewModel.HasSemVer2Dependency);\n- }\n-\n- [Theory]\n- [InlineData(\"2.0.0-alpha\")]\n- [InlineData(\"2.0.0\")]\n- [InlineData(\"2.0.0.0\")]\n- public void HasSemVer2VersionIsFalseWhenNonSemVer2Version(string version)\n- {\n- // Arrange\n- var package = CreateTestPackage(version);\n-\n- // Act\n- var viewModel = CreateDisplayPackageViewModel(package, currentUser: null, packageKeyToDeprecation: null, readmeHtml: null);\n-\n- // Assert\n- Assert.False(viewModel.HasSemVer2Version);\n- }\n-\n- [Theory]\n- [InlineData(\"2.0.0-alpha.1\")]\n- [InlineData(\"2.0.0+metadata\")]\n- [InlineData(\"2.0.0-alpha+metadata\")]\n- public void HasSemVer2VersionIsTrueWhenSemVer2Version(string version)\n- {\n- // Arrange\n- var package = CreateTestPackage(version);\n-\n- // Act\n- var viewModel = CreateDisplayPackageViewModel(package, currentUser: null, packageKeyToDeprecation: null, readmeHtml: null);\n-\n- // Assert\n- Assert.True(viewModel.HasSemVer2Version);\n- }\n-\nprivate Package CreateTestPackage(string version, string dependencyVersion = null)\n{\nvar package = new Package\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/ViewModels/ListPackageItemViewModelFacts.cs",
"new_path": "tests/NuGetGallery.Facts/ViewModels/ListPackageItemViewModelFacts.cs",
"diff": "@@ -167,33 +167,6 @@ public void AuthorsIsFlattenedAuthors()\nAssert.Equal(flattenedAuthors, listPackageItemViewModel.Authors);\n}\n- [Fact]\n- public void UseVersionIfLatestAndStableNotSame()\n- {\n- var package = new Package()\n- {\n- Version = \"1.0.0\",\n- PackageRegistration = new PackageRegistration { Id = \"SomeId\" },\n- IsLatest = true,\n- IsLatestStable = false\n- };\n-\n- var listPackageItemViewModel = CreateListPackageItemViewModel(package);\n- Assert.True(listPackageItemViewModel.UseVersion);\n-\n- listPackageItemViewModel.LatestVersion = false;\n- listPackageItemViewModel.LatestStableVersion = true;\n- Assert.True(listPackageItemViewModel.UseVersion);\n-\n- listPackageItemViewModel.LatestVersion = false;\n- listPackageItemViewModel.LatestStableVersion = false;\n- Assert.True(listPackageItemViewModel.UseVersion);\n-\n- listPackageItemViewModel.LatestVersion = true;\n- listPackageItemViewModel.LatestStableVersion = true;\n- Assert.False(listPackageItemViewModel.UseVersion);\n- }\n-\n[Fact]\npublic void UseVersionIfLatestSemVer2AndStableSemVer2NotSame()\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Remove the SemVer 2.0.0 warnings from push and display packages (#7837)
Address https://github.com/NuGet/NuGetGallery/issues/7836 |
455,736 | 06.02.2020 14:03:04 | 28,800 | 7ef040b3493efd273354e1e1b20386db142bf958 | Enable using managed identities for KeyVault
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-dev-3383587</Version>\n+ <Version>4.3.0-dev-3453620</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>\n<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n- <PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3383587</Version>\n- </PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3383587</Version>\n+ <Version>4.3.0-dev-3453620</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3383587</Version>\n+ <Version>4.3.0-dev-3453620</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/SecretReader/SecretReaderFactory.cs",
"new_path": "src/NuGetGallery.Services/Configuration/SecretReader/SecretReaderFactory.cs",
"diff": "@@ -11,6 +11,7 @@ namespace NuGetGallery.Configuration.SecretReader\npublic class SecretReaderFactory : ISecretReaderFactory\n{\ninternal const string KeyVaultConfigurationPrefix = \"KeyVault.\";\n+ internal const string UseManagedIdentityConfigurationKey = \"UseManagedIdentity\";\ninternal const string VaultNameConfigurationKey = \"VaultName\";\ninternal const string ClientIdConfigurationKey = \"ClientId\";\ninternal const string CertificateThumbprintConfigurationKey = \"CertificateThumbprint\";\n@@ -45,14 +46,23 @@ public ISecretReader CreateSecretReader()\nvar vaultName = _configurationService.ReadRawSetting(ResolveKeyVaultSettingName(VaultNameConfigurationKey));\nif (!string.IsNullOrEmpty(vaultName))\n+ {\n+ var useManagedIdentity = GetOptionalKeyVaultBoolSettingValue(UseManagedIdentityConfigurationKey, defaultValue: false);\n+\n+ KeyVaultConfiguration keyVaultConfiguration;\n+ if (useManagedIdentity)\n+ {\n+ keyVaultConfiguration = new KeyVaultConfiguration(vaultName);\n+ }\n+ else\n{\nvar clientId = _configurationService.ReadRawSetting(ResolveKeyVaultSettingName(ClientIdConfigurationKey));\nvar certificateThumbprint = _configurationService.ReadRawSetting(ResolveKeyVaultSettingName(CertificateThumbprintConfigurationKey));\nvar storeName = GetOptionalKeyVaultEnumSettingValue(CertificateStoreName, StoreName.My);\nvar storeLocation = GetOptionalKeyVaultEnumSettingValue(CertificateStoreLocation, StoreLocation.LocalMachine);\nvar certificate = CertificateUtility.FindCertificateByThumbprint(storeName, storeLocation, certificateThumbprint, validationRequired: true);\n-\n- var keyVaultConfiguration = new KeyVaultConfiguration(vaultName, clientId, certificate);\n+ keyVaultConfiguration = new KeyVaultConfiguration(vaultName, clientId, certificate);\n+ }\nsecretReader = new KeyVaultReader(keyVaultConfiguration);\n}\n@@ -64,6 +74,17 @@ public ISecretReader CreateSecretReader()\nreturn new CachingSecretReader(secretReader);\n}\n+ private bool GetOptionalKeyVaultBoolSettingValue(string settingName, bool defaultValue)\n+ {\n+ var settingValueStr = _configurationService.ReadRawSetting(ResolveKeyVaultSettingName(settingName));\n+ if (!bool.TryParse(settingValueStr, out var settingValue))\n+ {\n+ return defaultValue;\n+ }\n+\n+ return settingValue;\n+ }\n+\nprivate TEnum GetOptionalKeyVaultEnumSettingValue<TEnum>(string settingName, TEnum defaultValue)\nwhere TEnum: struct\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.67.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.66.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.67.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.67.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.67.0</Version>\n+ <Version>2.68.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Enable using managed identities for KeyVault (#7840)
Progress on https://github.com/NuGet/Engineering/issues/2970 |
455,747 | 10.02.2020 16:12:11 | 28,800 | b18a543faa3c7603d2e2a864ae241ad1e8612bc7 | Nit fix to add empty config for managed identity | [
{
"change_type": "MODIFY",
"old_path": "src/GalleryTools/App.config",
"new_path": "src/GalleryTools/App.config",
"diff": "<!-- KeyVault configuration to fetch secrets. -->\n<add key=\"KeyVault.VaultName\" value=\"\"/>\n+ <add key=\"KeyVault.UseManagedIdentity\" value=\"\"/>\n<add key=\"KeyVault.ClientId\" value=\"\"/>\n<add key=\"KeyVault.CertificateThumbprint\" value=\"\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<!-- KeyVault settings. -->\n<!-- ***************** -->\n<add key=\"KeyVault.VaultName\" value=\"\"/>\n+ <add key=\"KeyVault.UseManagedIdentity\" value=\"\"/>\n<add key=\"KeyVault.ClientId\" value=\"\"/>\n<add key=\"KeyVault.CertificateThumbprint\" value=\"\"/>\n<!-- *********************** -->\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Nit fix to add empty config for managed identity (#7841) |
455,736 | 13.02.2020 13:58:30 | 28,800 | 778cb52e20d8d0c0c89165fbe4a3af95d17d83b3 | Sign Owin.dll | [
{
"change_type": "MODIFY",
"old_path": "sign.thirdparty.props",
"new_path": "sign.thirdparty.props",
"diff": "<ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.dll\" />\n<ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.NetStd.dll\" />\n<ThirdPartyBinaries Include=\"Newtonsoft.Json.dll\" />\n+ <ThirdPartyBinaries Include=\"Owin.dll\" />\n<ThirdPartyBinaries Include=\"Polly.dll\" />\n<ThirdPartyBinaries Include=\"Polly.Extensions.Http.dll\" />\n<ThirdPartyBinaries Include=\"QueryInterceptor.dll\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Sign Owin.dll (#7845) |
455,744 | 13.02.2020 19:23:35 | 28,800 | f75e20299af1d9ed8e778a3fd988809d62da2521 | Removed some hot path logs
* Removed logging in hot path.
Fixed the ResilientSearchHttpClient constructor exceptions.
* Build fix | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "@@ -1138,7 +1138,6 @@ private static List<(string name, Uri searchUri)> GetPreviewSearchClientsFromCon\nreturn new ResilientSearchHttpClient(\nhttpClientWrappers,\n- c.Resolve<ILogger<ResilientSearchHttpClient>>(),\nc.Resolve<ITelemetryService>());\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Infrastructure/Lucene/ResilientSearchHttpClient.cs",
"new_path": "src/NuGetGallery/Infrastructure/Lucene/ResilientSearchHttpClient.cs",
"diff": "@@ -16,14 +16,12 @@ namespace NuGetGallery.Infrastructure.Search\npublic class ResilientSearchHttpClient : IResilientSearchClient\n{\nprivate readonly IEnumerable<IHttpClientWrapper> _httpClients;\n- private readonly ILogger _logger;\nprivate readonly ITelemetryService _telemetryService;\n- public ResilientSearchHttpClient(IEnumerable<IHttpClientWrapper> searchClients, ILogger<ResilientSearchHttpClient> logger, ITelemetryService telemetryService)\n+ public ResilientSearchHttpClient(IEnumerable<IHttpClientWrapper> searchClients, ITelemetryService telemetryService)\n{\n- _httpClients = searchClients ?? throw new ArgumentNullException(nameof(logger));\n- _logger = logger ?? throw new ArgumentNullException(nameof(logger));\n- _telemetryService = telemetryService ?? throw new ArgumentNullException(nameof(logger));\n+ _httpClients = searchClients ?? throw new ArgumentNullException(nameof(searchClients));\n+ _telemetryService = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));\n}\npublic async Task<HttpResponseMessage> GetAsync(string path, string queryString)\n@@ -33,7 +31,6 @@ public async Task<HttpResponseMessage> GetAsync(string path, string queryString)\nforeach(var client in _httpClients)\n{\nsearchUri = client.BaseAddress.AppendPathToUri(path, queryString);\n- _logger.LogInformation(\"Sent GetAsync request for {Url}\", searchUri.AbsoluteUri);\nvar result = await client.GetAsync(searchUri);\nif (result.IsSuccessStatusCode)\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Infrastructure/Lucene/ResilientSearchServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Infrastructure/Lucene/ResilientSearchServiceFacts.cs",
"diff": "@@ -123,7 +123,7 @@ private static ILogger<ResilientSearchHttpClient> GetLogger()\nmockISearchHttpClient2.Setup(x => x.GetAsync(It.IsAny<Uri>())).ReturnsAsync(getAsyncResultMessage2);\nList<IHttpClientWrapper> clients = new List<IHttpClientWrapper>() { mockISearchHttpClient1.Object, mockISearchHttpClient2.Object };\n- return new ResilientSearchHttpClient(clients, GetLogger(), mockTelemetryService.Object);\n+ return new ResilientSearchHttpClient(clients, mockTelemetryService.Object);\n}\nprivate static HttpResponseMessage GetResponseMessage(Uri uri, HttpStatusCode statusCode)\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Queries/AutocompleteServicePackageIdsQueryFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Queries/AutocompleteServicePackageIdsQueryFacts.cs",
"diff": "@@ -44,7 +44,7 @@ private IResilientSearchClient GetResilientSearchClient()\n{\nBaseAddress = new Uri(\"https://example\")\n}));\n- return new ResilientSearchHttpClient(clients, GetLogger(), mockTelemetryService.Object);\n+ return new ResilientSearchHttpClient(clients, mockTelemetryService.Object);\n}\n[Fact]\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Queries/AutocompleteServicePackageVersionsQueryFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Queries/AutocompleteServicePackageVersionsQueryFacts.cs",
"diff": "@@ -45,7 +45,7 @@ private IResilientSearchClient GetResilientSearchClient()\n{\nBaseAddress = new Uri(\"https://example\")\n}));\n- return new ResilientSearchHttpClient(clients, GetLogger(), mockTelemetryService.Object);\n+ return new ResilientSearchHttpClient(clients, mockTelemetryService.Object);\n}\n[Fact]\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Removed some hot path logs (#7846)
* Removed logging in hot path.
Fixed the ResilientSearchHttpClient constructor exceptions.
* Build fix |
455,747 | 21.02.2020 14:37:41 | 28,800 | 2a8ab4b70c7fdcae9ffd637192515b40e02d78f0 | [HOTFIX] Fix GalleryAccount deleter job DI issue | [
{
"change_type": "MODIFY",
"old_path": "sign.thirdparty.props",
"new_path": "sign.thirdparty.props",
"diff": "<ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.dll\" />\n<ThirdPartyBinaries Include=\"Microsoft.CookieCompliance.NetStd.dll\" />\n<ThirdPartyBinaries Include=\"Newtonsoft.Json.dll\" />\n+ <ThirdPartyBinaries Include=\"Owin.dll\" />\n<ThirdPartyBinaries Include=\"Polly.dll\" />\n<ThirdPartyBinaries Include=\"Polly.Extensions.Http.dll\" />\n<ThirdPartyBinaries Include=\"QueryInterceptor.dll\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/Job.cs",
"new_path": "src/AccountDeleter/Job.cs",
"diff": "@@ -127,6 +127,7 @@ protected void ConfigureGalleryServices(IServiceCollection services)\nservices.AddScoped<IUserService, AccountDeleteUserService>();\nservices.AddScoped<IDiagnosticsService, DiagnosticsService>();\n+ services.AddScoped<IDiagnosticsSource>(ds => new TraceDiagnosticsSource(nameof(TelemetryService), ds.GetRequiredService<ITelemetryClient>()));\nservices.AddScoped<IPackageService, PackageService>();\nservices.AddScoped<IPackageUpdateService, PackageUpdateService>();\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | [HOTFIX] Fix GalleryAccount deleter job DI issue (#7851) |
455,736 | 27.02.2020 16:42:21 | 28,800 | 9dab14db4e8d65e743f07c8e7da74c0108a01141 | Initialize cookie compliance service during startup
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using System.Net.Http;\nusing System.Net.Mail;\nusing System.Security.Principal;\n+using System.Threading;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Hosting;\nusing Elmah;\nusing Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.ApplicationInsights.Extensibility.Implementation;\n-using Microsoft.AspNet.TelemetryCorrelation;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Http;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n-using Microsoft.WindowsAzure.Storage;\nusing NuGet.Services.Entities;\nusing NuGet.Services.FeatureFlags;\nusing NuGet.Services.KeyVault;\n@@ -1434,9 +1433,11 @@ private static void RegisterCookieComplianceService(ContainerBuilder builder, Co\nif (configuration.Current.IsHosted)\n{\n- // Initialize the service on App_Start to avoid any performance degradation during initial requests.\nvar siteName = configuration.GetSiteRoot(true);\n- HostingEnvironment.QueueBackgroundWorkItem(async cancellationToken => await service.InitializeAsync(siteName, diagnostics, cancellationToken));\n+\n+ // We must initialize during app start so that the cookie compliance service is ready when the first\n+ // request comes in.\n+ service.InitializeAsync(siteName, diagnostics, CancellationToken.None).Wait();\n}\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Initialize cookie compliance service during startup (#7856)
Progress on https://github.com/NuGet/Engineering/issues/2980 |
455,756 | 03.03.2020 18:14:12 | 28,800 | 891af3544dfecceadbf6088d2e9bcaf82bd6e1b1 | Trigger the active update of SQL certificates | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"new_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"diff": "@@ -31,6 +31,11 @@ public class ConfigurationService : IGalleryConfigurationService\nprivate readonly Lazy<FeatureConfiguration> _lazyFeatureConfiguration;\nprivate readonly Lazy<IServiceBusConfiguration> _lazyServiceBusConfiguration;\nprivate readonly Lazy<IPackageDeleteConfiguration> _lazyPackageDeleteConfiguration;\n+ private readonly HashSet<string> _NotInjectedSettingNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase) {\n+ SettingPrefix + \"SqlServer\",\n+ SettingPrefix + \"SqlServerReadOnlyReplica\",\n+ SettingPrefix + \"SupportRequestSqlServer\",\n+ SettingPrefix + \"ValidationSqlServer\" };\npublic ISecretInjector SecretInjector { get; set; }\n@@ -120,7 +125,7 @@ public async Task<string> ReadSettingAsync(string settingName)\n{\nvar value = ReadRawSetting(settingName);\n- if (!string.IsNullOrEmpty(value))\n+ if (!string.IsNullOrEmpty(value) && !_NotInjectedSettingNames.Contains(settingName))\n{\nvalue = await SecretInjector.InjectAsync(value);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/App_Start/ConfigurationServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/App_Start/ConfigurationServiceFacts.cs",
"diff": "@@ -187,6 +187,33 @@ public async Task WhenSettingIsNotEmptySecretInjectorIsRan()\n// Assert\nAssert.Equal(\"somevalueparsed\", result);\n}\n+\n+ [Theory]\n+ [InlineData(\"Gallery.SqlServer\")]\n+ [InlineData(\"Gallery.SqlServerReadOnlyReplica\")]\n+ [InlineData(\"Gallery.SupportRequestSqlServer\")]\n+ [InlineData(\"Gallery.ValidationSqlServer\")]\n+ [InlineData(\"Gallery.sqlserver\")]\n+ [InlineData(\"Gallery.sqlserverreadonlyreplica\")]\n+ [InlineData(\"Gallery.supportrequestsqlserver\")]\n+ [InlineData(\"Gallery.validationsqlserver\")]\n+ public async Task GivenNotInjectedSettingNameSecretInjectorIsNotRan(string settingName)\n+ {\n+ // Arrange\n+ var secretInjectorMock = new Mock<ISecretInjector>();\n+ secretInjectorMock.Setup(x => x.InjectAsync(It.IsAny<string>()))\n+ .Returns<string>(s => Task.FromResult(s + \"parsed\"));\n+\n+ var configurationService = new TestableConfigurationService(secretInjectorMock.Object);\n+ configurationService.CloudSettingStub = \"somevalue\";\n+\n+ // Act\n+ string result = await configurationService.ReadSettingAsync(settingName);\n+\n+ // Assert\n+ secretInjectorMock.Verify(x => x.InjectAsync(It.IsAny<string>()), Times.Never);\n+ Assert.Equal(\"somevalue\", result);\n+ }\n}\n}\n}\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Trigger the active update of SQL certificates |
455,756 | 04.03.2020 22:17:14 | 28,800 | d855bce6772b4d747fe92ecb8126a0b790deb628 | Update server common dependencies | [
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<Version>4.3.0-dev-3453620</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>2.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.68.0</Version>\n+ <Version>2.69.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Update server common dependencies (#7860) |
455,736 | 04.03.2020 16:46:50 | 28,800 | 779ef3f637a222e046cba030930cdcabe89c77cb | Reject broken ZIPs on API push with better message
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/ApiController.cs",
"new_path": "src/NuGetGallery/Controllers/ApiController.cs",
"diff": "@@ -549,7 +549,21 @@ private async Task<ActionResult> CreatePackageInternal()\nStrings.PackageEntryFromTheFuture,\nentryInTheFuture.Name));\n}\n+ }\n+ catch (Exception ex)\n+ {\n+ // This is not very elegant to catch every Exception type here. However, the types of exceptions\n+ // that could be thrown when reading a garbage ZIP is undocumented. We've seen ArgumentOutOfRangeException\n+ // get thrown from HttpInputStream and InvalidDataException thrown from ZipArchive.\n+ ex.Log();\n+\n+ return new HttpStatusCodeWithBodyResult(HttpStatusCode.BadRequest, string.Format(\n+ CultureInfo.CurrentCulture,\n+ Strings.FailedToReadUploadFile));\n+ }\n+ try\n+ {\nusing (var packageToPush = new PackageArchiveReader(packageStream, leaveStreamOpen: false))\n{\ntry\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -396,6 +396,9 @@ public virtual async Task<JsonResult> UploadPackage(HttpPostedFileBase uploadFil\n}\ncatch (Exception ex)\n{\n+ // This is not very elegant to catch every Exception type here. However, the types of exceptions\n+ // that could be thrown when reading a garbage ZIP is undocumented. We've seen ArgumentOutOfRangeException\n+ // get thrown from HttpInputStream and InvalidDataException thrown from ZipArchive.\nreturn FailedToReadFile(ex);\n}\nfinally\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"diff": "@@ -696,6 +696,25 @@ public async Task CreatePackageReturns400IfEnsureValidThrowsExceptionMessage(Typ\nAssert.Equal(expectExceptionMessageInResponse ? EnsureValidExceptionMessage : Strings.FailedToReadUploadFile, (result as HttpStatusCodeWithBodyResult).StatusDescription);\n}\n+ [Fact]\n+ public async Task WillRejectBrokenZipFiles()\n+ {\n+ // Arrange\n+ var package = new MemoryStream(TestDataResourceUtility.GetResourceBytes(\"Zip64Package.Corrupted.1.0.0.nupkg\"));\n+\n+ var user = new User() { EmailAddress = \"[email protected]\" };\n+ var controller = new TestableApiController(GetConfigurationService());\n+ controller.SetCurrentUser(user);\n+ controller.SetupPackageFromInputStream(package);\n+\n+ // Act\n+ ActionResult result = await controller.CreatePackagePut();\n+\n+ // Assert\n+ ResultAssert.IsStatusCode(result, HttpStatusCode.BadRequest);\n+ Assert.Equal(Strings.FailedToReadUploadFile, (result as HttpStatusCodeWithBodyResult).StatusDescription);\n+ }\n+\n[Fact]\npublic async Task CreatePackageReturns400IfMinClientVersionIsTooHigh()\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"diff": "@@ -263,7 +263,7 @@ public class PackagesControllerFacts\nfakeNuGetPackage = TestPackage.CreateTestPackageStream(\"thePackageId\", \"1.0.0\");\n}\n- controller.Setup(x => x.CreatePackage(It.IsAny<Stream>())).Returns(new PackageArchiveReader(fakeNuGetPackage, true));\n+ controller.Setup(x => x.CreatePackage(It.IsAny<Stream>())).Returns(() => new PackageArchiveReader(fakeNuGetPackage, true));\n}\nreturn controller.Object;\n@@ -5585,6 +5585,26 @@ public async Task WillShowViewWithErrorsIfEnsureValidThrowsExceptionMessage(Type\n(result.Data as JsonValidationMessage[])[0].PlainTextMessage);\n}\n+ [Fact]\n+ public async Task WillRejectBrokenZipFiles()\n+ {\n+ // Arrange\n+ var fakeUploadedFile = new Mock<HttpPostedFileBase>();\n+ fakeUploadedFile.Setup(x => x.FileName).Returns(\"file.nupkg\");\n+ var fakeFileStream = new MemoryStream(TestDataResourceUtility.GetResourceBytes(\"Zip64Package.Corrupted.1.0.0.nupkg\"));\n+ fakeUploadedFile.Setup(x => x.InputStream).Returns(fakeFileStream);\n+\n+ var controller = CreateController(\n+ GetConfigurationService(),\n+ fakeNuGetPackage: fakeFileStream);\n+ controller.SetCurrentUser(TestUtility.FakeUser);\n+\n+ var result = await controller.UploadPackage(fakeUploadedFile.Object) as JsonResult;\n+\n+ Assert.NotNull(result);\n+ Assert.Equal(\"Central Directory corrupt.\", (result.Data as JsonValidationMessage[])[0].PlainTextMessage);\n+ }\n+\n[Theory]\n[InlineData(\"ILike*Asterisks\")]\n[InlineData(\"I_.Like.-Separators\")]\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"new_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"diff": "<EmbeddedResource Include=\"TestData\\certificate.cer\" />\n<EmbeddedResource Include=\"TestData\\icon.png\" />\n<EmbeddedResource Include=\"TestData\\icon.jpg\" />\n+ <EmbeddedResource Include=\"TestData\\Zip64Package.Corrupted.1.0.0.nupkg\" />\n</ItemGroup>\n<ItemGroup>\n<ProjectReference Include=\"..\\..\\src\\NuGet.Services.Entities\\NuGet.Services.Entities.csproj\">\n"
},
{
"change_type": "ADD",
"old_path": "tests/NuGetGallery.Facts/TestData/Zip64Package.Corrupted.1.0.0.nupkg",
"new_path": "tests/NuGetGallery.Facts/TestData/Zip64Package.Corrupted.1.0.0.nupkg",
"diff": "Binary files /dev/null and b/tests/NuGetGallery.Facts/TestData/Zip64Package.Corrupted.1.0.0.nupkg differ\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Reject broken ZIPs on API push with better message (#7859)
Address https://github.com/NuGet/Engineering/issues/3046 |
455,736 | 05.03.2020 11:35:21 | 28,800 | 99784abd06c683a9be9c3f31a049e1d2e4f49f66 | Populate MEF container to allow early initialization
Related to | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Providers/RuntimeServiceProvider.cs",
"new_path": "src/NuGetGallery.Services/Providers/RuntimeServiceProvider.cs",
"diff": "using System;\nusing System.Collections.Generic;\n+using System.ComponentModel.Composition;\nusing System.ComponentModel.Composition.Hosting;\nusing System.IO;\nusing System.Linq;\n@@ -41,6 +42,26 @@ public static RuntimeServiceProvider Create(string baseDirectoryPath)\nreturn new RuntimeServiceProvider(compositionContainer);\n}\n+ public void ComposeExportedValue<T>(string contractName, T exportedValue)\n+ {\n+ if (_isDisposed)\n+ {\n+ throw new ObjectDisposedException(nameof(RuntimeServiceProvider));\n+ }\n+\n+ _compositionContainer.ComposeExportedValue(contractName, exportedValue);\n+ }\n+\n+ public void ComposeExportedValue<T>(T exportedValue)\n+ {\n+ if (_isDisposed)\n+ {\n+ throw new ObjectDisposedException(nameof(RuntimeServiceProvider));\n+ }\n+\n+ _compositionContainer.ComposeExportedValue(exportedValue);\n+ }\n+\npublic IEnumerable<T> GetExportedValues<T>()\n{\nif (_isDisposed)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using System.Net.Http;\nusing System.Net.Mail;\nusing System.Security.Principal;\n-using System.Threading;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Hosting;\nusing Elmah;\nusing Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.ApplicationInsights.Extensibility.Implementation;\n+using Microsoft.AspNet.TelemetryCorrelation;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Http;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n+using Microsoft.WindowsAzure.Storage;\nusing NuGet.Services.Entities;\nusing NuGet.Services.FeatureFlags;\nusing NuGet.Services.KeyVault;\n@@ -1389,19 +1390,25 @@ private static IAuditingService CombineAuditingServices(IEnumerable<IAuditingSer\nreturn new AggregateAuditingService(services);\n}\n- private static IEnumerable<T> GetAddInServices<T>(ContainerBuilder builder)\n+ private static IEnumerable<T> GetAddInServices<T>()\n+ {\n+ return GetAddInServices<T>(sp => { });\n+ }\n+\n+ private static IEnumerable<T> GetAddInServices<T>(Action<RuntimeServiceProvider> populateProvider)\n{\nvar addInsDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, \"bin\", \"add-ins\");\nusing (var serviceProvider = RuntimeServiceProvider.Create(addInsDirectoryPath))\n{\n+ populateProvider(serviceProvider);\nreturn serviceProvider.GetExportedValues<T>();\n}\n}\nprivate static void RegisterAuditingServices(ContainerBuilder builder, IAuditingService defaultAuditingService)\n{\n- var auditingServices = GetAddInServices<IAuditingService>(builder);\n+ var auditingServices = GetAddInServices<IAuditingService>();\nvar services = new List<IAuditingService>(auditingServices);\nif (defaultAuditingService != null)\n@@ -1419,26 +1426,27 @@ private static void RegisterAuditingServices(ContainerBuilder builder, IAuditing\nprivate static void RegisterCookieComplianceService(ContainerBuilder builder, ConfigurationService configuration, DiagnosticsService diagnostics)\n{\n- var service = GetAddInServices<ICookieComplianceService>(builder).FirstOrDefault() as CookieComplianceServiceBase;\n+ CookieComplianceServiceBase service = null;\n+ if (configuration.Current.IsHosted)\n+ {\n+ var siteName = configuration.GetSiteRoot(true);\n+ service = GetAddInServices<ICookieComplianceService>(sp =>\n+ {\n+ sp.ComposeExportedValue(\"Domain\", siteName);\n+ sp.ComposeExportedValue<IDiagnosticsService>(diagnostics);\n+ }).FirstOrDefault() as CookieComplianceServiceBase;\n- if (service == null)\n+ if (service != null)\n{\n- service = new NullCookieComplianceService();\n+ // Initialize the service on App_Start to avoid any performance degradation during initial requests.\n+ HostingEnvironment.QueueBackgroundWorkItem(async cancellationToken => await service.InitializeAsync(siteName, diagnostics, cancellationToken));\n+ }\n}\n- builder.RegisterInstance(service)\n+ builder.RegisterInstance(service ?? new NullCookieComplianceService())\n.AsSelf()\n.As<ICookieComplianceService>()\n.SingleInstance();\n-\n- if (configuration.Current.IsHosted)\n- {\n- var siteName = configuration.GetSiteRoot(true);\n-\n- // We must initialize during app start so that the cookie compliance service is ready when the first\n- // request comes in.\n- service.InitializeAsync(siteName, diagnostics, CancellationToken.None).Wait();\n- }\n}\n}\n}\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Populate MEF container to allow early initialization (#7862)
Related to https://github.com/NuGet/Engineering/issues/2980 |
455,736 | 10.03.2020 10:34:29 | 25,200 | ec483fa73d2cd0651254aa3ca0e116677ecf9aa1 | Support KeyVault secrets in functional test configuration
Move to PackageReference and .NET 4.7.2
Progress on | [
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.FunctionalTests.Core/GalleryConfiguration.cs",
"new_path": "tests/NuGetGallery.FunctionalTests.Core/GalleryConfiguration.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n-using System.Collections.Generic;\n-using System.IO;\n-using Newtonsoft.Json;\n+using System.Net;\n+using Microsoft.Extensions.Configuration;\n+using NuGet.Services.Configuration;\nnamespace NuGetGallery.FunctionalTests\n{\n@@ -14,38 +14,43 @@ public class GalleryConfiguration\npublic string GalleryBaseUrl => \"staging\".Equals(Slot, StringComparison.OrdinalIgnoreCase) ? StagingBaseUrl : ProductionBaseUrl;\n- [JsonProperty]\n- private string Slot { get; set; }\n- [JsonProperty]\n- private string ProductionBaseUrl { get; set; }\n- [JsonProperty]\n- private string StagingBaseUrl { get; set; }\n- [JsonProperty]\n- public string SearchServiceBaseUrl { get; private set; }\n- [JsonProperty]\n- public string EmailServerHost { get; private set; }\n- [JsonProperty]\n- public bool DefaultSecurityPoliciesEnforced { get; private set; }\n- [JsonProperty]\n- public bool TestPackageLock { get; private set; }\n- [JsonProperty]\n- public AccountConfiguration Account { get; private set; }\n- [JsonProperty]\n- public OrganizationConfiguration AdminOrganization { get; private set; }\n- [JsonProperty]\n- public OrganizationConfiguration CollaboratorOrganization { get; private set; }\n- [JsonProperty]\n- public BrandingConfiguration Branding { get; private set; }\n- [JsonProperty]\n- public bool TyposquattingCheckAndBlockUsers { get; private set; }\n+ public string Slot { get; set; }\n+ public string ProductionBaseUrl { get; set; }\n+ public string StagingBaseUrl { get; set; }\n+ public string SearchServiceBaseUrl { get; set; }\n+ public string EmailServerHost { get; set; }\n+ public bool DefaultSecurityPoliciesEnforced { get; set; }\n+ public bool TestPackageLock { get; set; }\n+ public AccountConfiguration Account { get; set; }\n+ public OrganizationConfiguration AdminOrganization { get; set; }\n+ public OrganizationConfiguration CollaboratorOrganization { get; set; }\n+ public BrandingConfiguration Branding { get; set; }\n+ public bool TyposquattingCheckAndBlockUsers { get; set; }\nstatic GalleryConfiguration()\n{\ntry\n{\n- var configurationFilePath = EnvironmentSettings.ConfigurationFilePath;\n- var configurationString = File.ReadAllText(configurationFilePath);\n- Instance = JsonConvert.DeserializeObject<GalleryConfiguration>(configurationString);\n+ // This test suite hits the gallery which requires TLS 1.2 (at least in some environments).\n+ ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;\n+\n+ // Load the configuration without injection. This allows us to read KeyVault configuration.\n+ var uninjectedBuilder = new ConfigurationBuilder()\n+ .AddJsonFile(EnvironmentSettings.ConfigurationFilePath, optional: false);\n+ var uninjectedConfiguration = uninjectedBuilder.Build();\n+\n+ // Initialize KeyVault integration.\n+ var secretReaderFactory = new ConfigurationRootSecretReaderFactory(uninjectedConfiguration);\n+ var secretInjector = secretReaderFactory.CreateSecretInjector(secretReaderFactory.CreateSecretReader());\n+\n+ // Initialize the configuration with KeyVault secrets injected.\n+ var builder = new ConfigurationBuilder()\n+ .SetBasePath(Environment.CurrentDirectory)\n+ .AddInjectedJsonFile(EnvironmentSettings.ConfigurationFilePath, secretInjector);\n+ var instance = new GalleryConfiguration();\n+ builder.Build().Bind(instance);\n+\n+ Instance = instance;\n}\ncatch (ArgumentException ae)\n{\n@@ -65,40 +70,27 @@ static GalleryConfiguration()\npublic class AccountConfiguration : OrganizationConfiguration\n{\n- [JsonProperty]\n- public string Email { get; private set; }\n- [JsonProperty]\n- public string Password { get; private set; }\n- [JsonProperty]\n- public string ApiKeyPush { get; private set; }\n- [JsonProperty]\n- public string ApiKeyPushVersion { get; private set; }\n- [JsonProperty]\n- public string ApiKeyUnlist { get; private set; }\n+ public string Email { get; set; }\n+ public string Password { get; set; }\n+ public string ApiKeyPush { get; set; }\n+ public string ApiKeyPushVersion { get; set; }\n+ public string ApiKeyUnlist { get; set; }\n}\npublic class OrganizationConfiguration\n{\n- [JsonProperty]\n- public string Name { get; private set; }\n- [JsonProperty]\n- public string ApiKey { get; private set; }\n+ public string Name { get; set; }\n+ public string ApiKey { get; set; }\n}\npublic class BrandingConfiguration\n{\n- [JsonProperty]\n- public string Message { get; private set; }\n- [JsonProperty]\n- public string Url { get; private set; }\n- [JsonProperty]\n- public string AboutUrl { get; private set; }\n- [JsonProperty]\n- public string PrivacyPolicyUrl { get; private set; }\n- [JsonProperty]\n- public string TermsOfUseUrl { get; private set; }\n- [JsonProperty]\n- public string TrademarksUrl { get; private set; }\n+ public string Message { get; set; }\n+ public string Url { get; set; }\n+ public string AboutUrl { get; set; }\n+ public string PrivacyPolicyUrl { get; set; }\n+ public string TermsOfUseUrl { get; set; }\n+ public string TrademarksUrl { get; set; }\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.LoadTests/App.config",
"new_path": "tests/NuGetGallery.LoadTests/App.config",
"diff": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<configuration>\n<startup>\n- <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.5.2\" />\n+ <supportedRuntime version=\"v4.0\" sku=\".NETFramework,Version=v4.7.2\"/>\n</startup>\n<appSettings>\n<add key=\"GalleryUrl\" value=\"https://int.nugettest.org/\"/>\n</providers>\n</roleManager>\n</system.web>\n- <runtime>\n- <assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.Web.XmlTransform\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-1.2.0.0\" newVersion=\"1.2.0.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"EntityFramework\" publicKeyToken=\"b77a5c561934e089\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-5.0.0.0\" newVersion=\"5.0.0.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.Owin\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-2.0.2.0\" newVersion=\"2.0.2.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.Owin.Security\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-2.0.2.0\" newVersion=\"2.0.2.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"System.Web.Mvc\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-4.0.0.0\" newVersion=\"4.0.0.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.WindowsAzure.Storage\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-2.1.0.3\" newVersion=\"2.1.0.3\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.WindowsAzure.Storage\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-2.1.0.3\" newVersion=\"2.1.0.3\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30ad4fe6b2a6aeed\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-4.5.0.0\" newVersion=\"4.5.0.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.Data.OData\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-5.6.0.0\" newVersion=\"5.6.0.0\" />\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"System.Web.Razor\" publicKeyToken=\"31bf3856ad364e35\" culture=\"neutral\" />\n- <bindingRedirect oldVersion=\"0.0.0.0-3.0.0.0\" newVersion=\"3.0.0.0\" />\n- </dependentAssembly>\n- </assemblyBinding>\n- </runtime>\n</configuration>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.LoadTests/NuGetGallery.LoadTests.csproj",
"new_path": "tests/NuGetGallery.LoadTests/NuGetGallery.LoadTests.csproj",
"diff": "<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>NuGetGallery.LoadTests</RootNamespace>\n<AssemblyName>NuGetGallery.LoadTests</AssemblyName>\n- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n<TestProjectType>WebTest</TestProjectType>\n<WarningLevel>4</WarningLevel>\n</PropertyGroup>\n<ItemGroup>\n- <Reference Include=\"FluentLinkChecker\">\n- <HintPath>..\\..\\packages\\FluentLinkChecker.1.0.0.10\\lib\\net40\\FluentLinkChecker.dll</HintPath>\n- </Reference>\n<Reference Include=\"Microsoft.VisualStudio.QualityTools.LoadTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a\" />\n<Reference Include=\"Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL\">\n<SpecificVersion>False</SpecificVersion>\n<CopyToOutputDirectory>Always</CopyToOutputDirectory>\n</None>\n<None Include=\"Search.loadtest\" />\n- <None Include=\"packages.config\" />\n</ItemGroup>\n<ItemGroup>\n<ProjectReference Include=\"..\\NuGetGallery.FunctionalTests.Core\\NuGetGallery.FunctionalTests.Core.csproj\">\n<Name>NuGetGallery.WebUITests.P2</Name>\n</ProjectReference>\n</ItemGroup>\n+ <ItemGroup>\n+ <PackageReference Include=\"FluentLinkChecker\">\n+ <Version>1.0.0.10</Version>\n+ </PackageReference>\n+ </ItemGroup>\n<Choose>\n<When Condition=\"'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'\">\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.WebUITests.P0/NuGetGallery.WebUITests.P0.csproj",
"new_path": "tests/NuGetGallery.WebUITests.P0/NuGetGallery.WebUITests.P0.csproj",
"diff": "<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>NuGetGallery.WebUITests.P0</RootNamespace>\n<AssemblyName>NuGetGallery.WebUITests.P0</AssemblyName>\n- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n<TestProjectType>WebTest</TestProjectType>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.WebUITests.P1/NuGetGallery.WebUITests.P1.csproj",
"new_path": "tests/NuGetGallery.WebUITests.P1/NuGetGallery.WebUITests.P1.csproj",
"diff": "<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>NuGetGallery.WebUITests.P1</RootNamespace>\n<AssemblyName>NuGetGallery.WebUITests.P1</AssemblyName>\n- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n<TestProjectType>WebTest</TestProjectType>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.WebUITests.P2/NuGetGallery.WebUITests.P2.csproj",
"new_path": "tests/NuGetGallery.WebUITests.P2/NuGetGallery.WebUITests.P2.csproj",
"diff": "<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>NuGetGallery.WebUITests.P2</RootNamespace>\n<AssemblyName>NuGetGallery.WebUITests.P2</AssemblyName>\n- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n<TestProjectType>WebTest</TestProjectType>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.WebUITests.ReadOnlyMode/NuGetGallery.WebUITests.ReadOnlyMode.csproj",
"new_path": "tests/NuGetGallery.WebUITests.ReadOnlyMode/NuGetGallery.WebUITests.ReadOnlyMode.csproj",
"diff": "<AppDesignerFolder>Properties</AppDesignerFolder>\n<RootNamespace>NuGetGallery.WebUITests.ReadOnlyMode</RootNamespace>\n<AssemblyName>NuGetGallery.WebUITests.ReadOnlyMode</AssemblyName>\n- <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>\n+ <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>\n<TestProjectType>WebTest</TestProjectType>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Support KeyVault secrets in functional test configuration (#7865)
Move to PackageReference and .NET 4.7.2
Progress on https://github.com/NuGet/Engineering/issues/3060 |
455,736 | 11.03.2020 18:13:50 | 25,200 | 2afaf673619c369ac20526ecb4125be6371c4448 | Add KnownOperation telemetry and add more configuration to DI
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<Version>4.3.0-dev-3453620</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"diff": "using System.ComponentModel;\nusing System.ComponentModel.DataAnnotations;\nusing System.Net.Mail;\n+using NuGet.Services.Configuration;\nnamespace NuGetGallery.Configuration\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"new_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"diff": "using System.ComponentModel;\nusing System.ComponentModel.DataAnnotations;\nusing System.Configuration;\n-using System.Diagnostics;\nusing System.Globalization;\nusing System.Linq;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Configuration;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n+using NuGet.Services.Configuration;\nusing NuGet.Services.KeyVault;\nnamespace NuGetGallery.Configuration\n{\n- public class ConfigurationService : IGalleryConfigurationService\n+ public class ConfigurationService : IGalleryConfigurationService, IConfigurationFactory\n{\nprotected const string SettingPrefix = \"Gallery.\";\nprotected const string FeaturePrefix = \"Feature.\";\n@@ -73,6 +73,21 @@ public string GetSiteRoot(bool useHttps)\nreturn useHttps ? _httpsSiteRootThunk.Value : _httpSiteRootThunk.Value;\n}\n+ public Task<T> Get<T>() where T : NuGet.Services.Configuration.Configuration, new()\n+ {\n+ // Get the prefix specified by the ConfigurationKeyPrefixAttribute on the class if it exists.\n+ var classPrefix = string.Empty;\n+ var configNamePrefixProperty = (ConfigurationKeyPrefixAttribute)typeof(T)\n+ .GetCustomAttributes(typeof(ConfigurationKeyPrefixAttribute), inherit: true)\n+ .FirstOrDefault();\n+ if (configNamePrefixProperty != null)\n+ {\n+ classPrefix = configNamePrefixProperty.Prefix;\n+ }\n+\n+ return ResolveConfigObject(Activator.CreateInstance<T>(), classPrefix);\n+ }\n+\npublic async Task<T> ResolveConfigObject<T>(T instance, string prefix)\n{\n// Iterate over the properties\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Compile Include=\"Extensions\\UriExtensions.cs\" />\n<Compile Include=\"Extensions\\UserExtensions.cs\" />\n<Compile Include=\"Helpers\\MailAddressConverter.cs\" />\n- <Compile Include=\"Helpers\\StringArrayConverter.cs\" />\n<Compile Include=\"Helpers\\UploadHelper.cs\" />\n<Compile Include=\"Models\\LuceneIndexLocation.cs\" />\n<Compile Include=\"Models\\ReportPackageReason.cs\" />\n<PackageReference Include=\"NuGet.Protocol\">\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n- <PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.69.0</Version>\n+ <PackageReference Include=\"NuGet.Services.Configuration\">\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using Elmah;\nusing Microsoft.ApplicationInsights.Extensibility;\nusing Microsoft.ApplicationInsights.Extensibility.Implementation;\n-using Microsoft.AspNet.TelemetryCorrelation;\nusing Microsoft.Extensions.DependencyInjection;\nusing Microsoft.Extensions.Http;\nusing Microsoft.Extensions.Logging;\nusing Microsoft.WindowsAzure.ServiceRuntime;\n-using Microsoft.WindowsAzure.Storage;\n+using NuGet.Services.Configuration;\nusing NuGet.Services.Entities;\nusing NuGet.Services.FeatureFlags;\nusing NuGet.Services.KeyVault;\n@@ -108,6 +107,10 @@ protected override void Load(ContainerBuilder builder)\nloggerConfiguration,\ntelemetryConfiguration: applicationInsightsConfiguration.TelemetryConfiguration);\n+ builder.RegisterInstance(applicationInsightsConfiguration.TelemetryConfiguration)\n+ .AsSelf()\n+ .SingleInstance();\n+\nbuilder.RegisterInstance(telemetryClient)\n.AsSelf()\n.As<ITelemetryClient>()\n@@ -126,6 +129,7 @@ protected override void Load(ContainerBuilder builder)\nbuilder.RegisterInstance(configuration)\n.AsSelf()\n+ .As<IConfigurationFactory>()\n.As<IGalleryConfigurationService>();\nbuilder.Register(c => configuration.Current)\n@@ -519,6 +523,7 @@ protected override void Load(ContainerBuilder builder)\n}\ntelemetryConfiguration.TelemetryInitializers.Add(new ClientInformationTelemetryEnricher());\n+ telemetryConfiguration.TelemetryInitializers.Add(new KnownOperationNameEnricher());\n// Add processors\ntelemetryConfiguration.TelemetryProcessorChainBuilder.Use(next =>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/Routes.cs",
"new_path": "src/NuGetGallery/App_Start/Routes.cs",
"diff": "@@ -223,7 +223,7 @@ public static void RegisterUIRoutes(RouteCollection routes)\n\"packages/{id}/{version}\",\nnew\n{\n- controller = \"packages\",\n+ controller = \"Packages\",\naction = \"DisplayPackage\",\nversion = UrlParameter.Optional\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Services\\ValidationService.cs\" />\n<Compile Include=\"Telemetry\\ClientInformationTelemetryEnricher.cs\" />\n<Compile Include=\"Telemetry\\ClientTelemetryPIIProcessor.cs\" />\n+ <Compile Include=\"Telemetry\\KnownOperationNameEnricher.cs\" />\n<Compile Include=\"Telemetry\\QuietExceptionLogger.cs\" />\n<Compile Include=\"Infrastructure\\PasswordValidationAttribute.cs\" />\n<Compile Include=\"Migrations\\201602181939424_RemovePackageStatistics.cs\" />\n<PackageReference Include=\"Microsoft.Extensions.Http.Polly\">\n<Version>2.2.0</Version>\n</PackageReference>\n- <PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.69.0</Version>\n- </PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Protocol\">\n<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n- <PackageReference Include=\"NuGet.Services.KeyVault\">\n- <Version>2.69.0</Version>\n+ <PackageReference Include=\"NuGet.Services.Licenses\">\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"Newtonsoft.Json\" publicKeyToken=\"30AD4FE6B2A6AEED\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-10.0.0.0\" newVersion=\"10.0.0.0\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-11.0.0.0\" newVersion=\"11.0.0.0\"/>\n</dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"Microsoft.Owin\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"new_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"diff": "@@ -152,6 +152,7 @@ private Action<ITelemetryInitializer>[] GetTelemetryInitializerInspectors(string\n{\n// Registered by DefaultDependenciesModule in NuGetGallery\nti => ti.GetType().Equals(typeof(ClientInformationTelemetryEnricher)),\n+ ti => ti.GetType().Equals(typeof(KnownOperationNameEnricher)),\n// Registered by applicationinsights.config\nti => ti.GetType().Equals(typeof(HttpDependenciesParsingTelemetryInitializer)),\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.FunctionalTests.Core/NuGetGallery.FunctionalTests.Core.csproj",
"new_path": "tests/NuGetGallery.FunctionalTests.Core/NuGetGallery.FunctionalTests.Core.csproj",
"diff": "<Version>2.8.6</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.69.0</Version>\n+ <Version>2.70.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Versioning\">\n<Version>4.4.0</Version>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add KnownOperation telemetry and add more configuration to DI (#7867)
Progress on https://github.com/NuGet/Engineering/issues/3020 |
455,736 | 20.03.2020 09:37:54 | 25,200 | a59722d64306b497d07f63e85a078a634c69cec6 | Add missing binding redirects
This helps with addressing Component Governance issues. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "</system.diagnostics>\n<runtime>\n<assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">\n- <dependentAssembly>\n- <assemblyIdentity name=\"Microsoft.IdentityModel.Clients.ActiveDirectory\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-5.2.6.0\" newVersion=\"5.2.6.0\"/>\n- </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"System.Spatial\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-5.8.4.0\" newVersion=\"5.8.4.0\"/>\n<assemblyIdentity name=\"NuGet.Versioning\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-5.0.0.1\" newVersion=\"5.0.0.1\"/>\n</dependentAssembly>\n+ <dependentAssembly>\n+ <assemblyIdentity name=\"NuGet.Services.KeyVault\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-2.71.0.0\" newVersion=\"2.71.0.0\"/>\n+ </dependentAssembly>\n+ <dependentAssembly>\n+ <assemblyIdentity name=\"NuGet.Services.Configuration\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-2.71.0.0\" newVersion=\"2.71.0.0\"/>\n+ </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"NuGet.Frameworks\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-5.0.0.1\" newVersion=\"5.0.0.1\"/>\n<assemblyIdentity name=\"System.Net.Http.Primitives\" publicKeyToken=\"B03F5F7F11D50A3A\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-4.2.29.0\" newVersion=\"4.2.29.0\"/>\n</dependentAssembly>\n+ <dependentAssembly>\n+ <assemblyIdentity name=\"Microsoft.IdentityModel.Clients.ActiveDirectory\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-5.2.6.0\" newVersion=\"5.2.6.0\"/>\n+ </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"Microsoft.Extensions.Logging.Abstractions\" publicKeyToken=\"ADB9793829DDAE60\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-2.2.0.0\" newVersion=\"2.2.0.0\"/>\n<assemblyIdentity name=\"Microsoft.ApplicationInsights\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-2.12.0.21496\" newVersion=\"2.12.0.21496\"/>\n</dependentAssembly>\n+ <dependentAssembly>\n+ <assemblyIdentity name=\"MessagePack\" publicKeyToken=\"B4A0369545F0A1BE\" culture=\"neutral\"/>\n+ <bindingRedirect oldVersion=\"0.0.0.0-1.9.0.0\" newVersion=\"1.9.0.0\"/>\n+ </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"EntityFramework\" publicKeyToken=\"B77A5C561934E089\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-6.0.0.0\" newVersion=\"6.0.0.0\"/>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add missing binding redirects (#7894)
This helps with addressing Component Governance issues. |
455,744 | 23.03.2020 14:47:38 | 25,200 | 00362bbf5878e4074e90489f15bd78cd1cf4b38c | Updated MaxSupportedMinClientVersion to match the client version about to be published. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/GalleryConstants.cs",
"new_path": "src/NuGetGallery/GalleryConstants.cs",
"diff": "@@ -27,7 +27,7 @@ public static class GalleryConstants\npublic const int GravatarCacheDurationSeconds = 300;\npublic const int MaxEmailSubjectLength = 255;\n- internal static readonly NuGetVersion MaxSupportedMinClientVersion = new NuGetVersion(\"5.3.0.0\");\n+ internal static readonly NuGetVersion MaxSupportedMinClientVersion = new NuGetVersion(\"5.5.0.0\");\npublic const string PackageFileDownloadUriTemplate = \"packages/{0}/{1}/download\";\npublic const string ReadMeFileSavePathTemplateActive = \"active/{0}/{1}{2}\";\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Updated MaxSupportedMinClientVersion to match the client version about to be published. (#7899) |
455,736 | 03.04.2020 18:27:57 | 25,200 | f93b9da1cfd280894683ee6d652c78dfd3769d6b | Update to latest ServerCommon and NuGet.Jobs version
This brings in the NoWarn and the 3.0.0.0 assembly version for ServerCommon assemblies. | [
{
"change_type": "MODIFY",
"old_path": "build.ps1",
"new_path": "build.ps1",
"diff": "@@ -10,7 +10,7 @@ param (\n[string]$PackageSuffix,\n[string]$Branch,\n[string]$CommitSHA,\n- [string]$BuildBranch = 'd298565f387e93995a179ef8ae6838f1be37904f',\n+ [string]$BuildBranch = '6d1fcf147a7af8b6b4db842494bc7beed3b1d0e9',\n[string]$VerifyMicrosoftPackageVersion = $null\n)\n"
},
{
"change_type": "DELETE",
"old_path": "ops.cmd",
"new_path": null,
"diff": "-@powershell -ExecutionPolicy RemoteSigned -NoProfile -NoExit \"%~dp0ops\\Scripts\\Enter-NuGetOps.ps1\"\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Common.Job\">\n- <Version>4.3.0-dev-3555917</Version>\n+ <Version>4.3.0-dev-3612825</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"new_path": "src/DatabaseMigrationTools/DatabaseMigrationTools.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<PrivateAssets>all</PrivateAssets>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3555917</Version>\n+ <Version>4.3.0-dev-3612825</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Cursor\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n</ItemGroup>\n<ItemGroup>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"new_path": "src/NuGet.Services.DatabaseMigration/NuGet.Services.DatabaseMigration.csproj",
"diff": "<Version>4.8.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Jobs.Common\">\n- <Version>4.3.0-dev-3555917</Version>\n+ <Version>4.3.0-dev-3612825</Version>\n</PackageReference>\n</ItemGroup>\n<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<PackageReference Include=\"NuGet.Services.FeatureFlags\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Messaging.Email\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Validation.Issues\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.AnglicanGeek.MarkdownMailer\">\n<Version>1.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Configuration\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Logging\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.StrongName.WebBackgrounder\">\n<Version>0.2.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Version>5.0.0-preview1.5665</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Licenses\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Owin\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"NuGet.Services.Sql\">\n- <Version>2.71.0</Version>\n+ <Version>2.74.0</Version>\n</PackageReference>\n<PackageReference Include=\"Owin\">\n<Version>1.0.0</Version>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<assemblyIdentity name=\"NuGet.Versioning\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-5.0.0.1\" newVersion=\"5.0.0.1\"/>\n</dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"NuGet.Services.KeyVault\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-2.71.0.0\" newVersion=\"2.71.0.0\"/>\n- </dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"NuGet.Services.Configuration\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-2.71.0.0\" newVersion=\"2.71.0.0\"/>\n- </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"NuGet.Frameworks\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-5.0.0.1\" newVersion=\"5.0.0.1\"/>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Update to latest ServerCommon and NuGet.Jobs version (#7929)
This brings in the NoWarn and the 3.0.0.0 assembly version for ServerCommon assemblies. |
455,736 | 06.04.2020 16:27:43 | 25,200 | 74cdb70286a6b6ae1ecf3faffdb471010c303447 | Remove "-staging" suffix from cloud role name
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "@@ -524,6 +524,7 @@ protected override void Load(ContainerBuilder builder)\ntelemetryConfiguration.TelemetryInitializers.Add(new ClientInformationTelemetryEnricher());\ntelemetryConfiguration.TelemetryInitializers.Add(new KnownOperationNameEnricher());\n+ telemetryConfiguration.TelemetryInitializers.Add(new AzureWebAppTelemetryInitializer());\n// Add processors\ntelemetryConfiguration.TelemetryProcessorChainBuilder.Use(next =>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"new_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"diff": "@@ -153,6 +153,7 @@ private Action<ITelemetryInitializer>[] GetTelemetryInitializerInspectors(string\n// Registered by DefaultDependenciesModule in NuGetGallery\nti => ti.GetType().Equals(typeof(ClientInformationTelemetryEnricher)),\nti => ti.GetType().Equals(typeof(KnownOperationNameEnricher)),\n+ ti => ti.GetType().Equals(typeof(AzureWebAppTelemetryInitializer)),\n// Registered by applicationinsights.config\nti => ti.GetType().Equals(typeof(HttpDependenciesParsingTelemetryInitializer)),\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Remove "-staging" suffix from cloud role name (#7935)
Address https://github.com/NuGet/Engineering/issues/3105 |
455,736 | 07.04.2020 12:55:24 | 25,200 | 51e063c91a7aac61d24a4c60ba0d03064bc7eaa0 | Add CustomerResourceId to enrich push metrics with tenant ID
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "<Compile Include=\"Auditing\\UserAuditRecord.cs\" />\n<Compile Include=\"Authentication\\AuthenticationExtensions.cs\" />\n<Compile Include=\"Authentication\\CredentialTypeInfo.cs\" />\n+ <Compile Include=\"Authentication\\MicrosoftClaims.cs\" />\n<Compile Include=\"Certificates\\CertificateFile.cs\" />\n<Compile Include=\"Cookies\\CookieComplianceServiceBase.cs\" />\n<Compile Include=\"Cookies\\CookieConsentMessage.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Extensions/HttpContextBaseExtensions.cs",
"new_path": "src/NuGetGallery.Services/Extensions/HttpContextBaseExtensions.cs",
"diff": "@@ -11,6 +11,8 @@ namespace NuGetGallery\n{\npublic static class HttpContextBaseExtensions\n{\n+ public static HttpContextBase GetCurrent() => new HttpContextWrapper(HttpContext.Current);\n+\npublic static User GetCurrentUser(this HttpContextBase httpContext)\n{\nreturn httpContext.GetOwinContext().GetCurrentUser();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Extensions/IOwinContextExtensions.cs",
"new_path": "src/NuGetGallery.Services/Extensions/IOwinContextExtensions.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n+using System.Linq;\nusing System.Security.Claims;\n-using System.Web;\nusing System.Web.Mvc;\nusing Microsoft.Owin;\nusing NuGet.Services.Entities;\n+using NuGetGallery.Authentication;\nnamespace NuGetGallery\n{\n@@ -64,9 +65,27 @@ private static User LoadUser(IOwinContext context)\nif (!String.IsNullOrEmpty(userName))\n{\n- return DependencyResolver.Current\n+ var user = DependencyResolver.Current\n.GetService<IUserService>()\n.FindByUsername(userName);\n+\n+ // Try to add the tenant ID information as an additional claim since we have the full user record\n+ // and the associated credentials.\n+ if (user != null && principal.Identity is ClaimsIdentity identity)\n+ {\n+ // From the schema, it is possible to have multiple credentials. Prefer the latest one.\n+ var externalCredential = user\n+ .Credentials\n+ .OrderByDescending(x => x.Created)\n+ .FirstOrDefault(c => c.IsExternal() && c.TenantId != null);\n+\n+ if (externalCredential != null)\n+ {\n+ identity.TryAddClaim(MicrosoftClaims.TenantId, externalCredential.TenantId);\n+ }\n+ }\n+\n+ return user;\n}\n}\nreturn null; // No user logged in, or credentials could not be resolved\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Extensions/PrincipalExtensions.cs",
"new_path": "src/NuGetGallery.Services/Extensions/PrincipalExtensions.cs",
"diff": "@@ -214,6 +214,17 @@ public static bool TryRemoveClaim(this IIdentity identity, string claimType)\nreturn false;\n}\n+ /// <summary>\n+ /// Get the tenant ID from the claims, if available. If no such claim exists, null is returned.\n+ /// </summary>\n+ /// <param name=\"identity\">The identity to look for claims in.</param>\n+ /// <returns>The tenant ID or null.</returns>\n+ public static string GetTenantIdOrNull(this IIdentity identity)\n+ {\n+ var claimsIdentity = identity as ClaimsIdentity;\n+ return claimsIdentity?.FindFirst(MicrosoftClaims.TenantId)?.Value;\n+ }\n+\n/// <summary>\n/// Try to add a new default claim to the identity. It will not replace an existing claim.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Telemetry/TelemetryService.cs",
"new_path": "src/NuGetGallery.Services/Telemetry/TelemetryService.cs",
"diff": "@@ -18,7 +18,7 @@ namespace NuGetGallery\n{\npublic class TelemetryService : ITelemetryService, IFeatureFlagTelemetryService\n{\n- internal class Events\n+ public class Events\n{\npublic const string ODataQueryFilter = \"ODataQueryFilter\";\npublic const string ODataCustomQuery = \"ODataCustomQuery\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "@@ -525,6 +525,7 @@ protected override void Load(ContainerBuilder builder)\ntelemetryConfiguration.TelemetryInitializers.Add(new ClientInformationTelemetryEnricher());\ntelemetryConfiguration.TelemetryInitializers.Add(new KnownOperationNameEnricher());\ntelemetryConfiguration.TelemetryInitializers.Add(new AzureWebAppTelemetryInitializer());\n+ telemetryConfiguration.TelemetryInitializers.Add(new CustomerResourceIdEnricher());\n// Add processors\ntelemetryConfiguration.TelemetryProcessorChainBuilder.Use(next =>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Services\\ValidationService.cs\" />\n<Compile Include=\"Telemetry\\ClientInformationTelemetryEnricher.cs\" />\n<Compile Include=\"Telemetry\\ClientTelemetryPIIProcessor.cs\" />\n+ <Compile Include=\"Telemetry\\CustomerResourceIdEnricher.cs\" />\n<Compile Include=\"Telemetry\\KnownOperationNameEnricher.cs\" />\n<Compile Include=\"Telemetry\\QuietExceptionLogger.cs\" />\n<Compile Include=\"Infrastructure\\PasswordValidationAttribute.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/ClientInformationTelemetryEnricher.cs",
"diff": "@@ -46,9 +46,6 @@ public void Initialize(ITelemetry telemetry)\n}\n}\n- protected virtual HttpContextBase GetHttpContext()\n- {\n- return new HttpContextWrapper(HttpContext.Current);\n- }\n+ protected virtual HttpContextBase GetHttpContext() => HttpContextBaseExtensions.GetCurrent();\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"new_path": "tests/NuGetGallery.Facts/App_Start/DefaultDependenciesModuleFacts.cs",
"diff": "@@ -154,6 +154,7 @@ private Action<ITelemetryInitializer>[] GetTelemetryInitializerInspectors(string\nti => ti.GetType().Equals(typeof(ClientInformationTelemetryEnricher)),\nti => ti.GetType().Equals(typeof(KnownOperationNameEnricher)),\nti => ti.GetType().Equals(typeof(AzureWebAppTelemetryInitializer)),\n+ ti => ti.GetType().Equals(typeof(CustomerResourceIdEnricher)),\n// Registered by applicationinsights.config\nti => ti.GetType().Equals(typeof(HttpDependenciesParsingTelemetryInitializer)),\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"new_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"diff": "<Compile Include=\"Services\\SearchSideBySideServiceFacts.cs\" />\n<Compile Include=\"Services\\PackageUpdateServiceFacts.cs\" />\n<Compile Include=\"Services\\StatusServiceFacts.cs\" />\n+ <Compile Include=\"Telemetry\\CustomerResourceIdEnricherFacts.cs\" />\n<Compile Include=\"TestData\\TestDataResourceUtility.cs\" />\n<Compile Include=\"UsernameValidationRegex.cs\" />\n<Compile Include=\"Extensions\\NumberExtensionsFacts.cs\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add CustomerResourceId to enrich push metrics with tenant ID (#7936)
Progress on https://github.com/NuGet/Engineering/issues/3106 |
455,736 | 14.04.2020 12:40:47 | 25,200 | 678fe47b79df25c9f038064ba9a97c21185e696c | Allow deletion of unconfirmed users and orgs
Fix minor styling issue on the delete account page when an exception bubbles out.
Fix bug in the account delete handler which would not delete users when notifications were turned off.
Address | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleteMessageHandler.cs",
"new_path": "src/AccountDeleter/AccountDeleteMessageHandler.cs",
"diff": "@@ -63,15 +63,25 @@ public async Task<bool> HandleAsync(AccountDeleteMessage command)\nthrow new UserNotFoundException();\n}\n- if (_accountDeleteConfigurationAccessor.Value.RespectEmailContactSetting && !user.EmailAllowed)\n- {\n- throw new EmailContactNotAllowedException();\n- }\n-\nvar recipientEmail = user.EmailAddress;\n+ var emailAllowed = user.EmailAllowed;\nvar deleteSuccess = await _accountManager.DeleteAccount(user, source);\n_telemetryService.TrackDeleteResult(source, deleteSuccess);\n+ if (recipientEmail == null)\n+ {\n+ _logger.LogWarning(\"User has no confirmed email address. The user has been deleted but no email was sent.\");\n+ _telemetryService.TrackUnconfirmedUser(source);\n+ messageProcessed = true;\n+ }\n+ else if (_accountDeleteConfigurationAccessor.Value.RespectEmailContactSetting && !emailAllowed)\n+ {\n+ _logger.LogWarning(\"User did not allow Email Contact. The user has been deleted but no email was sent.\");\n+ _telemetryService.TrackEmailBlocked(source);\n+ messageProcessed = true;\n+ }\n+ else\n+ {\nvar baseEmailBuilder = _emailBuilderFactory.GetEmailBuilder(source, deleteSuccess);\nif (baseEmailBuilder != null)\n{\n@@ -86,10 +96,11 @@ public async Task<bool> HandleAsync(AccountDeleteMessage command)\nvar recipients = new EmailRecipients(toEmail, ccEmail);\nvar emailBuilder = new DisposableEmailBuilder(baseEmailBuilder, recipients, username);\nawait _messenger.SendMessageAsync(emailBuilder);\n- _telemetryService.TrackEmailSent(source, user.EmailAllowed);\n+ _telemetryService.TrackEmailSent(source, emailAllowed);\nmessageProcessed = true;\n}\n}\n+ }\ncatch (UnknownSourceException)\n{\n// Should definitely log if source isn't expected. Should we even send mail? or log and alert?\n@@ -98,12 +109,6 @@ public async Task<bool> HandleAsync(AccountDeleteMessage command)\n_telemetryService.TrackUnknownSource(source);\nmessageProcessed = false;\n}\n- catch (EmailContactNotAllowedException)\n- {\n- // Should we not send? or should we ignore the setting.\n- _logger.LogWarning(\"User did not allow Email Contact.\");\n- _telemetryService.TrackEmailBlocked(source);\n- }\ncatch (UserNotFoundException)\n{\n_logger.LogWarning(\"User was not found. They may have already been deleted.\");\n@@ -112,8 +117,8 @@ public async Task<bool> HandleAsync(AccountDeleteMessage command)\n}\ncatch (Exception e)\n{\n- _logger.LogError(0, e, \"An unknown exception occured: {ExceptionMessage}\");\n- throw e;\n+ _logger.LogError(e, \"An unknown exception occurred.\");\n+ throw;\n}\nreturn messageProcessed;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "<Compile Include=\"Evaluators\\IUserEvaluatorFactory.cs\" />\n<Compile Include=\"Evaluators\\UserEvaluatorComparer.cs\" />\n<Compile Include=\"Evaluators\\UserEvaluatorFactory.cs\" />\n- <Compile Include=\"Exceptions\\EmailContactNotAllowedException.cs\" />\n<Compile Include=\"Exceptions\\UnknownEvaluatorException.cs\" />\n<Compile Include=\"Exceptions\\UnknownSourceException.cs\" />\n<Compile Include=\"Exceptions\\UserNotFoundException.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/Telemetry/AccountDeleteTelemetryService.cs",
"new_path": "src/AccountDeleter/Telemetry/AccountDeleteTelemetryService.cs",
"diff": "@@ -17,6 +17,7 @@ public class AccountDeleteTelemetryService : IAccountDeleteTelemetryService, ISu\nprivate const string EmailBlockedEventName = TelemetryPrefix + \"EmailBlocked\";\nprivate const string UnknownSourceEventName = TelemetryPrefix + \"UnknownSource\";\nprivate const string UserNotFoundEventName = TelemetryPrefix + \"UserNotFound\";\n+ private const string UnconfirmedUserEventName = TelemetryPrefix + \"UnconfirmedUser\";\nprivate const string CallGuidDimensionName = \"CallGuid\";\nprivate const string ContactAllowedDimensionName = \"ContactAllowed\";\n@@ -130,5 +131,14 @@ public void TrackMessageLockLost<TMessage>(Guid callGuid)\n{ CallGuidDimensionName, callGuid.ToString() }\n});\n}\n+\n+ public void TrackUnconfirmedUser(string source)\n+ {\n+ _telemetryClient.TrackEvent(UnconfirmedUserEventName,\n+ new Dictionary<string, string>\n+ {\n+ { SourceDimensionName, source }\n+ });\n+ }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs",
"new_path": "src/NuGetGallery.Services/SupportRequest/SupportRequestService.cs",
"diff": "@@ -21,6 +21,8 @@ public class SupportRequestService\nprivate readonly string _siteRoot;\nprivate const string _unassignedAdmin = \"unassigned\";\nprivate const string _deletedAccount = \"_deletedaccount\";\n+ private const string _unconfirmedEmailAddress = \"_unconfirmed\";\n+ private const string _deletedEmailAddress = \"deletedaccount\";\nprivate const string _NuGetDSRAccount = \"_NuGetDSR\";\npublic SupportRequestService(\n@@ -221,7 +223,7 @@ public async Task<bool> TryAddDeleteSupportRequestAsync(User user)\nvar requestSent = await AddNewSupportRequestAsync(\nServicesStrings.AccountDelete_SupportRequestTitle,\nServicesStrings.AccountDelete_SupportRequestTitle,\n- user.EmailAddress,\n+ user.EmailAddress ?? _unconfirmedEmailAddress,\n\"The user requested to have the account deleted.\",\nuser) != null;\nvar status = requestSent ? DeleteAccountAuditRecord.ActionStatus.Success : DeleteAccountAuditRecord.ActionStatus.Failure;\n@@ -303,7 +305,7 @@ public async Task DeleteSupportRequestsAsync(User user)\n}\nforeach (var accountDeletedIssue in userIssues.Where(i => string.Equals(i.IssueTitle, ServicesStrings.AccountDelete_SupportRequestTitle)))\n{\n- accountDeletedIssue.OwnerEmail = \"deletedaccount\";\n+ accountDeletedIssue.OwnerEmail = _deletedEmailAddress;\nif(!accountDeletedIssue.CreatedBy.Equals(_NuGetDSRAccount, StringComparison.OrdinalIgnoreCase))\n{\naccountDeletedIssue.CreatedBy = _deletedAccount;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/DeleteAccount.cshtml",
"new_path": "src/NuGetGallery/Views/Users/DeleteAccount.cshtml",
"diff": "@if ((TempData[\"RequestFailedMessage\"] != null))\n{\nvar message = (string)TempData[\"RequestFailedMessage\"];\n- @ViewHelpers.AlertDanger(@<p><b class=\"keywords\">@message</b> <br /></p>)\n+ @ViewHelpers.AlertDanger(@<b class=\"keywords\">@message</b>)\n}\nelse\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/AccountDeleter.Facts/AccountDeleter.Facts.csproj",
"new_path": "tests/AccountDeleter.Facts/AccountDeleter.Facts.csproj",
"diff": "<ProjectGuid>{98765110-844D-41BE-8083-22E064136E05}</ProjectGuid>\n<OutputType>Library</OutputType>\n<AppDesignerFolder>Properties</AppDesignerFolder>\n- <RootNamespace>AccountDeleter.Facts</RootNamespace>\n+ <RootNamespace>NuGet.AccountDeleter.Facts</RootNamespace>\n<AssemblyName>AccountDeleter.Facts</AssemblyName>\n<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>\n<FileAlignment>512</FileAlignment>\n<Reference Include=\"System.Xml\" />\n</ItemGroup>\n<ItemGroup>\n+ <Compile Include=\"AccountDeleteMessageHandlerFacts.cs\" />\n<Compile Include=\"EmailBuilderFacts.cs\" />\n<Compile Include=\"Properties\\AssemblyInfo.cs\" />\n<Compile Include=\"EvaluatorFacts.cs\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Allow deletion of unconfirmed users and orgs (#7948)
Fix minor styling issue on the delete account page when an exception bubbles out.
Fix bug in the account delete handler which would not delete users when notifications were turned off.
Address https://github.com/NuGet/Engineering/issues/3099 |
455,736 | 10.04.2020 10:30:17 | 25,200 | cfcc1bada8b07bd6f86158dd0b021ab4f596f008 | Add simulated error for exceptions in view and error page
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using System.Net.Http;\nusing System.Net.Mail;\nusing System.Security.Principal;\n+using System.Threading;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Hosting;\n@@ -171,7 +172,7 @@ protected override void Load(ContainerBuilder builder)\n.InstancePerLifetimeScope();\nvar galleryDbConnectionFactory = CreateDbConnectionFactory(\n- diagnosticsService,\n+ loggerFactory,\nnameof(EntitiesContext),\nconfiguration.Current.SqlConnectionString,\nsecretInjector);\n@@ -262,10 +263,10 @@ protected override void Load(ContainerBuilder builder)\n.As<IEntityRepository<PackageDeprecation>>()\n.InstancePerLifetimeScope();\n- ConfigureGalleryReadOnlyReplicaEntitiesContext(builder, diagnosticsService, configuration, secretInjector);\n+ ConfigureGalleryReadOnlyReplicaEntitiesContext(builder, loggerFactory, configuration, secretInjector);\nvar supportDbConnectionFactory = CreateDbConnectionFactory(\n- diagnosticsService,\n+ loggerFactory,\nnameof(SupportRequestDbContext),\nconfiguration.Current.SqlConnectionStringSupportRequest,\nsecretInjector);\n@@ -451,7 +452,7 @@ protected override void Load(ContainerBuilder builder)\nbreak;\n}\n- RegisterAsynchronousValidation(builder, diagnosticsService, configuration, secretInjector);\n+ RegisterAsynchronousValidation(builder, loggerFactory, configuration, secretInjector);\nRegisterAuditingServices(builder, defaultAuditingService);\n@@ -829,10 +830,13 @@ private static void RegisterAsynchronousEmailMessagingService(ContainerBuilder b\n.InstancePerDependency();\n}\n- private static ISqlConnectionFactory CreateDbConnectionFactory(IDiagnosticsService diagnostics, string name,\n- string connectionString, ISecretInjector secretInjector)\n+ private static ISqlConnectionFactory CreateDbConnectionFactory(\n+ ILoggerFactory loggerFactory,\n+ string name,\n+ string connectionString,\n+ ISecretInjector secretInjector)\n{\n- var logger = diagnostics.SafeGetSource($\"AzureSqlConnectionFactory-{name}\");\n+ var logger = loggerFactory.CreateLogger($\"AzureSqlConnectionFactory-{name}\");\nreturn new AzureSqlConnectionFactory(connectionString, secretInjector, logger);\n}\n@@ -841,13 +845,14 @@ private static DbConnection CreateDbConnection(ISqlConnectionFactory connectionF\nreturn Task.Run(() => connectionFactory.CreateAsync()).Result;\n}\n- private static void ConfigureGalleryReadOnlyReplicaEntitiesContext(ContainerBuilder builder,\n- IDiagnosticsService diagnostics,\n+ private static void ConfigureGalleryReadOnlyReplicaEntitiesContext(\n+ ContainerBuilder builder,\n+ ILoggerFactory loggerFactory,\nConfigurationService configuration,\nISecretInjector secretInjector)\n{\nvar galleryDbReadOnlyReplicaConnectionFactory = CreateDbConnectionFactory(\n- diagnostics,\n+ loggerFactory,\nnameof(ReadOnlyEntitiesContext),\nconfiguration.Current.SqlReadOnlyReplicaConnectionString ?? configuration.Current.SqlConnectionString,\nsecretInjector);\n@@ -861,11 +866,14 @@ private static DbConnection CreateDbConnection(ISqlConnectionFactory connectionF\n.InstancePerLifetimeScope();\n}\n- private static void ConfigureValidationEntitiesContext(ContainerBuilder builder, IDiagnosticsService diagnostics,\n- ConfigurationService configuration, ISecretInjector secretInjector)\n+ private static void ConfigureValidationEntitiesContext(\n+ ContainerBuilder builder,\n+ ILoggerFactory loggerFactory,\n+ ConfigurationService configuration,\n+ ISecretInjector secretInjector)\n{\nvar validationDbConnectionFactory = CreateDbConnectionFactory(\n- diagnostics,\n+ loggerFactory,\nnameof(ValidationEntitiesContext),\nconfiguration.Current.SqlConnectionStringValidation,\nsecretInjector);\n@@ -887,8 +895,11 @@ private static DbConnection CreateDbConnection(ISqlConnectionFactory connectionF\n.InstancePerLifetimeScope();\n}\n- private void RegisterAsynchronousValidation(ContainerBuilder builder, IDiagnosticsService diagnostics,\n- ConfigurationService configuration, ISecretInjector secretInjector)\n+ private void RegisterAsynchronousValidation(\n+ ContainerBuilder builder,\n+ ILoggerFactory loggerFactory,\n+ ConfigurationService configuration,\n+ ISecretInjector secretInjector)\n{\nbuilder\n.RegisterType<NuGet.Services.Validation.ServiceBusMessageSerializer>()\n@@ -914,7 +925,7 @@ private static DbConnection CreateDbConnection(ISqlConnectionFactory connectionF\nif (configuration.Current.AsynchronousPackageValidationEnabled)\n{\n- ConfigureValidationEntitiesContext(builder, diagnostics, configuration, secretInjector);\n+ ConfigureValidationEntitiesContext(builder, loggerFactory, configuration, secretInjector);\nbuilder\n.Register(c =>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PagesController.cs",
"diff": "@@ -159,7 +159,13 @@ public virtual async Task<ActionResult> Privacy()\n[HttpGet]\npublic virtual ActionResult SimulateError(SimulatedErrorType type = SimulatedErrorType.Exception)\n{\n+ switch (type)\n+ {\n+ case SimulatedErrorType.ExceptionInView:\n+ return View(type);\n+ default:\nreturn type.MapToMvcResult();\n}\n}\n}\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Extensions/SimulatedErrorTypeExtensions.cs",
"new_path": "src/NuGetGallery/Extensions/SimulatedErrorTypeExtensions.cs",
"diff": "@@ -59,6 +59,7 @@ public static ActionResult MapToMvcResult(this SimulatedErrorType type)\nthrow type.MapToException();\n}\n}\n+\npublic static string GetMessage(this SimulatedErrorType type)\n{\nreturn $\"{nameof(SimulatedErrorType)} {type}\";\n@@ -98,6 +99,9 @@ public static Exception MapToException(this SimulatedErrorType type)\nReasonPhrase = message,\n});\ncase SimulatedErrorType.Exception:\n+ case SimulatedErrorType.ExceptionInView:\n+ case SimulatedErrorType.ExceptionInInlineErrorPage:\n+ case SimulatedErrorType.ExceptionInDedicatedErrorPage:\nreturn new Exception(message);\ncase SimulatedErrorType.UserSafeException:\nreturn new UserSafeException(message);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Content Include=\"Areas\\Admin\\Views\\ApiKeys\\Index.cshtml\" />\n<Content Include=\"App_Data\\Files\\Content\\OData-Cache-Configuration.json\" />\n<Content Include=\"App_Data\\Files\\Content\\GitHubUsage.v1.json\" />\n- <None Include=\"Properties\\PublishProfiles\\nuget-staging-frontend.pubxml\" />\n<Content Include=\"Scripts\\gallery\\async-file-upload.js\" />\n<Content Include=\"Scripts\\gallery\\autocomplete.js\" />\n<Content Include=\"Scripts\\gallery\\bootstrap.js\" />\n<Content Include=\"Views\\Experiments\\SearchSideBySide.cshtml\" />\n<Content Include=\"Views\\Api\\HealthProbeApi.cshtml\" />\n<Content Include=\"Views\\Pages\\_Enable2FA.cshtml\" />\n+ <Content Include=\"Views\\Pages\\SimulateError.cshtml\" />\n</ItemGroup>\n<ItemGroup>\n<Service Include=\"{508349B6-6B84-4DF5-91F0-309BEEBAD82D}\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/RequestModels/SimulatedErrorType.cs",
"new_path": "src/NuGetGallery/RequestModels/SimulatedErrorType.cs",
"diff": "@@ -20,5 +20,8 @@ public enum SimulatedErrorType\nException,\nUserSafeException,\nReadOnlyMode,\n+ ExceptionInView,\n+ ExceptionInInlineErrorPage,\n+ ExceptionInDedicatedErrorPage,\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Errors/InternalError.cshtml",
"new_path": "src/NuGetGallery/Views/Errors/InternalError.cshtml",
"diff": "Response.StatusCode = 500;\n}\n+@if (StringComparer.OrdinalIgnoreCase.Equals(Request.Path, \"/pages/simulate-error\")\n+ && StringComparer.OrdinalIgnoreCase.Equals(Request.QueryString[\"type\"], SimulatedErrorType.ExceptionInInlineErrorPage.ToString()))\n+{\n+ throw SimulatedErrorType.ExceptionInInlineErrorPage.MapToException();\n+}\n+\n+@if (StringComparer.OrdinalIgnoreCase.Equals(Request.Path, \"/Errors/500\")\n+ && Request.Cookies[\"simulatedErrorType\"] != null\n+ && StringComparer.OrdinalIgnoreCase.Equals(Request.Cookies[\"simulatedErrorType\"].Value, SimulatedErrorType.ExceptionInDedicatedErrorPage.ToString()))\n+{\n+ throw SimulatedErrorType.ExceptionInDedicatedErrorPage.MapToException();\n+}\n+\[email protected](Url, Html, \"500\", \"Internal Server Error\", @<text>\n<p>An error occurred while processing your request. We really messed up this time...</p></text>, @<text>\n<p>We have logged the error and will look into it so that it doesn't happen again; however, if you keep seeing this page, please <a href=\"https://github.com/NuGet/NuGetGallery/issues\">file a bug!</a></p></text>)\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.FunctionalTests/ErrorHandling/SimulatedErrorRequest.cs",
"new_path": "tests/NuGetGallery.FunctionalTests/ErrorHandling/SimulatedErrorRequest.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n+using System.Collections.Generic;\nnamespace NuGetGallery.FunctionalTests.ErrorHandling\n{\n@@ -41,6 +42,18 @@ public string GetRelativePath()\nreturn $\"{path}?type={SimulatedErrorType}\";\n}\n+ public IReadOnlyDictionary<string, string> GetCookies()\n+ {\n+ var cookies = new Dictionary<string, string>();\n+\n+ if (SimulatedErrorType == SimulatedErrorType.ExceptionInDedicatedErrorPage)\n+ {\n+ cookies[\"simulatedErrorType\"] = SimulatedErrorType.ToString();\n+ }\n+\n+ return cookies;\n+ }\n+\npublic override bool Equals(object obj)\n{\nreturn Equals(obj as SimulatedErrorRequest);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.FunctionalTests/ErrorHandling/SimulatedErrorType.cs",
"new_path": "tests/NuGetGallery.FunctionalTests/ErrorHandling/SimulatedErrorType.cs",
"diff": "@@ -24,5 +24,8 @@ public enum SimulatedErrorType\nException,\nUserSafeException,\nReadOnlyMode,\n+ ExceptionInView,\n+ ExceptionInInlineErrorPage,\n+ ExceptionInDedicatedErrorPage,\n}\n}\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add simulated error for exceptions in view and error page (#7958)
Progress on https://github.com/NuGet/NuGetGallery/issues/7868 |
455,736 | 22.04.2020 09:25:48 | 25,200 | a0644313992f97be807594b37f208b04802402ba | Remove redirects from error handling and clean Elmah
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"new_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"diff": "@@ -237,6 +237,7 @@ private static void AppPostStart(IAppConfiguration configuration)\nGlobalFilters.Filters.Add(new ReadOnlyModeErrorFilter());\nGlobalFilters.Filters.Add(new AntiForgeryErrorFilter());\nGlobalFilters.Filters.Add(new UserDeletedErrorFilter());\n+ GlobalFilters.Filters.Add(new RequestValidationExceptionFilter());\nValueProviderFactories.Factories.Add(new HttpHeaderValueProviderFactory());\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Infrastructure\\ABTestEnrollmentState.cs\" />\n<Compile Include=\"Infrastructure\\ABTestEnrollmentFactory.cs\" />\n<Compile Include=\"Infrastructure\\CookieBasedABTestService.cs\" />\n+ <Compile Include=\"Infrastructure\\RequestValidationExceptionFilter.cs\" />\n<Compile Include=\"Infrastructure\\IABTestEnrollmentFactory.cs\" />\n<Compile Include=\"Infrastructure\\IABTestService.cs\" />\n<Compile Include=\"Infrastructure\\ILuceneDocumentFactory.cs\" />\n<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>\n<SubType>Designer</SubType>\n</Content>\n+ <Content Include=\"App_404.aspx\" />\n+ <Content Include=\"App_400.aspx\" />\n+ <Content Include=\"App_500.aspx\" />\n<Content Include=\"Areas\\Admin\\DynamicData\\FieldTemplates\\Url_Edit.ascx\" />\n<Content Include=\"Areas\\Admin\\DynamicData\\PageTemplates\\ListDetails.aspx\" />\n<Content Include=\"Content\\admin\\SupportRequestStyles.css\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<security allowRemoteAccess=\"true\"/>\n<errorFilter>\n<test>\n+ <or>\n<equal binding=\"HttpStatusCode\" value=\"404\" type=\"Int32\"/>\n+ <equal binding=\"HttpStatusCode\" value=\"409\" type=\"Int32\"/>\n+\n+ <regex binding=\"Exception.Message\" pattern=\"(?ix: \\b potentially \\b.+?\\b dangerous \\b.+?\\b value \\b.+?\\b detected \\b.+?\\b client \\b )\" />\n+\n+ <!-- Ignore errors from the simulated error (fault injection) test path. -->\n+ <equal binding=\"Context.Request.Path\" value=\"/pages/simulate-error\" type=\"String\" />\n+ <equal binding=\"Context.Request.Path\" value=\"/api/simulate-error\" type=\"String\" />\n+ <equal binding=\"Context.Request.Path\" value=\"/api/v1/SimulateError()\" type=\"String\" />\n+ <regex binding=\"Exception.Message\" pattern=\"^SimulatedErrorType \\w+$\" />\n+ </or>\n</test>\n</errorFilter>\n<errorLog type=\"Elmah.SqlErrorLog, Elmah, Version=1.2.14706.0, Culture=neutral, PublicKeyToken=57eac04b2e0f138e, processorArchitecture=MSIL\" connectionStringName=\"NuGetGallery\"/>\n<!-- Remove Default HTTP Handler -->\n<remove path=\"*\" verb=\"GET,HEAD,POST\"/>\n</httpHandlers>\n- <customErrors mode=\"RemoteOnly\" defaultRedirect=\"~/Errors/500\" redirectMode=\"ResponseRedirect\">\n- <!-- Adding ? at the end of the redirect URL prevents the illegal request to be passed\n- as a query parameter to the redirect URL and causing additional failures -->\n- <error statusCode=\"400\" redirect=\"~/Errors/400\"/>\n- <error statusCode=\"404\" redirect=\"~/Errors/404\"/>\n- <error statusCode=\"500\" redirect=\"~/Errors/500\"/>\n+ <customErrors mode=\"RemoteOnly\" defaultRedirect=\"~/App_500.aspx\" redirectMode=\"ResponseRewrite\">\n+ <error statusCode=\"400\" redirect=\"~/App_400.aspx\"/>\n+ <error statusCode=\"404\" redirect=\"~/App_404.aspx\"/>\n+ <error statusCode=\"500\" redirect=\"~/App_500.aspx\"/>\n</customErrors>\n<sessionState mode=\"Off\"/>\n</system.web>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Remove redirects from error handling and clean Elmah (#7960)
Progress on https://github.com/NuGet/NuGetGallery/issues/7868 |
455,737 | 24.04.2020 16:02:20 | 25,200 | e927718b992014f57551be62dab31d86c9a8ffb7 | Use ToLowerInvariant to avoid locale issues. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Authentication/ApiKeyV4.cs",
"new_path": "src/NuGetGallery.Services/Authentication/ApiKeyV4.cs",
"diff": "@@ -143,7 +143,7 @@ private bool TryParseInternal(string plaintextApiKey)\nprivate string Normalize(string input)\n{\n- return input.ToLower();\n+ return input.ToLowerInvariant();\n}\n}\n}\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Use ToLowerInvariant to avoid locale issues. (#7967) |
455,744 | 27.04.2020 17:16:06 | 25,200 | bc46376a638add24f21784bb23eaf6feac280194 | Not using `Uri.ToString()`. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageHelper.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageHelper.cs",
"diff": "@@ -67,7 +67,7 @@ public static bool TryPrepareUrlForRendering(string uriString, out string readyU\nif (returnUri != null)\n{\n- readyUriString = returnUri.ToString();\n+ readyUriString = returnUri.AbsoluteUri;\nreturn true;\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Not using `Uri.ToString()`. (#7970) |
455,736 | 24.04.2020 16:32:10 | 25,200 | 8178e167690a920e25a4d7c349db119aa18d4c2c | Add support for alternate instrumentation system in browser
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/Configuration/GalleryConfiguration.cs",
"new_path": "src/AccountDeleter/Configuration/GalleryConfiguration.cs",
"diff": "@@ -112,5 +112,6 @@ public string SiteRoot\npublic int? MaxWorkerThreads { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic int? MinIoThreads { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic int? MaxIoThreads { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n+ public string InternalMicrosoftTenantKey { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/AppConfiguration.cs",
"diff": "@@ -413,5 +413,6 @@ public string ExternalBrandingMessage\npublic int? MinIoThreads { get; set; }\n[DefaultValue(null)]\npublic int? MaxIoThreads { get; set; }\n+ public string InternalMicrosoftTenantKey { get; set; }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"new_path": "src/NuGetGallery.Services/Configuration/IAppConfiguration.cs",
"diff": "@@ -210,6 +210,12 @@ public interface IAppConfiguration : IMessageServiceConfiguration\n/// </summary>\nint AppInsightsHeartbeatIntervalSeconds { get; set; }\n+ /// <summary>\n+ /// The tenant key used for Microsoft's internal instrumentation system similar to Application Insights.\n+ /// Because it is internal, this setting is not useful if used outside of Microsoft.\n+ /// </summary>\n+ string InternalMicrosoftTenantKey { get; set; }\n+\n/// <summary>\n/// Gets the protocol-independent site root\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Code/ViewHelpers.cshtml",
"new_path": "src/NuGetGallery/App_Code/ViewHelpers.cshtml",
"diff": "@helper InstrumentationScript()\n{\n- // Get instrumentation key\n+ // Get instrumentation keys\nvar config = DependencyResolver.Current.GetService<IGalleryConfigurationService>();\nvar iKey = config == null ? string.Empty : config.Current.AppInsightsInstrumentationKey;\nvar samplingPct = config == null ? 100 : config.Current.AppInsightsSamplingPercentage;\n+ var tenantKey = config == null ? string.Empty : config.Current.InternalMicrosoftTenantKey;\n- if (!string.IsNullOrEmpty(iKey))\n+ if (!string.IsNullOrEmpty(iKey) || !string.IsNullOrEmpty(tenantKey))\n{\nvar cookieService = DependencyResolver.Current.GetService<ICookieComplianceService>();\nif (cookieService.CanWriteNonEssentialCookies(Request))\n{\n- <!-- Telemetry -->\n+ if (!string.IsNullOrEmpty(tenantKey))\n+ {\n+ @System.Web.Optimization.Scripts.Render(\"~/Scripts/gallery/instrumentation.min.js\")\n+ <script type=\"text/javascript\">\n+ if (window.initializeNuGetInstrumentation) {\n+ window.NuGetInstrumentation = window.initializeNuGetInstrumentation({\n+ appInsightsInstrumentationKey: \"@iKey\",\n+ appInsightsSamplingPercentage: @samplingPct,\n+ tenantKey: \"@tenantKey\",\n+ });\n+ }\n+ </script>\n+ }\n+ else\n+ {\n<script type=\"text/javascript\">\nvar appInsights = window.appInsights || function (config) {\nfunction s(config) {\n}\n}\n}\n+}\n@helper ReleaseTag()\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"new_path": "src/NuGetGallery/App_Start/AppActivator.cs",
"diff": "@@ -124,6 +124,10 @@ private static void BundlingPostStart()\n.Include(\"~/Content/gallery/css/fabric.css\");\nBundleTable.Bundles.Add(newStyleBundle);\n+ var instrumentationBundle = new ScriptBundle(\"~/Scripts/gallery/instrumentation.min.js\")\n+ .Include(\"~/Scripts/gallery/instrumentation.js\");\n+ BundleTable.Bundles.Add(instrumentationBundle);\n+\nvar scriptBundle = new ScriptBundle(\"~/Scripts/gallery/site.min.js\")\n.Include(\"~/Scripts/gallery/jquery-3.4.1.js\")\n.Include(\"~/Scripts/gallery/jquery.validate-1.16.0.js\")\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "</Content>\n<Content Include=\"Areas\\Admin\\Views\\Revalidation\\Index.cshtml\" />\n<Content Include=\"App_Data\\Files\\Content\\Symbols-Configuration.json\" />\n+ <Content Include=\"Scripts\\gallery\\instrumentation.js\" />\n<Content Include=\"Views\\Shared\\SiteMenu.cshtml\">\n<SubType>Code</SubType>\n</Content>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Scripts/gallery/common.js",
"new_path": "src/NuGetGallery/Scripts/gallery/common.js",
"diff": "return typeof window.appInsights === 'object';\n};\n+ nuget.isInstrumentationAvailable = function () {\n+ return typeof window.NuGetInstrumentation === 'object';\n+ };\n+\nnuget.getDateFormats = function (input) {\nvar datetime = moment.utc(input);\n}\n};\n- nuget.sendAiMetric = function (name, value, properties) {\n- if (window.nuget.isAiAvailable()) {\n+ nuget.sendMetric = function (name, value, properties) {\n+ if (window.nuget.isInstrumentationAvailable()) {\n+ window.NuGetInstrumentation.trackMetric({\n+ name: name,\n+ average: value,\n+ sampleCount: 1,\n+ min: value,\n+ max: value\n+ }, properties);\n+ } else if (window.nuget.isAiAvailable()) {\nwindow.appInsights.trackMetric(name, value, 1, value, value, properties);\n}\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/NuGetGallery/Scripts/gallery/instrumentation.js",
"diff": "+window[\"initializeNuGetInstrumentation\"] = function (config) {\n+ var instrumentation = {\n+ initialize: function () {\n+ console.log(\"NuGet instrumentation shim: initialized %o\", config);\n+ },\n+ trackMetric: function (metric, customProperties) {\n+ console.log(\"NuGet instrumentation shim: metric %o %o\", metric, customProperties);\n+ }\n+ };\n+ instrumentation.initialize();\n+ return instrumentation;\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Scripts/gallery/page-home.js",
"new_path": "src/NuGetGallery/Scripts/gallery/page-home.js",
"diff": "@@ -49,7 +49,7 @@ $(function () {\ndata: obj,\nsuccess: function (data) {\nif (data.success) {\n- emitAIMetric(\"Enable2FAModalProvidedFeedback\");\n+ emitMetric(\"Enable2FAModalProvidedFeedback\");\nviewModel.dismissModalOrGetFeedback(false);\n} else {\nviewModel.message(data.message);\n@@ -65,7 +65,7 @@ $(function () {\nviewModel.setupFeedbackView();\n}\nelse {\n- emitAIMetric('Enable2FAModalDismissed');\n+ emitMetric('Enable2FAModalDismissed');\n$(\"#popUp2FAModal\").modal('hide');\n}\n},\n@@ -109,15 +109,15 @@ $(function () {\nfunction show2FAModal() {\nviewModel.setupEnable2FAView();\n- emitAIMetric(\"Enable2FAModalShown\");\n+ emitMetric(\"Enable2FAModalShown\");\n$(\"#popUp2FAModal\").modal({\nshow: true,\nfocus: true\n});\n}\n- function emitAIMetric(metricName) {\n- window.nuget.sendAiMetric(metricName, 1, {});\n+ function emitMetric(metricName) {\n+ window.nuget.sendMetric(metricName, 1, {});\n}\nfunction updateStats() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Shared/ListPackages.cshtml",
"new_path": "src/NuGetGallery/Views/Shared/ListPackages.cshtml",
"diff": "// event to be correlated in Google Analytics.\n<text>\nwindow.nuget.sendAnalyticsEvent('@category', '@action', @Html.Raw(Json.Encode(Model.SearchTerm)), @Model.PageIndex);\n- window.nuget.sendAiMetric('BrowserSearchPage', @Model.PageIndex, {\n+ window.nuget.sendMetric('BrowserSearchPage', @Model.PageIndex, {\nSearchId: '@searchId',\nSearchTerm: @Html.Raw(Json.Encode(Model.SearchTerm)),\nIncludePrerelease: '@Model.IncludePrerelease',\n}\n$(function () {\n- var emitAiClickEvent = function () {\n- if (!window.nuget.isAiAvailable()) {\n- return;\n- }\n-\n+ var emitClickEvent = function () {\nvar $this = $(this);\nvar data = $this.data();\nif ($this.attr('href') && data.track) {\n- window.nuget.sendAiMetric('BrowserSearchSelection', data.trackValue, {\n+ window.nuget.sendMetric('BrowserSearchSelection', data.trackValue, {\nSearchId: '@searchId',\nSearchTerm: @Html.Raw(Json.Encode(Model.SearchTerm)),\nIncludePrerelease: '@Model.IncludePrerelease',\n$.each($('a[data-track]'), function () {\n$(this).on('mouseup', function (e) {\nif (e.which === 2) { // Middle-mouse click\n- emitAiClickEvent.call(this, e);\n+ emitClickEvent.call(this, e);\n}\n});\n$(this).on('click', function (e) {\n- emitAiClickEvent.call(this, e);\n+ emitClickEvent.call(this, e);\n});\n});\n});\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add support for alternate instrumentation system in browser (#7971)
Progress on https://github.com/NuGet/Engineering/issues/3020 |
455,736 | 29.04.2020 13:23:46 | 25,200 | 53b80d60412e85c604a25eb727352bef4eaeb3b5 | Add build hook to AccountDeleter and GitHubVulnerabilities2Db
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/AccountDeleter/AccountDeleter.csproj",
"new_path": "src/AccountDeleter/AccountDeleter.csproj",
"diff": "</PropertyGroup>\n<Import Project=\"$(SignPath)\\sign.targets\" Condition=\"Exists('$(SignPath)\\sign.targets')\" />\n<Import Project=\"$(SignPath)\\sign.microbuild.targets\" Condition=\"Exists('$(SignPath)\\sign.microbuild.targets')\" />\n+ <Import Project=\"$(NuGetBuildExtensions)\" Condition=\"'$(NuGetBuildExtensions)' != '' And Exists('$(NuGetBuildExtensions)')\" />\n</Project>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<Import Project=\"$(MSBuildToolsPath)\\Microsoft.CSharp.targets\" />\n<Import Project=\"$(SignPath)\\sign.targets\" Condition=\"Exists('$(SignPath)\\sign.targets')\" />\n<Import Project=\"$(SignPath)\\sign.microbuild.targets\" Condition=\"Exists('$(SignPath)\\sign.microbuild.targets')\" />\n+ <Import Project=\"$(NuGetBuildExtensions)\" Condition=\"'$(NuGetBuildExtensions)' != '' And Exists('$(NuGetBuildExtensions)')\" />\n</Project>\n\\ No newline at end of file\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add build hook to AccountDeleter and GitHubVulnerabilities2Db (#7973)
Progress on https://github.com/NuGet/Engineering/issues/2891 |
455,736 | 11.05.2020 13:06:53 | 25,200 | 1e6329b96ee098ed10fd0de678b1730427291c0d | Remove unnecessary binding redirect
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<assemblyIdentity name=\"Microsoft.ApplicationInsights\" publicKeyToken=\"31BF3856AD364E35\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-2.12.0.21496\" newVersion=\"2.12.0.21496\"/>\n</dependentAssembly>\n- <dependentAssembly>\n- <assemblyIdentity name=\"MessagePack\" publicKeyToken=\"B4A0369545F0A1BE\" culture=\"neutral\"/>\n- <bindingRedirect oldVersion=\"0.0.0.0-1.9.0.0\" newVersion=\"1.9.0.0\"/>\n- </dependentAssembly>\n<dependentAssembly>\n<assemblyIdentity name=\"EntityFramework\" publicKeyToken=\"B77A5C561934E089\" culture=\"neutral\"/>\n<bindingRedirect oldVersion=\"0.0.0.0-6.0.0.0\" newVersion=\"6.0.0.0\"/>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Remove unnecessary binding redirect (#7989)
Progress on https://github.com/NuGet/Engineering/issues/3128 |
455,754 | 08.05.2020 16:01:18 | -36,000 | 10dee3eca16738e8e8891999df2670246c2c0f67 | ListPackages (default packages action) now responds to delete requests with a 405. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -796,6 +796,10 @@ private static async Task<byte[]> ReadPackageFile(PackageArchiveReader packageAr\n}\n}\n+ [HttpDelete]\n+ public HttpStatusCodeResult DisplayPackage() => new HttpStatusCodeResult(HttpStatusCode.MethodNotAllowed);\n+\n+ [HttpGet]\npublic virtual async Task<ActionResult> DisplayPackage(string id, string version)\n{\nstring normalized = NuGetVersionFormatter.Normalize(version);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | ListPackages (default packages action) now responds to delete requests with a 405. |
455,754 | 12.05.2020 13:38:07 | -36,000 | e805b73a823b094c7168719f7edd43f68938a3ad | Added header to result, and test | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "using System;\nusing System.Collections.Generic;\n+using System.Collections.Specialized;\nusing System.Diagnostics;\nusing System.Globalization;\nusing System.IO;\n@@ -796,8 +797,10 @@ private static async Task<byte[]> ReadPackageFile(PackageArchiveReader packageAr\n}\n}\n+ // This additional delete action addresses issue https://github.com/NuGet/Engineering/issues/2866 - we need to error out.\n[HttpDelete]\n- public HttpStatusCodeResult DisplayPackage() => new HttpStatusCodeResult(HttpStatusCode.MethodNotAllowed);\n+ public HttpStatusCodeResult DisplayPackage()\n+ => new HttpStatusCodeWithHeadersResult(HttpStatusCode.MethodNotAllowed, new NameValueCollection() { { \"allow\", \"GET\" } });\n[HttpGet]\npublic virtual async Task<ActionResult> DisplayPackage(string id, string version)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Infrastructure\\ABTestEnrollmentFactory.cs\" />\n<Compile Include=\"Infrastructure\\CookieBasedABTestService.cs\" />\n<Compile Include=\"Infrastructure\\RequestValidationExceptionFilter.cs\" />\n+ <Compile Include=\"Infrastructure\\HttpStatusCodeWithHeadersResult.cs\" />\n<Compile Include=\"Infrastructure\\IABTestEnrollmentFactory.cs\" />\n<Compile Include=\"Infrastructure\\IABTestService.cs\" />\n<Compile Include=\"Infrastructure\\ILuceneDocumentFactory.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ControllerTests.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ControllerTests.cs",
"diff": "@@ -74,6 +74,7 @@ public void AllActionsHaveAntiForgeryTokenIfNotGet()\nnew ControllerActionRuleException(typeof(ApiController), nameof(ApiController.DeletePackage)),\nnew ControllerActionRuleException(typeof(ApiController), nameof(ApiController.PublishPackage)),\nnew ControllerActionRuleException(typeof(ApiController), nameof(ApiController.DeprecatePackage)),\n+ new ControllerActionRuleException(typeof(PackagesController), nameof(PackagesController.DisplayPackage)),\n};\n// Act\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"diff": "using System;\nusing System.Collections;\nusing System.Collections.Generic;\n+using System.Collections.Specialized;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n@@ -498,6 +499,19 @@ public async Task GivenANonExistentPackageIt404s()\nResultAssert.IsNotFound(result);\n}\n+ [Fact]\n+ public void GivenADeleteMethodIt405sWithAllowHeader()\n+ {\n+ // Arrange\n+ var controller = CreateController(GetConfigurationService());\n+\n+ // Act\n+ var result = controller.DisplayPackage();\n+\n+ // Assert\n+ ResultAssert.IsStatusCodeWithHeaders(result, HttpStatusCode.MethodNotAllowed, new NameValueCollection() { { \"allow\", \"GET\" } });\n+ }\n+\npublic static IEnumerable<PackageStatus> ValidatingPackageStatuses =\nnew[] { PackageStatus.Validating, PackageStatus.FailedValidation };\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/TestUtils/ResultAssert.cs",
"new_path": "tests/NuGetGallery.Facts/TestUtils/ResultAssert.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\nusing System.Collections.Generic;\n+using System.Collections.Specialized;\nusing System.Net;\nusing System.Web.Mvc;\nusing System.Web.Routing;\n@@ -127,6 +128,19 @@ public static HttpStatusCodeResult IsStatusCode(ActionResult result, int statusC\nreturn statusCodeResult;\n}\n+ public static HttpStatusCodeWithHeadersResult IsStatusCodeWithHeaders(ActionResult result, HttpStatusCode statusCode, NameValueCollection headers)\n+ {\n+ var statusCodeResult = Assert.IsAssignableFrom<HttpStatusCodeWithHeadersResult>(result);\n+ Assert.Equal((int)statusCode, statusCodeResult.StatusCode);\n+\n+ foreach (var key in headers.AllKeys)\n+ {\n+ Assert.Equal(headers.Get(key), statusCodeResult.Headers.Get(key));\n+ }\n+\n+ return statusCodeResult;\n+ }\n+\npublic static EmptyResult IsEmpty(ActionResult result)\n{\nreturn Assert.IsType<EmptyResult>(result);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Added header to result, and test |
455,754 | 12.05.2020 17:49:36 | -36,000 | e8acf7d79ebaf19e561565a865f9be14b99a5f36 | Force a number of significant figures in Y axis values | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"diff": "@@ -142,22 +142,37 @@ public string DisplayPercentage(float amount, float total)\nreturn (amount / total).ToString(\"P0\", CultureInfo.CurrentCulture);\n}\n- public string DisplayShortNumber(long number)\n+ public string DisplayShortNumber(double number, int sigFigures = 3)\n{\nvar numDiv = 0;\nwhile (number >= 1000)\n{\n- number = number / 1000;\n+ number /= 1000;\nnumDiv++;\n}\n+ // Find a rounding factor based on size, and round to sigFigures, e.g. for 3 sig figs, 1.774545 becomes 1.77.\n+ var placeValues = Math.Ceiling(Math.Log10(number));\n+ var roundingFactor = Math.Pow(10, sigFigures - placeValues);\n+ var roundedNum = Math.Round(number * roundingFactor) / roundingFactor;\n+\n+ // Pad from right with zeroes to sigFigures length, so for 3 sig figs, 1.6 becomes 1.60\n+ var formattedNum = roundedNum.ToString(\"F\" + sigFigures);\n+ var desiredLength = formattedNum.Contains('.') ? sigFigures + 1 : sigFigures;\n+ if (formattedNum.Length > desiredLength)\n+ {\n+ formattedNum = formattedNum.Substring(0, desiredLength);\n+ }\n+\n+ formattedNum = formattedNum.TrimEnd('.');\n+\nif (numDiv >= _magnitudeAbbreviations.Length)\n{\n- return number + $\"10^{numDiv*3}\";\n+ return formattedNum + $\"10^{numDiv*3}\";\n}\n- return number + _magnitudeAbbreviations[numDiv];\n+ return formattedNum + _magnitudeAbbreviations[numDiv];\n}\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Force a number of significant figures in Y axis values |
455,754 | 13.05.2020 09:38:19 | -36,000 | 020aed833a4fbbde4d0ede6ac885a18ee83bc593 | Add unit test for short number formatter | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"diff": "@@ -18,7 +18,7 @@ public enum WeekFormats\nYearWeekNumber\n}\n- private readonly string[] _magnitudeAbbreviations = new string[] { \"\", \"k\", \"M\", \"B\", \"T\", \"q\", \"Q\", \"s\", \"S\", \"o\", \"n\" };\n+ private static readonly string[] _magnitudeAbbreviations = new string[] { \"\", \"k\", \"M\", \"B\", \"T\", \"q\", \"Q\", \"s\", \"S\", \"o\", \"n\" };\nprivate DateTime? _lastUpdatedUtc;\n@@ -142,7 +142,9 @@ public string DisplayPercentage(float amount, float total)\nreturn (amount / total).ToString(\"P0\", CultureInfo.CurrentCulture);\n}\n- public string DisplayShortNumber(double number, int sigFigures = 3)\n+ public string DisplayShortNumber(double number) => DisplayShortNumber(number, sigFigures: 3);\n+\n+ internal static string DisplayShortNumber(double number, int sigFigures = 3)\n{\nvar numDiv = 0;\n@@ -152,7 +154,7 @@ public string DisplayShortNumber(double number, int sigFigures = 3)\nnumDiv++;\n}\n- // Find a rounding factor based on size, and round to sigFigures, e.g. for 3 sig figs, 1.774545 becomes 1.77.\n+ // Find a rounding factor based on size, and round to sigFigures, e.g. for 3 sig figs, 1.776545 becomes 1.78.\nvar placeValues = Math.Ceiling(Math.Log10(number));\nvar roundingFactor = Math.Pow(10, sigFigures - placeValues);\nvar roundedNum = Math.Round(number * roundingFactor) / roundingFactor;\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"new_path": "tests/NuGetGallery.Facts/NuGetGallery.Facts.csproj",
"diff": "<Compile Include=\"ViewModels\\ListPackageItemRequiredSignerViewModelFacts.cs\" />\n<Compile Include=\"ViewModels\\ListPackageItemViewModelFacts.cs\" />\n<Compile Include=\"ViewModels\\PackageViewModelFacts.cs\" />\n+ <Compile Include=\"ViewModels\\StatisticsPackagesViewModelFacts.cs\" />\n<Compile Include=\"ViewModels\\PreviousNextPagerViewModelFacts.cs\" />\n<Compile Include=\"ViewModels\\SignerViewModelFacts.cs\" />\n<Compile Include=\"ViewModels\\UserProfileModelFacts.cs\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add unit test for short number formatter |
455,754 | 18.05.2020 14:14:11 | -36,000 | ac27bd5ce0c8e66e2135fe260e797b22ff86d425 | Append FAQ address to AAD unmanaged tenant authentication error
Append FAQ address to AAD unmanaged tenant authentication error | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"new_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"diff": "@@ -810,10 +810,23 @@ private string GetEmailAddressFromExternalLoginResult(AuthenticateExternalLoginR\n}\nprivate ActionResult AuthenticationFailureOrExternalLinkExpired(string errorMessage = null)\n+ {\n+ // We need a special case here because of https://github.com/NuGet/NuGetGallery/issues/7544. An unmanaged tenant scenario\n+ // needs the FAQ URI appended to the AAD error, and we do that here so it appears in the header.\n+ if (!string.IsNullOrEmpty(errorMessage) &&\n+ errorMessage.IndexOf(\"AADSTS65005\", StringComparison.OrdinalIgnoreCase) > -1 &&\n+ errorMessage.IndexOf(\"unmanaged\", StringComparison.OrdinalIgnoreCase) > -1)\n+ {\n+ TempData[\"RawErrorMessage\"] = errorMessage + \"<br/>\" + string.Format(Strings.DirectUserToUnmanagedTenantFAQ,\n+ UriExtensions.GetExternalUrlAnchorTag(\"FAQs page\", GalleryConstants.FAQLinks.AccountBelongsToUnmanagedTenant));\n+ }\n+ else\n{\n// User got here without an external login cookie (or an expired one)\n// Send them to the logon action with a message\nTempData[\"ErrorMessage\"] = string.IsNullOrEmpty(errorMessage) ? Strings.ExternalAccountLinkExpired : errorMessage;\n+ }\n+\nreturn Redirect(Url.LogOn(null, relativeUrl: false));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/GalleryConstants.cs",
"new_path": "src/NuGetGallery/GalleryConstants.cs",
"diff": "@@ -113,6 +113,7 @@ public static class FAQLinks\npublic const string NuGetChangeUsername = \"https://aka.ms/nuget-faq-change-username\";\npublic const string NuGetDeleteAccount = \"https://aka.ms/nuget-faq-delete-account\";\npublic const string TransformToOrganization = \"https://aka.ms/nuget-faq-transform-org\";\n+ public const string AccountBelongsToUnmanagedTenant = \"https://aka.ms/nuget-faq-unmanaged-tenant\";\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.Designer.cs",
"new_path": "src/NuGetGallery/Strings.Designer.cs",
"diff": "@@ -865,6 +865,15 @@ public class Strings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to Please refer to the {0} for steps to resolve this issue..\n+ /// </summary>\n+ public static string DirectUserToUnmanagedTenantFAQ {\n+ get {\n+ return ResourceManager.GetString(\"DirectUserToUnmanagedTenantFAQ\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to The password login is discontinued and has been removed for your account. Please use your Microsoft account to log into {0} going forward..\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.resx",
"new_path": "src/NuGetGallery/Strings.resx",
"diff": "@@ -693,6 +693,9 @@ For more information, please contact '{2}'.</value>\n<value>The account with the email {0} is linked to another Microsoft account.\nIf you would like to update the linked Microsoft account you can do so from the account settings page.</value>\n</data>\n+ <data name=\"DirectUserToUnmanagedTenantFAQ\" xml:space=\"preserve\">\n+ <value>Please refer to the {0} for steps to resolve this issue.</value>\n+ </data>\n<data name=\"ChangeCredential_Failed\" xml:space=\"preserve\">\n<value>Failed to update the Microsoft account with '{0}'. This could happen if it is already linked to another NuGet account. See {1} for more details.</value>\n</data>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Append FAQ address to AAD unmanaged tenant authentication error (#7993)
Append FAQ address to AAD unmanaged tenant authentication error |
455,754 | 20.05.2020 16:46:32 | -36,000 | 73b80387d68d69eb88261f247f3c1bfdd38f9345 | Suppress ValidateAntiForgeryToken message in FxCop (nuget.exe doesn't provide one) | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "using System.Collections.Generic;\nusing System.Collections.Specialized;\nusing System.Diagnostics;\n+using System.Diagnostics.CodeAnalysis;\nusing System.Globalization;\nusing System.IO;\nusing System.Linq;\n@@ -799,6 +800,7 @@ private static async Task<byte[]> ReadPackageFile(PackageArchiveReader packageAr\n// This additional delete action addresses issue https://github.com/NuGet/Engineering/issues/2866 - we need to error out.\n[HttpDelete]\n+ [SuppressMessage(\"Microsoft.Security.Web.Configuration\", \"CA3147: Missing ValidateAntiForgeryTokenAttribute\", Justification = \"nuget.exe will not provide a token\")]\npublic HttpStatusCodeResult DisplayPackage()\n=> new HttpStatusCodeWithHeadersResult(HttpStatusCode.MethodNotAllowed, new NameValueCollection() { { \"allow\", \"GET\" } });\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Suppress ValidateAntiForgeryToken message in FxCop (nuget.exe doesn't provide one) (#7998) |
455,741 | 20.05.2020 19:02:32 | 25,200 | ca0db5127a818355ee2e0e0eb7c3541a8e4e094f | UI fix for long username in profile page and display package(#7809) | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -998,6 +998,10 @@ img.reserved-indicator-icon {\n}\n.page-package-details .owner-list li {\nmargin-bottom: 8px;\n+ display: block;\n+ overflow: hidden;\n+ white-space: nowrap;\n+ text-overflow: ellipsis;\n}\n.page-package-details .owner-list img {\nmargin-right: 8px;\n@@ -1438,6 +1442,9 @@ img.reserved-indicator-icon {\ndisplay: -webkit-flex;\ndisplay: -ms-flexbox;\ndisplay: flex;\n+ -webkit-flex-wrap: wrap;\n+ -ms-flex-wrap: wrap;\n+ flex-wrap: wrap;\n-webkit-box-pack: justify;\n-webkit-justify-content: space-between;\n-ms-flex-pack: justify;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/page-display-package.less",
"new_path": "src/Bootstrap/less/theme/page-display-package.less",
"diff": ".owner-list {\nli {\nmargin-bottom: 8px;\n+ display: block;\n+ overflow: hidden;\n+ white-space: nowrap;\n+ text-overflow: ellipsis;\n}\nimg {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/page-profile.less",
"new_path": "src/Bootstrap/less/theme/page-profile.less",
"diff": "margin-top: (@padding-large-vertical * 5);\ndisplay: flex;\n+ flex-wrap: wrap;\njustify-content: space-between;\nalign-items: baseline;\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | UI fix for long username in profile page and display package(#7809) |
455,744 | 29.05.2020 14:30:07 | 25,200 | 3e83e7fe85d020b7d10d04d4d11ead0968d18ce3 | Fix for statistics not refreshing | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Services/JsonStatisticsService.cs",
"new_path": "src/NuGetGallery/Services/JsonStatisticsService.cs",
"diff": "@@ -32,6 +32,11 @@ public class JsonStatisticsService : IStatisticsService\n/// </summary>\nprivate readonly IReportService _reportService;\n+ /// <summary>\n+ /// Mockable source of current time.\n+ /// </summary>\n+ private readonly IDateTimeProvider _dateTimeProvider;\n+\n/// <summary>\n/// The semaphore used to update the statistics service's reports.\n/// </summary>\n@@ -52,9 +57,10 @@ public class JsonStatisticsService : IStatisticsService\nprivate readonly List<StatisticsNuGetUsageItem> _nuGetClientVersion = new List<StatisticsNuGetUsageItem>();\nprivate readonly List<StatisticsWeeklyUsageItem> _last6Weeks = new List<StatisticsWeeklyUsageItem>();\n- public JsonStatisticsService(IReportService reportService)\n+ public JsonStatisticsService(IReportService reportService, IDateTimeProvider dateTimeProvider)\n{\n- _reportService = reportService;\n+ _reportService = reportService ?? throw new ArgumentNullException(nameof(reportService));\n+ _dateTimeProvider = dateTimeProvider ?? throw new ArgumentNullException(nameof(dateTimeProvider));\n}\npublic StatisticsReportResult PackageDownloadsResult { get; private set; }\n@@ -126,7 +132,7 @@ public async Task Refresh()\n.Select(r => r.LastUpdatedUtc)\n.FirstOrDefault();\n- _lastRefresh = DateTime.UtcNow;\n+ _lastRefresh = _dateTimeProvider.UtcNow;\n}\nfinally\n{\n@@ -143,7 +149,7 @@ private bool ShouldRefresh()\nreturn true;\n}\n- return (_lastRefresh - DateTime.UtcNow) >= _refreshInterval;\n+ return (_dateTimeProvider.UtcNow - _lastRefresh) >= _refreshInterval;\n}\nprivate Task<StatisticsReportResult> LoadDownloadPackages()\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"diff": "@@ -2780,7 +2780,7 @@ public async Task VerifyRecentPopularityStatsDownloads()\nvar controller = new TestableApiController(GetConfigurationService())\n{\n- StatisticsService = new JsonStatisticsService(fakeReportService.Object),\n+ StatisticsService = new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()),\n};\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n@@ -2831,7 +2831,7 @@ public async Task VerifyRecentPopularityStatsDownloadsCount()\nvar controller = new TestableApiController(GetConfigurationService())\n{\n- StatisticsService = new JsonStatisticsService(fakeReportService.Object),\n+ StatisticsService = new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()),\n};\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/StatisticsControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/StatisticsControllerFacts.cs",
"diff": "@@ -108,7 +108,7 @@ public async Task StatisticsHomePage_ValidateReportStructureAndAvailability()\nfakeReportService.Setup(x => x.Load(\"nugetclientversion.json\")).Returns(Task.FromResult(new StatisticsReport(fakeNuGetClientVersion, DateTime.MinValue)));\nfakeReportService.Setup(x => x.Load(\"last6weeks.json\")).Returns(Task.FromResult(new StatisticsReport(fakeLast6Weeks, updatedUtc)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nvar model = (StatisticsPackagesViewModel)((ViewResult)await controller.Index()).Model;\n@@ -218,7 +218,7 @@ public async Task StatisticsHomePage_ValidateFullReportStructureAndAvailability(\nfakeReportService.Setup(x => x.Load(\"nugetclientversion.json\")).Returns(Task.FromResult(new StatisticsReport(fakeNuGetClientVersion, DateTime.UtcNow)));\nfakeReportService.Setup(x => x.Load(\"last6weeks.json\")).Returns(Task.FromResult(new StatisticsReport(fakeLast6Weeks, DateTime.UtcNow)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nvar model = (StatisticsPackagesViewModel)((ViewResult)await controller.Index()).Model;\n@@ -282,7 +282,7 @@ public async Task StatisticsHomePage_Packages_ValidateReportStructureAndAvailabi\nfakeReportService.Setup(x => x.Load(\"recentpopularity.json\")).Returns(Task.FromResult(new StatisticsReport(fakePackageReport, DateTime.UtcNow)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nvar model = (StatisticsPackagesViewModel)((ViewResult)await controller.Packages()).Model;\n@@ -330,7 +330,7 @@ public async Task StatisticsHomePage_PackageVersions_ValidateReportStructureAndA\nfakeReportService.Setup(x => x.Load(\"recentpopularitydetail.json\")).Returns(Task.FromResult(new StatisticsReport(fakePackageVersionReport, updatedUtc1)));\nfakeReportService.Setup(x => x.Load(\"recentcommunitypopularitydetail.json\")).Returns(Task.FromResult(new StatisticsReport(fakePackageVersionReport, updatedUtc2)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nvar model = (StatisticsPackagesViewModel)((ViewResult)await controller.PackageVersions()).Model;\n@@ -353,7 +353,7 @@ public async void StatisticsHomePage_Per_Package_ValidateModel()\nvar fakeReportService = new Mock<IReportService>();\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n@@ -425,7 +425,7 @@ public async Task StatisticsHomePage_Per_Package_ValidateReportStructureAndAvail\nvar updatedUtc = new DateTime(2001, 01, 01, 10, 20, 30);\nfakeReportService.Setup(x => x.Load(reportName)).Returns(Task.FromResult(new StatisticsReport(fakeReport, updatedUtc)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n@@ -507,7 +507,7 @@ public async Task StatisticsHomePage_Per_Package_ValidateReportStructureAndAvail\nvar updatedUtc = new DateTime(2001, 01, 01, 10, 20, 30);\nfakeReportService.Setup(x => x.Load(reportName)).Returns(Task.FromResult(new StatisticsReport(fakeReport, updatedUtc)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n@@ -537,7 +537,7 @@ public async void Statistics_By_Client_Operation_ValidateModel()\nvar fakeReportService = new Mock<IReportService>();\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n@@ -611,7 +611,7 @@ public async Task Statistics_By_Client_Operation_ValidateReportStructureAndAvail\nvar updatedUtc = new DateTime(2001, 01, 01, 10, 20, 30);\nfakeReportService.Setup(x => x.Load(reportName)).Returns(Task.FromResult(new StatisticsReport(fakeReport, updatedUtc)));\n- var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object));\n+ var controller = new StatisticsController(new JsonStatisticsService(fakeReportService.Object, new DateTimeProvider()));\nTestUtility.SetupUrlHelperForUrlGeneration(controller);\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/JsonStatisticsServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/JsonStatisticsServiceFacts.cs",
"diff": "@@ -107,6 +107,25 @@ public async Task LoadReportsFailsIfDownloadsIsMissingOrNotInteger()\nVerifyReportsLoadedOnce();\n}\n+\n+ [Fact]\n+ public async Task RefreshesAfter1Hour()\n+ {\n+ var time = DateTime.UtcNow - TimeSpan.FromHours(2);\n+ _dateTimeProvider\n+ .SetupGet(st => st.UtcNow)\n+ .Returns(time);\n+\n+ await _target.Refresh();\n+ VerifyReportsLoadedOnce();\n+\n+ _dateTimeProvider\n+ .SetupGet(st => st.UtcNow)\n+ .Returns(time + TimeSpan.FromHours(1.1));\n+\n+ await _target.Refresh();\n+ VerifyReportsLoaded(Times.Exactly(2));\n+ }\n}\npublic class FactsBase\n@@ -124,6 +143,7 @@ public class FactsBase\npublic readonly int Package2Downloads = 789;\nprotected readonly Mock<IReportService> _reportService;\n+ protected readonly Mock<IDateTimeProvider> _dateTimeProvider;\nprotected readonly JsonStatisticsService _target;\nprotected Dictionary<string, object>[] PackageDownloadsReport => new[]\n@@ -168,8 +188,12 @@ public class FactsBase\npublic FactsBase()\n{\n_reportService = new Mock<IReportService>();\n+ _dateTimeProvider = new Mock<IDateTimeProvider>();\n+ _dateTimeProvider\n+ .SetupGet(st => st.UtcNow)\n+ .Returns(() => DateTime.UtcNow);\n- _target = new JsonStatisticsService(_reportService.Object);\n+ _target = new JsonStatisticsService(_reportService.Object, _dateTimeProvider.Object);\n}\nprotected void Mock(\n@@ -223,20 +247,22 @@ Task<StatisticsReport> CreateReport(IEnumerable<Dictionary<string, object>> repo\n.Returns(CreateReport(communityPackageVersionDownloadsReport, communityPackageVersionsLastUpdateTimeUtc));\n}\n- protected void VerifyReportsLoadedOnce()\n+ protected void VerifyReportsLoaded(Times times)\n{\n_reportService\n- .Verify(s => s.Load(It.Is<string>(n => n == \"recentpopularity.json\")), Times.Once);\n+ .Verify(s => s.Load(It.Is<string>(n => n == \"recentpopularity.json\")), times);\n_reportService\n- .Verify(s => s.Load(It.Is<string>(n => n == \"recentcommunitypopularity.json\")), Times.Once);\n+ .Verify(s => s.Load(It.Is<string>(n => n == \"recentcommunitypopularity.json\")), times);\n_reportService\n- .Verify(s => s.Load(It.Is<string>(n => n == \"recentpopularitydetail.json\")), Times.Once);\n+ .Verify(s => s.Load(It.Is<string>(n => n == \"recentpopularitydetail.json\")), times);\n_reportService\n- .Verify(s => s.Load(It.Is<string>(n => n == \"recentcommunitypopularitydetail.json\")), Times.Once);\n+ .Verify(s => s.Load(It.Is<string>(n => n == \"recentcommunitypopularitydetail.json\")), times);\n}\n+\n+ protected void VerifyReportsLoadedOnce() => VerifyReportsLoaded(Times.Once());\n}\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix for statistics not refreshing (#8015) |
455,756 | 01.06.2020 17:57:36 | 25,200 | 7950ae64186c4e54ac8e4861ab6ff654b24ad26e | client version | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/GalleryConstants.cs",
"new_path": "src/NuGetGallery/GalleryConstants.cs",
"diff": "@@ -27,7 +27,7 @@ public static class GalleryConstants\npublic const int GravatarCacheDurationSeconds = 300;\npublic const int MaxEmailSubjectLength = 255;\n- internal static readonly NuGetVersion MaxSupportedMinClientVersion = new NuGetVersion(\"5.6.0.0\");\n+ internal static readonly NuGetVersion MaxSupportedMinClientVersion = new NuGetVersion(\"5.7.0.0\");\npublic const string PackageFileDownloadUriTemplate = \"packages/{0}/{1}/download\";\npublic const string ReadMeFileSavePathTemplateActive = \"active/{0}/{1}{2}\";\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | client version (#8018) |
455,736 | 30.04.2020 01:15:43 | 0 | 6d955d13396271d3fe86d8b54790752177d59591 | Change to regex Matches instead of Replace
Also use ToJson which is more DRY. | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"new_path": "src/NuGetGallery/Controllers/AuthenticationController.cs",
"diff": "using System.Net.Mail;\nusing System.Security.Claims;\nusing System.Threading.Tasks;\n+using System.Web;\nusing System.Web.Mvc;\nusing NuGet.Services.Entities;\nusing NuGet.Services.Messaging.Email;\n@@ -527,7 +528,7 @@ public virtual async Task<ActionResult> LinkOrChangeExternalCredential(string re\n// The identity value contains cookie non-compliant characters like `<, >`(eg: John Doe <[email protected]>),\n// These need to be replaced so that they are not treated as HTML tags\nTempData[\"RawErrorMessage\"] = string.Format(Strings.ChangeCredential_Failed,\n- newCredential.Identity.Replace(\"<\", \"<\").Replace(\">\", \">\"),\n+ HttpUtility.HtmlEncode(newCredential.Identity),\nUriExtensions.GetExternalUrlAnchorTag(\"FAQs page\", GalleryConstants.FAQLinks.MSALinkedToAnotherAccount));\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Helpers/HtmlExtensions.cs",
"new_path": "src/NuGetGallery/Helpers/HtmlExtensions.cs",
"diff": "using System.Diagnostics;\nusing System.Linq;\nusing System.Linq.Expressions;\n+using System.Text;\nusing System.Text.RegularExpressions;\nusing System.Web;\nusing System.Web.Mvc;\n@@ -60,21 +61,34 @@ public static IHtmlString BreakWord(this HtmlHelper self, string text)\npublic static IHtmlString PreFormattedText(this HtmlHelper self, string text, IGalleryConfigurationService configurationService)\n{\n- // Encode HTML entities. Important! Security!\n- var encodedText = HttpUtility.HtmlEncode(text);\n- // Turn HTTP and HTTPS URLs into links.\n- // Source: https://stackoverflow.com/a/4750468\n- string anchorEvaluator(Match match)\n+ void appendText(StringBuilder builder, string inputText)\n+ {\n+ var encodedText = HttpUtility.HtmlEncode(inputText);\n+\n+ // Replace new lines with the <br /> tag.\n+ encodedText = encodedText.Replace(\"\\n\", \"<br />\");\n+\n+ // Replace more than one space in a row with a space then .\n+ encodedText = RegexEx.TryReplaceWithTimeout(\n+ encodedText,\n+ \" +\",\n+ match => \" \" + string.Join(string.Empty, Enumerable.Repeat(\" \", match.Value.Length - 1)),\n+ RegexOptions.None);\n+\n+ builder.Append(encodedText);\n+ }\n+\n+ void appendUrl(StringBuilder builder, string inputText)\n{\nstring trimmedEntityValue = string.Empty;\n- string trimmedAnchorValue = match.Value;\n+ string trimmedAnchorValue = inputText;\nforeach (var trimmedEntity in _trimmedHtmlEntities)\n{\n- if (match.Value.EndsWith(trimmedEntity))\n+ if (inputText.EndsWith(trimmedEntity))\n{\n// Remove trailing html entity from anchor URL\n- trimmedAnchorValue = match.Value.Substring(0, match.Value.Length - trimmedEntity.Length);\n+ trimmedAnchorValue = inputText.Substring(0, inputText.Length - trimmedEntity.Length);\ntrimmedEntityValue = trimmedEntity;\nbreak;\n@@ -85,36 +99,67 @@ string anchorEvaluator(Match match)\n{\nstring anchorText = formattedUri;\nstring siteRoot = configurationService.GetSiteRoot(useHttps: true);\n+\n// Format links to NuGet packages\n- Match packageMatch = RegexEx.MatchWithTimeout(formattedUri, $@\"({Regex.Escape(siteRoot)}\\/packages\\/(?<name>\\w+([_.-]\\w+)*(\\/[0-9a-zA-Z-.]+)?)\\/?$)\", RegexOptions.IgnoreCase);\n+ Match packageMatch = RegexEx.MatchWithTimeout(\n+ formattedUri,\n+ $@\"({Regex.Escape(siteRoot)}\\/packages\\/(?<name>\\w+([_.-]\\w+)*(\\/[0-9a-zA-Z-.]+)?)\\/?$)\",\n+ RegexOptions.IgnoreCase);\nif (packageMatch != null && packageMatch.Groups[\"name\"].Success)\n{\nanchorText = packageMatch.Groups[\"name\"].Value;\n}\n- return $\"<a href=\\\"{formattedUri}\\\" rel=\\\"nofollow\\\">{anchorText}</a>\" + trimmedEntityValue;\n+ builder.AppendFormat(\n+ \"<a href=\\\"{0}\\\" rel=\\\"nofollow\\\">{1}</a>{2}\",\n+ HttpUtility.HtmlEncode(formattedUri),\n+ HttpUtility.HtmlEncode(anchorText),\n+ HttpUtility.HtmlEncode(trimmedEntityValue));\n+ }\n+ else\n+ {\n+ builder.Append(HttpUtility.HtmlEncode(inputText));\n}\n-\n- return match.Value;\n}\n- encodedText = RegexEx.TryReplaceWithTimeout(\n- encodedText,\n+ // Turn HTTP and HTTPS URLs into links.\n+ // Source: https://stackoverflow.com/a/4750468\n+ var matches = RegexEx.MatchesWithTimeout(\n+ text,\n@\"((http|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?)\",\n- anchorEvaluator,\nRegexOptions.IgnoreCase);\n- // Replace new lines with the <br /> tag.\n- encodedText = encodedText.Replace(\"\\n\", \"<br />\");\n+ var output = new StringBuilder(text.Length);\n+ var currentIndex = 0;\n- // Replace more than one space in a row with a space then .\n- encodedText = RegexEx.TryReplaceWithTimeout(\n- encodedText,\n- \" +\",\n- match => \" \" + string.Join(string.Empty, Enumerable.Repeat(\" \", match.Value.Length - 1)),\n- RegexOptions.None);\n+ if (matches != null && matches.Count > 0)\n+ {\n+ foreach (Match match in matches)\n+ {\n+ // Encode the text literal before the URL, if any.\n+ var literalLength = match.Index - currentIndex;\n+ if (literalLength > 0)\n+ {\n+ var literal = text.Substring(currentIndex, literalLength);\n+ appendText(output, literal);\n+ }\n+\n+ // Encode the URL.\n+ var url = match.Value;\n+ appendUrl(output, url);\n+\n+ currentIndex = match.Index + match.Length;\n+ }\n+ }\n+\n+ // Encode the text literal appearing after the last URL, if any.\n+ if (currentIndex < text.Length)\n+ {\n+ var literal = text.Substring(currentIndex, text.Length - currentIndex);\n+ appendText(output, literal);\n+ }\n- return self.Raw(encodedText);\n+ return self.Raw(output.ToString());\n}\npublic static IHtmlString ValidationSummaryFor(this HtmlHelper html, string key)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Helpers/RegexEx.cs",
"new_path": "src/NuGetGallery/Helpers/RegexEx.cs",
"diff": "@@ -40,5 +40,20 @@ public static class RegexEx\nreturn null;\n}\n}\n+\n+ public static MatchCollection MatchesWithTimeout(\n+ string input,\n+ string pattern,\n+ RegexOptions options)\n+ {\n+ try\n+ {\n+ return Regex.Matches(input, pattern, options, Timeout);\n+ }\n+ catch (RegexMatchTimeoutException)\n+ {\n+ return null;\n+ }\n+ }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Organizations/ManageOrganization.cshtml",
"new_path": "src/NuGetGallery/Views/Organizations/ManageOrganization.cshtml",
"diff": "@section BottomScripts {\n<script type=\"text/javascript\">\n- var initialData = @Html.Raw(JsonConvert.SerializeObject(new\n+ var initialData = @Html.ToJson(new\n{\nAccountName = Model.AccountName,\nMembers = Model.Members.Select(m => new\nUpdateMemberUrl = Url.UpdateOrganizationMember(Model.AccountName),\nDeleteMemberUrl = Url.DeleteOrganizationMember(Model.AccountName),\nProfileUrlTemplate = Url.UserTemplate().LinkTemplate\n- }));\n+ });\n</script>\[email protected](this)\[email protected](\"~/Scripts/gallery/page-manage-organization.min.js\")\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"diff": "</style>\n<script type=\"text/javascript\">\n- var packageManagers = [@Html.Raw(string.Join(\",\", packageManagers.Select(pm => \"\\\"\" + pm.Id + \"\\\"\")))];\n+ var packageManagers = @Html.ToJson(packageManagers.Select(pm => pm.Id).ToList());\n</script>\[email protected](\"~/Scripts/gallery/page-display-package.min.js\")\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/Manage.cshtml",
"diff": "var strings_RemovingOrganization = \"@Html.Raw(Strings.ManagePackageOwners_RemovingOrganization)\";\nvar strings_RemovingSelf = \"@Html.Raw(Strings.ManagePackageOwners_RemovingSelf)\";\n- // We are using JsonConvert instead of Json to serialize JSON in this CSHTML file because otherwise, with a large number of versions, this will overflow the maximum output JSON length limit for Json.\n+ // We are using ToJson (which uses Newtonsoft.Json) instead of Json.Encode to serialize JSON in this CSHTML\n+ // file because otherwise, with a large number of versions, this will overflow the maximum output JSON length limit for Json.\n// Set up delete section\n- var versionListedState = @Html.Raw(JsonConvert.SerializeObject(Model.VersionListedStateDictionary));\n+ var versionListedState = @Html.ToJson(Model.VersionListedStateDictionary);\n// Set up deprecation section\nvar strings_SelectAlternateVersionOption = \"Latest\";\n- var versionDeprecationState = @Html.Raw(JsonConvert.SerializeObject(Model.VersionDeprecationStateDictionary));\n+ var versionDeprecationState = @Html.ToJson(Model.VersionDeprecationStateDictionary);\n$(function () {\n// Set up documentation section\nvar readMeModel = {\n- \"Versions\": @Html.Raw(JsonConvert.SerializeObject(Model.VersionReadMeStateDictionary)),\n+ \"Versions\": @Html.ToJson(Model.VersionReadMeStateDictionary),\n\"Edit\": @Html.Raw(Json.Encode(Model.ReadMe))\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"new_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"diff": "@section bottomScripts {\n<script type=\"text/javascript\">\n- var initialData = @Html.Raw(JsonConvert.SerializeObject(new\n+ var initialData = @Html.ToJson(new\n{\nApiKeys = Model.ApiKeys,\nPackageOwners = Model.PackageOwners,\nApiKeyNew = Url.Absolute(\"~/Content/gallery/img/api-key-new.svg\"),\nApiKeyNewFallback = Url.Absolute(\"~/Content/gallery/img/api-key-new-256x256.png\"),\n}\n- }));\n+ });\n</script>\[email protected](\"~/Scripts/gallery/page-api-keys.min.js\")\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/Packages.cshtml",
"new_path": "src/NuGetGallery/Views/Users/Packages.cshtml",
"diff": "var strings_RequiredSigner_AnyWithSignedResult = \"@Html.Raw(Strings.RequiredSigner_AnyWithSignedResult)\";\nvar strings_RequiredSigner_Confirm = \"@Html.Raw(Strings.RequiredSigner_Confirm)\";\n- var initialData = @Html.Raw(JsonConvert.SerializeObject(new\n+ var initialData = @Html.ToJson(new\n{\nOwners = Model.Owners,\nListedPackages = Model.ListedPackages\n.Select(r => GetSerializableOwnerRequest(r)),\nDefaultPackageIconUrl = Url.Absolute(\"~/Content/gallery/img/default-package-icon.svg\"),\nPackageIconUrlFallback = Url.Absolute(\"~/Content/gallery/img/default-package-icon-256x256.png\")\n- }));\n+ });\n</script>\[email protected](this)\[email protected](\"~/Scripts/gallery/page-manage-packages.min.js\")\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Change to regex Matches instead of Replace
Also use ToJson which is more DRY. |
455,737 | 08.06.2020 15:47:37 | 25,200 | 9e7b90921cdf31b7fba83923c436cb682fcfdac4 | Fix input group read out from table to nothing. | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap.css",
"new_path": "src/Bootstrap/dist/css/bootstrap.css",
"diff": "@@ -3075,7 +3075,7 @@ tbody.collapse.in {\n}\n.input-group {\nposition: relative;\n- display: table;\n+ display: table-row;\nborder-collapse: separate;\n}\n.input-group[class*=\"col-\"] {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/input-groups.less",
"new_path": "src/Bootstrap/less/input-groups.less",
"diff": "// -------------------------\n.input-group {\nposition: relative; // For dropdowns\n- display: table;\n+ display: table-row;\nborder-collapse: separate; // prevent input groups from inheriting border styles from table cells when placed within a table\n// Undo padding and float of grid classes\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix input group read out from table to nothing. (#8003) |
455,764 | 09.06.2020 18:05:08 | 0 | 95da6d9db90973de65a61665653ceebffb5c6af4 | Added UI to reverse dependencies
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -912,6 +912,14 @@ img.reserved-indicator-icon {\nfont-size: 25px;\ncolor: red;\n}\n+.page-package-details {\n+ /*\n+ .used-by-adjust-stars {\n+ word-break: normal;\n+ display: inline-block;\n+ }\n+ */\n+}\n.page-package-details .no-border {\nborder: 0;\n}\n@@ -1013,7 +1021,7 @@ img.reserved-indicator-icon {\nmargin-right: 8px;\ndisplay: inline-block;\n}\n-.page-package-details .gh-desc {\n+.page-package-details .used-by-desc {\nfont-family: 'Segoe UI', \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 14px;\ncolor: #333333;\n@@ -1030,14 +1038,26 @@ img.reserved-indicator-icon {\n/* number of lines to show */\n-webkit-box-orient: vertical;\n}\n-.page-package-details .gh-link {\n+.page-package-details .used-by-link {\nfont-family: 'Segoe UI', \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 16px;\nline-height: 19px;\ncolor: #337ab7;\nwidth: auto;\n}\n-.page-package-details .gh-star-count {\n+.page-package-details .gh-link,\n+.page-package-details .ngp-link {\n+ font-family: 'Segoe UI', \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n+ font-size: 16px;\n+ line-height: 19px;\n+ color: #337ab7;\n+ width: auto;\n+}\n+.page-package-details .used-by-download-icon {\n+ font-size: 14px;\n+ line-height: 12px;\n+}\n+.page-package-details .used-by-count {\nfont-family: 'Segoe UI', \"Helvetica Neue\", Helvetica, Arial, sans-serif;\nfont-size: 14px;\nline-height: 16px;\n@@ -1049,11 +1069,14 @@ img.reserved-indicator-icon {\nline-height: 12px;\ncolor: #ef8b00;\n}\n-.page-package-details .gh-repo-column {\n- width: 70%;\n+.page-package-details .used-by h3 strong {\n+ font-weight: 400;\n+}\n+.page-package-details .used-by-adjust-table-head {\n+ word-break: normal;\n}\n-.page-package-details .gh-empty-column {\n- width: 15%;\n+.page-package-details .used-by-desc-column {\n+ width: 85%;\n}\n.page-package-details .install-tabs {\nfont-size: 0.8em;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/page-display-package.less",
"new_path": "src/Bootstrap/less/theme/page-display-package.less",
"diff": "}\n}\n- .gh-desc {\n+ .used-by-desc {\nfont-family: @font-family-base;\nfont-size: 14px;\ncolor: #333333;\n-webkit-box-orient: vertical;\n}\n-.gh-link {\n+ .used-by-link {\nfont-family: @font-family-base;\nfont-size: 16px;\nline-height: 19px;\nwidth: auto;\n}\n-.gh-star-count {\n+ .gh-link, .ngp-link {\n+ font-family: @font-family-base;\n+ font-size: 16px;\n+ line-height: 19px;\n+ color: @brand-primary;\n+ width: auto;\n+ }\n+\n+ .used-by-download-icon {\n+ font-size: 14px;\n+ line-height: 12px;\n+ }\n+\n+ .used-by-count {\nfont-family: @font-family-base;\nfont-size: 14px;\nline-height: 16px;\ncolor: @brand-warning;\n}\n-.gh-repo-column {\n- width: 70%;\n+ .used-by {\n+ h3 {\n+ strong {\n+ font-weight: 400;\n+ }\n+ }\n+ }\n+\n+ .used-by-adjust-table-head {\n+ word-break: normal;\n}\n-.gh-empty-column {\n- width: 15%;\n+ .used-by-desc-column {\n+ width: 85%;\n}\n.install-tabs {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/GitHub/NuGetPackageGitHubInformation.cs",
"new_path": "src/NuGetGallery.Core/GitHub/NuGetPackageGitHubInformation.cs",
"diff": "@@ -9,7 +9,7 @@ namespace NuGetGallery\n{\npublic class NuGetPackageGitHubInformation\n{\n- public const int ReposPerPackage = 10;\n+ public const int ReposPerPackage = 5;\npublic readonly static NuGetPackageGitHubInformation Empty = new NuGetPackageGitHubInformation(new List<RepositoryInformation>());\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"diff": "@@ -26,6 +26,7 @@ public class PackageService : CorePackageService, IPackageService\nprivate readonly ITelemetryService _telemetryService;\nprivate readonly ISecurityPolicyService _securityPolicyService;\nprivate readonly IEntitiesContext _entitiesContext;\n+ private const int packagesDisplayed = 5;\npublic PackageService(\nIEntityRepository<PackageRegistration> packageRegistrationRepository,\n@@ -161,25 +162,16 @@ public PackageDependents GetPackageDependents(string id)\nprivate IReadOnlyCollection<PackageDependent> GetListOfDependents(string id)\n{\n- var packageDependentsList = new List<PackageDependent>();\nvar listPackages = (from pd in _entitiesContext.PackageDependencies\njoin p in _entitiesContext.Packages on pd.PackageKey equals p.Key\njoin pr in _entitiesContext.PackageRegistrations on p.PackageRegistrationKey equals pr.Key\nwhere p.IsLatestSemVer2 && pd.Id == id\ngroup 1 by new { pr.Id, pr.DownloadCount, p.Description } into ng\norderby ng.Key.DownloadCount descending\n- select new { ng.Key.Id, ng.Key.DownloadCount, ng.Key.Description }\n- ).Take(5).ToList();\n+ select new PackageDependent { Id = ng.Key.Id, DownloadCount = ng.Key.DownloadCount, Description = ng.Key.Description }\n+ ).Take(packagesDisplayed).ToList();\n- foreach(var pd in listPackages)\n- {\n- var packageDependent = new PackageDependent();\n- packageDependent.Description = pd.Description;\n- packageDependent.DownloadCount = pd.DownloadCount;\n- packageDependent.Id = pd.Id;\n- packageDependentsList.Add(packageDependent);\n- }\n- return packageDependentsList;\n+ return listPackages;\n}\nprivate int GetDependentCount(string id)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -960,7 +960,7 @@ private PackageDependents GetPackageDependents(string id)\ncacheDependentsCacheKey,\ndependents,\nnull,\n- DateTime.UtcNow.AddMinutes(5),\n+ DateTime.UtcNow.AddMinutes(60),\nCache.NoSlidingExpiration,\nCacheItemPriority.Default, null);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Scripts/gallery/page-display-package.js",
"new_path": "src/NuGetGallery/Scripts/gallery/page-display-package.js",
"diff": "@@ -64,7 +64,7 @@ $(function () {\n// Configure expanders\nwindow.nuget.configureExpanderHeading(\"dependency-groups\");\n- window.nuget.configureExpanderHeading(\"github-usage\");\n+ window.nuget.configureExpanderHeading(\"used-by\");\nwindow.nuget.configureExpanderHeading(\"version-history\");\nwindow.nuget.configureExpander(\n\"hidden-versions\",\n@@ -121,12 +121,12 @@ $(function () {\nga('send', 'event', 'dependencies', e.type);\n});\n- // Emit a Google Analytics event when the user expands or collapses the GitHub Usage section.\n- $(\"#github-usage\").on('hide.bs.collapse show.bs.collapse', function (e) {\n- ga('send', 'event', 'github-usage', e.type);\n+ // Emit a Google Analytics event when the user expands or collapses the Used By section.\n+ $(\"#used-by\").on('hide.bs.collapse show.bs.collapse', function (e) {\n+ ga('send', 'event', 'used-by', e.type);\n});\n- // Emit a Google Analytics event when the user clicks on a repo link in the GitHub Usage section.\n+ // Emit a Google Analytics event when the user clicks on a repo link in the GitHub Repos area of the Used By section.\n$(\".gh-link\").on('click', function (elem) {\nif (!elem.delegateTarget.dataset.indexNumber) {\nconsole.error(\"indexNumber property doesn't exist!\");\n@@ -135,28 +135,15 @@ $(function () {\nga('send', 'event', 'github-usage', 'link-click-' + linkIndex);\n}\n});\n- }\n- // Add smooth scrolling to dependent-repos-link\n- $(\"#dependent-repos-link\").on('click', function (event) {\n- // Emit a Google Analytics event\n- if (window.nuget.isGaAvailable()) {\n- ga('send', 'event', 'github-usage', 'sidebar-link-click');\n- }\n-\n- if (this.hash !== \"\") {\n- event.preventDefault();\n- var hash = this.hash;\n- var hashElem = $(hash);\n- if (hashElem.attr(\"aria-expanded\") == \"false\") {\n- hashElem.click();\n+ // Emit a Google Analytics event when the user clicks on a package link in the NuGet Packages area of the Used By section.\n+ $(\".ngp-link\").on('click', function (elem) {\n+ if (!elem.delegateTarget.dataset.indexNumber) {\n+ console.error(\"indexNumber property doesn't exist!\");\n+ } else {\n+ var linkIndex = elem.delegateTarget.dataset.indexNumber;\n+ ga('send', 'event', 'used-by-packages', 'link-click-' + linkIndex);\n}\n- $('html, body').animate({\n- scrollTop: hashElem.offset().top\n- }, 400, function () {\n- // Add hash (#) to URL when done scrolling (default click behavior)\n- window.location.hash = hash;\n});\n}\n});\n-});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"diff": "}\n}\n- @if(Model.IsGitHubUsageEnabled && !Model.IsDotnetToolPackageType)\n+ @if (!Model.IsDotnetToolPackageType && (Model.IsGitHubUsageEnabled || Model.IsPackageDependentsEnabled))\n{\n<h2>\n- <a href=\"#\" role=\"button\" data-toggle=\"collapse\" data-target=\"#github-usage\"\n- aria-expanded=\"false\" aria-controls=\"github-usage\" id=\"show-github-usage\">\n+ <a href=\"#\" role=\"button\" data-toggle=\"collapse\" data-target=\"#used-by\"\n+ aria-expanded=\"false\" aria-controls=\"used-by\" id=\"show-used-by\">\n<i class=\"ms-Icon ms-Icon--ChevronRight\" aria-hidden=\"true\"></i>\n- <span>GitHub Usage</span>\n+ <span>Used By</span>\n</a>\n</h2>\n+\n+ <div class=\"used-by panel-collapse collapse\" id=\"used-by\">\n+ @if (Model.IsPackageDependentsEnabled)\n+ {\n+ if (Model.PackageDependents.TotalPackageCount > 0)\n+ {\n+ <h3>\n+ <strong>NuGet packages </strong> (@Model.PackageDependents.TotalPackageCount.ToKiloFormat()+)\n+ </h3>\n+ <p>\n+ Showing the top @(Model.PackageDependents.TopPackages.Count) NuGet packages that depend on @(Model.Id):\n+ </p>\n+ <table class=\"table borderless\">\n+ <thead>\n+ <tr>\n+ <th class=\"used-by-adjust-table-head\">Package</th>\n+ <th class=\"used-by-adjust-table-head\">Downloads</th>\n+ </tr>\n+ </thead>\n+ <tbody class=\"no-border\">\n+ @foreach (var item in Model.PackageDependents.TopPackages)\n+ {\n+ <tr>\n+ <td class=\"used-by-desc-column\">\n+ <a class=\"text-left ngp-link\" href=\"@Url.Package(item.Id)\">\n+ @(item.Id)\n+ </a>\n+ <div class=\"row used-by-desc\">\n+ <span>@(item.Description)</span>\n+ </div>\n+ </td>\n+ <td>\n+ <i class=\"ms-Icon ms-Icon--Download used-by-download-icon\" aria-hidden=\"true\"></i> <label class=\"used-by-count\">@(item.DownloadCount.ToKiloFormat())</label>\n+ </td>\n+ </tr>\n+ }\n+ </tbody>\n+ </table>\n+ }\n+ else\n+ {\n+ <h3>\n+ <strong>NuGet packages </strong> (0)\n+ </h3>\n+ <p>\n+ This package is not used by any NuGet packages.\n+ </p>\n+ }\n+ }\n+\n+ @if (Model.IsGitHubUsageEnabled)\n+ {\nif (Model.GitHubDependenciesInformation.Repos.Any())\n{\n- <div class=\"github-usage panel-collapse collapse\" aria-expanded=\"true\" id=\"github-usage\">\n+ <h3>\n+ <strong>GitHub repositories </strong> (@Model.GitHubDependenciesInformation.TotalRepos.ToKiloFormat()+)\n+ </h3>\n<p>\nShowing the top @(Model.GitHubDependenciesInformation.Repos.Count) GitHub repositories that depend on @(Model.Id):\n</p>\n<table class=\"table borderless\">\n<thead>\n<tr>\n- <th>Repository</th>\n- <th></th>\n- <th>Stars</th>\n+ <th class=\"used-by-adjust-table-head\">Repository</th>\n+ <th class=\"used-by-adjust-table-head\">Stars</th>\n</tr>\n</thead>\n<tbody class=\"no-border\">\n@foreach (var item in Model.GitHubDependenciesInformation.Repos.Select((elem, i) => new { Value = elem, Idx = i }))\n{\n<tr>\n- <td class=\"gh-repo-column\">\n+ <td class=\"used-by-desc-column\">\n<a data-index-number=\"@item.Idx\" class=\"text-left gh-link\" href=\"@item.Value.Url\" target=\"_blank\">\n@(item.Value.Id)\n</a>\n- <div class=\"row gh-desc\">\n+ <div class=\"row used-by-desc\">\n<span>@(item.Value.Description)</span>\n</div>\n</td>\n- <td class=\"gh-empty-column\"></td>\n<td>\n- <i class=\"ms-Icon ms-Icon--FavoriteStarFill gh-star\" aria-hidden=\"true\"></i> <label class=\"gh-star-count\">@(item.Value.Stars.ToKiloFormat())</label>\n+ <i class=\"ms-Icon ms-Icon--FavoriteStarFill gh-star\" aria-hidden=\"true\"></i> <label class=\"used-by-count\">@(item.Value.Stars.ToKiloFormat())</label>\n</td>\n</tr>\n}\n</tbody>\n</table>\n- <p>\n- Read more about the GitHub Usage information on\n-\n- <a href=\"https://docs.microsoft.com/en-us/nuget/consume-packages/finding-and-choosing-packages#evaluating-packages\" title=\"Read more about the GitHub Usage information\">our documentation</a>.\n- </p>\n- </div>\n}\n+\nelse\n{\n- <p class=\"github-usage panel-collapse collapse\" aria-expanded=\"true\" id=\"github-usage\">\n+ <h3>\n+ <strong>GitHub repositories </strong> (0)\n+ </h3>\n+ <p>\nThis package is not used by any popular GitHub repositories.\n</p>\n}\n}\n+ </div>\n+ }\n<h2>\n<a href=\"#\" role=\"button\" data-toggle=\"collapse\" data-target=\"#version-history\"\n</a>\n</li>\n}\n- @if (Model.IsGitHubUsageEnabled && !Model.IsDotnetToolPackageType && Model.GitHubDependenciesInformation.TotalRepos > 0)\n- {\n- <li>\n- <img class=\"icon\" aria-hidden=\"true\" alt=\"GitHub logo\"\n- src=\"@Url.Absolute(\"~/Content/gallery/img/github.svg\")\"\n- @ViewHelpers.ImageFallback(Url.Absolute(\"~/Content/gallery/img/github-32x32.png\")) />\n- <a href=\"#show-github-usage\" title=\"View the top dependent repositories\" id=\"dependent-repos-link\">Dependent repositories</a>\n- (@(Model.GitHubDependenciesInformation.TotalRepos.ToKiloFormat())+)\n- </li>\n- }\n@if (!Model.Deleted && Model.LicenseUrl != null)\n{\nif (Model.EmbeddedLicenseType == EmbeddedLicenseFileType.Absent || !Model.Validating)\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Added UI to reverse dependencies (#8017)
Progress on https://github.com/NuGet/Engineering/issues/3143 |
455,741 | 10.06.2020 00:53:14 | 25,200 | a412007e12e28a1783e37c74e2575c337306f1a2 | API key generation without defaulting to the current owner selection | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Scripts/gallery/page-api-keys.js",
"new_path": "src/NuGetGallery/Scripts/gallery/page-api-keys.js",
"diff": "}\nthis.PackageOwner(existingOwner);\n- } else {\n- this.PackageOwner(this.PackageOwners[0]);\n}\n};\n+\nthis.Key = ko.observable(0);\nthis.Type = ko.observable();\nthis.Value = ko.observable();\nreturn self.PackageOwner() && self.PackageOwner().Owner;\n}, this);\nthis.PackageOwner.subscribe(function (newOwner) {\n+ if (newOwner == null) {\n+ return;\n+ }\n+\n// When the package owner scope is changed, update the selected action scopes to those that are allowed on behalf of the new package owner.\nvar isPushNewSelected = function () {\nreturn self.PushScope() === initialData.PackagePushScope;\nthis.PackageOwner.subscribe(function (newValue) {\n// Initialize each package ID as a view model. This view model is used to track manual checkbox checks\n// and whether the glob pattern matches the ID.\n+ if (newValue == null) {\n+ return;\n+ }\n+\nvar packageIdToViewModel = {};\nself.packageViewModels = [];\n$.each(newValue.PackageIds, function (i, packageId) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"new_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"diff": "data-bind=\"attr: { id: PackageOwnerId,\nname: PackageOwnerId,\n'aria-labelledby': PackageOwnerId() + '-label' },\n- options: PackageOwners, value: PackageOwner, optionsText: 'Owner'\"></select>\n+ options: PackageOwners, value: PackageOwner, optionsText: 'Owner', optionsCaption: 'Select an owner...' \"></select>\n+ <div class=\"has-error\">\n+ <span class=\"field-validation-valid help-block\"\n+ data-bind=\"text: PackageOwner() ? '' : 'A package owner must be selected.'\"></span>\n+ </div>\n</div>\n</div>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | API key generation without defaulting to the current owner selection |
455,764 | 10.06.2020 22:22:29 | 0 | 5582e036be1c94a0832e1d3d9ed4fc86693b6935 | Added index for package dependencies table
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Migrations\\202004030548285_AddPackageRename.designer.cs\">\n<DependentUpon>202004030548285_AddPackageRename.cs</DependentUpon>\n</Compile>\n+ <Compile Include=\"Migrations\\202006011927336_AddIndexToPackageDependencies.cs\" />\n+ <Compile Include=\"Migrations\\202006011927336_AddIndexToPackageDependencies.designer.cs\">\n+ <DependentUpon>202006011927336_AddIndexToPackageDependencies.cs</DependentUpon>\n+ </Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n<Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\GravatarProxyResult.cs\" />\n<EmbeddedResource Include=\"Migrations\\202004030548285_AddPackageRename.resx\">\n<DependentUpon>202004030548285_AddPackageRename.cs</DependentUpon>\n</EmbeddedResource>\n+ <EmbeddedResource Include=\"Migrations\\202006011927336_AddIndexToPackageDependencies.resx\">\n+ <DependentUpon>202006011927336_AddIndexToPackageDependencies.cs</DependentUpon>\n+ </EmbeddedResource>\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1packages.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1search.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv2getupdates.json\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Added index for package dependencies table (#8029)
Progress on https://github.com/NuGet/NuGetGallery/issues/4718 |
455,741 | 10.06.2020 21:05:42 | 25,200 | 3bdf081d34f39c9b574aa5c8502c768337fc7951 | Handle single owner and fix ui accessibility issue | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Scripts/gallery/page-api-keys.js",
"new_path": "src/NuGetGallery/Scripts/gallery/page-api-keys.js",
"diff": "}\nthis.PackageOwner(existingOwner);\n+\n+ } else if (this.PackageOwners.length == 1) {\n+ this.PackageOwner(this.PackageOwners[0]);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"new_path": "src/NuGetGallery/Views/Users/ApiKeys.cshtml",
"diff": "}\n</div>\n- <div class=\"row\" style=\"@(Model.PackageOwners.Count == 1 ? \"display:none\" : \"\")\">\n+ <div class=\"row\">\n<div class=\"col-sm-7 form-group\">\n<label data-bind=\"attr: { for: PackageOwnerId,\nid: PackageOwnerId() + '-label' }\">Package Owner</label>\noptions: PackageOwners, value: PackageOwner, optionsText: 'Owner', optionsCaption: 'Select an owner...' \"></select>\n<div class=\"has-error\">\n<span class=\"field-validation-valid help-block\"\n- data-bind=\"text: PackageOwner() ? '' : 'A package owner must be selected.'\"></span>\n+ data-bind=\"text: PackageOwner() ? '' : 'A package owner must be selected.'\" aria-live=\"polite\" role=\"alert\"></span>\n</div>\n</div>\n</div>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Handle single owner and fix ui accessibility issue |
455,764 | 12.06.2020 20:51:26 | 0 | 7e5573db6328fc605fa6230badd88f34e890657d | Added verified checkmark to packages
Progress on: | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -912,14 +912,6 @@ img.reserved-indicator-icon {\nfont-size: 25px;\ncolor: red;\n}\n-.page-package-details {\n- /*\n- .used-by-adjust-stars {\n- word-break: normal;\n- display: inline-block;\n- }\n- */\n-}\n.page-package-details .no-border {\nborder: 0;\n}\n@@ -1072,6 +1064,12 @@ img.reserved-indicator-icon {\n.page-package-details .used-by h3 strong {\nfont-weight: 400;\n}\n+.page-package-details .used-by .reserved-indicator {\n+ width: 14px;\n+ margin-bottom: 3px;\n+ margin-left: 2px;\n+ vertical-align: middle;\n+}\n.page-package-details .used-by-adjust-table-head {\nword-break: normal;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/page-display-package.less",
"new_path": "src/Bootstrap/less/theme/page-display-package.less",
"diff": "font-weight: 400;\n}\n}\n+\n+ .reserved-indicator {\n+ width: 14px;\n+ margin-bottom: 3px;\n+ margin-left: 2px;\n+ vertical-align: middle;\n+ }\n}\n.used-by-adjust-table-head {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Models/PackageDependent.cs",
"new_path": "src/NuGetGallery.Services/Models/PackageDependent.cs",
"diff": "@@ -10,9 +10,7 @@ public class PackageDependent\npublic string Id { get; set; }\npublic int DownloadCount { get; set; }\npublic string Description { get; set; }\n-\n- // TODO Add verify checkmark\n- // https://github.com/NuGet/NuGetGallery/issues/4718\n+ public bool IsVerified { get; set; }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"diff": "@@ -166,9 +166,9 @@ private IReadOnlyCollection<PackageDependent> GetListOfDependents(string id)\njoin p in _entitiesContext.Packages on pd.PackageKey equals p.Key\njoin pr in _entitiesContext.PackageRegistrations on p.PackageRegistrationKey equals pr.Key\nwhere p.IsLatestSemVer2 && pd.Id == id\n- group 1 by new { pr.Id, pr.DownloadCount, p.Description } into ng\n+ group 1 by new { pr.Id, pr.DownloadCount, pr.IsVerified, p.Description } into ng\norderby ng.Key.DownloadCount descending\n- select new PackageDependent { Id = ng.Key.Id, DownloadCount = ng.Key.DownloadCount, Description = ng.Key.Description }\n+ select new PackageDependent { Id = ng.Key.Id, DownloadCount = ng.Key.DownloadCount, IsVerified = ng.Key.IsVerified, Description = ng.Key.Description }\n).Take(packagesDisplayed).ToList();\nreturn listPackages;\n"
},
{
"change_type": "ADD",
"old_path": "src/NuGetGallery/Content/gallery/img/reserved-indicator-14x14.png",
"new_path": "src/NuGetGallery/Content/gallery/img/reserved-indicator-14x14.png",
"diff": "Binary files /dev/null and b/src/NuGetGallery/Content/gallery/img/reserved-indicator-14x14.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"diff": "<a class=\"text-left ngp-link\" href=\"@Url.Package(item.Id)\">\n@(item.Id)\n</a>\n+ @if (item.IsVerified)\n+ {\n+ <img class=\"reserved-indicator\"\n+ src=\"~/Content/gallery/img/reserved-indicator.svg\"\n+ @ViewHelpers.ImageFallback(Url.Absolute(\"~/Content/gallery/img/reserved-indicator-14x14.png\"))\n+ title=\"@Strings.ReservedNamespace_ReservedIndicatorTooltip\" />\n+ }\n<div class=\"row used-by-desc\">\n<span>@(item.Description)</span>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"diff": "@@ -2142,7 +2142,7 @@ private void AddMemberToOrganization(Organization organization, User member)\npublic class TheGetPackageDependentsMethod\n{\n[Fact]\n- public void ThereAreExactlyFivePackages()\n+ public void ThereAreExactlyFivePackagesAndAllPackagesAreVerified()\n{\nstring id = \"foo\";\nint packageLimit = 5;\n@@ -2185,15 +2185,15 @@ public void ThereAreExactlyFivePackages()\n.Returns(entityContext.PackageRegistrations);\nvar result = service.GetPackageDependents(id);\n+\nAssert.Equal(packageLimit, result.TotalPackageCount);\nAssert.Equal(packageLimit, result.TopPackages.Count);\n- var topPackage = result.TopPackages.ElementAt(0);\n- var runnerUpPackage = result.TopPackages.ElementAt(1);\n- Assert.True(topPackage.DownloadCount > runnerUpPackage.DownloadCount);\n+\n+ PackageTestsWhereAllPackagesAreVerified(result, packageLimit);\n}\n[Fact]\n- public void ThereAreMoreThanFivePackages()\n+ public void ThereAreMoreThanFivePackagesAndAllPackagesAreVerified()\n{\nstring id = \"foo\";\n@@ -2232,15 +2232,15 @@ public void ThereAreMoreThanFivePackages()\n.Returns(entityContext.PackageRegistrations);\nvar result = service.GetPackageDependents(id);\n+\nAssert.Equal(6, result.TotalPackageCount);\nAssert.Equal(5, result.TopPackages.Count);\n- var topPackage = result.TopPackages.ElementAt(0);\n- var runnerUpPackage = result.TopPackages.ElementAt(1);\n- Assert.True(topPackage.DownloadCount > runnerUpPackage.DownloadCount);\n+\n+ PackageTestsWhereAllPackagesAreVerified(result, result.TopPackages.Count);\n}\n[Fact]\n- public void ThereAreLessThanFivePackages()\n+ public void ThereAreLessThanFivePackagesAndAllPackagesAreVerified()\n{\nstring id = \"foo\";\nint packageLimit = 3;\n@@ -2283,11 +2283,11 @@ public void ThereAreLessThanFivePackages()\n.Returns(entityContext.PackageRegistrations);\nvar result = service.GetPackageDependents(id);\n+\nAssert.Equal(packageLimit, result.TotalPackageCount);\nAssert.Equal(packageLimit, result.TopPackages.Count);\n- var topPackage = result.TopPackages.ElementAt(0);\n- var runnerUpPackage = result.TopPackages.ElementAt(1);\n- Assert.True(topPackage.DownloadCount > runnerUpPackage.DownloadCount);\n+\n+ PackageTestsWhereAllPackagesAreVerified(result, packageLimit);\n}\n[Fact]\n@@ -2356,10 +2356,157 @@ public void PackageIsNotLatestSemVer2()\n.Returns(entityContext.PackageRegistrations);\nvar result = service.GetPackageDependents(id);\n+\nAssert.Equal(0, result.TotalPackageCount);\nAssert.Equal(0, result.TopPackages.Count);\n}\n+ [Fact]\n+ public void NoVerifiedPackages()\n+ {\n+ string id = \"foo\";\n+\n+ var context = new Mock<IEntitiesContext>();\n+ var entityContext = new FakeEntitiesContext();\n+\n+ var service = CreateService(context: context);\n+\n+ var packageDependenciesList = SetupPackageDependency(id);\n+ var packageList = SetupPackages();\n+ var packageRegistrationsList = SetupPackageRegistration();\n+\n+ foreach (var packageDependency in packageDependenciesList)\n+ {\n+ entityContext.PackageDependencies.Add(packageDependency);\n+ }\n+\n+ foreach (var package in packageList)\n+ {\n+ entityContext.Packages.Add(package);\n+ }\n+\n+ foreach (var packageRegistration in packageRegistrationsList)\n+ {\n+ packageRegistration.IsVerified = false;\n+ entityContext.PackageRegistrations.Add(packageRegistration);\n+ }\n+\n+ context\n+ .Setup(f => f.PackageDependencies)\n+ .Returns(entityContext.PackageDependencies);\n+ context\n+ .Setup(f => f.Packages)\n+ .Returns(entityContext.Packages);\n+ context\n+ .Setup(f => f.PackageRegistrations)\n+ .Returns(entityContext.PackageRegistrations);\n+\n+ var result = service.GetPackageDependents(id);\n+\n+ Assert.Equal(6, result.TotalPackageCount);\n+ Assert.Equal(5, result.TopPackages.Count);\n+\n+ for (int i = 0; i < result.TopPackages.Count; i++)\n+ {\n+ var currentPackage = result.TopPackages.ElementAt(i);\n+ var prevPackage = i > 0 ? result.TopPackages.ElementAt(i - 1) : null;\n+ if (prevPackage != null)\n+ {\n+ Assert.True(currentPackage.DownloadCount <= prevPackage.DownloadCount);\n+ }\n+ Assert.False(currentPackage.IsVerified);\n+ }\n+ }\n+\n+ [Fact]\n+ public void MixtureOfVerifiedAndNonVerifiedPackages()\n+ {\n+ string id = \"foo\";\n+ int packageLimit = 5;\n+\n+ var context = new Mock<IEntitiesContext>();\n+ var entityContext = new FakeEntitiesContext();\n+\n+ var service = CreateService(context: context);\n+\n+ var packageDependenciesList = SetupPackageDependency(id);\n+ var packageList = SetupPackages();\n+ var packageRegistrationsList = SetupPackageRegistration();\n+\n+ for (int i = 0; i < packageLimit; i++)\n+ {\n+ var packageDependency = packageDependenciesList[i];\n+ entityContext.PackageDependencies.Add(packageDependency);\n+ }\n+\n+ for (int i = 0; i < packageLimit; i++)\n+ {\n+ var package = packageList[i];\n+ entityContext.Packages.Add(package);\n+ }\n+\n+ for (int i = 0; i < packageLimit; i++)\n+ {\n+ var packageRegistration = packageRegistrationsList[i];\n+\n+ if (i % 2 == 0)\n+ {\n+ packageRegistration.IsVerified = false;\n+ }\n+\n+ entityContext.PackageRegistrations.Add(packageRegistration);\n+ }\n+\n+ context\n+ .Setup(f => f.PackageDependencies)\n+ .Returns(entityContext.PackageDependencies);\n+ context\n+ .Setup(f => f.Packages)\n+ .Returns(entityContext.Packages);\n+ context\n+ .Setup(f => f.PackageRegistrations)\n+ .Returns(entityContext.PackageRegistrations);\n+\n+ var result = service.GetPackageDependents(id);\n+\n+ Assert.Equal(packageLimit, result.TotalPackageCount);\n+ Assert.Equal(packageLimit, result.TopPackages.Count);\n+\n+ for (int i = 0; i < packageLimit; i++)\n+ {\n+ var currentPackage = result.TopPackages.ElementAt(i);\n+ var prevPackage = i > 0 ? result.TopPackages.ElementAt(i - 1) : null;\n+ if (prevPackage != null)\n+ {\n+ Assert.True(currentPackage.DownloadCount <= prevPackage.DownloadCount);\n+ }\n+\n+ if (i % 2 == 0)\n+ {\n+ Assert.False(currentPackage.IsVerified);\n+ }\n+\n+ else\n+ {\n+ Assert.True(currentPackage.IsVerified);\n+ }\n+ }\n+ }\n+\n+ private void PackageTestsWhereAllPackagesAreVerified(PackageDependents result, int packages)\n+ {\n+ for (int i = 0; i < packages; i++)\n+ {\n+ var currentPackage = result.TopPackages.ElementAt(i);\n+ var prevPackage = i > 0 ? result.TopPackages.ElementAt(i - 1) : null;\n+ if (prevPackage != null)\n+ {\n+ Assert.True(currentPackage.DownloadCount <= prevPackage.DownloadCount);\n+ }\n+ Assert.True(currentPackage.IsVerified);\n+ }\n+ }\n+\nprivate List<PackageDependency> SetupPackageDependency(string id)\n{\nvar packageDependencyList = new List<PackageDependency>();\n@@ -2480,41 +2627,47 @@ private List<PackageRegistration> SetupPackageRegistration()\n{\nKey = 11,\nDownloadCount = 100,\n- Id = \"p1\"\n+ Id = \"p1\",\n+ IsVerified = true\n};\nvar prFoo2 = new PackageRegistration()\n{\nKey = 22,\nDownloadCount = 200,\n- Id = \"p2\"\n+ Id = \"p2\",\n+ IsVerified = true\n};\nvar prFoo3 = new PackageRegistration()\n{\nKey = 33,\nDownloadCount = 300,\n- Id = \"p3\"\n+ Id = \"p3\",\n+ IsVerified = true\n};\nvar prFoo4 = new PackageRegistration()\n{\nKey = 44,\nDownloadCount = 400,\n- Id = \"p4\"\n+ Id = \"p4\",\n+ IsVerified = true\n};\nvar prFoo5 = new PackageRegistration()\n{\nKey = 55,\nDownloadCount = 500,\n- Id = \"p5\"\n+ Id = \"p5\",\n+ IsVerified = true\n};\nvar prFoo6 = new PackageRegistration()\n{\nKey = 66,\nDownloadCount = 600,\n- Id = \"p6\"\n+ Id = \"p6\",\n+ IsVerified = true\n};\npackageRegistrationList.Add(prFoo1);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Added verified checkmark to packages (#8031)
Progress on: https://github.com/NuGet/NuGetGallery/issues/4718 |
455,764 | 16.06.2020 00:34:02 | 0 | 0f52bc90a9e3aaaa5e9ba97ca64b428b1030cc06 | Adding extra icon to csproj
Quick changes are in! | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Content Include=\"Content\\gallery\\img\\orange-circle.svg\" />\n<Content Include=\"Content\\gallery\\img\\purple-circle-225x225.png\" />\n<Content Include=\"Content\\gallery\\img\\purple-circle.svg\" />\n+ <Content Include=\"Content\\gallery\\img\\reserved-indicator-14x14.png\" />\n<Content Include=\"Content\\gallery\\img\\reserved-indicator-20x20.png\" />\n<Content Include=\"Content\\gallery\\img\\reserved-indicator-256x256.png\" />\n<Content Include=\"Content\\gallery\\img\\reserved-indicator-25x25.png\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Adding extra icon to csproj (#8049)
Quick changes are in! |
455,764 | 16.06.2020 20:22:01 | 0 | c1e16fbbb75b29c40acefcec97460b3d4625979e | Added configurable cache
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Compile Include=\"Authentication\\V3Hasher.cs\" />\n<Compile Include=\"Configuration\\ABTestConfiguration.cs\" />\n<Compile Include=\"Configuration\\AppConfiguration.cs\" />\n+ <Compile Include=\"Configuration\\CacheConfiguration.cs\" />\n<Compile Include=\"Configuration\\CertificatesConfiguration.cs\" />\n<Compile Include=\"Configuration\\ConfigurationService.cs\" />\n<Compile Include=\"Configuration\\FeatureConfiguration.cs\" />\n<Compile Include=\"Configuration\\FeatureFlagService.cs\" />\n<Compile Include=\"Configuration\\IABTestConfiguration.cs\" />\n<Compile Include=\"Configuration\\IAppConfiguration.cs\" />\n+ <Compile Include=\"Configuration\\ICacheConfiguration.cs\" />\n<Compile Include=\"Configuration\\ICertificatesConfiguration.cs\" />\n<Compile Include=\"Configuration\\IFeatureFlagService.cs\" />\n<Compile Include=\"Configuration\\IGalleryConfigurationService.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesConstants.cs",
"new_path": "src/NuGetGallery.Services/ServicesConstants.cs",
"diff": "@@ -55,6 +55,7 @@ public static class ContentNames\npublic static readonly string NuGetPackagesGitHubDependencies = \"GitHubUsage.v1\";\npublic static readonly string ABTestConfiguration = \"AB-Test-Configuration\";\npublic static readonly string ODataCacheConfiguration = \"OData-Cache-Configuration\";\n+ public static readonly string CacheConfiguration = \"Cache-Configuration\";\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"new_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"diff": "@@ -26,6 +26,7 @@ public ContentObjectService(IContentService contentService)\nGitHubUsageConfiguration = new GitHubUsageConfiguration(Array.Empty<RepositoryInformation>());\nABTestConfiguration = new ABTestConfiguration();\nODataCacheConfiguration = new ODataCacheConfiguration();\n+ CacheConfiguration = new CacheConfiguration();\n}\npublic ILoginDiscontinuationConfiguration LoginDiscontinuationConfiguration { get; private set; }\n@@ -35,6 +36,7 @@ public ContentObjectService(IContentService contentService)\npublic IGitHubUsageConfiguration GitHubUsageConfiguration { get; private set; }\npublic IABTestConfiguration ABTestConfiguration { get; private set; }\npublic IODataCacheConfiguration ODataCacheConfiguration { get; private set; }\n+ public ICacheConfiguration CacheConfiguration { get; private set; }\npublic async Task Refresh()\n{\n@@ -66,6 +68,10 @@ public async Task Refresh()\nODataCacheConfiguration =\nawait Refresh<ODataCacheConfiguration>(ServicesConstants.ContentNames.ODataCacheConfiguration) ??\nnew ODataCacheConfiguration();\n+\n+ CacheConfiguration =\n+ await Refresh<CacheConfiguration>(ServicesConstants.ContentNames.CacheConfiguration) ??\n+ new CacheConfiguration();\n}\nprivate async Task<T> Refresh<T>(string contentName)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Storage/IContentObjectService.cs",
"new_path": "src/NuGetGallery.Services/Storage/IContentObjectService.cs",
"diff": "@@ -15,6 +15,7 @@ public interface IContentObjectService\nIGitHubUsageConfiguration GitHubUsageConfiguration { get; }\nIABTestConfiguration ABTestConfiguration { get; }\nIODataCacheConfiguration ODataCacheConfiguration { get; }\n+ ICacheConfiguration CacheConfiguration { get; }\nTask Refresh();\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"new_path": "src/NuGetGallery/Controllers/PackagesController.cs",
"diff": "@@ -960,7 +960,7 @@ private PackageDependents GetPackageDependents(string id)\ncacheDependentsCacheKey,\ndependents,\nnull,\n- DateTime.UtcNow.AddMinutes(60),\n+ DateTime.UtcNow.AddSeconds(_contentObjectService.CacheConfiguration.PackageDependentsCacheTimeInSeconds),\nCache.NoSlidingExpiration,\nCacheItemPriority.Default, null);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<ItemGroup>\n<Content Include=\"Views\\Packages\\_DisplayPackageRenames.cshtml\" />\n</ItemGroup>\n+ <ItemGroup>\n+ <Content Include=\"App_Data\\Files\\Content\\Cache-Configuration.json\" />\n+ </ItemGroup>\n<PropertyGroup>\n<VisualStudioVersion Condition=\"'$(VisualStudioVersion)' == ''\">10.0</VisualStudioVersion>\n<VSToolsPath Condition=\"'$(VSToolsPath)' == ''\">$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)</VSToolsPath>\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs",
"diff": "@@ -1613,8 +1613,8 @@ public async Task UsesProperIconUrl()\n[Fact]\npublic async Task CheckFeatureFlagIsOff()\n{\n- string id = \"foo\";\n- string cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\nvar packageService = new Mock<IPackageService>();\nvar featureFlagService = new Mock<IFeatureFlagService>();\n@@ -1658,8 +1658,8 @@ public async Task CheckFeatureFlagIsOff()\n[Fact]\npublic async Task CheckABTestIsOff()\n{\n- string id = \"foo\";\n- string cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\nvar packageService = new Mock<IPackageService>();\nvar abTestService = new Mock<IABTestService>();\n@@ -1704,8 +1704,8 @@ public async Task CheckABTestIsOff()\n[Fact]\npublic async Task CheckABTestIsOnAndFeatFlagIsOff()\n{\n- string id = \"foo\";\n- string cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\nvar packageService = new Mock<IPackageService>();\nvar abTestService = new Mock<IABTestService>();\nvar featureFlagService = new Mock<IFeatureFlagService>();\n@@ -1757,8 +1757,8 @@ public async Task CheckABTestIsOnAndFeatFlagIsOff()\n[Fact]\npublic async Task WhenCacheIsOccupiedGetProperPackageDependent()\n{\n- string id = \"foo\";\n- string cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\nvar packageService = new Mock<IPackageService>();\nvar abTestService = new Mock<IABTestService>();\nvar httpContext = new Mock<HttpContextBase>();\n@@ -1815,25 +1815,34 @@ public async Task WhenCacheIsOccupiedGetProperPackageDependent()\n[Fact]\npublic async Task OccupyEmptyCache()\n{\n- string id = \"foo\";\n- string cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\nvar packageService = new Mock<IPackageService>();\nvar abTestService = new Mock<IABTestService>();\nvar httpContext = new Mock<HttpContextBase>();\n+ var contentObjectService = new Mock<IContentObjectService>();\n+\n+ var cacheConfiguration = new CacheConfiguration\n+ {\n+ PackageDependentsCacheTimeInSeconds = 60\n+ };\nPackageDependents pd = new PackageDependents();\nabTestService\n.Setup(x => x.IsPackageDependendentsABEnabled(It.IsAny<User>()))\n.Returns(true);\n-\nhttpContext\n.Setup(c => c.Cache)\n.Returns(_cache);\n+ contentObjectService\n+ .Setup(c => c.CacheConfiguration)\n+ .Returns(cacheConfiguration);\nvar controller = CreateController(\nGetConfigurationService(),\npackageService: packageService,\nabTestService: abTestService,\n+ contentObjectService: contentObjectService,\nhttpContext: httpContext);\nvar package = new Package\n@@ -1846,8 +1855,9 @@ public async Task OccupyEmptyCache()\nVersion = \"2.0.0\",\nNormalizedVersion = \"2.0.0\",\n};\n-\nvar packages = new List<Package> { package };\n+ var gitHubInformation = new NuGetPackageGitHubInformation(new List<RepositoryInformation>());\n+\npackageService\n.Setup(p => p.FindPackagesById(id, /*includePackageRegistration:*/ true))\n.Returns(packages);\n@@ -1857,6 +1867,9 @@ public async Task OccupyEmptyCache()\npackageService\n.Setup(p => p.GetPackageDependents(It.IsAny<string>()))\n.Returns(pd);\n+ contentObjectService\n+ .Setup(c => c.GitHubUsageConfiguration.GetPackageInformation(It.IsAny<string>()))\n+ .Returns(gitHubInformation);\nvar result = await controller.DisplayPackage(id, version: null);\nvar model = ResultAssert.IsView<DisplayPackageViewModel>(result);\n@@ -1870,18 +1883,26 @@ public async Task OccupyEmptyCache()\n[Fact]\npublic async Task CheckThatCacheKeyIsNotCaseSensitive()\n{\n- string id1 = \"fooBAr\";\n- string id2 = \"FOObAr\";\n- string cacheKey = \"CacheDependents_foobar\";\n+ var id1 = \"fooBAr\";\n+ var id2 = \"FOObAr\";\n+ var cacheKey = \"CacheDependents_foobar\";\nvar packageService = new Mock<IPackageService>();\nvar abTestService = new Mock<IABTestService>();\n+ var contentObjectService = new Mock<IContentObjectService>();\nvar httpContext = new Mock<HttpContextBase>();\n+\n+ var cacheConfiguration = new CacheConfiguration\n+ {\n+ PackageDependentsCacheTimeInSeconds = 60\n+ };\nPackageDependents pd = new PackageDependents();\n+ contentObjectService\n+ .Setup(c => c.CacheConfiguration)\n+ .Returns(cacheConfiguration);\nabTestService\n.Setup(x => x.IsPackageDependendentsABEnabled(It.IsAny<User>()))\n.Returns(true);\n-\nhttpContext\n.Setup(c => c.Cache)\n.Returns(_cache);\n@@ -1890,6 +1911,7 @@ public async Task CheckThatCacheKeyIsNotCaseSensitive()\nGetConfigurationService(),\npackageService: packageService,\nabTestService: abTestService,\n+ contentObjectService: contentObjectService,\nhttpContext: httpContext);\nvar package = new Package\n@@ -1902,8 +1924,9 @@ public async Task CheckThatCacheKeyIsNotCaseSensitive()\nVersion = \"2.0.0\",\nNormalizedVersion = \"2.0.0\",\n};\n-\nvar packages = new List<Package> { package };\n+ var gitHubInformation = new NuGetPackageGitHubInformation(new List<RepositoryInformation>());\n+\npackageService\n.Setup(p => p.FindPackagesById(It.IsAny<string>(), /*includePackageRegistration:*/ true))\n.Returns(packages);\n@@ -1913,6 +1936,9 @@ public async Task CheckThatCacheKeyIsNotCaseSensitive()\npackageService\n.Setup(p => p.GetPackageDependents(It.IsAny<string>()))\n.Returns(pd);\n+ contentObjectService\n+ .Setup(c => c.GitHubUsageConfiguration.GetPackageInformation(It.IsAny<string>()))\n+ .Returns(gitHubInformation);\nvar result1 = await controller.DisplayPackage(id1, version: null);\nvar model1 = ResultAssert.IsView<DisplayPackageViewModel>(result1);\n@@ -1926,6 +1952,76 @@ public async Task CheckThatCacheKeyIsNotCaseSensitive()\nAssert.Same(pd, _cache.Get(cacheKey));\n}\n+ [Fact]\n+ public async Task OneSecondCacheTime()\n+ {\n+ var id = \"foo\";\n+ var cacheKey = \"CacheDependents_\" + id.ToLowerInvariant();\n+ var packageService = new Mock<IPackageService>();\n+ var abTestService = new Mock<IABTestService>();\n+ var contentObjectService = new Mock<IContentObjectService>();\n+ var httpContext = new Mock<HttpContextBase>();\n+ var pd = new PackageDependents();\n+\n+ abTestService\n+ .Setup(x => x.IsPackageDependendentsABEnabled(It.IsAny<User>()))\n+ .Returns(true);\n+\n+ httpContext\n+ .Setup(c => c.Cache)\n+ .Returns(_cache);\n+\n+ var cacheConfiguration = new CacheConfiguration\n+ {\n+ PackageDependentsCacheTimeInSeconds = 1\n+ };\n+\n+ contentObjectService\n+ .Setup(c => c.CacheConfiguration)\n+ .Returns(cacheConfiguration);\n+\n+ var controller = CreateController(\n+ GetConfigurationService(),\n+ packageService: packageService,\n+ abTestService: abTestService,\n+ contentObjectService: contentObjectService);\n+\n+ var package = new Package\n+ {\n+ PackageRegistration = new PackageRegistration()\n+ {\n+ Id = id,\n+ Owners = new List<User>(),\n+ },\n+ Version = \"2.0.0\",\n+ NormalizedVersion = \"2.0.0\",\n+ };\n+ var packages = new List<Package> { package };\n+ var gitHubInformation = new NuGetPackageGitHubInformation(new List<RepositoryInformation>());\n+\n+ packageService\n+ .Setup(p => p.FindPackagesById(id, /*includePackageRegistration:*/ true))\n+ .Returns(packages);\n+ packageService\n+ .Setup(p => p.FilterLatestPackage(It.IsAny<IReadOnlyCollection<Package>>(), It.IsAny<int?>(), true))\n+ .Returns(package);\n+ packageService\n+ .Setup(p => p.GetPackageDependents(It.IsAny<string>()))\n+ .Returns(pd);\n+ contentObjectService\n+ .Setup(c => c.GitHubUsageConfiguration.GetPackageInformation(It.IsAny<string>()))\n+ .Returns(gitHubInformation);\n+\n+ var result = await controller.DisplayPackage(id, version: null);\n+ var model = ResultAssert.IsView<DisplayPackageViewModel>(result);\n+\n+ Assert.Same(pd, model.PackageDependents);\n+ await Task.Delay(TimeSpan.FromSeconds(1));\n+ Assert.Empty(_cache);\n+ packageService\n+ .Verify(iup => iup.GetPackageDependents(It.IsAny<string>()), Times.Once());\n+ }\n+\nprotected override void Dispose(bool disposing)\n{\n// Clear the cache to avoid test interaction.\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Added configurable cache (#8043)
Progress on https://github.com/NuGet/NuGetGallery/issues/4718 |
455,736 | 18.06.2020 13:21:53 | 25,200 | 9e163d7eec650109e9350ba6b48764468265545c | Don't track the package push failure if the client has disconnected
Address | [
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Gallery/ThrowingTelemetryService.cs",
"new_path": "src/GitHubVulnerabilities2Db/Gallery/ThrowingTelemetryService.cs",
"diff": "@@ -236,6 +236,11 @@ public void TrackPackageOwnershipAutomaticallyAdded(string packageId, string pac\nthrow new NotImplementedException();\n}\n+ public void TrackPackagePushDisconnectEvent()\n+ {\n+ throw new NotImplementedException();\n+ }\n+\npublic void TrackPackagePushEvent(Package package, User user, IIdentity identity)\n{\nthrow new NotImplementedException();\n@@ -316,6 +321,11 @@ public void TrackSymbolPackageFailedGalleryValidationEvent(string packageId, str\nthrow new NotImplementedException();\n}\n+ public void TrackSymbolPackagePushDisconnectEvent()\n+ {\n+ throw new NotImplementedException();\n+ }\n+\npublic void TrackSymbolPackagePushEvent(string packageId, string packageVersion)\n{\nthrow new NotImplementedException();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Telemetry/ITelemetryService.cs",
"new_path": "src/NuGetGallery.Services/Telemetry/ITelemetryService.cs",
"diff": "@@ -32,6 +32,8 @@ public interface ITelemetryService\nvoid TrackPackagePushFailureEvent(string id, NuGetVersion version);\n+ void TrackPackagePushDisconnectEvent();\n+\nvoid TrackPackageUnlisted(Package package);\nvoid TrackPackageListed(Package package);\n@@ -202,6 +204,11 @@ public interface ITelemetryService\n/// <param name=\"packageVersion\">The version of the package that has the symbols uploaded.</param>\nvoid TrackSymbolPackagePushFailureEvent(string packageId, string packageVersion);\n+ /// <summary>\n+ /// A telemetry event emitted when a symbol package push failed due to client disconnect.\n+ /// </summary>\n+ void TrackSymbolPackagePushDisconnectEvent();\n+\n/// <summary>\n/// A telemetry event emitted when a symbol package fails Gallery validation.\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Telemetry/TelemetryService.cs",
"new_path": "src/NuGetGallery.Services/Telemetry/TelemetryService.cs",
"diff": "@@ -87,6 +87,8 @@ public class Events\npublic const string ABTestEnrollmentInitialized = \"ABTestEnrollmentInitialized\";\npublic const string ABTestEnrollmentUpgraded = \"ABTestEnrollmentUpgraded\";\npublic const string ABTestEvaluated = \"ABTestEvaluated\";\n+ public const string PackagePushDisconnect = \"PackagePushDisconnect\";\n+ public const string SymbolPackagePushDisconnect = \"SymbolPackagePushDisconnect\";\n}\nprivate readonly IDiagnosticsSource _diagnosticsSource;\n@@ -1082,6 +1084,16 @@ public void TrackMetricForSearchOnTimeout(string searchName, string correlationI\n});\n}\n+ public void TrackPackagePushDisconnectEvent()\n+ {\n+ TrackMetric(Events.PackagePushDisconnect, 1, p => { });\n+ }\n+\n+ public void TrackSymbolPackagePushDisconnectEvent()\n+ {\n+ TrackMetric(Events.SymbolPackagePushDisconnect, 1, p => { });\n+ }\n+\n/// <summary>\n/// We use <see cref=\"ITelemetryClient.TrackMetric(string, double, IDictionary{string, string})\"/> instead of\n/// <see cref=\"ITelemetryClient.TrackEvent(string, IDictionary{string, string}, IDictionary{string, double})\"/>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Controllers/ApiController.cs",
"new_path": "src/NuGetGallery/Controllers/ApiController.cs",
"diff": "@@ -512,6 +512,15 @@ public virtual async Task<ActionResult> CreateSymbolPackagePutAsync()\nHttpStatusCode.RequestEntityTooLarge,\nStrings.PackageFileTooLarge);\n}\n+ catch (HttpException ex) when (!Response.IsClientConnected)\n+ {\n+ // ASP.NET throws HttpException when the client has disconnected during the upload.\n+ TelemetryService.TrackSymbolPackagePushDisconnectEvent();\n+ QuietLog.LogHandledException(ex);\n+ return new HttpStatusCodeWithBodyResult(\n+ HttpStatusCode.BadRequest,\n+ Strings.PackageUploadCancelled);\n+ }\ncatch (Exception ex)\n{\nex.Log();\n@@ -811,6 +820,15 @@ private async Task<ActionResult> CreatePackageInternal()\nHttpStatusCode.RequestEntityTooLarge,\nStrings.PackageFileTooLarge);\n}\n+ catch (HttpException ex) when (!Response.IsClientConnected)\n+ {\n+ // ASP.NET throws HttpException when the client has disconnected during the upload.\n+ TelemetryService.TrackPackagePushDisconnectEvent();\n+ QuietLog.LogHandledException(ex);\n+ return new HttpStatusCodeWithBodyResult(\n+ HttpStatusCode.BadRequest,\n+ Strings.PackageUploadCancelled);\n+ }\ncatch (Exception)\n{\nTelemetryService.TrackPackagePushFailureEvent(id, version);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.Designer.cs",
"new_path": "src/NuGetGallery/Strings.Designer.cs",
"diff": "@@ -1426,6 +1426,15 @@ public class Strings {\n}\n}\n+ /// <summary>\n+ /// Looks up a localized string similar to The package upload failed due to the client disconnecting..\n+ /// </summary>\n+ public static string PackageUploadCancelled {\n+ get {\n+ return ResourceManager.GetString(\"PackageUploadCancelled\", resourceCulture);\n+ }\n+ }\n+\n/// <summary>\n/// Looks up a localized string similar to Package versions that differ only by metadata cannot be uploaded. A package with ID '{0}' and version '{1}' already exists and cannot be modified..\n/// </summary>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Strings.resx",
"new_path": "src/NuGetGallery/Strings.resx",
"diff": "@@ -1159,4 +1159,7 @@ The {1} Team</value>\n<data name=\"TwoFAFeedback_Error\" xml:space=\"preserve\">\n<value>There was an unexpected error when submitting feedback. Please contact NuGet support.</value>\n</data>\n+ <data name=\"PackageUploadCancelled\" xml:space=\"preserve\">\n+ <value>The package upload failed due to the client disconnecting.</value>\n+ </data>\n</root>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Telemetry/CustomerResourceIdEnricher.cs",
"new_path": "src/NuGetGallery/Telemetry/CustomerResourceIdEnricher.cs",
"diff": "@@ -20,6 +20,10 @@ public class CustomerResourceIdEnricher : ITelemetryInitializer\n{\nTelemetryService.Events.PackagePush,\nTelemetryService.Events.PackagePushFailure,\n+ TelemetryService.Events.PackagePushDisconnect,\n+ TelemetryService.Events.SymbolPackagePush,\n+ TelemetryService.Events.SymbolPackagePushFailure,\n+ TelemetryService.Events.SymbolPackagePushDisconnect,\n};\npublic void Initialize(ITelemetry telemetry)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/VerifyMicrosoftPackage/Fakes/FakeTelemetryService.cs",
"new_path": "src/VerifyMicrosoftPackage/Fakes/FakeTelemetryService.cs",
"diff": "@@ -233,6 +233,11 @@ public void TrackPackageOwnershipAutomaticallyAdded(string packageId, string pac\nthrow new NotImplementedException();\n}\n+ public void TrackPackagePushDisconnectEvent()\n+ {\n+ throw new NotImplementedException();\n+ }\n+\npublic void TrackPackagePushEvent(Package package, User user, IIdentity identity)\n{\nthrow new NotImplementedException();\n@@ -313,6 +318,11 @@ public void TrackSymbolPackageFailedGalleryValidationEvent(string packageId, str\nthrow new NotImplementedException();\n}\n+ public void TrackSymbolPackagePushDisconnectEvent()\n+ {\n+ throw new NotImplementedException();\n+ }\n+\npublic void TrackSymbolPackagePushEvent(string packageId, string packageVersion)\n{\nthrow new NotImplementedException();\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Controllers/ApiControllerFacts.cs",
"diff": "using System.Linq;\nusing System.Linq.Expressions;\nusing System.Net;\n+using System.Security.Principal;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Mvc;\n@@ -64,7 +65,8 @@ internal class TestableApiController\nIGalleryConfigurationService configurationService,\nMockBehavior behavior = MockBehavior.Default,\nISecurityPolicyService securityPolicyService = null,\n- IUserService userService = null)\n+ IUserService userService = null,\n+ Mock<HttpResponseBase> responseMock = null)\n{\nSetOwinContextOverride(Fakes.CreateOwinContext());\nApiScopeEvaluator = (MockApiScopeEvaluator = new Mock<IApiScopeEvaluator>()).Object;\n@@ -159,6 +161,12 @@ internal class TestableApiController\nrequestMock.Setup(m => m.IsSecureConnection).Returns(true);\nrequestMock.Setup(m => m.Url).Returns(new Uri(TestUtility.GallerySiteRootHttps));\n+ if (responseMock == null)\n+ {\n+ responseMock = new Mock<HttpResponseBase>();\n+ responseMock.Setup(m => m.IsClientConnected).Returns(true);\n+ }\n+\nvar httpContextMock = new Mock<HttpContextBase>();\nhttpContextMock.Setup(m => m.Request).Returns(requestMock.Object);\n@@ -244,6 +252,33 @@ public async Task CreateSymbolPackage_ReturnsFailedActionWhenValidationFails()\nResultAssert.IsStatusCode(result, HttpStatusCode.BadRequest);\n}\n+ [Fact]\n+ public async Task CreateSymbolPackage_TracksClientDisconnectedWithoutFailureMetric()\n+ {\n+ // Arrange\n+ var responseMock = new Mock<HttpResponseBase>();\n+ responseMock.Setup(x => x.IsClientConnected).Returns(false);\n+\n+ var controller = new TestableApiController(GetConfigurationService(), responseMock: responseMock);\n+ controller.SetCurrentUser(new User() { EmailAddress = \"[email protected]\" });\n+ controller.MockSymbolPackageUploadService\n+ .Setup(p => p.ValidateUploadedSymbolsPackage(\n+ It.IsAny<Stream>(),\n+ It.IsAny<User>()))\n+ .Throws(new HttpException());\n+\n+ controller.SetupPackageFromInputStream(TestPackage.CreateTestSymbolPackageStream());\n+\n+ // Act\n+ var result = await controller.CreateSymbolPackagePutAsync();\n+\n+ // Assert\n+ ResultAssert.IsStatusCode(result, HttpStatusCode.BadRequest, \"The package upload failed due to the client disconnecting.\");\n+ controller.MockTelemetryService.Verify(x => x.TrackSymbolPackagePushDisconnectEvent(), Times.Once);\n+ controller.MockTelemetryService.Verify(x => x.TrackSymbolPackagePushEvent(It.IsAny<string>(), It.IsAny<string>()), Times.Never);\n+ controller.MockTelemetryService.Verify(x => x.TrackSymbolPackagePushFailureEvent(It.IsAny<string>(), It.IsAny<string>()), Times.Never);\n+ }\n+\n[Fact]\npublic async Task CreateSymbolPackage_UnauthorizedUserWillGet403()\n{\n@@ -456,6 +491,36 @@ public async Task CreatePackage_TracksFailureIfUnexpectedExceptionWithoutIdVersi\ncontroller.MockTelemetryService.Verify(x => x.TrackPackagePushFailureEvent(null, null), Times.Once());\n}\n+ [Fact]\n+ public async Task CreatePackage_TracksClientDisconnectedWithoutFailureMetric()\n+ {\n+ // Arrange\n+ var responseMock = new Mock<HttpResponseBase>();\n+ responseMock.Setup(x => x.IsClientConnected).Returns(false);\n+\n+ var controller = new TestableApiController(GetConfigurationService(), responseMock: responseMock);\n+ controller.SetCurrentUser(new User() { EmailAddress = \"[email protected]\" });\n+ controller.MockPackageUploadService\n+ .Setup(p => p.GeneratePackageAsync(\n+ It.IsAny<string>(),\n+ It.IsAny<PackageArchiveReader>(),\n+ It.IsAny<PackageStreamMetadata>(),\n+ It.IsAny<User>(),\n+ It.IsAny<User>()))\n+ .Throws(new HttpException());\n+\n+ controller.SetupPackageFromInputStream(TestPackage.CreateTestPackageStream());\n+\n+ // Act\n+ var result = await controller.CreatePackagePut();\n+\n+ // Assert\n+ ResultAssert.IsStatusCode(result, HttpStatusCode.BadRequest, \"The package upload failed due to the client disconnecting.\");\n+ controller.MockTelemetryService.Verify(x => x.TrackPackagePushDisconnectEvent(), Times.Once);\n+ controller.MockTelemetryService.Verify(x => x.TrackPackagePushEvent(It.IsAny<Package>(), It.IsAny<User>(), It.IsAny<IIdentity>()), Times.Never);\n+ controller.MockTelemetryService.Verify(x => x.TrackPackagePushFailureEvent(It.IsAny<string>(), It.IsAny<NuGetVersion>()), Times.Never);\n+ }\n+\n[Fact]\npublic async Task CreatePackage_TracksFailureIfUnexpectedExceptionWithIdVersion()\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/TelemetryServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/TelemetryServiceFacts.cs",
"diff": "@@ -331,6 +331,14 @@ public static IEnumerable<object[]> TrackMetricNames_Data\nyield return new object[] { \"ABTestEvaluated\",\n(TrackAction)(s => s.TrackABTestEvaluated(\"SearchPreview\", true, true, 0, 20))\n};\n+\n+ yield return new object[] { \"PackagePushDisconnect\",\n+ (TrackAction)(s => s.TrackPackagePushDisconnectEvent())\n+ };\n+\n+ yield return new object[] { \"SymbolPackagePushDisconnect\",\n+ (TrackAction)(s => s.TrackSymbolPackagePushDisconnectEvent())\n+ };\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Telemetry/CustomerResourceIdEnricherFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Telemetry/CustomerResourceIdEnricherFacts.cs",
"diff": "@@ -123,6 +123,10 @@ private TestableCustomerResourceIdEnricher CreateTestEnricher(IReadOnlyDictionar\n{\nnew object[] { \"PackagePush\" },\nnew object[] { \"PackagePushFailure\" },\n+ new object[] { \"PackagePushDisconnect\" },\n+ new object[] { \"SymbolPackagePush\" },\n+ new object[] { \"SymbolPackagePushFailure\" },\n+ new object[] { \"SymbolPackagePushDisconnect\" },\n};\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Don't track the package push failure if the client has disconnected (#8060)
Address https://github.com/NuGet/NuGetGallery/issues/8022 |
455,764 | 19.06.2020 20:29:59 | 0 | e18ce5484451c062880f6e9198e24d16f03cdf9b | Made some UI polish
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"new_path": "src/NuGetGallery/Views/Packages/DisplayPackage.cshtml",
"diff": "if (Model.PackageDependents.TotalPackageCount > 0)\n{\n<h3>\n- <strong>NuGet packages </strong> (@Model.PackageDependents.TotalPackageCount.ToKiloFormat()+)\n+ <strong>NuGet packages </strong> (@Model.PackageDependents.TotalPackageCount.ToKiloFormat())\n</h3>\n<p>\nShowing the top @(Model.PackageDependents.TopPackages.Count) NuGet packages that depend on @(Model.Id):\nelse\n{\n<h3>\n- <strong>NuGet packages </strong> (0)\n+ <strong>NuGet packages</strong>\n</h3>\n<p>\nThis package is not used by any NuGet packages.\nif (Model.GitHubDependenciesInformation.Repos.Any())\n{\n<h3>\n- <strong>GitHub repositories </strong> (@Model.GitHubDependenciesInformation.TotalRepos.ToKiloFormat()+)\n+ <strong>GitHub repositories </strong> (@Model.GitHubDependenciesInformation.TotalRepos.ToKiloFormat())\n</h3>\n<p>\n- Showing the top @(Model.GitHubDependenciesInformation.Repos.Count) GitHub repositories that depend on @(Model.Id):\n+ Showing the top @(Model.GitHubDependenciesInformation.Repos.Count) popular GitHub repositories that depend on @(Model.Id):\n</p>\n<table class=\"table borderless\">\n<thead>\nelse\n{\n<h3>\n- <strong>GitHub repositories </strong> (0)\n+ <strong>GitHub repositories</strong>\n</h3>\n<p>\nThis package is not used by any popular GitHub repositories.\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Made some UI polish (#8065)
Progress on https://github.com/NuGet/NuGetGallery/issues/4718 |
455,736 | 26.06.2020 12:21:09 | 25,200 | 17e57fb01d745dbdee4bb8971c9038125795e93c | Clear banner, aligning with partner teams | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -177,10 +177,6 @@ body h3 {\n.banner.banner-info {\nbackground: #fff4ce;\n}\n-.banner.banner-blm {\n- background-color: #000;\n- color: #fff;\n-}\n.alert a {\ncolor: #2e6da4;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/base.less",
"new_path": "src/Bootstrap/less/theme/base.less",
"diff": "@@ -230,11 +230,6 @@ body {\n&.banner-info {\nbackground: @info-bg;\n}\n-\n- &.banner-blm {\n- background-color: #000;\n- color: #fff;\n- }\n}\n.alert {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Shared/Gallery/Header.cshtml",
"new_path": "src/NuGetGallery/Views/Shared/Gallery/Header.cshtml",
"diff": "var rawErrorMessage = TempData.ContainsKey(\"RawErrorMessage\") ? TempData[\"RawErrorMessage\"].ToString() : null;\n}\n-<div class=\"container-fluid banner banner-blm text-center\">\n- <div class=\"row\">\n- <div class=\"col-sm-12\">\n- <span>\n- Black Lives Matter.\n- </span>\n- </div>\n- </div>\n-</div>\n-\n<div class=\"container-fluid banner banner-info text-center\">\n<div class=\"row\">\n<div class=\"col-sm-12\">\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Clear banner, aligning with partner teams (#8072) |
455,754 | 29.06.2020 09:17:51 | -36,000 | edb3cb9491131717c80b10857d22e60dcffe5fc9 | Make statistical significant figures formatting culture-sensitive | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"new_path": "src/NuGetGallery/ViewModels/StatisticsPackagesViewModel.cs",
"diff": "using System.Collections.Generic;\nusing System.Globalization;\nusing System.Linq;\n+using System.Threading;\nnamespace NuGetGallery\n{\n@@ -160,14 +161,20 @@ internal static string DisplayShortNumber(double number, int sigFigures = 3)\nvar roundedNum = Math.Round(number * roundingFactor) / roundingFactor;\n// Pad from right with zeroes to sigFigures length, so for 3 sig figs, 1.6 becomes 1.60\n- var formattedNum = roundedNum.ToString(\"F\" + sigFigures);\n- var desiredLength = formattedNum.Contains('.') ? sigFigures + 1 : sigFigures;\n+ var decimalPoint = Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator;\n+ var formattedNum = roundedNum.ToString(\"F\" + sigFigures, Thread.CurrentThread.CurrentUICulture.NumberFormat);\n+ var desiredLength = formattedNum.Contains(decimalPoint) ? sigFigures + decimalPoint.Length : sigFigures;\nif (formattedNum.Length > desiredLength)\n{\nformattedNum = formattedNum.Substring(0, desiredLength);\n}\n- formattedNum = formattedNum.TrimEnd('.');\n+ // If trailing char/s is/are decimal point separator, trim it\n+ if (formattedNum.Length > decimalPoint.Length &&\n+ formattedNum.Substring(formattedNum.Length - decimalPoint.Length, decimalPoint.Length) == decimalPoint)\n+ {\n+ formattedNum = formattedNum.Substring(0, formattedNum.Length - decimalPoint.Length);\n+ }\nif (numDiv >= _magnitudeAbbreviations.Length)\n{\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Make statistical significant figures formatting culture-sensitive (#8039) |
455,736 | 10.07.2020 16:18:32 | 25,200 | e58f23ce57731f63debd8067d4f3ea3bf8b3a62a | Add RECOMPILE query hint to package dependents SQL
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/EntitiesContext.cs",
"diff": "@@ -56,7 +56,18 @@ public EntitiesContext(DbConnection connection, bool readOnly)\nReadOnly = readOnly;\n}\n+ public IDisposable WithQueryHint(string queryHint)\n+ {\n+ if (QueryHint != null)\n+ {\n+ throw new InvalidOperationException(\"A query hint is already applied.\");\n+ }\n+\n+ return new QueryHintScope(this, queryHint);\n+ }\n+\npublic bool ReadOnly { get; private set; }\n+ public string QueryHint { get; private set; }\npublic DbSet<Package> Packages { get; set; }\npublic DbSet<PackageDeprecation> Deprecations { get; set; }\npublic DbSet<PackageRegistration> PackageRegistrations { get; set; }\n@@ -503,5 +514,21 @@ protected override void OnModelCreating(DbModelBuilder modelBuilder)\n.WillCascadeOnDelete(false);\n}\n#pragma warning restore 618\n+\n+ private class QueryHintScope : IDisposable\n+ {\n+ private readonly EntitiesContext _entitiesContext;\n+\n+ public QueryHintScope(EntitiesContext entitiesContext, string queryHint)\n+ {\n+ _entitiesContext = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));\n+ _entitiesContext.QueryHint = queryHint;\n+ }\n+\n+ public void Dispose()\n+ {\n+ _entitiesContext.QueryHint = null;\n+ }\n+ }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/IReadOnlyEntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/IReadOnlyEntitiesContext.cs",
"diff": "@@ -14,5 +14,19 @@ public interface IReadOnlyEntitiesContext : IDisposable\nDbSet<T> Set<T>() where T : class;\nvoid SetCommandTimeout(int? seconds);\n+\n+ /// <summary>\n+ /// Sets the <see cref=\"QueryHint\"/> for queries to the provided value until the returned disposable is disposed.\n+ /// Note that this method MUST NOT be called with user input.\n+ /// </summary>\n+ /// <param name=\"queryHint\">The query hint.</param>\n+ /// <example>Provide \"RECOMPILE\" to disable query plan caching.</example>\n+ /// <returns>A disposable that determines the lifetime of the provided query hint.</returns>\n+ IDisposable WithQueryHint(string queryHint);\n+\n+ /// <summary>\n+ /// The current query hint to use for queries. Can be set using <see cref=\"WithQueryHint(string)\"/>.\n+ /// </summary>\n+ string QueryHint { get; }\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/Entities/ReadOnlyEntitiesContext.cs",
"new_path": "src/NuGetGallery.Core/Entities/ReadOnlyEntitiesContext.cs",
"diff": "@@ -30,6 +30,8 @@ public DbSet<Package> Packages\n}\n}\n+ public string QueryHint => _entitiesContext.QueryHint;\n+\nDbSet<T> IReadOnlyEntitiesContext.Set<T>()\n{\nreturn _entitiesContext.Set<T>();\n@@ -44,5 +46,7 @@ public void Dispose()\n{\n_entitiesContext.Dispose();\n}\n+\n+ public IDisposable WithQueryHint(string queryHint) => _entitiesContext.WithQueryHint(queryHint);\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"new_path": "src/NuGetGallery.Core/NuGetGallery.Core.csproj",
"diff": "<Compile Include=\"DisposableAction.cs\" />\n<Compile Include=\"Entities\\DatabaseWrapper.cs\" />\n<Compile Include=\"Entities\\DbContextTransactionWrapper.cs\" />\n+ <Compile Include=\"Entities\\QueryHintInterceptor.cs\" />\n<Compile Include=\"Entities\\ReadOnlyEntitiesContext.cs\" />\n<Compile Include=\"Entities\\IReadOnlyEntitiesContext.cs\" />\n<Compile Include=\"Entities\\ReadOnlyEntityRepository.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"diff": "@@ -155,8 +155,13 @@ public PackageDependents GetPackageDependents(string id)\n}\nPackageDependents result = new PackageDependents();\n+\n+ using (_entitiesContext.WithQueryHint(\"RECOMPILE\"))\n+ {\nresult.TopPackages = GetListOfDependents(id);\nresult.TotalPackageCount = GetDependentCount(id);\n+ }\n+\nreturn result;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Data/Files/Content/AB-Test-Configuration.json",
"new_path": "src/NuGetGallery/App_Data/Files/Content/AB-Test-Configuration.json",
"diff": "{\n\"PreviewSearchPercentage\": 0,\n\"PreviewHijackPercentage\": 0,\n- \"DependentsPercentage\": 0\n+ \"DependentsPercentage\": 100\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Data/Files/Content/flags.json",
"new_path": "src/NuGetGallery/App_Data/Files/Content/flags.json",
"diff": "\"Domains\": []\n},\n\"NuGetGallery.PackageDependents\": {\n- \"All\": false,\n- \"SiteAdmins\": true,\n+ \"All\": true,\n+ \"SiteAdmins\": false,\n\"Accounts\": [],\n\"Domains\": []\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using System.Collections.Generic;\nusing System.Data.Common;\nusing System.Data.Entity;\n+using System.Data.Entity.Infrastructure.Interception;\nusing System.IO;\nusing System.Linq;\nusing System.Net;\n@@ -172,6 +173,8 @@ protected override void Load(ContainerBuilder builder)\n.As<ICacheService>()\n.InstancePerLifetimeScope();\n+ DbInterception.Add(new QueryHintInterceptor());\n+\nvar galleryDbConnectionFactory = CreateDbConnectionFactory(\nloggerFactory,\nnameof(EntitiesContext),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/VerifyMicrosoftPackage/Fakes/FakeEntitiesContext.cs",
"new_path": "src/VerifyMicrosoftPackage/Fakes/FakeEntitiesContext.cs",
"diff": "@@ -27,6 +27,8 @@ class FakeEntitiesContext : IEntitiesContext\npublic DbSet<Package> Packages { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\npublic DbSet<PackageRename> PackageRenames { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }\n+ public string QueryHint => throw new NotImplementedException();\n+\npublic void DeleteOnCommit<T>(T entity) where T : class\n{\nthrow new NotImplementedException();\n@@ -56,5 +58,10 @@ public void SetCommandTimeout(int? seconds)\n{\nthrow new NotImplementedException();\n}\n+\n+ public IDisposable WithQueryHint(string queryHint)\n+ {\n+ throw new NotImplementedException();\n+ }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"diff": "using System;\nusing System.Collections.Generic;\nusing System.Data.Entity;\n-using System.Data.Entity.Migrations.Model;\nusing System.Linq;\nusing System.Text.RegularExpressions;\nusing System.Threading.Tasks;\n-using Microsoft.Ajax.Utilities;\nusing Moq;\nusing NuGet.Frameworks;\nusing NuGet.Packaging;\n@@ -2141,6 +2139,58 @@ private void AddMemberToOrganization(Organization organization, User member)\npublic class TheGetPackageDependentsMethod\n{\n+ [Fact]\n+ public void AllQueriesShouldUseRecompileQueryHint()\n+ {\n+ string id = \"foo\";\n+ var context = new Mock<IEntitiesContext>();\n+ var entityContext = new FakeEntitiesContext();\n+ var disposable = new Mock<IDisposable>();\n+\n+ var operations = new List<string>();\n+\n+ disposable\n+ .Setup(x => x.Dispose())\n+ .Callback(() => operations.Add(nameof(IDisposable.Dispose)));\n+ context\n+ .Setup(x => x.WithQueryHint(It.IsAny<string>()))\n+ .Returns(() => disposable.Object)\n+ .Callback(() => operations.Add(nameof(EntitiesContext.WithQueryHint)));\n+ context\n+ .Setup(f => f.PackageDependencies)\n+ .Returns(entityContext.PackageDependencies)\n+ .Callback(() => operations.Add(nameof(EntitiesContext.PackageDependencies)));\n+ context\n+ .Setup(f => f.Packages)\n+ .Returns(entityContext.Packages)\n+ .Callback(() => operations.Add(nameof(EntitiesContext.Packages)));\n+ context\n+ .Setup(f => f.PackageRegistrations)\n+ .Returns(entityContext.PackageRegistrations)\n+ .Callback(() => operations.Add(nameof(EntitiesContext.PackageRegistrations)));\n+\n+ var service = CreateService(context: context);\n+\n+ service.GetPackageDependents(id);\n+\n+ Assert.Equal(nameof(EntitiesContext.WithQueryHint), operations.First());\n+ Assert.All(\n+ operations.Skip(1).Take(operations.Count - 2),\n+ o => Assert.Contains(\n+ o,\n+ new[]\n+ {\n+ nameof(EntitiesContext.PackageDependencies),\n+ nameof(EntitiesContext.Packages),\n+ nameof(EntitiesContext.PackageRegistrations),\n+ }));\n+ Assert.Equal(nameof(IDisposable.Dispose), operations.Last());\n+\n+ disposable.Verify(x => x.Dispose(), Times.Once);\n+ context.Verify(x => x.WithQueryHint(It.IsAny<string>()), Times.Once);\n+ context.Verify(x => x.WithQueryHint(\"RECOMPILE\"), Times.Once);\n+ }\n+\n[Fact]\npublic void ThereAreExactlyFivePackagesAndAllPackagesAreVerified()\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/TestUtils/FakeEntitiesContext.cs",
"new_path": "tests/NuGetGallery.Facts/TestUtils/FakeEntitiesContext.cs",
"diff": "@@ -209,6 +209,8 @@ public DbSet<PackageRename> PackageRenames\n}\n}\n+ public virtual string QueryHint => throw new NotImplementedException();\n+\npublic Task<int> SaveChangesAsync()\n{\n_areChangesSaved = true;\n@@ -312,5 +314,10 @@ public void SetupDatabase(IDatabase database)\npublic void Dispose()\n{\n}\n+\n+ public virtual IDisposable WithQueryHint(string queryHint)\n+ {\n+ throw new NotImplementedException();\n+ }\n}\n}\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add RECOMPILE query hint to package dependents SQL (#8096)
Progress on https://github.com/NuGet/NuGetGallery/issues/8078 |
455,744 | 14.07.2020 12:41:10 | 25,200 | f8c378009d25a293ee49f4cda5d96c7e50433ed5 | Removing TLS banner | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Shared/Gallery/Header.cshtml",
"new_path": "src/NuGetGallery/Views/Shared/Gallery/Header.cshtml",
"diff": "var rawErrorMessage = TempData.ContainsKey(\"RawErrorMessage\") ? TempData[\"RawErrorMessage\"].ToString() : null;\n}\n-<div class=\"container-fluid banner banner-info text-center\">\n- <div class=\"row\">\n- <div class=\"col-sm-12\">\n- <i class=\"ms-Icon ms-Icon--Warning\" aria-hidden=\"true\"></i>\n- <span>\n- NuGet.org had TLS 1.0 and 1.1 disabled. Please refer to our <a href=\"https://devblogs.microsoft.com/nuget/deprecating-tls-1-0-and-1-1-on-nuget-org/\">blog post</a> if you are having connection issues.\n- </span>\n- </div>\n- </div>\n-</div>\n-\n@if (!string.IsNullOrWhiteSpace(Config.Current.WarningBanner))\n{\n<div class=\"container-fluid banner banner-bright text-center\">\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Removing TLS banner (#8101) |
455,736 | 13.07.2020 11:21:58 | 25,200 | e6d6dc88d316f93fb21ff5081c581e3f19f305c0 | Use protected configuration provider instead of reflection
Address | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"new_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"diff": "@@ -64,8 +64,6 @@ public static void Configuration(IAppBuilder app)\nvar config = dependencyResolver.GetService<IGalleryConfigurationService>();\nvar auth = dependencyResolver.GetService<AuthenticationService>();\n- // Configure machine key for session persistence across slots\n- SessionPersistence.Setup(config);\n// Refresh the content for the ContentObjectService to guarantee it has loaded the latest configuration on startup.\nvar contentObjectService = dependencyResolver.GetService<IContentObjectService>();\nHostingEnvironment.QueueBackgroundWorkItem(async token =>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<Compile Include=\"ActionName.cs\" />\n+ <Compile Include=\"App_Start\\GalleryMachineKeyConfigurationProvider.cs\" />\n<Compile Include=\"App_Start\\LatestVersionRouteConstraint.cs\" />\n<Compile Include=\"App_Start\\NuGetODataV2FeedConfig.cs\" />\n<Compile Include=\"App_Start\\NuGetODataV1FeedConfig.cs\" />\n<Compile Include=\"App_Start\\NuGetODataConfig.cs\" />\n<Compile Include=\"App_Start\\StorageDependent.cs\" />\n- <Compile Include=\"App_Start\\SessionPersistence.cs\" />\n<Compile Include=\"App_Start\\WebApiConfig.cs\" />\n<Compile Include=\"App_Start\\AutofacConfig.cs\" />\n<Compile Include=\"Areas\\Admin\\Controllers\\ApiKeysController.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<section name=\"dataCacheClients\" type=\"Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core\" allowLocation=\"true\" allowDefinition=\"Everywhere\"/>\n<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->\n</configSections>\n+ <configProtectedData>\n+ <providers>\n+ <add name=\"GalleryMachineKeyConfigurationProvider\" type=\"NuGetGallery.GalleryMachineKeyConfigurationProvider, NuGetGallery\"/>\n+ </providers>\n+ </configProtectedData>\n<appSettings>\n<!-- If you're running in Azure, we suggest you set these in your .cscfg file. -->\n<!-- ******************* -->\n<error statusCode=\"500\" redirect=\"~/App_500.aspx\"/>\n</customErrors>\n<sessionState mode=\"Off\"/>\n+ <machineKey configProtectionProvider=\"GalleryMachineKeyConfigurationProvider\">\n+ <EncryptedData />\n+ </machineKey>\n</system.web>\n<system.webServer>\n<tracing>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Use protected configuration provider instead of reflection (#8098)
Address https://github.com/NuGet/Engineering/issues/3206 |
455,754 | 15.07.2020 14:53:21 | -36,000 | 9518c24bab0679bccbcd9244bb4f343e7f193571 | Replace advisory permalink workaround with GitHub advisory permalink field | [
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryBuilder.cs",
"new_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryBuilder.cs",
"diff": "@@ -21,7 +21,7 @@ public string CreateSecurityAdvisoriesQuery(DateTimeOffset? updatedSince = null,\ncursor\nnode {\ndatabaseId\n- ghsaId\n+ permalink\nseverity\nupdatedAt\n\" + CreateVulnerabilitiesConnectionQuery() + @\"\n@@ -33,7 +33,7 @@ public string CreateSecurityAdvisoriesQuery(DateTimeOffset? updatedSince = null,\npublic string CreateSecurityAdvisoryQuery(SecurityAdvisory advisory)\n=> @\"\n{\n- securityAdvisory(ghsaId: \" + advisory.GhsaId + @\") {\n+ securityAdvisory(databaseId: \" + advisory.DatabaseId + @\") {\nseverity\nupdatedAt\nidentifiers {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"new_path": "src/GitHubVulnerabilities2Db/GitHubVulnerabilities2Db.csproj",
"diff": "<Compile Include=\"GraphQL\\SecurityAdvisory.cs\" />\n<Compile Include=\"GraphQL\\QueryResponse.cs\" />\n<Compile Include=\"GraphQL\\QueryService.cs\" />\n- <Compile Include=\"GraphQL\\SecurityAdvisoryExtensions.cs\" />\n<Compile Include=\"GraphQL\\SecurityVulnerability.cs\" />\n<Compile Include=\"Ingest\\AdvisoryIngestor.cs\" />\n<Compile Include=\"Ingest\\GitHubVersionRangeParser.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/GraphQL/SecurityAdvisory.cs",
"new_path": "src/GitHubVulnerabilities2Db/GraphQL/SecurityAdvisory.cs",
"diff": "@@ -11,12 +11,7 @@ namespace GitHubVulnerabilities2Db.GraphQL\npublic class SecurityAdvisory : INode\n{\npublic int DatabaseId { get; set; }\n-\n- /// <summary>\n- /// The GitHub SecurityAdvisory ID in the format 'GHSA-xxxx-xxxx-xxxx'.\n- /// </summary>\n- public string GhsaId { get; set; }\n-\n+ public string Permalink { get; set; }\npublic string Severity { get; set; }\npublic DateTimeOffset UpdatedAt { get; set; }\npublic DateTimeOffset? WithdrawnAt { get; set; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"new_path": "src/GitHubVulnerabilities2Db/Ingest/AdvisoryIngestor.cs",
"diff": "@@ -41,7 +41,7 @@ public async Task IngestAsync(IReadOnlyList<SecurityAdvisory> advisories)\n{\nGitHubDatabaseKey = advisory.DatabaseId,\nSeverity = (PackageVulnerabilitySeverity)Enum.Parse(typeof(PackageVulnerabilitySeverity), advisory.Severity, ignoreCase: true),\n- AdvisoryUrl = advisory.GetPermalink()\n+ AdvisoryUrl = advisory.Permalink\n};\nforeach (var securityVulnerability in advisory.Vulnerabilities?.Edges?.Select(e => e.Node) ?? Enumerable.Empty<SecurityVulnerability>())\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"new_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"diff": "@@ -40,7 +40,7 @@ public async Task IngestsAdvisoryWithoutVulnerability(bool withdrawn)\nvar advisory = new SecurityAdvisory\n{\nDatabaseId = 1,\n- GhsaId = \"ghsa\",\n+ Permalink = \"GHSA-3456-abcd-7890\",\nSeverity = \"MODERATE\",\nWithdrawnAt = withdrawn ? new DateTimeOffset() : (DateTimeOffset?)null\n};\n@@ -51,7 +51,7 @@ public async Task IngestsAdvisoryWithoutVulnerability(bool withdrawn)\n{\nAssert.Equal(advisory.DatabaseId, vulnerability.GitHubDatabaseKey);\nAssert.Equal(PackageVulnerabilitySeverity.Moderate, vulnerability.Severity);\n- Assert.Equal(advisory.GetPermalink(), vulnerability.AdvisoryUrl);\n+ Assert.Equal(advisory.Permalink, vulnerability.AdvisoryUrl);\n})\n.Returns(Task.CompletedTask)\n.Verifiable();\n@@ -82,7 +82,7 @@ public async Task IngestsAdvisory(bool withdrawn, bool vulnerabilityHasFirstPatc\nvar advisory = new SecurityAdvisory\n{\nDatabaseId = 1,\n- GhsaId = \"ghsa\",\n+ Permalink = \"https://example/advisories/GHSA-6543-dcba-0987\",\nSeverity = \"CRITICAL\",\nWithdrawnAt = withdrawn ? new DateTimeOffset() : (DateTimeOffset?)null,\nVulnerabilities = new ConnectionResponseData<SecurityVulnerability>\n@@ -110,7 +110,7 @@ public async Task IngestsAdvisory(bool withdrawn, bool vulnerabilityHasFirstPatc\n{\nAssert.Equal(advisory.DatabaseId, vulnerability.GitHubDatabaseKey);\nAssert.Equal(PackageVulnerabilitySeverity.Critical, vulnerability.Severity);\n- Assert.Equal(advisory.GetPermalink(), vulnerability.AdvisoryUrl);\n+ Assert.Equal(advisory.Permalink, vulnerability.AdvisoryUrl);\nvar range = vulnerability.AffectedRanges.Single();\nAssert.Equal(securityVulnerability.Package.Name, range.PackageId);\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Replace advisory permalink workaround with GitHub advisory permalink field (#8088) |
455,754 | 16.07.2020 08:55:17 | -36,000 | 5caec434ffa3eca0849e8d58de4931ebd91236bf | Made a test permalink a more realistic URL | [
{
"change_type": "MODIFY",
"old_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"new_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryIngestorFacts.cs",
"diff": "@@ -40,7 +40,7 @@ public async Task IngestsAdvisoryWithoutVulnerability(bool withdrawn)\nvar advisory = new SecurityAdvisory\n{\nDatabaseId = 1,\n- Permalink = \"GHSA-3456-abcd-7890\",\n+ Permalink = \"https://example/advisories/GHSA-3456-abcd-7890\",\nSeverity = \"MODERATE\",\nWithdrawnAt = withdrawn ? new DateTimeOffset() : (DateTimeOffset?)null\n};\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Made a test permalink a more realistic URL (#8108) |
455,736 | 17.07.2020 16:07:59 | 25,200 | 3df003b9740ad886365ec64aa976d727def21f13 | Use OPTIMIZE FOR UNKNOWN for dependents queries
* Use OPTIMIZE FOR UNKNOWN for dependents queries
* Add query hint configuration to RECOMPILE for some package IDs
Progress on | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"new_path": "src/NuGetGallery.Services/NuGetGallery.Services.csproj",
"diff": "<Compile Include=\"Configuration\\ILoginDiscontinuationConfiguration.cs\" />\n<Compile Include=\"Configuration\\IPackageDeleteConfiguration.cs\" />\n<Compile Include=\"Configuration\\IODataCacheConfiguration.cs\" />\n+ <Compile Include=\"Configuration\\IQueryHintConfiguration.cs\" />\n<Compile Include=\"Configuration\\IServiceBusConfiguration.cs\" />\n<Compile Include=\"Configuration\\ISymbolsConfiguration.cs\" />\n<Compile Include=\"Configuration\\ITyposquattingConfiguration.cs\" />\n<Compile Include=\"Configuration\\LoginDiscontinuationConfiguration.cs\" />\n<Compile Include=\"Configuration\\ODataCacheConfiguration.cs\" />\n<Compile Include=\"Configuration\\PackageDeleteConfiguration.cs\" />\n+ <Compile Include=\"Configuration\\QueryHintConfiguration.cs\" />\n<Compile Include=\"Configuration\\SecretReader\\EmptySecretReaderFactory.cs\" />\n<Compile Include=\"Configuration\\SecretReader\\SecretReaderFactory.cs\" />\n<Compile Include=\"Configuration\\ServiceBusConfiguration.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"new_path": "src/NuGetGallery.Services/PackageManagement/PackageService.cs",
"diff": "using System;\nusing System.Collections.Generic;\n-using System.Data.Common;\nusing System.Data.Entity;\nusing System.IO;\nusing System.Linq;\n@@ -26,6 +25,7 @@ public class PackageService : CorePackageService, IPackageService\nprivate readonly ITelemetryService _telemetryService;\nprivate readonly ISecurityPolicyService _securityPolicyService;\nprivate readonly IEntitiesContext _entitiesContext;\n+ private readonly IContentObjectService _contentObjectService;\nprivate const int packagesDisplayed = 5;\npublic PackageService(\n@@ -35,13 +35,15 @@ public class PackageService : CorePackageService, IPackageService\nIAuditingService auditingService,\nITelemetryService telemetryService,\nISecurityPolicyService securityPolicyService,\n- IEntitiesContext entitiesContext)\n+ IEntitiesContext entitiesContext,\n+ IContentObjectService contentObjectService)\n: base(packageRepository, packageRegistrationRepository, certificateRepository)\n{\n_auditingService = auditingService ?? throw new ArgumentNullException(nameof(auditingService));\n_telemetryService = telemetryService ?? throw new ArgumentNullException(nameof(telemetryService));\n_securityPolicyService = securityPolicyService ?? throw new ArgumentNullException(nameof(securityPolicyService));\n_entitiesContext = entitiesContext ?? throw new ArgumentNullException(nameof(entitiesContext));\n+ _contentObjectService = contentObjectService ?? throw new ArgumentNullException(nameof(contentObjectService));\n}\n/// <summary>\n@@ -156,7 +158,33 @@ public PackageDependents GetPackageDependents(string id)\nPackageDependents result = new PackageDependents();\n- using (_entitiesContext.WithQueryHint(\"RECOMPILE\"))\n+ // We use OPTIMIZE FOR UNKNOWN by default here because there are distinct 2-3 query plans that may be\n+ // selected via SQL Server parameter sniffing. Because SQL Server caches query plans, this means that the\n+ // first parameter plus query combination that SQL sees defines which query plan is selected and cached for\n+ // all subsequent parameter values of the same query. This could result in a non-optimal query plan getting\n+ // cached depending on what package ID is viewed first. Using OPTIMIZE FOR UNKNOWN causes a predictable\n+ // query plan to be cached.\n+ //\n+ // For example, the query plan for Newtonsoft.Json is very good for that specific parameter value since\n+ // there are so many package dependents but the same query plan takes a very long time for packages with few\n+ // or no dependents. The query plan for \"UNKNOWN\" (that is a package ID with unknown SQL Server statistic)\n+ // behaves somewhat poorly for Newtonsoft.Json (2-5 seconds) but very well for the vast majority of\n+ // packages. Because we have in-memory caching above this layer, OPTIMIZE FOR UNKNOWN is acceptable other\n+ // unconfigured cases similar to Newtonsoft.Json because the extra cost of the non-optimal query plan is\n+ // amortized over many, many page views. For the long tail packages, in-memory caching is less effective\n+ // (low page views) so an optimal query should be selected for this category.\n+ //\n+ // For the cases where RECOMPILE is known to perform the best, the package ID can be added to the query hint\n+ // configuration JSON file from the content object service. This should only be done when the following\n+ // things are true:\n+ //\n+ // 1. The overhead of SQL Server recompile is worth it. We have seen the overhead to be 5-50ms.\n+ // 2. SQL Server has up to date statistics which will lead to the proper query plan being selected.\n+ // 3. SQL Server actually picks the proper query plan. We have observed cases where this does not happen\n+ // even with up-to-date statistics.\n+ //\n+ var useRecompile = _contentObjectService.QueryHintConfiguration.ShouldUseRecompileForPackageDependents(id);\n+ using (_entitiesContext.WithQueryHint(useRecompile ? \"RECOMPILE\" : \"OPTIMIZE FOR UNKNOWN\"))\n{\nresult.TopPackages = GetListOfDependents(id);\nresult.TotalPackageCount = GetDependentCount(id);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/ServicesConstants.cs",
"new_path": "src/NuGetGallery.Services/ServicesConstants.cs",
"diff": "@@ -56,6 +56,7 @@ public static class ContentNames\npublic static readonly string ABTestConfiguration = \"AB-Test-Configuration\";\npublic static readonly string ODataCacheConfiguration = \"OData-Cache-Configuration\";\npublic static readonly string CacheConfiguration = \"Cache-Configuration\";\n+ public static readonly string QueryHintConfiguration = \"Query-Hint-Configuration\";\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"new_path": "src/NuGetGallery.Services/Storage/ContentObjectService.cs",
"diff": "@@ -27,6 +27,7 @@ public ContentObjectService(IContentService contentService)\nABTestConfiguration = new ABTestConfiguration();\nODataCacheConfiguration = new ODataCacheConfiguration();\nCacheConfiguration = new CacheConfiguration();\n+ QueryHintConfiguration = new QueryHintConfiguration();\n}\npublic ILoginDiscontinuationConfiguration LoginDiscontinuationConfiguration { get; private set; }\n@@ -37,6 +38,7 @@ public ContentObjectService(IContentService contentService)\npublic IABTestConfiguration ABTestConfiguration { get; private set; }\npublic IODataCacheConfiguration ODataCacheConfiguration { get; private set; }\npublic ICacheConfiguration CacheConfiguration { get; private set; }\n+ public IQueryHintConfiguration QueryHintConfiguration { get; private set; }\npublic async Task Refresh()\n{\n@@ -72,6 +74,10 @@ public async Task Refresh()\nCacheConfiguration =\nawait Refresh<CacheConfiguration>(ServicesConstants.ContentNames.CacheConfiguration) ??\nnew CacheConfiguration();\n+\n+ QueryHintConfiguration =\n+ await Refresh<QueryHintConfiguration>(ServicesConstants.ContentNames.QueryHintConfiguration) ??\n+ new QueryHintConfiguration();\n}\nprivate async Task<T> Refresh<T>(string contentName)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Storage/IContentObjectService.cs",
"new_path": "src/NuGetGallery.Services/Storage/IContentObjectService.cs",
"diff": "@@ -16,6 +16,7 @@ public interface IContentObjectService\nIABTestConfiguration ABTestConfiguration { get; }\nIODataCacheConfiguration ODataCacheConfiguration { get; }\nICacheConfiguration CacheConfiguration { get; }\n+ IQueryHintConfiguration QueryHintConfiguration { get; }\nTask Refresh();\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/NuGetGallery/App_Data/Files/Content/Query-Hint-Configuration.json",
"diff": "+{\n+ \"RecompileForPackageDependents\": []\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<ItemGroup>\n<Content Include=\"App_Data\\Files\\Content\\Cache-Configuration.json\" />\n</ItemGroup>\n+ <ItemGroup>\n+ <Content Include=\"App_Data\\Files\\Content\\Query-Hint-Configuration.json\" />\n+ </ItemGroup>\n<PropertyGroup>\n<VisualStudioVersion Condition=\"'$(VisualStudioVersion)' == ''\">10.0</VisualStudioVersion>\n<VSToolsPath Condition=\"'$(VSToolsPath)' == ''\">$(MSBuildExtensionsPath32)\\Microsoft\\VisualStudio\\v$(VisualStudioVersion)</VSToolsPath>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/VerifyMicrosoftPackage/Application.cs",
"new_path": "src/VerifyMicrosoftPackage/Application.cs",
"diff": "@@ -265,6 +265,7 @@ private static PackageService GetPackageService()\nvar telemetryService = new FakeTelemetryService();\nvar securityPolicyService = new FakeSecurityPolicyService();\nvar contextFake = new FakeEntitiesContext();\n+ var contentObjectService = new FakeContentObjectService();\nvar packageService = new PackageService(\npackageRegistrationRepository,\n@@ -273,7 +274,9 @@ private static PackageService GetPackageService()\nauditingService,\ntelemetryService,\nsecurityPolicyService,\n- contextFake);\n+ contextFake,\n+ contentObjectService);\n+\nreturn packageService;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/VerifyMicrosoftPackage/VerifyMicrosoftPackage.csproj",
"new_path": "src/VerifyMicrosoftPackage/VerifyMicrosoftPackage.csproj",
"diff": "<ItemGroup>\n<Compile Include=\"Application.cs\" />\n<Compile Include=\"Fakes\\FakeAuditingService.cs\" />\n+ <Compile Include=\"Fakes\\FakeContentObjectService.cs\" />\n<Compile Include=\"Fakes\\FakeEntitiesContext.cs\" />\n<Compile Include=\"Fakes\\FakeEntityRepository.cs\" />\n<Compile Include=\"Fakes\\FakeSecurityPolicyService.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs",
"diff": "using NuGetGallery.Framework;\nusing NuGetGallery.Packaging;\nusing NuGetGallery.Security;\n+using NuGetGallery.Services;\nusing NuGetGallery.TestUtils;\nusing Xunit;\n@@ -31,7 +32,8 @@ public class PackageServiceFacts\nMock<ITelemetryService> telemetryService = null,\nMock<ISecurityPolicyService> securityPolicyService = null,\nAction<Mock<PackageService>> setup = null,\n- Mock<IEntitiesContext> context = null)\n+ Mock<IEntitiesContext> context = null,\n+ Mock<IContentObjectService> contentObjectService = null)\n{\npackageRegistrationRepository = packageRegistrationRepository ?? new Mock<IEntityRepository<PackageRegistration>>();\npackageRepository = packageRepository ?? new Mock<IEntityRepository<Package>>();\n@@ -41,6 +43,12 @@ public class PackageServiceFacts\nsecurityPolicyService = securityPolicyService ?? new Mock<ISecurityPolicyService>();\ncontext = context ?? new Mock<IEntitiesContext>();\n+ if (contentObjectService == null)\n+ {\n+ contentObjectService = new Mock<IContentObjectService>();\n+ contentObjectService.Setup(x => x.QueryHintConfiguration).Returns(Mock.Of<IQueryHintConfiguration>());\n+ }\n+\nvar packageService = new Mock<PackageService>(\npackageRegistrationRepository.Object,\npackageRepository.Object,\n@@ -48,7 +56,8 @@ public class PackageServiceFacts\nauditingService,\ntelemetryService.Object,\nsecurityPolicyService.Object,\n- context.Object);\n+ context.Object,\n+ contentObjectService.Object);\npackageService.CallBase = true;\n@@ -2140,7 +2149,7 @@ private void AddMemberToOrganization(Organization organization, User member)\npublic class TheGetPackageDependentsMethod\n{\n[Fact]\n- public void AllQueriesShouldUseRecompileQueryHint()\n+ public void AllQueriesShouldUseQueryHint()\n{\nstring id = \"foo\";\nvar context = new Mock<IEntitiesContext>();\n@@ -2188,6 +2197,33 @@ public void AllQueriesShouldUseRecompileQueryHint()\ndisposable.Verify(x => x.Dispose(), Times.Once);\ncontext.Verify(x => x.WithQueryHint(It.IsAny<string>()), Times.Once);\n+ context.Verify(x => x.WithQueryHint(\"OPTIMIZE FOR UNKNOWN\"), Times.Once);\n+ }\n+\n+ [Fact]\n+ public void UsesRecompileIfConfigured()\n+ {\n+ string id = \"Newtonsoft.Json\";\n+\n+ var context = new Mock<IEntitiesContext>();\n+ var contentObjectService = new Mock<IContentObjectService>();\n+ var queryHintConfiguration = new Mock<IQueryHintConfiguration>();\n+ contentObjectService.Setup(x => x.QueryHintConfiguration).Returns(() => queryHintConfiguration.Object);\n+ queryHintConfiguration.Setup(x => x.ShouldUseRecompileForPackageDependents(id)).Returns(true);\n+\n+ var entityContext = new FakeEntitiesContext();\n+\n+ context.Setup(f => f.PackageDependencies).Returns(entityContext.PackageDependencies);\n+ context.Setup(f => f.Packages).Returns(entityContext.Packages);\n+ context.Setup(f => f.PackageRegistrations).Returns(entityContext.PackageRegistrations);\n+\n+ var service = CreateService(context: context, contentObjectService: contentObjectService);\n+\n+ service.GetPackageDependents(id);\n+\n+ queryHintConfiguration.Verify(x => x.ShouldUseRecompileForPackageDependents(It.IsAny<string>()), Times.Once);\n+ queryHintConfiguration.Verify(x => x.ShouldUseRecompileForPackageDependents(id), Times.Once);\n+ context.Verify(x => x.WithQueryHint(It.IsAny<string>()), Times.Once);\ncontext.Verify(x => x.WithQueryHint(\"RECOMPILE\"), Times.Once);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/Services/ReflowPackageServiceFacts.cs",
"new_path": "tests/NuGetGallery.Facts/Services/ReflowPackageServiceFacts.cs",
"diff": "@@ -344,6 +344,7 @@ private static Mock<PackageService> SetupPackageService(Package package)\nvar telemetryService = new Mock<ITelemetryService>();\nvar securityPolicyService = new Mock<ISecurityPolicyService>();\nvar entitiesContext = new Mock<IEntitiesContext>();\n+ var contentObjectService = new Mock<IContentObjectService>();\nvar packageService = new Mock<PackageService>(\npackageRegistrationRepository.Object,\n@@ -352,7 +353,8 @@ private static Mock<PackageService> SetupPackageService(Package package)\nauditingService,\ntelemetryService.Object,\nsecurityPolicyService.Object,\n- entitiesContext.Object);\n+ entitiesContext.Object,\n+ contentObjectService.Object);\npackageService.CallBase = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/NuGetGallery.Facts/TestUtils/TestServiceUtility.cs",
"new_path": "tests/NuGetGallery.Facts/TestUtils/TestServiceUtility.cs",
"diff": "@@ -196,6 +196,7 @@ private Mock<PackageService> SetupPackageService()\nvar telemetryService = new Mock<ITelemetryService>();\nvar securityPolicyService = new Mock<ISecurityPolicyService>();\nvar entitiesContext = new Mock<IEntitiesContext>();\n+ var contentObjectService = new Mock<IContentObjectService>();\nvar packageService = new Mock<PackageService>(\npackageRegistrationRepository.Object,\n@@ -204,7 +205,8 @@ private Mock<PackageService> SetupPackageService()\nauditingService,\ntelemetryService.Object,\nsecurityPolicyService.Object,\n- entitiesContext.Object);\n+ entitiesContext.Object,\n+ contentObjectService.Object);\npackageService.CallBase = true;\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Use OPTIMIZE FOR UNKNOWN for dependents queries (#8112)
* Use OPTIMIZE FOR UNKNOWN for dependents queries
* Add query hint configuration to RECOMPILE for some package IDs
Progress on https://github.com/NuGet/NuGetGallery/issues/8078 |
455,739 | 20.07.2020 14:41:05 | 14,400 | 18887a4f2aad26ea843f7b55488a34e197ae227d | Fix filter button alignment on small screens for Advanced Search panel | [
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"new_path": "src/Bootstrap/dist/css/bootstrap-theme.css",
"diff": "@@ -1334,6 +1334,11 @@ img.reserved-indicator-icon {\nmargin-left: 10px;\nmargin-right: 10px;\n}\n+@media (min-width: 768px) {\n+ .page-list-packages .text-align-right {\n+ text-align: right;\n+ }\n+}\n.page-manage-deprecation .full-line {\ndisplay: block;\nwidth: 100%;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Bootstrap/less/theme/page-list-packages.less",
"new_path": "src/Bootstrap/less/theme/page-list-packages.less",
"diff": "margin-right: 10px;\n}\n}\n+\n+ @media (min-width: @screen-sm) {\n+ .text-align-right {\n+ text-align: right;\n+ }\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Views/Shared/ListPackages.cshtml",
"new_path": "src/NuGetGallery/Views/Shared/ListPackages.cshtml",
"diff": "}\n</h1>\n</div>\n- <div class=\"col-md-2 col-xs-3 col-sm-1 text-right no-padding\">\n+ <div class=\"col-md-2 col-xs-3 col-sm-1 text-align-right no-padding\">\n@if (Model.IsAdvancedSearchFlightEnabled)\n{\n<button class=\"btn-command\" data-toggle=\"collapse\" data-target=\"#advancedSearchPanel\" aria-expanded=\"false\" aria-controls=\"advancedSearchPanel\">\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Fix filter button alignment on small screens for Advanced Search panel (#8113) |
455,741 | 14.07.2020 17:21:04 | 0 | f0fdd66034dcd8b4619f82343896cb1dbd1c5c69 | 3268 add column EmbeddedReadmeFileType to Package tables | [
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"new_path": "src/NuGet.Services.Entities/NuGet.Services.Entities.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<Compile Include=\"AccountDelete.cs\" />\n+ <Compile Include=\"EmbeddedReadmeFileType.cs\" />\n<Compile Include=\"CredentialRevocationSource.cs\" />\n<Compile Include=\"Certificate.cs\" />\n<Compile Include=\"Constants.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGet.Services.Entities/Package.cs",
"new_path": "src/NuGet.Services.Entities/Package.cs",
"diff": "@@ -285,5 +285,7 @@ public bool HasReadMe\n/// A flag that indicates that the package metadata had an embedded icon specified.\n/// </summary>\npublic bool HasEmbeddedIcon { get; set; }\n+\n+ public EmbeddedReadmeFileType EmbeddedReadmeType { get; set; }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "<Compile Include=\"Migrations\\202006011927336_AddIndexToPackageDependencies.designer.cs\">\n<DependentUpon>202006011927336_AddIndexToPackageDependencies.cs</DependentUpon>\n</Compile>\n+ <Compile Include=\"Migrations\\202007220027197_AddEmbeddedReadmeTypeColumn.cs\" />\n+ <Compile Include=\"Migrations\\202007220027197_AddEmbeddedReadmeTypeColumn.designer.cs\">\n+ <DependentUpon>202007220027197_AddEmbeddedReadmeTypeColumn.cs</DependentUpon>\n+ </Compile>\n<Compile Include=\"Services\\ConfigurationIconFileProvider.cs\" />\n<Compile Include=\"Services\\IconUrlDeprecationValidationMessage.cs\" />\n<Compile Include=\"Services\\GravatarProxyResult.cs\" />\n<EmbeddedResource Include=\"Migrations\\202006011927336_AddIndexToPackageDependencies.resx\">\n<DependentUpon>202006011927336_AddIndexToPackageDependencies.cs</DependentUpon>\n</EmbeddedResource>\n+ <EmbeddedResource Include=\"Migrations\\202007220027197_AddEmbeddedReadmeTypeColumn.resx\">\n+ <DependentUpon>202007220027197_AddEmbeddedReadmeTypeColumn.cs</DependentUpon>\n+ </EmbeddedResource>\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1packages.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv1search.json\" />\n<EmbeddedResource Include=\"OData\\QueryAllowed\\Data\\apiv2getupdates.json\" />\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | 3268 add column EmbeddedReadmeFileType to Package tables |
455,736 | 31.07.2020 11:08:22 | 25,200 | c2fbceefafd25b59e111c50d4450afe855644189 | Use protected configuration provider instead of reflection (WITHOUT DI)
Address
Related to | [
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"new_path": "src/NuGetGallery.Services/Configuration/ConfigurationService.cs",
"diff": "using Microsoft.WindowsAzure.ServiceRuntime;\nusing NuGet.Services.Configuration;\nusing NuGet.Services.KeyVault;\n+using NuGetGallery.Configuration.SecretReader;\nnamespace NuGetGallery.Configuration\n{\n@@ -40,6 +41,22 @@ public class ConfigurationService : IGalleryConfigurationService, IConfiguration\npublic ISecretInjector SecretInjector { get; set; }\n+ /// <summary>\n+ /// Initializes the configuration service and associates a secret injector based on the configured KeyVault\n+ /// settings.\n+ /// </summary>\n+ public static ConfigurationService Initialize()\n+ {\n+ var configuration = new ConfigurationService();\n+ var secretReaderFactory = new SecretReaderFactory(configuration);\n+ var secretReader = secretReaderFactory.CreateSecretReader();\n+ var secretInjector = secretReaderFactory.CreateSecretInjector(secretReader);\n+\n+ configuration.SecretInjector = secretInjector;\n+\n+ return configuration;\n+ }\n+\npublic ConfigurationService()\n{\n_httpSiteRootThunk = new Lazy<string>(GetHttpSiteRoot);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"new_path": "src/NuGetGallery/App_Start/DefaultDependenciesModule.cs",
"diff": "using System.Net.Http;\nusing System.Net.Mail;\nusing System.Security.Principal;\n-using System.Threading;\nusing System.Threading.Tasks;\nusing System.Web;\nusing System.Web.Hosting;\nusing NuGetGallery.Security;\nusing NuGetGallery.Services;\nusing Role = NuGet.Services.Entities.Role;\n-using SecretReaderFactory = NuGetGallery.Configuration.SecretReader.SecretReaderFactory;\nnamespace NuGetGallery\n{\n@@ -88,18 +86,14 @@ protected override void Load(ContainerBuilder builder)\n{\nvar services = new ServiceCollection();\n- var configuration = new ConfigurationService();\n- var secretReaderFactory = new SecretReaderFactory(configuration);\n- var secretReader = secretReaderFactory.CreateSecretReader();\n- var secretInjector = secretReaderFactory.CreateSecretInjector(secretReader);\n+ var configuration = ConfigurationService.Initialize();\n+ var secretInjector = configuration.SecretInjector;\nbuilder.RegisterInstance(secretInjector)\n.AsSelf()\n.As<ISecretInjector>()\n.SingleInstance();\n- configuration.SecretInjector = secretInjector;\n-\n// Register the ILoggerFactory and configure AppInsights.\nvar applicationInsightsConfiguration = ConfigureApplicationInsights(\nconfiguration.Current,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"new_path": "src/NuGetGallery/App_Start/OwinStartup.cs",
"diff": "using System;\nusing System.Collections.Generic;\n+using System.Configuration;\nusing System.Linq;\nusing System.Net;\nusing System.Threading;\nusing System.Web.Http;\nusing System.Web.Mvc;\nusing Elmah;\n-using Microsoft.Extensions.Logging;\nusing Microsoft.Owin;\nusing Microsoft.Owin.Logging;\nusing Microsoft.Owin.Security;\nusing NuGetGallery.Infrastructure;\nusing Owin;\n-using ILoggerFactory = Microsoft.Extensions.Logging.ILoggerFactory;\n-\n[assembly: OwinStartup(typeof(NuGetGallery.OwinStartup))]\nnamespace NuGetGallery\n@@ -64,8 +62,19 @@ public static void Configuration(IAppBuilder app)\nvar config = dependencyResolver.GetService<IGalleryConfigurationService>();\nvar auth = dependencyResolver.GetService<AuthenticationService>();\n- // Configure machine key for session persistence across slots\n- SessionPersistence.Setup(config);\n+ // Ensure the machine key provider has the shared configuration instance and force the machine key\n+ // configuration section to be initialized. This is normally done only when the first request needs the\n+ // machine key but we choose to aggressively execute the initialization here outside of the request context\n+ // since it is internally awaiting an asynchronous API in a synchronous method. This cannot be done in a\n+ // request context because it will cause a deadlock.\n+ //\n+ // Note that is is technically possible for some code before this to initialize the machine key (e.g. by\n+ // calling an API that uses the machine key configuration). If this happens, the machine key will be\n+ // fetched from KeyVault seperately. This will be slightly slower (two KeyVault secret resolutions instead\n+ // of one) but will not be harmful.\n+ GalleryMachineKeyConfigurationProvider.Configuration = config;\n+ ConfigurationManager.GetSection(\"system.web/machineKey\");\n+\n// Refresh the content for the ContentObjectService to guarantee it has loaded the latest configuration on startup.\nvar contentObjectService = dependencyResolver.GetService<IContentObjectService>();\nHostingEnvironment.QueueBackgroundWorkItem(async token =>\n"
},
{
"change_type": "DELETE",
"old_path": "src/NuGetGallery/App_Start/SessionPersistence.cs",
"new_path": null,
"diff": "-// Copyright (c) .NET Foundation. All rights reserved.\n-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n-\n-using System.Configuration;\n-using System.Reflection;\n-using System.Web.Configuration;\n-using NuGetGallery.Configuration;\n-\n-namespace NuGetGallery\n-{\n- public static class SessionPersistence\n- {\n- public static void Setup(IGalleryConfigurationService config)\n- {\n- // The machine keys are used for encrypting/decrypting cookies used by ASP.NET, these are usually set by IIS in 'Auto' mode.\n- // During a deployment to Azure cloud service the same machine key values are set on all the instances of a given cloud service,\n- // thereby providing session persistence across different instances in the same deployment slot. However, across different slots(staging vs production)\n- // these session keys are different. Thereby causing the loss of session upon a slot swap. Manually setting these values on role start ensures same\n- // keys are used by all the instances across all the slots of a Azure cloud service. See more analysis here: https://github.com/NuGet/Engineering/issues/1329\n- if (config.Current.EnableMachineKeyConfiguration\n- && !string.IsNullOrWhiteSpace(config.Current.MachineKeyDecryption)\n- && !string.IsNullOrWhiteSpace(config.Current.MachineKeyDecryptionKey)\n- && !string.IsNullOrWhiteSpace(config.Current.MachineKeyValidationAlgorithm)\n- && !string.IsNullOrWhiteSpace(config.Current.MachineKeyValidationKey))\n- {\n- var mksType = typeof(MachineKeySection);\n- var mksSection = ConfigurationManager.GetSection(\"system.web/machineKey\") as MachineKeySection;\n- var resetMethod = mksType.GetMethod(\"Reset\", BindingFlags.NonPublic | BindingFlags.Instance);\n-\n- var machineKeyConfig = new MachineKeySection();\n- machineKeyConfig.ApplicationName = mksSection.ApplicationName;\n- machineKeyConfig.CompatibilityMode = mksSection.CompatibilityMode;\n- machineKeyConfig.DataProtectorType = mksSection.DataProtectorType;\n- machineKeyConfig.Validation = mksSection.Validation;\n-\n- machineKeyConfig.DecryptionKey = config.Current.MachineKeyDecryptionKey;\n- machineKeyConfig.Decryption = config.Current.MachineKeyDecryption;\n- machineKeyConfig.ValidationKey = config.Current.MachineKeyValidationKey;\n- machineKeyConfig.ValidationAlgorithm = config.Current.MachineKeyValidationAlgorithm;\n-\n- resetMethod.Invoke(mksSection, new object[] { machineKeyConfig });\n- }\n- }\n- }\n-}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/NuGetGallery.csproj",
"new_path": "src/NuGetGallery/NuGetGallery.csproj",
"diff": "</ItemGroup>\n<ItemGroup>\n<Compile Include=\"ActionName.cs\" />\n+ <Compile Include=\"App_Start\\GalleryMachineKeyConfigurationProvider.cs\" />\n<Compile Include=\"App_Start\\LatestVersionRouteConstraint.cs\" />\n<Compile Include=\"App_Start\\NuGetODataV2FeedConfig.cs\" />\n<Compile Include=\"App_Start\\NuGetODataV1FeedConfig.cs\" />\n<Compile Include=\"App_Start\\NuGetODataConfig.cs\" />\n<Compile Include=\"App_Start\\StorageDependent.cs\" />\n- <Compile Include=\"App_Start\\SessionPersistence.cs\" />\n<Compile Include=\"App_Start\\WebApiConfig.cs\" />\n<Compile Include=\"App_Start\\AutofacConfig.cs\" />\n<Compile Include=\"Areas\\Admin\\Controllers\\ApiKeysController.cs\" />\n"
},
{
"change_type": "MODIFY",
"old_path": "src/NuGetGallery/Web.config",
"new_path": "src/NuGetGallery/Web.config",
"diff": "<section name=\"dataCacheClients\" type=\"Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core\" allowLocation=\"true\" allowDefinition=\"Everywhere\"/>\n<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->\n</configSections>\n+ <configProtectedData>\n+ <providers>\n+ <add name=\"GalleryMachineKeyConfigurationProvider\" type=\"NuGetGallery.GalleryMachineKeyConfigurationProvider, NuGetGallery\"/>\n+ </providers>\n+ </configProtectedData>\n<appSettings>\n<!-- If you're running in Azure, we suggest you set these in your .cscfg file. -->\n<!-- ******************* -->\n<error statusCode=\"500\" redirect=\"~/App_500.aspx\"/>\n</customErrors>\n<sessionState mode=\"Off\"/>\n+ <machineKey configProtectionProvider=\"GalleryMachineKeyConfigurationProvider\">\n+ <EncryptedData/>\n+ </machineKey>\n</system.web>\n<system.webServer>\n<tracing>\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Use protected configuration provider instead of reflection (WITHOUT DI) (#8132)
Address https://github.com/NuGet/NuGetGallery/issues/8121
Related to https://github.com/NuGet/Engineering/issues/3206 |
455,776 | 03.08.2020 00:40:35 | 25,200 | df53bf857eaf3aabe4235992af0906b539eca71d | Add command to compare PackageVulnerabilities to GitHub API
Add command to compare PackageVulnerabilities to GitHub API | [
{
"change_type": "MODIFY",
"old_path": "src/GalleryTools/GalleryTools.csproj",
"new_path": "src/GalleryTools/GalleryTools.csproj",
"diff": "<Compile Include=\"Commands\\ReflowCommand.cs\" />\n<Compile Include=\"Commands\\UpdateIsLatestCommand.cs\" />\n<Compile Include=\"Commands\\VerifyApiKeyCommand.cs\" />\n+ <Compile Include=\"Commands\\VerifyGitHubVulnerabilitiesCommand.cs\" />\n<Compile Include=\"Program.cs\" />\n<Compile Include=\"Properties\\AssemblyInfo.cs\" />\n<Compile Include=\"Properties\\AssemblyInfo.*.cs\" />\n<None Include=\"App.config\" />\n</ItemGroup>\n<ItemGroup>\n+ <ProjectReference Include=\"..\\GitHubVulnerabilities2Db\\GitHubVulnerabilities2Db.csproj\">\n+ <Project>{26bb718a-e1c1-4e70-9008-fb8ee7a7f7e5}</Project>\n+ <Name>GitHubVulnerabilities2Db</Name>\n+ </ProjectReference>\n<ProjectReference Include=\"..\\NuGet.Services.Entities\\NuGet.Services.Entities.csproj\">\n<Project>{6262f4fc-29be-4226-b676-db391c89d396}</Project>\n<Name>NuGet.Services.Entities</Name>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GalleryTools/Program.cs",
"new_path": "src/GalleryTools/Program.cs",
"diff": "@@ -21,6 +21,7 @@ public static int Main(params string[] args)\ncommandLineApplication.Command(\"filldevdeps\", BackfillDevelopmentDependencyCommand.Configure);\ncommandLineApplication.Command(\"verifyapikey\", VerifyApiKeyCommand.Configure);\ncommandLineApplication.Command(\"updateIsLatest\", UpdateIsLatestCommand.Configure);\n+ commandLineApplication.Command(\"verifyVulnerabilities\", VerifyGitHubVulnerabilitiesCommand.Configure);\ntry\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryCollector.cs",
"new_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryCollector.cs",
"diff": "@@ -32,7 +32,9 @@ public class AdvisoryCollector : IAdvisoryCollector\npublic async Task<bool> ProcessAsync(CancellationToken token)\n{\n- var advisories = await _queryService.GetAdvisoriesSinceAsync(_cursor, token);\n+ await _cursor.Load(token);\n+ var lastUpdated = _cursor.Value;\n+ var advisories = await _queryService.GetAdvisoriesSinceAsync(lastUpdated, token);\nvar hasAdvisories = advisories != null && advisories.Any();\n_logger.LogInformation(\"Found {AdvisoryCount} new advisories to process\", advisories?.Count() ?? 0);\nif (hasAdvisories)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryService.cs",
"new_path": "src/GitHubVulnerabilities2Db/Collector/AdvisoryQueryService.cs",
"diff": "using System.Threading.Tasks;\nusing GitHubVulnerabilities2Db.GraphQL;\nusing Microsoft.Extensions.Logging;\n-using NuGet.Services.Cursor;\nnamespace GitHubVulnerabilities2Db.Collector\n{\n@@ -28,10 +27,8 @@ public class AdvisoryQueryService : IAdvisoryQueryService\n_logger = logger ?? throw new ArgumentNullException(nameof(logger));\n}\n- public async Task<IReadOnlyList<SecurityAdvisory>> GetAdvisoriesSinceAsync(ReadCursor<DateTimeOffset> cursor, CancellationToken token)\n+ public async Task<IReadOnlyList<SecurityAdvisory>> GetAdvisoriesSinceAsync(DateTimeOffset lastUpdated, CancellationToken token)\n{\n- await cursor.Load(token);\n- var lastUpdated = cursor.Value;\n_logger.LogInformation(\"Fetching advisories updated since {LastUpdated}\", lastUpdated);\nvar firstQuery = _queryBuilder.CreateSecurityAdvisoriesQuery(lastUpdated);\nvar firstResponse = await _queryService.QueryAsync(firstQuery, token);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/GitHubVulnerabilities2Db/Collector/IAdvisoryQueryService.cs",
"new_path": "src/GitHubVulnerabilities2Db/Collector/IAdvisoryQueryService.cs",
"diff": "@@ -15,6 +15,6 @@ namespace GitHubVulnerabilities2Db.Collector\n/// </summary>\npublic interface IAdvisoryQueryService\n{\n- Task<IReadOnlyList<SecurityAdvisory>> GetAdvisoriesSinceAsync(ReadCursor<DateTimeOffset> cursor, CancellationToken token);\n+ Task<IReadOnlyList<SecurityAdvisory>> GetAdvisoriesSinceAsync(DateTimeOffset lastUpdated, CancellationToken token);\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryQueryServiceFacts.cs",
"new_path": "tests/GitHubVulnerabilities2Db.Facts/AdvisoryQueryServiceFacts.cs",
"diff": "// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\nusing System;\n-using System.Collections;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Linq.Expressions;\nusing GitHubVulnerabilities2Db.GraphQL;\nusing Microsoft.Extensions.Logging;\nusing Moq;\n-using NuGet.Services.Cursor;\nusing Xunit;\nnamespace GitHubVulnerabilities2Db.Facts\n@@ -22,16 +20,7 @@ public class AdvisoryQueryServiceFacts\npublic AdvisoryQueryServiceFacts()\n{\n_token = CancellationToken.None;\n- _cursorMock = new Mock<ReadWriteCursor<DateTimeOffset>>();\n- _cursorMock\n- .Setup(x => x.Load(_token))\n- .Returns(Task.CompletedTask)\n- .Verifiable();\n-\n- _cursorValue = new DateTimeOffset(2019, 10, 28, 1, 1, 1, TimeSpan.Zero);\n- _cursorMock\n- .Setup(x => x.Value)\n- .Returns(_cursorValue);\n+ _lastUpdated = new DateTimeOffset(2019, 10, 28, 1, 1, 1, TimeSpan.Zero);\n_queryServiceMock = new Mock<IQueryService>();\n_maxResultsPerQuery = 3;\n@@ -49,8 +38,7 @@ public AdvisoryQueryServiceFacts()\nprivate readonly Mock<IQueryService> _queryServiceMock;\nprivate readonly int _maxResultsPerQuery;\nprivate readonly Mock<IAdvisoryQueryBuilder> _queryBuilderMock;\n- private readonly Mock<ReadWriteCursor<DateTimeOffset>> _cursorMock;\n- private readonly DateTimeOffset _cursorValue;\n+ private readonly DateTimeOffset _lastUpdated;\nprivate readonly CancellationToken _token;\nprivate readonly AdvisoryQueryService _service;\n@@ -62,12 +50,11 @@ public async Task NoResults()\n// Act\nvar results = await _service.GetAdvisoriesSinceAsync(\n- _cursorMock.Object, _token);\n+ _lastUpdated, _token);\n// Assert\nAssert.Empty(results);\n- _cursorMock.Verify();\n_queryBuilderMock.Verify();\n_queryServiceMock.Verify();\n}\n@@ -90,12 +77,11 @@ public async Task OneResult()\n// Act\nvar results = await _service.GetAdvisoriesSinceAsync(\n- _cursorMock.Object, _token);\n+ _lastUpdated, _token);\n// Assert\nAssert.Single(results, advisory);\n- _cursorMock.Verify();\n_queryBuilderMock.Verify();\n_queryServiceMock.Verify();\n}\n@@ -135,7 +121,7 @@ public async Task DedupesIdenticalVulnerabilities()\n// Act\nvar results = await _service.GetAdvisoriesSinceAsync(\n- _cursorMock.Object, _token);\n+ _lastUpdated, _token);\n// Assert\nAssert.Single(results, advisory);\n@@ -144,7 +130,6 @@ public async Task DedupesIdenticalVulnerabilities()\nAssert.Equal(id, node.Package.Name);\nAssert.Equal(range, node.VulnerableVersionRange);\n- _cursorMock.Verify();\n_queryBuilderMock.Verify();\n_queryServiceMock.Verify();\n}\n@@ -172,13 +157,12 @@ public async Task ManyResultsShouldPage()\n// Act\nvar results = await _service.GetAdvisoriesSinceAsync(\n- _cursorMock.Object, _token);\n+ _lastUpdated, _token);\n// Assert\nAssert.Equal(_maxResultsPerQuery * 2, results.Count());\nAssert.Equal(_maxResultsPerQuery * 2 - 1, results.Last().DatabaseId);\n- _cursorMock.Verify();\n_queryBuilderMock.Verify();\n_queryServiceMock.Verify();\n}\n@@ -247,13 +231,12 @@ public async Task OneResultWithManyVulnerabilitiesShouldPage()\n// Act\nvar results = await _service.GetAdvisoriesSinceAsync(\n- _cursorMock.Object, _token);\n+ _lastUpdated, _token);\n// Assert\nAssert.Equal(_maxResultsPerQuery * 2, results.Single().Vulnerabilities.Edges.Count());\nAssert.Equal((_maxResultsPerQuery * 2 - 1).ToString(), results.Single().Vulnerabilities.Edges.Last().Cursor);\n- _cursorMock.Verify();\n_queryBuilderMock.Verify();\n_queryServiceMock.Verify();\n}\n@@ -281,7 +264,7 @@ private QueryResponse CreateResponseFromAdvisory(SecurityAdvisory advisory)\nprivate void SetupFirstQueryResult(QueryResponse response)\n=> SetupQueryResult(\n- x => x.CreateSecurityAdvisoriesQuery(_cursorValue, null),\n+ x => x.CreateSecurityAdvisoriesQuery(_lastUpdated, null),\nresponse);\nprivate void SetupAfterCursorQueryResponse(string afterCursor, QueryResponse response)\n"
}
]
| C# | Apache License 2.0 | nuget/nugetgallery | Add command to compare PackageVulnerabilities to GitHub API (#7706)
Add command to compare PackageVulnerabilities to GitHub API |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.