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

Commit 4f21c81

Browse files
authored
Merge pull request #273 from NuGet/dev
[ReleasePrep][2017.12.04] RI of dev into master
2 parents 68728f1 + e4b0397 commit 4f21c81

23 files changed

Lines changed: 290 additions & 259 deletions

src/NuGet.Jobs.Common/JobRunner.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Diagnostics;
88
using System.Linq;
99
using System.Net;
10-
using System.Threading;
1110
using System.Threading.Tasks;
1211
using Microsoft.Extensions.Logging;
1312
using NuGet.Services.Logging;
@@ -163,7 +162,7 @@ private static async Task JobLoop(JobBase job, bool runContinuously, int sleepDu
163162
// Wait for <sleepDuration> milliSeconds and run the job again
164163
_logger.LogInformation("Will sleep for {SleepDuration} before the next Job run", PrettyPrintTime(sleepDuration));
165164

166-
Thread.Sleep(sleepDuration);
165+
await Task.Delay(sleepDuration);
167166
}
168167
}
169168
}

src/NuGet.Services.Validation.Orchestrator/NuGet.Services.Validation.Orchestrator.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,22 +125,22 @@
125125
<Version>1.1.2</Version>
126126
</PackageReference>
127127
<PackageReference Include="NuGet.Services.Configuration">
128-
<Version>2.4.3</Version>
128+
<Version>2.5.0</Version>
129129
</PackageReference>
130130
<PackageReference Include="NuGet.Services.Contracts">
131-
<Version>2.4.3</Version>
131+
<Version>2.5.0</Version>
132132
</PackageReference>
133133
<PackageReference Include="NuGet.Services.KeyVault">
134-
<Version>2.4.3</Version>
134+
<Version>2.5.0</Version>
135135
</PackageReference>
136136
<PackageReference Include="NuGet.Services.Logging">
137-
<Version>2.4.3</Version>
137+
<Version>2.5.0</Version>
138138
</PackageReference>
139139
<PackageReference Include="NuGet.Services.ServiceBus">
140-
<Version>2.4.3</Version>
140+
<Version>2.5.0</Version>
141141
</PackageReference>
142142
<PackageReference Include="NuGet.Services.Validation">
143-
<Version>2.4.3</Version>
143+
<Version>2.5.0</Version>
144144
</PackageReference>
145145
<PackageReference Include="NuGet.Versioning">
146146
<Version>4.3.0</Version>

src/NuGet.Services.Validation.Orchestrator/PackageCertificates/CertificateVerificationEnqueuer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CertificateVerificationEnqueuer(ITopicClient topicClient)
1818
_topicClient = topicClient ?? throw new ArgumentNullException(nameof(topicClient));
1919
}
2020

21-
public async Task EnqueueVerificationAsync(IValidationRequest request, Certificate certificate)
21+
public async Task EnqueueVerificationAsync(IValidationRequest request, EndCertificate certificate)
2222
{
2323
var message = new CertificateValidationMessage(certificate.Key, request.ValidationId);
2424
var brokeredMessage = _serializer.Serialize(message);

src/NuGet.Services.Validation.Orchestrator/PackageCertificates/ICertificateVerificationEnqueuer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public interface ICertificateVerificationEnqueuer
1212
{
1313
/// <summary>
1414
/// Kicks off the certificate verification process for the given request. Verification will begin when the
15-
/// <see cref="ValidationEntitiesContext"/> has a <see cref="CertificateValidation"/> that matches the
15+
/// <see cref="ValidationEntitiesContext"/> has a <see cref="EndCertificateValidation"/> that matches the
1616
/// <see cref="IValidationRequest"/>'s validationId. Once verification completes, the <see cref="CertificateValidation"/>'s
1717
/// State will be updated to a non-NULL value.
1818
/// </summary>
1919
/// <param name="request">The request that details the package to be verified.</param>
2020
/// <param name="certificate">The certificate to verify.</param>
2121
/// <returns>A task that will complete when the verification process has been queued.</returns>
22-
Task EnqueueVerificationAsync(IValidationRequest request, Certificate certificate);
22+
Task EnqueueVerificationAsync(IValidationRequest request, EndCertificate certificate);
2323
}
2424
}

src/NuGet.Services.Validation.Orchestrator/PackageCertificates/PackageCertificatesValidator.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ private Task<List<PackageSignature>> FindSignaturesAsync(IValidationRequest requ
224224
.PackageSignatures
225225
.Where(s => s.PackageKey == request.PackageKey)
226226
.Include(s => s.TrustedTimestamps)
227-
.Include(s => s.Certificate)
227+
.Include(s => s.EndCertificate)
228228
.ToListAsync();
229229
}
230230

