Skip to content
This repository was archived by the owner on Jul 30, 2024. It is now read-only.

Commit 68728f1

Browse files
authored
Merge pull request #263 from NuGet/dev
[ReleasePrep][2017.11.27] RI of dev into master
2 parents 68c5d3d + 92704bb commit 68728f1

65 files changed

Lines changed: 4755 additions & 22 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

NuGet.Jobs.sln

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26923.0
4+
VisualStudioVersion = 15.0.27121.1
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Jobs.Common", "src\NuGet.Jobs.Common\NuGet.Jobs.Common.csproj", "{4B4B1EFB-8F33-42E6-B79F-54E7F3293D31}"
77
EndProject
@@ -97,6 +97,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NuGet.Services.Validation.O
9797
EndProject
9898
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Validation.Common.Tests", "tests\Validation.Common.Tests\Validation.Common.Tests.csproj", "{F9690B52-3C92-42A0-B41F-1A6040C2D2EE}"
9999
EndProject
100+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Validation.PackageSigning.Core", "src\Validation.PackageSigning.Core\Validation.PackageSigning.Core.csproj", "{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10}"
101+
EndProject
102+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Validation.PackageSigning.ExtractAndValidateSignature", "src\Validation.PackageSigning.ExtractAndValidateSignature\Validation.PackageSigning.ExtractAndValidateSignature.csproj", "{DD043977-6BCD-475A-BEE2-8C34309EC622}"
103+
EndProject
104+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Validation.PackageSigning.ExtractAndValidateSignature.Tests", "tests\Validation.PackageSigning.ExtractAndValidateSignature.Tests\Validation.PackageSigning.ExtractAndValidateSignature.Tests.csproj", "{26435822-8938-48C9-96FD-0DCCF8F7CE00}"
105+
EndProject
100106
Global
101107
GlobalSection(SolutionConfigurationPlatforms) = preSolution
102108
Debug|Any CPU = Debug|Any CPU
@@ -241,6 +247,18 @@ Global
241247
{F9690B52-3C92-42A0-B41F-1A6040C2D2EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
242248
{F9690B52-3C92-42A0-B41F-1A6040C2D2EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
243249
{F9690B52-3C92-42A0-B41F-1A6040C2D2EE}.Release|Any CPU.Build.0 = Release|Any CPU
250+
{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
251+
{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10}.Debug|Any CPU.Build.0 = Debug|Any CPU
252+
{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10}.Release|Any CPU.ActiveCfg = Release|Any CPU
253+
{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10}.Release|Any CPU.Build.0 = Release|Any CPU
254+
{DD043977-6BCD-475A-BEE2-8C34309EC622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
255+
{DD043977-6BCD-475A-BEE2-8C34309EC622}.Debug|Any CPU.Build.0 = Debug|Any CPU
256+
{DD043977-6BCD-475A-BEE2-8C34309EC622}.Release|Any CPU.ActiveCfg = Release|Any CPU
257+
{DD043977-6BCD-475A-BEE2-8C34309EC622}.Release|Any CPU.Build.0 = Release|Any CPU
258+
{26435822-8938-48C9-96FD-0DCCF8F7CE00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
259+
{26435822-8938-48C9-96FD-0DCCF8F7CE00}.Debug|Any CPU.Build.0 = Debug|Any CPU
260+
{26435822-8938-48C9-96FD-0DCCF8F7CE00}.Release|Any CPU.ActiveCfg = Release|Any CPU
261+
{26435822-8938-48C9-96FD-0DCCF8F7CE00}.Release|Any CPU.Build.0 = Release|Any CPU
244262
EndGlobalSection
245263
GlobalSection(SolutionProperties) = preSolution
246264
HideSolutionNode = FALSE
@@ -279,6 +297,9 @@ Global
279297
{0C887292-C5AB-4107-946C-A53B18A38D22} = {6A776396-02B1-475D-A104-26940ADB04AB}
280298
{A3B0B15D-22D9-4F1F-94C4-B24B28ECF632} = {6A776396-02B1-475D-A104-26940ADB04AB}
281299
{F9690B52-3C92-42A0-B41F-1A6040C2D2EE} = {6A776396-02B1-475D-A104-26940ADB04AB}
300+
{91C060DA-736F-4DA9-A57F-CB3AC0E6CB10} = {678D7B14-F8BC-4193-99AF-2EE8AA390A02}
301+
{DD043977-6BCD-475A-BEE2-8C34309EC622} = {678D7B14-F8BC-4193-99AF-2EE8AA390A02}
302+
{26435822-8938-48C9-96FD-0DCCF8F7CE00} = {6A776396-02B1-475D-A104-26940ADB04AB}
282303
EndGlobalSection
283304
GlobalSection(ExtensibilityGlobals) = postSolution
284305
SolutionGuid = {284A7AC3-FB43-4F1F-9C9C-2AF0E1F46C2B}

build.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ Invoke-BuildStep 'Set version metadata in AssemblyInfo.cs' { `
102102
"$PSScriptRoot\src\CopyAzureContainer\Properties\AssemblyInfo.g.cs",
103103
"$PSScriptRoot\src\NuGetCDNRedirect\Properties\AssemblyInfo.g.cs",
104104
"$PSScriptRoot\src\NuGet.Services.Validation.Orchestrator\Properties\AssemblyInfo.g.cs",
105-
"$PSScriptRoot\src\Stats.CollectAzureChinaCDNLogs\Properties\AssemblyInfo.g.cs"
105+
"$PSScriptRoot\src\Stats.CollectAzureChinaCDNLogs\Properties\AssemblyInfo.g.cs",
106+
"$PSScriptRoot\src\Validation.PackageSigning.ExtractAndValidateSignature\Properties\AssemblyInfo.g.cs"
106107

107108

108109
$versionMetadata | ForEach-Object {
@@ -150,7 +151,8 @@ Invoke-BuildStep 'Creating artifacts' {
150151
"src/CopyAzureContainer/CopyAzureContainer.csproj", `
151152
"src/NuGetCDNRedirect/NuGetCDNRedirect.csproj", `
152153
"src/NuGet.Services.Validation.Orchestrator/NuGet.Services.Validation.Orchestrator.csproj", `
153-
"src/Stats.CollectAzureChinaCDNLogs/Stats.CollectAzureChinaCDNLogs.csproj"
154+
"src/Stats.CollectAzureChinaCDNLogs/Stats.CollectAzureChinaCDNLogs.csproj", `
155+
"src/Validation.PackageSigning.ExtractAndValidateSignature/Validation.PackageSigning.ExtractAndValidateSignature.csproj"
154156

155157
Foreach ($Project in $Projects) {
156158
New-Package (Join-Path $PSScriptRoot "$Project") -Configuration $Configuration -BuildNumber $BuildNumber -Version $SemanticVersion -Branch $Branch -MSBuildVersion "$msBuildVersion"

src/LoadTests/DownloadPackageApiV2.webtest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<WebTest Name="DownloadPackageApiV2" Id="f0c6d88d-bc9d-4256-b1f0-c70866d59e2e" Owner="" Priority="2147483647" Enabled="True" CssProjectStructure="" CssIteration="" Timeout="0" WorkItemIds="" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" Description="" CredentialUserName="" CredentialPassword="" PreAuthenticate="True" Proxy="default" StopOnError="False" RecordedResultFile="WebTest1.7ffeba66-45d9-4625-9ca6-ca2b95c6c76a.rec.webtestresult" ResultsLocale="">
33
<Items>
4-
<Request Method="GET" Guid="ea523c76-15f8-4fae-96cd-ac46a2a3fe40" Version="1.1" Url="https://dev.nugettest.org/api/v2/package/Newtonsoft.Json/6.0.1-beta1" ThinkTime="25" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="https://f168.wpc.azureedge.net/80F168/nugetdevlegacy.blob.core.windows.net/packages/newtonsoft.json.6.0.1-beta1.nupkg" ReportingName="Download package through v2 API" IgnoreHttpStatusCode="False" />
4+
<Request Method="GET" Guid="ea523c76-15f8-4fae-96cd-ac46a2a3fe40" Version="1.1" Url="https://dev.nugettest.org/api/v2/package/Newtonsoft.Json/6.0.1-beta1" ThinkTime="25" Timeout="300" ParseDependentRequests="True" FollowRedirects="True" RecordResult="True" Cache="False" ResponseTimeGoal="0" Encoding="utf-8" ExpectedHttpStatusCode="0" ExpectedResponseUrl="https://az640577.vo.msecnd.net/packages/newtonsoft.json.6.0.1-beta1.nupkg" ReportingName="Download package through v2 API" IgnoreHttpStatusCode="False" />
55
</Items>
66
<ValidationRules>
77
<ValidationRule Classname="Microsoft.VisualStudio.TestTools.WebTesting.Rules.ValidateResponseUrl, Microsoft.VisualStudio.QualityTools.WebTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" DisplayName="Response URL" Description="Validates that the response URL after redirects are followed is the same as the recorded response URL. QueryString parameters are ignored." Level="Low" ExectuionOrder="BeforeDependents" />

src/NuGet.Services.Validation.Orchestrator/App.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
55
</configSections>
66
<startup>
7-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
7+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
88
</startup>
99
<entityFramework codeConfigurationType="NuGetGallery.EntitiesConfiguration, NuGetGallery.Core">
1010
</entityFramework>
11-
</configuration>
11+
</configuration>

src/NuGet.Services.Validation.Orchestrator/Error.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,12 @@ public static class Error
1414
public static EventId VcsValidationUnexpectedAuditFound = new EventId(5, "VCS validation unexpected audit found");
1515
public static EventId OrchestratorOnMessageException = new EventId(6, "Failed to process orchestrator message");
1616
public static EventId UpdatingPackageDbStatusFailed = new EventId(7, "Failed to update package status in DB");
17+
18+
public static EventId PackageSigningValidationAlreadyStarted = new EventId(100, "Package Signing validation already started");
19+
20+
public static EventId PackageCertificateValidationAlreadyFailed = new EventId(200, "Package Signing state is already invalid");
21+
public static EventId PackageCertificateValidationInvalidSignatureState = new EventId(201, "Package Signature has invalid Status");
22+
23+
// NOTE: EventIds 1000-1999 are reserved for the "Validation.PackageSigning.Core" project.
1724
}
1825
}

src/NuGet.Services.Validation.Orchestrator/Job.cs

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@
1616
using NuGet.Jobs;
1717
using NuGet.Jobs.Configuration;
1818
using NuGet.Jobs.Validation.Common;
19+
using NuGet.Jobs.Validation.PackageSigning.Messages;
20+
using NuGet.Jobs.Validation.PackageSigning.Storage;
1921
using NuGet.Services.Configuration;
2022
using NuGet.Services.KeyVault;
2123
using NuGet.Services.ServiceBus;
24+
using NuGet.Services.Validation.PackageCertificates;
25+
using NuGet.Services.Validation.PackageSigning;
2226
using NuGet.Services.Validation.Vcs;
2327

2428
namespace NuGet.Services.Validation.Orchestrator
@@ -30,12 +34,17 @@ public class Job : JobBase
3034

3135
private const string ConfigurationSectionName = "Configuration";
3236
private const string VcsSectionName = "Vcs";
37+
private const string PackageSigningSectionName = "PackageSigning";
38+
private const string PackageCertificatesSectionName = "PackageCertificates";
3339
private const string RunnerConfigurationSectionName = "RunnerConfiguration";
3440
private const string GalleryDbConfigurationSectionName = "GalleryDb";
3541
private const string ValidationDbConfigurationSectionName = "ValidationDb";
3642
private const string ServiceBusConfigurationSectionName = "ServiceBus";
3743

3844
private const string VcsBindingKey = VcsSectionName;
45+
private const string PackageVerificationTopicClientBindingKey = "PackageVerificationTopicClient";
46+
private const string PackageSigningBindingKey = PackageSigningSectionName;
47+
private const string PackageCertificatesBindingKey = PackageCertificatesSectionName;
3948
private const string ValidationStorageBindingKey = "ValidationStorage";
4049
private const string OrchestratorBindingKey = "Orchestrator";
4150

@@ -123,6 +132,8 @@ private void ConfigureJobServices(IServiceCollection services, IConfigurationRoo
123132
{
124133
services.Configure<ValidationConfiguration>(configurationRoot.GetSection(ConfigurationSectionName));
125134
services.Configure<VcsConfiguration>(configurationRoot.GetSection(VcsSectionName));
135+
services.Configure<PackageSigningConfiguration>(configurationRoot.GetSection(PackageSigningSectionName));
136+
services.Configure<PackageCertificatesConfiguration>(configurationRoot.GetSection(PackageCertificatesSectionName));
126137
services.Configure<OrchestrationRunnerConfiguration>(configurationRoot.GetSection(RunnerConfigurationSectionName));
127138
services.Configure<GalleryDbConfiguration>(configurationRoot.GetSection(GalleryDbConfigurationSectionName));
128139
services.Configure<ValidationDbConfiguration>(configurationRoot.GetSection(ValidationDbConfigurationSectionName));
@@ -138,6 +149,8 @@ private void ConfigureJobServices(IServiceCollection services, IConfigurationRoo
138149
services.AddScoped(serviceProvider =>
139150
new ValidationEntitiesContext(
140151
serviceProvider.GetRequiredService<IOptionsSnapshot<ValidationDbConfiguration>>().Value.ConnectionString));
152+
services.AddScoped<IValidationEntitiesContext>(serviceProvider =>
153+
serviceProvider.GetRequiredService<ValidationEntitiesContext>());
141154
services.AddScoped<IValidationStorageService, ValidationStorageService>();
142155
services.Add(ServiceDescriptor.Transient(typeof(NuGetGallery.IEntityRepository<>), typeof(NuGetGallery.EntityRepository<>)));
143156
services.AddTransient<NuGetGallery.ICorePackageService, NuGetGallery.CorePackageService>();
@@ -159,6 +172,10 @@ private void ConfigureJobServices(IServiceCollection services, IConfigurationRoo
159172
services.AddTransient<IBrokeredMessageSerializer<PackageValidationMessageData>, PackageValidationMessageDataSerializationAdapter>();
160173
services.AddTransient<IPackageCriteriaEvaluator, PackageCriteriaEvaluator>();
161174
services.AddTransient<VcsValidator>();
175+
services.AddTransient<IPackageSignatureVerificationEnqueuer, PackageSignatureVerificationEnqueuer>();
176+
services.AddTransient<IBrokeredMessageSerializer<SignatureValidationMessage>, SignatureValidationMessageSerializer>();
177+
services.AddTransient<IValidatorStateService, ValidatorStateService>();
178+
services.AddTransient<PackageSigningValidator>();
162179
}
163180

164181
private static IServiceProvider CreateProvider(IServiceCollection services)
@@ -177,6 +194,14 @@ private static IServiceProvider CreateProvider(IServiceCollection services)
177194
return cloudStorageAccount;
178195
})
179196
.Keyed<CloudStorageAccount>(VcsBindingKey);
197+
containerBuilder
198+
.Register(c =>
199+
{
200+
var serviceBusConfiguration = c.Resolve<IOptionsSnapshot<ServiceBusConfiguration>>();
201+
var topicClient = new TopicClientWrapper(serviceBusConfiguration.Value.ConnectionString, serviceBusConfiguration.Value.TopicPath);
202+
return topicClient;
203+
})
204+
.Keyed<TopicClientWrapper>(PackageVerificationTopicClientBindingKey);
180205

181206
containerBuilder
182207
.RegisterType<PackageValidationService>()
@@ -194,6 +219,17 @@ private static IServiceProvider CreateProvider(IServiceCollection services)
194219
(pi, ctx) => ctx.Resolve<IOptionsSnapshot<VcsConfiguration>>().Value.ContainerName))
195220
.As<IPackageValidationAuditor>();
196221

222+
containerBuilder
223+
.RegisterType<PackageSignatureVerificationEnqueuer>()
224+
.WithParameter(new ResolvedParameter(
225+
(pi, ctx) => pi.ParameterType == typeof(ITopicClient),
226+
(pi, ctx) => ctx.ResolveKeyed<TopicClientWrapper>(PackageVerificationTopicClientBindingKey)))
227+
.WithParameter(new ResolvedParameter(
228+
(pi, ctx) => pi.ParameterType == typeof(IBrokeredMessageSerializer<SignatureValidationMessage>),
229+
(pi, ctx) => ctx.Resolve<SignatureValidationMessageSerializer>()
230+
))
231+
.As<IPackageSignatureVerificationEnqueuer>();
232+
197233
containerBuilder
198234
.Register(c =>
199235
{
@@ -235,9 +271,79 @@ private static IServiceProvider CreateProvider(IServiceCollection services)
235271
IMessageHandler<PackageValidationMessageData>>(
236272
OrchestratorBindingKey);
237273

274+
ConfigurePackageSigningValidator(containerBuilder);
275+
ConfigurePackageCertificatesValidator(containerBuilder);
276+
238277
return new AutofacServiceProvider(containerBuilder.Build());
239278
}
240279

280+
private static void ConfigurePackageSigningValidator(ContainerBuilder builder)
281+
{
282+
// Configure the validator state service for the package certificates validator.
283+
builder
284+
.RegisterType<ValidatorStateService>()
285+
.WithParameter(
286+
(pi, ctx) => pi.ParameterType == typeof(Type),
287+
(pi, ctx) => typeof(PackageSigningValidator))
288+
.Keyed<IValidatorStateService>(PackageSigningBindingKey);
289+
290+
// Configure the package signature verification enqueuer.
291+
builder
292+
.Register(c =>
293+
{
294+
var configuration = c.Resolve<IOptionsSnapshot<PackageSigningConfiguration>>().Value.ServiceBus;
295+
296+
return new TopicClientWrapper(configuration.ConnectionString, configuration.TopicPath);
297+
})
298+
.Keyed<ITopicClient>(PackageSigningBindingKey);
299+
300+
builder
301+
.RegisterType<PackageSignatureVerificationEnqueuer>()
302+
.WithKeyedParameter(typeof(ITopicClient), PackageSigningBindingKey)
303+
.As<IPackageSignatureVerificationEnqueuer>();
304+
305+
// Configure the package signing validator.
306+
builder
307+
.RegisterType<PackageSigningValidator>()
308+
.WithKeyedParameter(typeof(IValidatorStateService), PackageSigningBindingKey)
309+
.As<PackageSigningValidator>();
310+
}
311+
312+
private static void ConfigurePackageCertificatesValidator(ContainerBuilder builder)
313+
{
314+
// Configure the validator state service for the package certificates validator.
315+
builder
316+
.RegisterType<ValidatorStateService>()
317+
.WithParameter(
318+
(pi, ctx) => pi.ParameterType == typeof(Type),
319+
(pi, ctx) => typeof(PackageCertificatesValidator))
320+
.Keyed<IValidatorStateService>(PackageCertificatesBindingKey);
321+
322+
// Configure the certificate verification enqueuer.
323+
builder
324+
.Register(c =>
325+
{
326+
var configuration = c.Resolve<IOptionsSnapshot<PackageCertificatesConfiguration>>().Value.ServiceBus;
327+
328+
return new TopicClientWrapper(configuration.ConnectionString, configuration.TopicPath);
329+
})
330+
.Keyed<ITopicClient>(PackageCertificatesBindingKey);
331+
332+
builder
333+
.RegisterType<CertificateVerificationEnqueuer>()
334+
.WithKeyedParameter(typeof(ITopicClient), PackageCertificatesBindingKey)
335+
.As<ICertificateVerificationEnqueuer>();
336+
337+
// Configure the certificates validator.
338+
builder
339+
.RegisterType<PackageCertificatesValidator>()
340+
.WithKeyedParameter(typeof(IValidatorStateService), PackageCertificatesBindingKey)
341+
.WithParameter(
342+
(pi, ctx) => pi.ParameterType == typeof(TimeSpan?),
343+
(pi, ctx) => ctx.Resolve<IOptionsSnapshot<PackageCertificatesConfiguration>>().Value.CertificateRevalidationThreshold)
344+
.As<PackageCertificatesValidator>();
345+
}
346+
241347
private T GetRequiredService<T>()
242348
{
243349
return _serviceProvider.GetRequiredService<T>();

0 commit comments

Comments
 (0)