Skip to content

Commit 933fe45

Browse files
authored
Give the manage packages page its own pva flag (perf concerns) (#8451)
1 parent 97b1a56 commit 933fe45

8 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/NuGetGallery.Services/Configuration/FeatureFlagService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class FeatureFlagService : IFeatureFlagService
2727
private const string ManageDeprecationForManyVersionsFeatureName = GalleryPrefix + "ManageDeprecationMany";
2828
private const string ManageDeprecationApiFeatureName = GalleryPrefix + "ManageDeprecationApi";
2929
private const string DisplayVulnerabilitiesFeatureName = GalleryPrefix + "DisplayVulnerabilities";
30+
private const string ManagePackagesVulnerabilitiesFeatureName = GalleryPrefix + "ManagePackagesVulnerabilities";
3031
private const string DisplayFuGetLinksFeatureName = GalleryPrefix + "DisplayFuGetLinks";
3132
private const string ODataReadOnlyDatabaseFeatureName = GalleryPrefix + "ODataReadOnlyDatabase";
3233
private const string PackagesAtomFeedFeatureName = GalleryPrefix + "PackagesAtomFeed";
@@ -141,6 +142,11 @@ public bool IsDisplayVulnerabilitiesEnabled()
141142
return _client.IsEnabled(DisplayVulnerabilitiesFeatureName, defaultValue: false);
142143
}
143144

145+
public bool IsManagePackagesVulnerabilitiesEnabled()
146+
{
147+
return _client.IsEnabled(ManagePackagesVulnerabilitiesFeatureName, defaultValue: false);
148+
}
149+
144150
public bool IsDisplayFuGetLinksEnabled()
145151
{
146152
return _client.IsEnabled(DisplayFuGetLinksFeatureName, defaultValue: false);

src/NuGetGallery.Services/Configuration/IFeatureFlagService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public interface IFeatureFlagService
6767
/// </summary>
6868
bool IsDisplayVulnerabilitiesEnabled();
6969

70+
/// <summary>
71+
/// Whether or not a package owner can view vulnerability advisory information on the Manage Packages page.
72+
/// </summary>
73+
bool IsManagePackagesVulnerabilitiesEnabled();
74+
7075
/// <summary>
7176
/// Whether or not a fuget.org link is visible on a package's details page.
7277
/// </summary>

src/NuGetGallery.Services/PackageManagement/PackageService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ private IEnumerable<Package> GetPackagesForOwners(IEnumerable<int> ownerKeys, bo
463463
.Include(p => p.PackageRegistration.Owners)
464464
.Include(p => p.PackageRegistration.RequiredSigners);
465465

466-
if (includeVulnerabilities)
466+
if (includeVulnerabilities && _featureFlagService.IsManagePackagesVulnerabilitiesEnabled())
467467
{
468468
result = result.Include($"{nameof(Package.VulnerablePackageRanges)}.{nameof(VulnerablePackageVersionRange.Vulnerability)}");
469469
}

src/NuGetGallery/App_Data/Files/Content/flags.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"NuGetGallery.ODataV2SearchNonHijacked": "Enabled",
2424
"NuGetGallery.ODataV2SearchCountNonHijacked": "Enabled",
2525
"NuGetGallery.DisplayVulnerabilities": "Enabled",
26+
"NuGetGallery.ManagePackagesVulnerabilities": "Enabled",
2627
"NuGetGallery.DisplayFuGetLinks": "Enabled",
2728
"NuGetGallery.PatternSetTfmHeuristics": "Enabled"
2829
},

src/NuGetGallery/Controllers/UsersController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ public virtual ActionResult Packages()
566566
ReservedNamespaces = reservedPrefixes,
567567
WasMultiFactorAuthenticated = User.WasMultiFactorAuthenticated(),
568568
IsCertificatesUIEnabled = ContentObjectService.CertificatesConfiguration?.IsUIEnabledForUser(currentUser) ?? false,
569-
IsPackageVulnerabilitiesEnabled = _featureFlagService.IsDisplayVulnerabilitiesEnabled()
569+
IsManagePackagesVulnerabilitiesEnabled = _featureFlagService.IsManagePackagesVulnerabilitiesEnabled()
570570
};
571571

572572
return View(model);

src/NuGetGallery/ViewModels/ManagePackagesViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public class ManagePackagesViewModel
2424

2525
public bool IsCertificatesUIEnabled { get; set; }
2626

27-
public bool IsPackageVulnerabilitiesEnabled { get; set; }
27+
public bool IsManagePackagesVulnerabilitiesEnabled { get; set; }
2828
}
2929
}

src/NuGetGallery/Views/Users/Packages.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
}
121121
<th class="sortable">Downloads</th>
122122
<th class="sortable">Latest Version</th>
123-
@if (Model.IsPackageVulnerabilitiesEnabled)
123+
@if (Model.IsManagePackagesVulnerabilitiesEnabled)
124124
{
125125
<th><span class="hidden">Package warnings</span></th>
126126
}
@@ -175,7 +175,7 @@
175175
<td class="align-middle text-nowrap" data-bind="attr: { 'data-sortby': VersionSortOrder }">
176176
<span data-bind="text: LatestVersion"></span>
177177
</td>
178-
@if (Model.IsPackageVulnerabilitiesEnabled)
178+
@if (Model.IsManagePackagesVulnerabilitiesEnabled)
179179
{
180180
<td class="package-icon-cell">
181181
<i class="ms-Icon ms-Icon--Warning package-icon" data-bind="visible: IsVulnerable" title="This version has at least one known vulnerability. Click on the package name for details."></i>

src/VerifyMicrosoftPackage/Fakes/FakeFeatureFlagService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public class FakeFeatureFlagService : IFeatureFlagService
3333

3434
public bool IsDisplayVulnerabilitiesEnabled() => throw new NotImplementedException();
3535

36+
public bool IsManagePackagesVulnerabilitiesEnabled() => throw new NotImplementedException();
37+
3638
public bool IsDisplayFuGetLinksEnabled() => throw new NotImplementedException();
3739

3840
public bool AreEmbeddedIconsEnabled(User user) => throw new NotImplementedException();

0 commit comments

Comments
 (0)