@@ -249,13 +249,13 @@ private void PromoteSignatures(IEnumerable<PackageSignature> signatures)
249249
/// <returns>True if the signature should be "Valid", false if it should be "InGracePeriod".</returns>
250250
private bool IsValidSignatureOutOfGracePeriod(PackageSignature signature)
251251
{
252-
var certificate = signature.Certificate;
252+
var certificate = signature.EndCertificate;
253253

254254
// A signature can be valid even if its certificate is revoked as long as the certificate
255255
// revocation date begins after the signature was created. The validation pipeline does
256256
// not revalidate revoked certificates, thus, a valid package signature with a revoked
257257
// certificate should be "Valid" regardless of the certificate's status update time.
258-
if (certificate.Status == CertificateStatus.Revoked)
258+
if (certificate.Status == EndCertificateStatus.Revoked)
259259
{
260260
return true;
261261
}
@@ -284,14 +284,14 @@ private IEnumerable<PackageSignature> FindSignaturesToInvalidate(IEnumerable<Pac
284284
{
285285
// Revalidation requests do NOT revalidate certificates that are known to be revoked. Thus,
286286
// certificates that were revoked before the package was signed ALWAYS invalidate the signature.
287-
if (s.Certificate.Status == CertificateStatus.Revoked)
287+
if (s.EndCertificate.Status == EndCertificateStatus.Revoked)
288288
{
289-
return s.TrustedTimestamps.Any(t => s.Certificate.RevocationTime.Value <= t.Value);
289+
return s.TrustedTimestamps.Any(t => s.EndCertificate.RevocationTime.Value <= t.Value);
290290
}
291291

292292
// Revalidation requests will revalidate invalid certificates. Therefore, invalid certificates
293293
// should invalidate the signature only if this is not a revalidation request.
294-
if (s.Certificate.Status == CertificateStatus.Invalid)
294+
if (s.EndCertificate.Status == EndCertificateStatus.Invalid)
295295
{
296296
return !isRevalidationRequest;
297297
}
@@ -330,14 +330,14 @@ private void InvalidatePackageSignatures(IValidationRequest request, PackageSign
330330
/// <param name="signatures">The signatures used to sign the package requested by the validation request.</param>
331331
/// <param name="isRevalidationRequest">Whether this package has already been validated.</param>
332332
/// <returns>The certificates used to sign the package that should be validated.</returns>
333-
private IEnumerable<Certificate> FindCertificatesToValidateAsync(IEnumerable<PackageSignature> signatures, bool isRevalidationRequest)
333+
private IEnumerable<EndCertificate> FindCertificatesToValidateAsync(IEnumerable<PackageSignature> signatures, bool isRevalidationRequest)
334334
{
335335
// Get all the certificates used to sign the signatures. Note that revoked certificates
336336
// should NEVER be revalidated as Certificate Authorities may, under certain conditions,
337337
// drop a revoked certificate's revocation information. Revalidating such a revoked
338338
// certificate would cause the certificate to be marked as "Good" when in reality it
339339
// should remain revoked.
340-
var certificates = signatures.Select(s => s.Certificate).Where(c => c.Status != CertificateStatus.Revoked);
340+
var certificates = signatures.Select(s => s.EndCertificate).Where(c => c.Status != EndCertificateStatus.Revoked);
341341

342342
// Skip certificates that have been validated recently unless this is a revalidation request.
343343
if (!isRevalidationRequest)
@@ -353,7 +353,7 @@ private IEnumerable<Certificate> FindCertificatesToValidateAsync(IEnumerable<Pac
353353
/// </summary>
354354
/// <param name="certificate">The certificate that may be revalidated.</param>
355355
/// <returns>Whether the certificate should be revalidated.</returns>
356-
private bool ShouldValidateCertificate(Certificate certificate)
356+
private bool ShouldValidateCertificate(EndCertificate certificate)
357357
{
358358
// Validate the certificate only if it has never been validated before, or, if
359359
// its last validation time is past the maximum revalidation threshold.
@@ -368,24 +368,24 @@ private bool ShouldValidateCertificate(Certificate certificate)
368368
}
369369

370370
/// <summary>
371-
/// Enqueue certificate verifications and add <see cref="CertificateValidation"/> entities
371+
/// Enqueue certificate verifications and add <see cref="EndCertificateValidation"/> entities
372372
/// for each validation. Note that this does NOT save the entity context!
373373
/// </summary>
374374
/// <param name="request">The package validation request.</param>
375375
/// <param name="certificates">The certificates that should be verified.</param>
376376
/// <returns>A task that completes when all certificate verifications have been enqueued.</returns>
377-
private Task StartCertificateValidationsAsync(IValidationRequest request, IEnumerable<Certificate> certificates)
377+
private Task StartCertificateValidationsAsync(IValidationRequest request, IEnumerable<EndCertificate> certificates)
378378
{
379379
var startCertificateVerificationTasks = new List<Task>();
380380

381381
foreach (var certificate in certificates)
382382
{
383383
startCertificateVerificationTasks.Add(_certificateVerificationEnqueuer.EnqueueVerificationAsync(request, certificate));
384384

385-
_validationContext.CertificateValidations.Add(new CertificateValidation
385+
_validationContext.CertificateValidations.Add(new EndCertificateValidation
386386
{
387387
ValidationId = request.ValidationId,
388-
Certificate = certificate,
388+
EndCertificate = certificate,
389389
Status = null,
390390
});
391391
}

src/NuGet.Services.Validation.Orchestrator/Vcs/VcsValidator.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ public async Task<ValidationStatus> GetStatusAsync(IValidationRequest request)
7777
case ValidationEvent.ValidatorException:
7878
case ValidationEvent.BeforeVirusScanRequest:
7979
case ValidationEvent.VirusScanRequestSent:
80+
case ValidationEvent.VirusScanRequestFailed:
8081
return ValidationStatus.Incomplete;
8182
case ValidationEvent.PackageClean:
8283
return ValidationStatus.Succeeded;

src/Validation.Common/Validation.Common.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@
105105
<Reference Include="NuGet.ApplicationInsights.Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
106106
<HintPath>..\..\packages\NuGet.ApplicationInsights.Owin.4.1.0\lib\net452\NuGet.ApplicationInsights.Owin.dll</HintPath>
107107
</Reference>
108-
<Reference Include="NuGet.Services.KeyVault, Version=2.4.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109-
<HintPath>..\..\packages\NuGet.Services.KeyVault.2.4.3\lib\net45\NuGet.Services.KeyVault.dll</HintPath>
108+
<Reference Include="NuGet.Services.KeyVault, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
109+
<HintPath>..\..\packages\NuGet.Services.KeyVault.2.5.0\lib\net45\NuGet.Services.KeyVault.dll</HintPath>
110110
</Reference>
111-
<Reference Include="NuGet.Services.Logging, Version=2.4.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
112-
<HintPath>..\..\packages\NuGet.Services.Logging.2.4.3\lib\net452\NuGet.Services.Logging.dll</HintPath>
111+
<Reference Include="NuGet.Services.Logging, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
112+
<HintPath>..\..\packages\NuGet.Services.Logging.2.5.0\lib\net452\NuGet.Services.Logging.dll</HintPath>
113113
</Reference>
114114
<Reference Include="NuGet.Services.VirusScanning.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115115
<HintPath>..\..\packages\NuGet.Services.VirusScanning.Vcs.3.2.0\lib\net452\NuGet.Services.VirusScanning.Core.dll</HintPath>

src/Validation.Common/packages.config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.1" targetFramework="net452" />
2323
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net452" />
2424
<package id="NuGet.ApplicationInsights.Owin" version="4.1.0" targetFramework="net452" />
25-
<package id="NuGet.Services.KeyVault" version="2.4.3" targetFramework="net452" />
26-
<package id="NuGet.Services.Logging" version="2.4.3" targetFramework="net452" />
25+
<package id="NuGet.Services.KeyVault" version="2.5.0" targetFramework="net452" />
26+
<package id="NuGet.Services.Logging" version="2.5.0" targetFramework="net452" />
2727
<package id="NuGet.Services.VirusScanning.Vcs" version="3.2.0" targetFramework="net452" />
2828
<package id="Owin" version="1.0" targetFramework="net452" />
2929
<package id="Serilog" version="2.0.0" targetFramework="net452" />

src/Validation.PackageSigning.Core/Error.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public static class Error
99
{
1010
public static EventId ValidatorStateServiceFailedToAddStatus = new EventId(1000, "Failed to add validator's status");
1111
public static EventId ValidatorStateServiceFailedToUpdateStatus = new EventId(1001, "Failed to update validator's status");
12+
13+
public static EventId ValidateSignatureFailedToDownloadPackageStatus = new EventId(1100, "Failed to download package");
1214
}
1315
}

src/Validation.PackageSigning.Core/Validation.PackageSigning.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
</ItemGroup>
3939
<ItemGroup>
4040
<PackageReference Include="NuGet.Services.ServiceBus">
41-
<Version>2.4.3</Version>
41+
<Version>2.5.0</Version>
4242
</PackageReference>
4343
<PackageReference Include="NuGet.Services.Validation">
44-
<Version>2.4.3</Version>
44+
<Version>2.5.0</Version>
4545
</PackageReference>
4646
</ItemGroup>
4747
<ItemGroup>

0 commit comments

Comments
 (0)