Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ReleasePrep][2024.11.22]RI of dev into main #10279

Merged
merged 40 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
2d5f34d
CloudBlobLeaseService using new SDK.
agr Jul 11, 2024
61eee26
Common storage creation methods.
agr Jul 13, 2024
f2b7a97
MSI support.
agr Jul 13, 2024
57b14c2
Typo fix
agr Jul 15, 2024
43b1a06
Post-rebase fixup
agr Aug 1, 2024
50b5df3
Overridable configuration source for storage MSI/ClientId.
agr Aug 1, 2024
e8d617a
remove Windows.Azure.Storage reference from Validation.Common.Job
advay26 Aug 13, 2024
c858945
added explicit WindowsAzure.Storage reference to downstream NuGet.Ser…
advay26 Aug 15, 2024
680149a
configure lease service with MSI
advay26 Aug 21, 2024
27bdba1
clean up connection string parsing
advay26 Aug 21, 2024
8213c64
added ManagedIdentityClientId as fallback for storage MSI
advay26 Aug 22, 2024
774816d
Merge branch 'agr-stsdk-ft-advay26' into dev-feature-sdkmigration
drewgillies Aug 22, 2024
5e91d55
Revert "Merge branch 'agr-stsdk-ft-advay26' into dev-feature-sdkmigra…
drewgillies Aug 22, 2024
7186abd
Merge branch 'dev' into dev-feature-sdkmigration
drewgillies Aug 26, 2024
1df257c
Migrate AccountDeleter job to MSI storage account access (#10165)
drewgillies Sep 1, 2024
37f3a71
Additional config changes to support AccountDeleter migration (#10180)
drewgillies Sep 11, 2024
1f8f302
Merge branch 'dev' into dev-feature-sdkmigration
drewgillies Sep 12, 2024
5e3dd5f
Use MSI for storage access in GitHubVulnerabilities2Db
drewgillies Sep 30, 2024
0c269f7
Revert "Use MSI for storage access in GitHubVulnerabilities2Db"
drewgillies Sep 30, 2024
dec8b76
Use MSI for storage access in GitHubVulnerabilities2Db (#10197)
drewgillies Oct 4, 2024
40d69b4
Merge branch 'main' into dev-feature-sdkmigration
drewgillies Oct 24, 2024
bddbd2d
Merge branch 'dev' into dev-feature-sdkmigration
drewgillies Oct 24, 2024
1593e94
Merge pull request #10238 from NuGet/dev-feature-sdkmigration
drewgillies Oct 28, 2024
d6ff752
Package deprecation should be case insensitive on version (#10243)
joelverhagen Oct 30, 2024
db3cc47
Migrate GithubVulnerabilities2V3 to MSI (#10239)
drewgillies Oct 31, 2024
a4de2bd
[SDKMigration]Attempt to fix missing authentication. (#10245)
ryuyu Nov 4, 2024
9d10a11
Search MSI migration + .NET 9 TFM support (#10248)
advay26 Nov 7, 2024
7e0e5a6
Convert direct reference for transitive references (#10255)
erdembayar Nov 8, 2024
7e57816
Mooncake log ingestion options to not write headers and add original …
agr Nov 8, 2024
2fdec88
Avoid calling CreateIfNotExists for Feature Flags (#10258)
advay26 Nov 11, 2024
088e9da
[OIDC] Add basic Entra ID token validation (#10251)
joelverhagen Nov 11, 2024
f9a22db
[OIDC] Add federated credential entities (no DB change yet) (#10252)
joelverhagen Nov 12, 2024
935a0a5
[OIDC] Add flight for using federated credentials (#10262)
joelverhagen Nov 12, 2024
7316c09
Make license text part of sidebar license link (#10246)
Goodyear2017 Nov 12, 2024
315ab74
[Storage Migration] V3 jobs (#10228)
dannyjdev Nov 18, 2024
5be598a
Do not audit values for removed/revoked API keys (#10272)
joelverhagen Nov 18, 2024
db81abe
Copy list of scopes before removing them (#10275)
joelverhagen Nov 19, 2024
d84cb2c
[OIDC] Add method to create a short-lived API key (minimal) (#10267)
joelverhagen Nov 22, 2024
45b5070
[OIDC] Add repository for federated credential DB entities (EF wrappe…
joelverhagen Nov 22, 2024
b9466ae
Merge pull request #10278 from NuGet/main
V-Manali Nov 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Collections.Generic;
Expand Down Expand Up @@ -27,6 +27,7 @@ public class AccountDeleteConfiguration
/// </summary>
public Dictionary<string, string> TemplateReplacements { get; set; }


/// <summary>
/// Storage container connection string where gallery content can be found
/// </summary>
Expand All @@ -50,4 +51,4 @@ public SourceConfiguration GetSourceConfiguration(string source)
throw new UnknownSourceException();
}
}
}
}
7 changes: 6 additions & 1 deletion src/AccountDeleter/EmptyFeatureFlagService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using NuGet.Services.Entities;
Expand Down Expand Up @@ -323,5 +323,10 @@ public bool IsAdvancedFrameworkFilteringEnabled(User user)
{
throw new NotImplementedException();
}

public bool CanUseFederatedCredentials(User user)
{
throw new NotImplementedException();
}
}
}
18 changes: 9 additions & 9 deletions src/AccountDeleter/Job.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -27,6 +27,7 @@
using NuGetGallery.Features;
using NuGetGallery.Infrastructure.Authentication;
using NuGetGallery.Security;
using ConfigConstants = NuGet.Services.Configuration.Constants;

namespace NuGetGallery.AccountDeleter
{
Expand Down Expand Up @@ -104,6 +105,13 @@ protected override void ConfigureJobServices(IServiceCollection services, IConfi
services.AddScoped<ITelemetryClient, TelemetryClientWrapper>(
sp => TelemetryClientWrapper.UseTelemetryConfiguration(ApplicationInsightsConfiguration.TelemetryConfiguration));

services.AddScoped<ICloudBlobClient>(serviceProvider =>
{
var options = serviceProvider.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>();
return CloudBlobClientWrapper.UsingMsi(options.Value.GalleryStorageConnectionString,
configurationRoot[ConfigConstants.StorageManagedIdentityClientIdPropertyName]);
});

ConfigureGalleryServices(services);
}

Expand Down Expand Up @@ -160,14 +168,6 @@ protected void ConfigureGalleryServices(IServiceCollection services)
return new SupportRequestDbContext(connection);
});

services.AddScoped<ICloudBlobClient>(sp =>
{
var options = sp.GetRequiredService<IOptionsSnapshot<AccountDeleteConfiguration>>();
var optionsSnapshot = options.Value;

return new CloudBlobClientWrapper(optionsSnapshot.GalleryStorageConnectionString, readAccessGeoRedundant: true);
});

services.AddScoped<ITelemetryService, TelemetryService>();
services.AddScoped<ISecurityPolicyService, SecurityPolicyService>();
services.AddScoped<IAppConfiguration, GalleryConfiguration>();
Expand Down
6 changes: 3 additions & 3 deletions src/Catalog/Dnx/DnxCatalogCollector.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -193,7 +193,7 @@ await catalogEntries.ForEachAsync(_maxConcurrentCommitItemsWithinBatch, async ca
return processedCatalogEntries;
}

private async Task<bool> AreRequiredPropertiesPresentAsync(Storage destinationStorage, Uri destinationUri)
private async Task<bool> AreRequiredPropertiesPresentAsync(Persistence.Storage destinationStorage, Uri destinationUri)
{
var azureStorage = destinationStorage as IAzureStorage;

Expand Down Expand Up @@ -561,4 +561,4 @@ internal static CatalogEntry Create(CatalogCommitItem item)
}
}
}
}
}
29 changes: 15 additions & 14 deletions src/Catalog/Dnx/DnxMaker.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand All @@ -16,6 +16,7 @@
using NuGet.Versioning;

using ILogger = Microsoft.Extensions.Logging.ILogger;
using CatalogStorage = NuGet.Services.Metadata.Catalog.Persistence.Storage;

namespace NuGet.Services.Metadata.Catalog.Dnx
{
Expand Down Expand Up @@ -154,7 +155,7 @@ public async Task DeletePackageAsync(string id, string version, CancellationToke
await DeleteNupkgAsync(storage, id, normalizedVersion, cancellationToken);
}

public async Task<bool> HasPackageInIndexAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
public async Task<bool> HasPackageInIndexAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
{
if (storage == null)
{
Expand All @@ -179,7 +180,7 @@ public async Task<bool> HasPackageInIndexAsync(Storage storage, string id, strin
return versionsContext.Versions.Contains(parsedVersion);
}

private async Task<Uri> SaveNuspecAsync(Storage storage, string id, string version, string nuspec, CancellationToken cancellationToken)
private async Task<Uri> SaveNuspecAsync(CatalogStorage storage, string id, string version, string nuspec, CancellationToken cancellationToken)
{
var relativeAddress = GetRelativeAddressNuspec(id, version);
var nuspecUri = new Uri(storage.BaseAddress, relativeAddress);
Expand Down Expand Up @@ -230,7 +231,7 @@ public async Task UpdatePackageVersionIndexAsync(string id, Action<HashSet<NuGet
}
}

private async Task<VersionsResult> GetVersionsAsync(Storage storage, CancellationToken cancellationToken)
private async Task<VersionsResult> GetVersionsAsync(CatalogStorage storage, CancellationToken cancellationToken)
{
var relativeAddress = "index.json";
var resourceUri = new Uri(storage.BaseAddress, relativeAddress);
Expand Down Expand Up @@ -265,7 +266,7 @@ private StorageContent CreateContent(IEnumerable<string> versions)
return new StringStorageContent(obj.ToString(), "application/json", Constants.NoStoreCacheControl);
}

private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, Storage storage, string id, string version, CancellationToken cancellationToken)
private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
{
Uri nupkgUri = new Uri(storage.BaseAddress, GetRelativeAddressNupkg(id, version));
var content = new StreamStorageContent(
Expand All @@ -280,7 +281,7 @@ private async Task<Uri> SaveNupkgAsync(Stream nupkgStream, Storage storage, stri

private async Task<Uri> CopyNupkgAsync(
IStorage sourceStorage,
Storage destinationStorage,
CatalogStorage destinationStorage,
string id, string version, CancellationToken cancellationToken)
{
var packageFileName = PackageUtility.GetPackageFileName(id, version);
Expand All @@ -300,7 +301,7 @@ await sourceStorage.CopyAsync(

private async Task CopyIconFromAzureStorageIfExistAsync(
IAzureStorage sourceStorage,
Storage destinationStorage,
CatalogStorage destinationStorage,
string packageId,
string normalizedPackageVersion,
string iconFilename,
Expand All @@ -321,7 +322,7 @@ await CopyIconAsync(
private async Task CopyIconFromNupkgStreamAsync(
Stream nupkgStream,
string iconFilename,
Storage destinationStorage,
CatalogStorage destinationStorage,
string packageId,
string normalizedPackageVersion,
CancellationToken cancellationToken)
Expand All @@ -338,7 +339,7 @@ await CopyIconAsync(
private async Task CopyIconAsync(
Stream packageStream,
string iconFilename,
Storage destinationStorage,
CatalogStorage destinationStorage,
string packageId,
string normalizedPackageVersion,
CancellationToken cancellationToken)
Expand Down Expand Up @@ -366,7 +367,7 @@ await ExtractAndStoreIconAsync(
private async Task ExtractAndStoreIconAsync(
Stream packageStream,
string iconPath,
Storage destinationStorage,
CatalogStorage destinationStorage,
Uri destinationUri,
CancellationToken cancellationToken,
string packageId,
Expand Down Expand Up @@ -406,7 +407,7 @@ private async Task<Stream> GetPackageStreamAsync(
return await packageSourceBlob.GetStreamAsync(cancellationToken);
}

private async Task DeleteNuspecAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
private async Task DeleteNuspecAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
{
string relativeAddress = GetRelativeAddressNuspec(id, version);
Uri nuspecUri = new Uri(storage.BaseAddress, relativeAddress);
Expand All @@ -416,7 +417,7 @@ private async Task DeleteNuspecAsync(Storage storage, string id, string version,
}
}

private async Task DeleteNupkgAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
private async Task DeleteNupkgAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
{
string relativeAddress = GetRelativeAddressNupkg(id, version);
Uri nupkgUri = new Uri(storage.BaseAddress, relativeAddress);
Expand All @@ -426,7 +427,7 @@ private async Task DeleteNupkgAsync(Storage storage, string id, string version,
}
}

private async Task DeleteIconAsync(Storage storage, string id, string version, CancellationToken cancellationToken)
private async Task DeleteIconAsync(CatalogStorage storage, string id, string version, CancellationToken cancellationToken)
{
string relativeAddress = GetRelativeAddressIcon(id, version);
Uri iconUri = new Uri(storage.BaseAddress, relativeAddress);
Expand Down Expand Up @@ -479,4 +480,4 @@ public VersionsResult(string relativeAddress, Uri resourceUri, HashSet<NuGetVers
public HashSet<NuGetVersion> Versions { get; }
}
}
}
}
8 changes: 4 additions & 4 deletions src/Catalog/DurableCursor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand All @@ -12,10 +12,10 @@ namespace NuGet.Services.Metadata.Catalog
public class DurableCursor : ReadWriteCursor
{
Uri _address;
Storage _storage;
Persistence.Storage _storage;
DateTime _defaultValue;

public DurableCursor(Uri address, Storage storage, DateTime defaultValue)
public DurableCursor(Uri address, Persistence.Storage storage, DateTime defaultValue)
{
_address = address;
_storage = storage;
Expand Down Expand Up @@ -43,4 +43,4 @@ public override async Task LoadAsync(CancellationToken cancellationToken)
Value = obj["value"].ToObject<DateTime>();
}
}
}
}
6 changes: 3 additions & 3 deletions src/Catalog/Helpers/DeletionAuditEntry.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand Down Expand Up @@ -163,7 +163,7 @@ public static Task<IEnumerable<DeletionAuditEntry>> GetAsync(
DateTime? maxTime = null,
ILogger logger = null)
{
Storage storage = auditingStorageFactory.Create(package != null ? GetAuditRecordPrefixFromPackage(package) : null);
Persistence.Storage storage = auditingStorageFactory.Create(package != null ? GetAuditRecordPrefixFromPackage(package) : null);
return GetAsync(storage, cancellationToken, minTime, maxTime, logger);
}

Expand Down Expand Up @@ -258,4 +258,4 @@ private static bool IsPackageDelete(StorageListItem auditRecord)
return FileNameSuffixes.Any(suffix => fileName.EndsWith(suffix));
}
}
}
}
6 changes: 4 additions & 2 deletions src/Catalog/Icons/CatalogLeafDataProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
Expand All @@ -12,6 +12,8 @@
using NuGet.Services.Metadata.Catalog.Helpers;
using NuGet.Services.Metadata.Catalog.Persistence;

using CatalogStorage = NuGet.Services.Metadata.Catalog.Persistence.Storage;

namespace NuGet.Services.Metadata.Catalog.Icons
{
public class CatalogLeafDataProcessor : ICatalogLeafDataProcessor
Expand Down Expand Up @@ -42,7 +44,7 @@ public CatalogLeafDataProcessor(
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
}

public async Task ProcessPackageDeleteLeafAsync(Storage storage, CatalogCommitItem item, CancellationToken cancellationToken)
public async Task ProcessPackageDeleteLeafAsync(CatalogStorage storage, CatalogCommitItem item, CancellationToken cancellationToken)
{
var targetStoragePath = GetTargetStorageIconPath(item);
await _iconProcessor.DeleteIconAsync(storage, targetStoragePath, cancellationToken, item.PackageIdentity.Id, item.PackageIdentity.Version.ToNormalizedString());
Expand Down
6 changes: 3 additions & 3 deletions src/Catalog/Icons/ICatalogLeafDataProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.Threading;
Expand All @@ -9,7 +9,7 @@ namespace NuGet.Services.Metadata.Catalog.Icons
{
public interface ICatalogLeafDataProcessor
{
Task ProcessPackageDeleteLeafAsync(Storage storage, CatalogCommitItem item, CancellationToken cancellationToken);
Task ProcessPackageDeleteLeafAsync(Persistence.Storage storage, CatalogCommitItem item, CancellationToken cancellationToken);
Task ProcessPackageDetailsLeafAsync(IStorage destinationStorage, IStorage iconCacheStorage, CatalogCommitItem item, string iconUrlString, string iconFile, CancellationToken cancellationToken);
}
}
}
1 change: 1 addition & 0 deletions src/Catalog/NuGet.Services.Metadata.Catalog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<ProjectReference Include="..\NuGet.Services.Configuration\NuGet.Services.Configuration.csproj" />
<ProjectReference Include="..\NuGet.Services.Logging\NuGet.Services.Logging.csproj" />
<ProjectReference Include="..\NuGet.Services.Sql\NuGet.Services.Sql.csproj" />
<ProjectReference Include="..\NuGet.Services.Storage\NuGet.Services.Storage.csproj" />
<ProjectReference Include="..\NuGetGallery.Core\NuGetGallery.Core.csproj" />
</ItemGroup>

Expand Down
6 changes: 4 additions & 2 deletions src/Catalog/Persistence/AzureStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Identity;
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Models;
using Azure.Storage.Blobs.Specialized;
using NuGet.Protocol;
using NuGet.Services.Metadata.Catalog.Extensions;
using NuGet.Services.Storage;
using NuGetGallery;

namespace NuGet.Services.Metadata.Catalog.Persistence
Expand All @@ -33,7 +35,7 @@ public class AzureStorage : Storage, IAzureStorage
public static readonly TimeSpan DefaultMaxExecutionTime = TimeSpan.FromMinutes(10);

public AzureStorage(
BlobServiceClient blobServiceClient,
IBlobServiceClientFactory blobServiceClient,
string containerName,
string path,
Uri baseAddress,
Expand Down Expand Up @@ -92,7 +94,7 @@ private static ICloudBlobDirectory GetCloudBlobDirectoryUri(Uri storageBaseUri)

var blobEndpoint = new Uri(storageBaseUri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
// Create BlobServiceClient with anonymous credentials
var blobServiceClient = new BlobServiceClient(blobEndpoint);
var blobServiceClient = new BlobServiceClientFactory(blobEndpoint);

string containerName = pathSegments[0];
string pathInContainer = string.Join("/", pathSegments.Skip(1));
Expand Down
9 changes: 5 additions & 4 deletions src/Catalog/Persistence/AzureStorageFactory.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using Azure.Storage.Blobs;
using NuGet.Protocol;
using NuGet.Services.Storage;

namespace NuGet.Services.Metadata.Catalog.Persistence
{
public class AzureStorageFactory : StorageFactory
{
private readonly BlobServiceClient _blobServiceClient;
private readonly IBlobServiceClientFactory _blobServiceClient;
private readonly string _containerName;
private readonly string _path;
private readonly Uri _differentBaseAddress = null;
Expand All @@ -19,7 +20,7 @@ public class AzureStorageFactory : StorageFactory
private readonly bool _initializeContainer;

public AzureStorageFactory(
BlobServiceClient blobServiceClient,
IBlobServiceClientFactory blobServiceClient,
string containerName,
TimeSpan maxExecutionTime,
TimeSpan serverTimeout,
Expand Down Expand Up @@ -107,4 +108,4 @@ public override Storage Create(string name = null)
Throttle);
}
}
}
}
Loading