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

AAD account checks on packages for safety reports #9360

Merged
merged 5 commits into from
Feb 6, 2023

Conversation

drewgillies
Copy link
Contributor

We'll allow safety report categories only on MSA-only account-owned packages as a first step.

@drewgillies drewgillies requested a review from a team as a code owner January 25, 2023 04:18
@@ -114,6 +115,17 @@ public static bool IsAzureActiveDirectoryAccount(string type)
return type?.Equals(External.AzureActiveDirectoryAccount, StringComparison.OrdinalIgnoreCase) ?? false;
}

public static bool PackageHasNoAadOwners(Package package)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving this check to the Controller. We can move to NuGetGallery.Core if we need to re-use it.

@@ -1384,7 +1384,8 @@ public virtual ActionResult ReportAbuse(string id, string version)

var model = new ReportAbuseViewModel
{
ReasonChoices = _featureFlagService.IsShowReportAbuseSafetyChangesEnabled()
ReasonChoices = _featureFlagService.IsShowReportAbuseSafetyChangesEnabled()
&& CredentialTypes.PackageHasNoAadOwners(package)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTs?

return true;
}

return !owners.Where(o => o.Credentials.GetAzureActiveDirectoryCredential() != null).Any();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will !owners.Any(o => o.Credentials.GetAzureActiveDirectoryCredential() != null);
work?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is valid or not, but could you do return !package?.PackageRegistration?.Owners?.Any(o => o.Credentials.GetAzureActiveDirectoryCredential() != null) ?? true? Just to mimic the other methods here.

Copy link
Contributor Author

@drewgillies drewgillies Jan 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skofman1 yes, that's cleaner--thanks. @camigthompson I'd like to leave it separate for readability, particularly as I'm separating our NRE-avoidance into its own block.

@skofman1
Copy link
Contributor

What should be the behavior if one of the package owners is an organization, and the org has collaborators that use AAD?

@drewgillies
Copy link
Contributor Author

@skofman1 This case is addressed now. Thanks for pointing it out!

@drewgillies drewgillies merged commit 3f692c3 into dev Feb 6, 2023
@drewgillies drewgillies deleted the dg-aad-reportaconcern branch February 6, 2023 20:33
@drewgillies drewgillies mentioned this pull request Feb 6, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants