Skip to content

Commit 0312a02

Browse files
authored
Merge pull request #10782 from NuGet/dev
[ReleasePrep][2026.04.14] RI dev to main
2 parents 0e80f87 + 37387a2 commit 0312a02

6 files changed

Lines changed: 54 additions & 15 deletions

File tree

build.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ Invoke-BuildStep 'Creating job packages from jobs solution' {
157157
"src\Validation.PackageSigning.ProcessSignature\Validation.PackageSigning.ProcessSignature.nuspec",
158158
"src\Validation.PackageSigning.RevalidateCertificate\Validation.PackageSigning.RevalidateCertificate.nuspec",
159159
"src\Validation.PackageSigning.ValidateCertificate\Validation.PackageSigning.ValidateCertificate.nuspec",
160-
"src\Validation.Symbols\Validation.Symbols.Job.nuspec"
160+
"src\Validation.Symbols\Validation.Symbols.Job.nuspec",
161+
"src\UpdateBlobProperties\UpdateBlobProperties.nuspec"
161162
$JobsNuspecProjects | ForEach-Object {
162163
New-Package (Join-Path $PSScriptRoot $_) -Configuration $Configuration -BuildNumber $BuildNumber -Version $JobsPackageVersion -Branch $Branch
163164
}

src/GitHubVulnerabilities2v3/Extensions/BlobStorageVulnerabilityWriter.cs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ private async Task RunUpdate(string stringContentOutput, string currentTime)
308308
var baseFolder = pathParts[pathParts.Length - 2];
309309

310310
// Start special case block
311-
var currentBaseContentUri = _primaryStorage.ResolveUri(Path.Combine(baseFolder, _configuration.BaseFileName));
311+
var currentBaseContentUri = _primaryStorage.ResolveUri(UrlPathCombine(baseFolder, _configuration.BaseFileName));
312312
var currentBaseContent = await _primaryStorage.LoadString(currentBaseContentUri, CancellationToken.None);
313313
var baseContentObject = JsonConvert.DeserializeObject<Dictionary<string, List<Advisory>>>(currentBaseContent);
314314

@@ -334,7 +334,7 @@ private async Task RunUpdate(string stringContentOutput, string currentTime)
334334

335335
_logger.LogInformation("Writing update to files");
336336
var primaryIndexContent = new StringStorageContent(JsonConvert.SerializeObject(indexEntries), contentType: JsonContentType, cacheControl: _configuration.IndexCacheControlHeader);
337-
var updateStorageUri = _primaryStorage.ResolveUri(Path.Combine(baseFolder, currentTime, _configuration.UpdateFileName));
337+
var updateStorageUri = _primaryStorage.ResolveUri(UrlPathCombine(baseFolder, currentTime, _configuration.UpdateFileName));
338338
var updateContent = new StringStorageContent(stringContentOutput, contentType: JsonContentType, cacheControl: _configuration.UpdateCacheControlHeader);
339339

340340
await _primaryStorage.Save(updateStorageUri, updateContent, overwrite: true, CancellationToken.None);
@@ -358,7 +358,7 @@ private async Task RunUpdate(string stringContentOutput, string currentTime)
358358
}
359359
}
360360
var secondaryIndexContent = new StringStorageContent(JsonConvert.SerializeObject(indexEntries), contentType: JsonContentType, cacheControl: _configuration.IndexCacheControlHeader);
361-
updateStorageUri = _secondaryStorage.ResolveUri(Path.Combine(baseFolder, currentTime, _configuration.UpdateFileName));
361+
updateStorageUri = _secondaryStorage.ResolveUri(UrlPathCombine(baseFolder, currentTime, _configuration.UpdateFileName));
362362
var secondaryIndexStorageUri = _secondaryStorage.ResolveUri(_configuration.IndexFileName);
363363

364364
await _secondaryStorage.Save(updateStorageUri, updateContent, overwrite: true, CancellationToken.None);
@@ -427,8 +427,8 @@ private async Task RunRegenerate(string stringContentOutput, string currentTime)
427427
var indexContent = new StringStorageContent(JsonConvert.SerializeObject(indexEntries), contentType: JsonContentType, cacheControl: _configuration.IndexCacheControlHeader);
428428

