Skip to content

Commit

Permalink
Add test that checks whether the licenses in UrlToLicenseMapping are …
Browse files Browse the repository at this point in the history
…valid
  • Loading branch information
sensslen committed Feb 13, 2024
1 parent f5788ca commit b530e36
Show file tree
Hide file tree
Showing 128 changed files with 14,297 additions and 75 deletions.
5 changes: 4 additions & 1 deletion src/NuGetUtility/AppLifetime.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility
{
/// <summary>
/// Inspired by: https://github.com/dotnet/aspnetcore/search?q=WebHostLifetime
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Extension/AsyncEnumerableExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Extension
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Extension
{
public static class AsyncEnumerableExtension
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Extensions/HashSetExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Extensions
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Extensions
{
public static class HashSetExtension
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Extensions/ProjectExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NuGetUtility.Wrapper.MsBuildWrapper;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.MsBuildWrapper;

namespace NuGetUtility.Extensions
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Text.RegularExpressions;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Text.RegularExpressions;

namespace NuGetUtility.Extensions
{
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/LicenseValidator/LicenseDownloadException.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Packaging.Core;

namespace NuGetUtility.LicenseValidator
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.LicenseValidator
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.LicenseValidator
{
public enum LicenseInformationOrigin
{
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/LicenseValidator/LicenseValidationResult.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Versioning;

namespace NuGetUtility.LicenseValidator
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/LicenseValidator/LicenseValidator.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Collections.Concurrent;
using System.Collections.Immutable;
using NuGetUtility.Extensions;
Expand Down
13 changes: 3 additions & 10 deletions src/NuGetUtility/LicenseValidator/UrlToLicenseMapping.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Collections.Immutable;

namespace NuGetUtility.LicenseValidator
{
public static class UrlToLicenseMapping
{
private const string Apache20 = "Apache-2.0";
private const string Bsd3Clause = "BSD-3-Clause";
private const string Gpl20 = "GPL-2.0";
private const string Mit = "MIT";
private const string MsPl = "MS-PL";
Expand All @@ -17,12 +19,10 @@ public static class UrlToLicenseMapping
{
KeyValuePair.Create( new Uri("http://www.apache.org/licenses/LICENSE-2.0.html"), Apache20 ),
KeyValuePair.Create( new Uri("http://www.apache.org/licenses/LICENSE-2.0"), Apache20 ),
KeyValuePair.Create( new Uri("http://opensource.org/licenses/Apache-2.0"), Apache20 ),
KeyValuePair.Create( new Uri("http://aws.amazon.com/apache2.0/"), Apache20 ),
KeyValuePair.Create( new Uri("http://logging.apache.org/log4net/license.html"), Apache20 ),
KeyValuePair.Create( new Uri("https://github.com/owin-contrib/owin-hosting/blob/master/LICENSE.txt"), Apache20 ),
KeyValuePair.Create( new Uri("https://raw.githubusercontent.com/aspnet/Home/2.0.0/LICENSE.txt"), Apache20 ),
KeyValuePair.Create( new Uri("http://opensource.org/licenses/BSD-3-Clause"), Bsd3Clause ),
KeyValuePair.Create(
new Uri("https://github.com/Microsoft/Microsoft.IO.RecyclableMemoryStream/blob/master/LICENSE"), Mit
),
Expand All @@ -31,18 +31,11 @@ public static class UrlToLicenseMapping
KeyValuePair.Create( new Uri("https://raw.githubusercontent.com/hey-red/markdownsharp/master/LICENSE"), Mit ),
KeyValuePair.Create( new Uri("https://raw.github.com/JamesNK/Newtonsoft.Json/master/LICENSE.md"), Mit ),
KeyValuePair.Create( new Uri("https://licenses.nuget.org/MIT"), Mit ),
KeyValuePair.Create( new Uri("http://opensource.org/licenses/MIT"), Mit ),
KeyValuePair.Create( new Uri("http://opensource.org/licenses/mit-license.php"), Mit ),
KeyValuePair.Create( new Uri("http://www.opensource.org/licenses/mit-license.php"), Mit ),
KeyValuePair.Create( new Uri("http://max.mit-license.org/"), Mit ),
KeyValuePair.Create( new Uri("https://github.com/dotnet/corefx/blob/master/LICENSE.TXT"), Mit ),
KeyValuePair.Create( new Uri("https://go.microsoft.com/fwlink/?linkid=868514"), Mit ),
KeyValuePair.Create( new Uri("http://go.microsoft.com/fwlink/?linkid=833178"), Mit ),
KeyValuePair.Create( new Uri("http://sourceforge.net/directory/license:mit/"), Mit ),
KeyValuePair.Create( new Uri("http://www.gnu.org/licenses/old-licenses/gpl-2.0.html"), Gpl20 ),
KeyValuePair.Create( new Uri("http://opensource.org/licenses/MS-PL"), MsPl ),
KeyValuePair.Create( new Uri("https://opensource.org/licenses/MS-PL"), MsPl ),
KeyValuePair.Create( new Uri("http://www.opensource.org/licenses/ms-pl"), MsPl ),
KeyValuePair.Create( new Uri("https://raw.githubusercontent.com/AArnott/Validation/8377954d86/LICENSE.txt"), MsPl ),
KeyValuePair.Create( new Uri("https://www.microsoft.com/web/webpi/eula/aspnetmvc3update-eula.htm"), MsEula ),
KeyValuePair.Create( new Uri("http://go.microsoft.com/fwlink/?LinkID=214339"), MsEula ),
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/LicenseValidator/ValidationError.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.LicenseValidator
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.LicenseValidator
{
public record ValidationError(string Error, string Context);
}
5 changes: 4 additions & 1 deletion src/NuGetUtility/Output/IOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NuGetUtility.LicenseValidator;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.LicenseValidator;

namespace NuGetUtility.Output
{
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Output/Json/JsonOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Text.Json;
using NuGetUtility.LicenseValidator;
using NuGetUtility.Serialization;
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Output/Table/TableOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.LicenseValidator;

namespace NuGetUtility.Output.Table
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Output/Table/TablePrinter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Output.Table
{
/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Output/Table/TablePrinterExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Output.Table
{
internal static class TablePrinterExtensions
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/OutputType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility
{
public enum OutputType
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Versioning;

namespace NuGetUtility.PackageInformationReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Runtime.CompilerServices;
using NuGetUtility.Wrapper.NuGetWrapper.Packaging;
using NuGetUtility.Wrapper.NuGetWrapper.Packaging.Core;
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/PackageInformationReader/PackageMetadata.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Packaging;
using NuGetUtility.Wrapper.NuGetWrapper.Packaging.Core;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Packaging.Core;

namespace NuGetUtility.PackageInformationReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Packaging;

namespace NuGetUtility.PackageInformationReader
Expand Down
6 changes: 4 additions & 2 deletions src/NuGetUtility/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Collections.Immutable;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Collections.Immutable;
using System.Reflection;
using System.Text.Json;
using McMaster.Extensions.CommandLineUtils;
using NuGet.Configuration;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
using NuGetUtility.Extension;
using NuGetUtility.LicenseValidator;
using NuGetUtility.Output;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NuGetUtility.Wrapper.MsBuildWrapper;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.MsBuildWrapper;

namespace NuGetUtility.ReferencedPackagesReader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Extensions;
using NuGetUtility.Wrapper.MsBuildWrapper;
using NuGetUtility.Wrapper.NuGetWrapper.Packaging.Core;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.ReferencedPackagesReader
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.ReferencedPackagesReader
{
public class ReferencedPackageReaderException : Exception
{
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Serialization/NuGetVersionJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Text.Json;
using System.Text.Json.Serialization;
using NuGetUtility.Wrapper.NuGetWrapper.Versioning;
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Serialization/UriDictionaryJsonConverter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Text.Json;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Text.Json;
using System.Text.Json.Serialization;

namespace NuGetUtility.Serialization
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Text.Json;
using System.Text.Json.Serialization;
using NuGetUtility.LicenseValidator;
Expand Down
5 changes: 3 additions & 2 deletions src/NuGetUtility/Wrapper/HttpClientWrapper/FileDownloader.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.HttpClientWrapper
{
Expand Down Expand Up @@ -27,12 +28,12 @@ public async Task DownloadFile(Uri url, string fileName, CancellationToken token
var request = new HttpRequestMessage(HttpMethod.Get, url);

HttpResponseMessage response = await _client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token);
response.EnsureSuccessStatusCode();
if (response.StatusCode == System.Net.HttpStatusCode.TooManyRequests)
{
await Task.Delay((int)Math.Pow(EXPONENTIAL_BACKOFF_WAIT_TIME_MILLISECONDS, i + 1), token);
continue;
}
response.EnsureSuccessStatusCode();
using Stream downloadStream = await response.Content.ReadAsStreamAsync(token);

await downloadStream.CopyToAsync(file, token);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.HttpClientWrapper
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.HttpClientWrapper
{
public interface IFileDownloader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.HttpClientWrapper
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.HttpClientWrapper
{
public class NopFileDownloader : IFileDownloader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.MsBuildWrapper
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.MsBuildWrapper
{
public interface IMsBuildAbstraction
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Wrapper/MsBuildWrapper/IProject.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.MsBuildWrapper
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.MsBuildWrapper
{
public interface IProject
{
Expand Down
3 changes: 3 additions & 0 deletions src/NuGetUtility/Wrapper/MsBuildWrapper/MsBuildAbstraction.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using Microsoft.Build.Construction;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Exceptions;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.MsBuildWrapper
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.MsBuildWrapper
{
public class MsBuildAbstractionException : Exception
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Wrapper/MsBuildWrapper/PackageReference.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NuGetUtility.Wrapper.NuGetWrapper.Versioning;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGetUtility.Wrapper.NuGetWrapper.Versioning;

namespace NuGetUtility.Wrapper.MsBuildWrapper
{
Expand Down
5 changes: 4 additions & 1 deletion src/NuGetUtility/Wrapper/MsBuildWrapper/ProjectWrapper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Microsoft.Build.Evaluation;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using Microsoft.Build.Evaluation;

namespace NuGetUtility.Wrapper.MsBuildWrapper
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Management;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using System.Management;
using System.Runtime.Versioning;

namespace NuGetUtility.Wrapper.MsBuildWrapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace NuGetUtility.Wrapper.NuGetWrapper.Frameworks
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

namespace NuGetUtility.Wrapper.NuGetWrapper.Frameworks
{
public interface INuGetFramework
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using NuGet.Frameworks;
// Licensed to the projects contributors.
// The license conditions are provided in the LICENSE file located in the project root

using NuGet.Frameworks;

namespace NuGetUtility.Wrapper.NuGetWrapper.Frameworks
{
Expand Down
Loading

0 comments on commit b530e36

Please sign in to comment.