Skip to content

Commit

Permalink
Add new license origin which makes clear that a license was actually …
Browse files Browse the repository at this point in the history
…validated with an overwrite
  • Loading branch information
sensslen committed Nov 24, 2023
1 parent ea1c1e9 commit 92135db
Show file tree
Hide file tree
Showing 263 changed files with 2,464 additions and 1,973 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
public enum LicenseInformationOrigin
{
Overwrite,
Expression,
Url,
Unknown,
Expand Down
13 changes: 10 additions & 3 deletions src/NuGetUtility/LicenseValidator/LicenseValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<IEnumerable<LicenseValidationResult>> Validate(

private bool IsIgnoredPackage(PackageIdentity identity)
{
return _ignoredPackages.Any(ignored => identity.Id.Like(ignored));
return Array.Exists(_ignoredPackages, ignored => identity.Id.Like(ignored));
}

private void AddOrUpdateLicense(
Expand Down Expand Up @@ -128,7 +128,7 @@ private void ValidateLicenseByMetadata(IPackageMetadata info,
{
AddOrUpdateLicense(result,
info,
LicenseInformationOrigin.Expression,
ToLicenseOrigin(info.LicenseMetadata.Type),
info.LicenseMetadata.License);
}
else
Expand Down Expand Up @@ -227,6 +227,13 @@ private string GetLicenseNotAllowedMessage(string license)
return $"License {license} not found in list of supported licenses";
}

private record LicenseNameAndVersion(string LicenseName, INuGetVersion Version);
private LicenseInformationOrigin ToLicenseOrigin(LicenseType type) => type switch
{
LicenseType.Overwrite => LicenseInformationOrigin.Overwrite,
LicenseType.Expression => LicenseInformationOrigin.Expression,
_ => throw new ArgumentOutOfRangeException(nameof(type), type, $"This conversion method only supports the {nameof(LicenseType.Overwrite)} and {nameof(LicenseType.Expression)} types for conversion")
};

private sealed record LicenseNameAndVersion(string LicenseName, INuGetVersion Version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private PackageSearchResult TryGetPackageInfoFromCustomInformation(PackageIdenti
return new PackageSearchResult();
}

return new PackageSearchResult(new PackageMetadata(package, resolvedCustomInformation.License));
return new PackageSearchResult(new PackageMetadata(package, resolvedCustomInformation.License, LicenseType.Overwrite));
}

private static async Task<IPackageMetadataResource?> TryGetPackageMetadataResource(ISourceRepository repository)
Expand Down
4 changes: 2 additions & 2 deletions src/NuGetUtility/PackageInformationReader/PackageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ public PackageMetadata(PackageIdentity identity)
Identity = identity;
}

public PackageMetadata(PackageIdentity identity, string licenseType)
public PackageMetadata(PackageIdentity identity, string licenseIdentifier, LicenseType licenseType)
{
Identity = identity;
LicenseMetadata = new LicenseMetadata(LicenseType.Expression, licenseType);
LicenseMetadata = new LicenseMetadata(licenseType, licenseIdentifier);
}

public PackageIdentity Identity { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace NuGetUtility.Wrapper.NuGetWrapper.Packaging
public enum LicenseType
{
File,
Expression
Expression,
Overwrite
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"PackageId":"Direct Intranet Facilitator","PackageVersion":"7.1.7","PackageProjectUrl":"https://garnet.net","ValidationErrors":[{"Error":"Alisha","Context":"http://alyson.name"},{"Error":"Carmelo","Context":"http://michele.name"},{"Error":"Miles","Context":"https://freddie.com"},{"Error":"Kade","Context":"https://jaunita.biz"},{"Error":"Marcelina","Context":"http://donna.net"},{"Error":"Darby","Context":"http://joana.org"},{"Error":"Albin","Context":"http://hal.com"},{"Error":"Betsy","Context":"http://quinton.com"},{"Error":"Emmalee","Context":"https://haleigh.name"}],"License":"synthesizing the feed won\u0027t do anything, we need to index the auxiliary SMTP feed!","LicenseInformationOrigin":1},{"PackageId":"Principal Functionality Agent","PackageVersion":"1.5.3","ValidationErrors":[{"Error":"Judson","Context":"https://wilson.net"},{"Error":"Guadalupe","Context":"http://otho.info"},{"Error":"General","Context":"https://skylar.name"},{"Error":"Haylie","Context":"http://audreanne.info"}],"License":"connecting the firewall won\u0027t do anything, we need to copy the digital XSS firewall!","LicenseInformationOrigin":0},{"PackageId":"Regional Accounts Technician","PackageVersion":"2.8.7","ValidationErrors":[{"Error":"Dawson","Context":"http://addie.org"},{"Error":"Xander","Context":"https://everette.info"},{"Error":"Otha","Context":"https://cletus.net"},{"Error":"Carlee","Context":"https://jaron.info"},{"Error":"Nannie","Context":"https://isaias.net"}],"LicenseInformationOrigin":0}]
[{"PackageId":"Direct Intranet Facilitator","PackageVersion":"7.1.7","PackageProjectUrl":"https://garnet.net","ValidationErrors":[{"Error":"Alisha","Context":"http://alyson.name"},{"Error":"Carmelo","Context":"http://michele.name"},{"Error":"Miles","Context":"https://freddie.com"},{"Error":"Kade","Context":"https://jaunita.biz"},{"Error":"Marcelina","Context":"http://donna.net"},{"Error":"Darby","Context":"http://joana.org"},{"Error":"Albin","Context":"http://hal.com"},{"Error":"Betsy","Context":"http://quinton.com"},{"Error":"Emmalee","Context":"https://haleigh.name"}],"License":"synthesizing the feed won\u0027t do anything, we need to index the auxiliary SMTP feed!","LicenseInformationOrigin":2},{"PackageId":"Principal Functionality Agent","PackageVersion":"1.5.3","ValidationErrors":[{"Error":"Judson","Context":"https://wilson.net"},{"Error":"Guadalupe","Context":"http://otho.info"},{"Error":"General","Context":"https://skylar.name"},{"Error":"Haylie","Context":"http://audreanne.info"}],"License":"connecting the firewall won\u0027t do anything, we need to copy the digital XSS firewall!","LicenseInformationOrigin":0},{"PackageId":"Regional Accounts Technician","PackageVersion":"2.8.7","ValidationErrors":[{"Error":"Dawson","Context":"http://addie.org"},{"Error":"Xander","Context":"https://everette.info"},{"Error":"Otha","Context":"https://cletus.net"},{"Error":"Carlee","Context":"https://jaron.info"},{"Error":"Nannie","Context":"https://isaias.net"}],"LicenseInformationOrigin":0}]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"PackageId":"National Solutions Coordinator","PackageVersion":"8.7.3","PackageProjectUrl":"https://adrianna.name","ValidationErrors":[{"Error":"Maximillian","Context":"http://leola.name"},{"Error":"Shaina","Context":"http://dean.name"},{"Error":"Juana","Context":"http://aniya.biz"},{"Error":"Fernando","Context":"http://shanna.com"},{"Error":"Katelyn","Context":"https://judd.com"},{"Error":"Earl","Context":"https://bradford.biz"}],"License":"Use the bluetooth USB panel, then you can calculate the bluetooth panel!","LicenseInformationOrigin":0},{"PackageId":"Principal Functionality Agent","PackageVersion":"1.5.3","ValidationErrors":[{"Error":"Judson","Context":"https://wilson.net"},{"Error":"Guadalupe","Context":"http://otho.info"},{"Error":"General","Context":"https://skylar.name"},{"Error":"Haylie","Context":"http://audreanne.info"}],"License":"connecting the firewall won\u0027t do anything, we need to copy the digital XSS firewall!","LicenseInformationOrigin":0},{"PackageId":"Regional Accounts Technician","PackageVersion":"2.8.7","ValidationErrors":[{"Error":"Dawson","Context":"http://addie.org"},{"Error":"Xander","Context":"https://everette.info"},{"Error":"Otha","Context":"https://cletus.net"},{"Error":"Carlee","Context":"https://jaron.info"},{"Error":"Nannie","Context":"https://isaias.net"}],"LicenseInformationOrigin":0},{"PackageId":"Direct Intranet Facilitator","PackageVersion":"7.1.7","PackageProjectUrl":"https://garnet.net","ValidationErrors":[{"Error":"Alisha","Context":"http://alyson.name"},{"Error":"Carmelo","Context":"http://michele.name"},{"Error":"Miles","Context":"https://freddie.com"},{"Error":"Kade","Context":"https://jaunita.biz"},{"Error":"Marcelina","Context":"http://donna.net"},{"Error":"Darby","Context":"http://joana.org"},{"Error":"Albin","Context":"http://hal.com"},{"Error":"Betsy","Context":"http://quinton.com"},{"Error":"Emmalee","Context":"https://haleigh.name"}],"License":"synthesizing the feed won\u0027t do anything, we need to index the auxiliary SMTP feed!","LicenseInformationOrigin":1},{"PackageId":"Senior Brand Developer","PackageVersion":"4.4.1","PackageProjectUrl":"http://adelbert.net","ValidationErrors":[{"Error":"Reid","Context":"https://amely.info"},{"Error":"Nikki","Context":"https://mckayla.info"},{"Error":"Kiara","Context":"https://floyd.net"},{"Error":"Libby","Context":"http://wade.biz"},{"Error":"Leola","Context":"https://pietro.info"},{"Error":"Arch","Context":"http://hazle.org"},{"Error":"Eldred","Context":"http://gabriel.net"}],"License":"If we override the system, we can get to the CSS system through the neural CSS system!","LicenseInformationOrigin":2}]
[{"PackageId":"National Solutions Coordinator","PackageVersion":"8.7.3","PackageProjectUrl":"https://adrianna.name","ValidationErrors":[{"Error":"Maximillian","Context":"http://leola.name"},{"Error":"Shaina","Context":"http://dean.name"},{"Error":"Juana","Context":"http://aniya.biz"},{"Error":"Fernando","Context":"http://shanna.com"},{"Error":"Katelyn","Context":"https://judd.com"},{"Error":"Earl","Context":"https://bradford.biz"}],"License":"Use the bluetooth USB panel, then you can calculate the bluetooth panel!","LicenseInformationOrigin":0},{"PackageId":"Principal Functionality Agent","PackageVersion":"1.5.3","ValidationErrors":[{"Error":"Judson","Context":"https://wilson.net"},{"Error":"Guadalupe","Context":"http://otho.info"},{"Error":"General","Context":"https://skylar.name"},{"Error":"Haylie","Context":"http://audreanne.info"}],"License":"connecting the firewall won\u0027t do anything, we need to copy the digital XSS firewall!","LicenseInformationOrigin":0},{"PackageId":"Regional Accounts Technician","PackageVersion":"2.8.7","ValidationErrors":[{"Error":"Dawson","Context":"http://addie.org"},{"Error":"Xander","Context":"https://everette.info"},{"Error":"Otha","Context":"https://cletus.net"},{"Error":"Carlee","Context":"https://jaron.info"},{"Error":"Nannie","Context":"https://isaias.net"}],"LicenseInformationOrigin":0},{"PackageId":"Direct Intranet Facilitator","PackageVersion":"7.1.7","PackageProjectUrl":"https://garnet.net","ValidationErrors":[{"Error":"Alisha","Context":"http://alyson.name"},{"Error":"Carmelo","Context":"http://michele.name"},{"Error":"Miles","Context":"https://freddie.com"},{"Error":"Kade","Context":"https://jaunita.biz"},{"Error":"Marcelina","Context":"http://donna.net"},{"Error":"Darby","Context":"http://joana.org"},{"Error":"Albin","Context":"http://hal.com"},{"Error":"Betsy","Context":"http://quinton.com"},{"Error":"Emmalee","Context":"https://haleigh.name"}],"License":"synthesizing the feed won\u0027t do anything, we need to index the auxiliary SMTP feed!","LicenseInformationOrigin":2},{"PackageId":"Senior Brand Developer","PackageVersion":"4.4.1","PackageProjectUrl":"http://adelbert.net","ValidationErrors":[{"Error":"Reid","Context":"https://amely.info"},{"Error":"Nikki","Context":"https://mckayla.info"},{"Error":"Kiara","Context":"https://floyd.net"},{"Error":"Libby","Context":"http://wade.biz"},{"Error":"Leola","Context":"https://pietro.info"},{"Error":"Arch","Context":"http://hazle.org"},{"Error":"Eldred","Context":"http://gabriel.net"}],"License":"If we override the system, we can get to the CSS system through the neural CSS system!","LicenseInformationOrigin":3}]

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 92135db

Please sign in to comment.