429429
var primaryIndexStorageUri = _primaryStorage.ResolveUri(_configuration.IndexFileName);
430-
var baseStorageUri = _primaryStorage.ResolveUri(Path.Combine(currentTime, _configuration.BaseFileName));
431-
var updateStorageUri = _primaryStorage.ResolveUri(Path.Combine(currentTime, currentTime, _configuration.UpdateFileName));
430+
var baseStorageUri = _primaryStorage.ResolveUri(UrlPathCombine(currentTime, _configuration.BaseFileName));
431+
var updateStorageUri = _primaryStorage.ResolveUri(UrlPathCombine(currentTime, currentTime, _configuration.UpdateFileName));
432432

433433
await _primaryStorage.Save(baseStorageUri, baseContent, overwrite: true, CancellationToken.None);
434434
await _primaryStorage.Save(updateStorageUri, updateContent, overwrite: true, CancellationToken.None);
@@ -442,8 +442,8 @@ private async Task RunRegenerate(string stringContentOutput, string currentTime)
442442

443443
_logger.LogInformation("Writing regenerated files to secondary storage");
444444
var secondaryIndexStorageUri = _secondaryStorage.ResolveUri(_configuration.IndexFileName);
445-
var secondaryBaseStorageUri = _secondaryStorage.ResolveUri(Path.Combine(currentTime, _configuration.BaseFileName));
446-
var secondaryUpdateStorageUri = _secondaryStorage.ResolveUri(Path.Combine(currentTime, currentTime, _configuration.UpdateFileName));
445+
var secondaryBaseStorageUri = _secondaryStorage.ResolveUri(UrlPathCombine(currentTime, _configuration.BaseFileName));
446+
var secondaryUpdateStorageUri = _secondaryStorage.ResolveUri(UrlPathCombine(currentTime, currentTime, _configuration.UpdateFileName));
447447

448448
await _secondaryStorage.Save(secondaryBaseStorageUri, baseContent, overwrite: true, CancellationToken.None);
449449
await _secondaryStorage.Save(secondaryUpdateStorageUri, updateContent, overwrite: true, CancellationToken.None);
@@ -454,5 +454,27 @@ private async Task RunRegenerate(string stringContentOutput, string currentTime)
454454
_cursor.Value = _firstVulnWrittenTimestamp;
455455
await _cursor.Save(CancellationToken.None);
456456
}
457+
458+
private static string UrlPathCombine(params string[] segments)
459+
{
460+
StringBuilder sb = new StringBuilder();
461+
foreach (var segment in segments)
462+
{
463+
if (!string.IsNullOrEmpty(segment))
464+
{
465+
if (segment.Contains("/") || segment.Contains("\\"))
466+
{
467+
throw new ArgumentException($"Path segments must not contain '/' or '\\' characters (segment: {segment}).", nameof(segments));
468+
}
469+
470+
if (sb.Length > 0)
471+
{
472+
sb.Append('/');
473+
}
474+
sb.Append(segment);
475+
}
476+
}
477+
return sb.ToString();
478+
}
457479
}
458480
}

src/UpdateBlobProperties/BlobInfoOfPackageVersionIndexInFlatContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override string GetBlobName(PackageInfo packageInfo)
2626

2727
if (string.IsNullOrWhiteSpace(packageInfo.Id))
2828
{
29-
throw new ArgumentException($"Invalid package Id with null or whitespace. Package Key: {packageInfo.Key}.");
29+
throw new ArgumentException($"Invalid package Id with null or whitespace. Package Registration Key: {packageInfo.Key}.");
3030
}
3131

3232
return $"/{packageInfo.Id.ToLowerInvariant()}/index.json";

src/UpdateBlobProperties/Collector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async IAsyncEnumerable<IList<PackageInfo>> GetPagesOfPackageInfosAsync(in
4141
var pis = await _blobInfo.GetPageOfPackageInfosToUpdateBlobsAsync(_packageRepo, pageStartKey, maxKey, maxPageSize);
4242
if (pis.Count > 0)
4343
{
44-
_logger.LogInformation("Loaded page: {pageIndex} of {pageSize} package infos from DB. The page starts from key: {startPackageKey} and ends at key: {endPackageKey}.",
44+
_logger.LogInformation("Loaded page: {pageIndex} of {pageSize} package infos from DB. The page starts from key: {pageStartKey} and ends at key: {pageEndKey}.",
4545
pageIndex, pis.Count, pis.First().Key, pis.Last().Key);
4646

4747
pageStartKey = pis.Last().Key + 1;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>UpdateBlobProperties</id>
5+
<version>$version$</version>
6+
<title>UpdateBlobProperties</title>
7+
<authors>.NET Foundation</authors>
8+
<owners>.NET Foundation</owners>
9+
<description>UpdateBlobProperties</description>
10+
<copyright>Copyright .NET Foundation</copyright>
11+
</metadata>
12+
<files>
13+
<file src="bin\$configuration$\net472\*.*" target="bin"/>
14+
</files>
15+
</package>

src/UpdateBlobProperties/Updater.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public async Task UpdateBlobPropertiesAsync(PackageInfo packageInfo, Cancellatio
3232
{
3333
var blobName = _blobInfo.GetBlobName(packageInfo);
3434
var blobClient = _blobContainerClient.GetBlobClient(blobName);
35+
var blobUri = blobClient.Uri.GetLeftPart(UriPartial.Path);
3536

3637
// Retries for concurrency control (Blob client is enabled with the retry policy)
3738
var retries = 0;
@@ -43,36 +44,36 @@ public async Task UpdateBlobPropertiesAsync(PackageInfo packageInfo, Cancellatio
4344
if (!TryGetHeadersWhenBlobPropertiesNotMatched(response.Value, _blobInfo.GetUpdatedBlobProperties(), out var blobHttpHeaders))
4445
{
4546
_logger.LogInformation("Blob properties of Package Id: {packageId} and Version: {packageVersion} (Blob Uri: {blobUri}) are matched.",
46-
packageInfo.Id, packageInfo.Version, blobClient.Uri);
47+
packageInfo.Id, packageInfo.Version, blobUri);
4748

4849
return;
4950
}
5051

5152
if (await UpdateAsync(blobClient, blobHttpHeaders, response.Value.ETag, token))
5253
{
5354
_logger.LogInformation("Blob properties of Package Id: {packageId} and Version: {packageVersion} (Blob Uri: {blobUri}) are updated successfully.",
54-
packageInfo.Id, packageInfo.Version, blobClient.Uri);
55+
packageInfo.Id, packageInfo.Version, blobUri);
5556

5657
return;
5758
}
5859
else
5960
{
6061
_logger.LogInformation("The blob of Package Id: {packageId} and Version: {packageVersion} (Blob Uri: {blobUri}) has been updated since the last read.",
61-
packageInfo.Id, packageInfo.Version, blobClient.Uri);
62+
packageInfo.Id, packageInfo.Version, blobUri);
6263
}
6364
}
6465
catch (RequestFailedException e) when (e.Status == (int)HttpStatusCode.NotFound)
6566
{
6667
_logger.LogInformation("The blob of Package Id: {packageId} and Version: {packageVersion} (Blob Uri: {blobUri}) does not exist.",
67-
packageInfo.Id, packageInfo.Version, blobClient.Uri);
68+
packageInfo.Id, packageInfo.Version, blobUri);
6869

6970
return;
7071
}
7172

7273
retries++;
7374
if (retries == MaxRetries)
7475
{
75-
throw new Exception($"Failed to update blob properties of Package Id: {packageInfo.Id} and Version: {packageInfo.Version} (Blob Uri: {blobClient.Uri}) after {MaxRetries} retries.");
76+
throw new Exception($"Failed to update blob properties of Package Id: {packageInfo.Id} and Version: {packageInfo.Version} (Blob Uri: {blobUri}) after {MaxRetries} retries.");
7677
}
7778

7879
await Task.Delay(TimeSpan.FromSeconds(retries * 5), token);

0 commit comments

Comments
 (0)