diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs index a985947c0c12..4bd0bb764a66 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs @@ -27,7 +27,7 @@ public sealed partial class DependencyManager : IDisposable, ICompilationInfoCon private readonly ILogger logger; private readonly IDiagnosticsWriter diagnosticsWriter; private readonly NugetPackageRestorer nugetPackageRestorer; - private readonly IDependabotProxy? dependabotProxy; + private readonly IRegistryProxy? registryProxy; private readonly IDotNet dotnet; private readonly FileContent fileContent; private readonly IFileProvider fileProvider; @@ -106,11 +106,11 @@ void exitCallback(int ret, string msg, bool silent) return BuildScript.Success; }).Run(SystemBuildActions.Instance, startCallback, exitCallback); - dependabotProxy = DependabotProxy.Make(logger, diagnosticsWriter, tempWorkingDirectory); + registryProxy = RegistryProxy.Make(logger, diagnosticsWriter, tempWorkingDirectory); try { - this.dotnet = DotNet.Make(logger, dotnetPath, tempWorkingDirectory, dependabotProxy); + this.dotnet = DotNet.Make(logger, dotnetPath, tempWorkingDirectory, registryProxy); runtimeLazy = new Lazy(() => new Runtime(dotnet)); } catch @@ -119,7 +119,7 @@ void exitCallback(int ret, string msg, bool silent) throw; } - nugetPackageRestorer = new NugetPackageRestorer(fileProvider, fileContent, dotnet, dependabotProxy, diagnosticsWriter, logger, this); + nugetPackageRestorer = new NugetPackageRestorer(fileProvider, fileContent, dotnet, registryProxy, diagnosticsWriter, logger, this); var dllLocations = fileProvider.Dlls.Select(x => new AssemblyLookupLocation(x)).ToHashSet(); dllLocations.UnionWith(nugetPackageRestorer.Restore()); @@ -544,7 +544,7 @@ private void AnalyseProject(FileInfo project) public void Dispose() { nugetPackageRestorer?.Dispose(); - dependabotProxy?.Dispose(); + registryProxy?.Dispose(); if (cleanupTempWorkingDirectory) { tempWorkingDirectory?.Dispose(); diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs index 340d86eb3914..babb811b25f0 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs @@ -31,11 +31,11 @@ private DotNet(IDotNetCliInvoker dotnetCliInvoker, ILogger logger, bool runDotne } } - private DotNet(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IDependabotProxy? dependabotProxy) : this(new DotNetCliInvoker(logger, Path.Join(dotNetPath ?? string.Empty, "dotnet"), dependabotProxy), logger, dotNetPath is null, tempWorkingDirectory) { } + private DotNet(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IRegistryProxy? registryProxy) : this(new DotNetCliInvoker(logger, Path.Join(dotNetPath ?? string.Empty, "dotnet"), registryProxy), logger, dotNetPath is null, tempWorkingDirectory) { } internal static IDotNet Make(IDotNetCliInvoker dotnetCliInvoker, ILogger logger, bool runDotnetInfo) => new DotNet(dotnetCliInvoker, logger, runDotnetInfo); - public static IDotNet Make(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IDependabotProxy? dependabotProxy) => new DotNet(logger, dotNetPath, tempWorkingDirectory, dependabotProxy); + public static IDotNet Make(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IRegistryProxy? registryProxy) => new DotNet(logger, dotNetPath, tempWorkingDirectory, registryProxy); private static void HandleRetryExitCode143(string dotnet, int attempt, ILogger logger) { diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliInvoker.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliInvoker.cs index c6f97c5f8be2..4e1a680eebf3 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliInvoker.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliInvoker.cs @@ -12,14 +12,14 @@ namespace Semmle.Extraction.CSharp.DependencyFetching internal sealed class DotNetCliInvoker : IDotNetCliInvoker { private readonly ILogger logger; - private readonly IDependabotProxy? proxy; + private readonly IRegistryProxy? proxy; public string Exec { get; } - public DotNetCliInvoker(ILogger logger, string exec, IDependabotProxy? dependabotProxy) + public DotNetCliInvoker(ILogger logger, string exec, IRegistryProxy? registryProxy) { this.logger = logger; - this.proxy = dependabotProxy; + this.proxy = registryProxy; this.Exec = exec; logger.LogInfo($"Using .NET CLI executable: '{Exec}'"); } @@ -46,7 +46,7 @@ private ProcessStartInfo MakeDotnetStartInfo(List args, string? workingD // Configure the proxy settings, if applicable. if (this.proxy != null) { - logger.LogDebug($"Configuring environment variables for the Dependabot proxy at {this.proxy.Address}"); + logger.LogDebug($"Configuring environment variables for the Registry proxy at {this.proxy.Address}"); startInfo.EnvironmentVariables["HTTP_PROXY"] = this.proxy.Address; startInfo.EnvironmentVariables["HTTPS_PROXY"] = this.proxy.Address; diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/EnvironmentVariableNames.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/EnvironmentVariableNames.cs index 94a87037cdbc..4b1512c661f0 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/EnvironmentVariableNames.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/EnvironmentVariableNames.cs @@ -75,17 +75,17 @@ internal static class EnvironmentVariableNames public const string DiagnosticDir = "CODEQL_EXTRACTOR_CSHARP_DIAGNOSTIC_DIR"; /// - /// Specifies the hostname of the Dependabot proxy. + /// Specifies the hostname of the Registry proxy. /// public const string ProxyHost = "CODEQL_PROXY_HOST"; /// - /// Specifies the hostname of the Dependabot proxy. + /// Specifies the port of the Registry proxy. /// public const string ProxyPort = "CODEQL_PROXY_PORT"; /// - /// Contains the certificate used by the Dependabot proxy. + /// Contains the certificate used by the Registry proxy. /// public const string ProxyCertificate = "CODEQL_PROXY_CA_CERTIFICATE"; diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs index aeca9c6b2a13..80c295afba46 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs @@ -89,15 +89,15 @@ internal sealed partial class FeedManager : IDisposable /// public ImmutableHashSet ReachableDefaultFeeds => lazyReachableDefaultFeeds.Value; - public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotProxy, IFileProvider fileProvider, IFeedManagerIO feedManagerIo) + public FeedManager(ILogger logger, IDotNet dotnet, IRegistryProxy? registryProxy, IFileProvider fileProvider, IFeedManagerIO feedManagerIo) { this.logger = logger; this.dotnet = dotnet; this.fileProvider = fileProvider; this.feedManagerIo = feedManagerIo; - privateRegistryFeeds = dependabotProxy?.RegistryURLs ?? []; + privateRegistryFeeds = registryProxy?.RegistryURLs ?? []; HasPrivateRegistryFeeds = privateRegistryFeeds.Count > 0; - privateRegistryBaseFeeds = dependabotProxy?.RegistryBaseURLs ?? []; + privateRegistryBaseFeeds = registryProxy?.RegistryBaseURLs ?? []; hasPrivateRegistryBaseFeeds = privateRegistryBaseFeeds.Count > 0; DefaultFeeds = hasPrivateRegistryBaseFeeds @@ -122,8 +122,8 @@ public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotP lazyReachableDefaultFeeds = new Lazy>(() => CheckSpecifiedFeeds(DefaultFeeds)); } - public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotProxy, IFileProvider fileProvider) - : this(logger, dotnet, dependabotProxy, fileProvider, new FeedManagerIO(logger, dependabotProxy)) + public FeedManager(ILogger logger, IDotNet dotnet, IRegistryProxy? registryProxy, IFileProvider fileProvider) + : this(logger, dotnet, registryProxy, fileProvider, new FeedManagerIO(logger, registryProxy)) { } diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManagerIO.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManagerIO.cs index 8e771f6037a4..4b9b6b243866 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManagerIO.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManagerIO.cs @@ -13,12 +13,12 @@ namespace Semmle.Extraction.CSharp.DependencyFetching public class FeedManagerIO : IFeedManagerIO { private readonly ILogger logger; - private readonly IDependabotProxy? dependabotProxy; + private readonly IRegistryProxy? registryProxy; - public FeedManagerIO(ILogger logger, IDependabotProxy? dependabotProxy) + public FeedManagerIO(ILogger logger, IRegistryProxy? registryProxy) { this.logger = logger; - this.dependabotProxy = dependabotProxy; + this.registryProxy = registryProxy; } public string? GetDirectoryName(string path) @@ -43,13 +43,13 @@ public bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount) { logger.LogInfo($"Checking if NuGet feed '{feed}' is reachable..."); - // Configure the HttpClient to be aware of the Dependabot Proxy, if used. + // Configure the HttpClient to be aware of the Registry proxy, if used. HttpClientHandler httpClientHandler = new(); - if (dependabotProxy != null) + if (registryProxy != null) { - httpClientHandler.Proxy = new WebProxy(dependabotProxy.Address); + httpClientHandler.Proxy = new WebProxy(registryProxy.Address); - if (dependabotProxy.Certificate != null) + if (registryProxy.Certificate != null) { httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, _) => { @@ -60,11 +60,11 @@ public bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount) : chain is null ? "chain" : "certificate"; - logger.LogWarning($"Dependabot proxy certificate validation failed due to missing {msg}"); + logger.LogWarning($"Registry proxy certificate validation failed due to missing {msg}"); return false; } chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust; - chain.ChainPolicy.CustomTrustStore.Add(dependabotProxy.Certificate); + chain.ChainPolicy.CustomTrustStore.Add(registryProxy.Certificate); return chain.Build(cert); }; } diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxy.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxy.cs similarity index 82% rename from csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxy.cs rename to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxy.cs index aafaf851e356..7ddc8f846aee 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxy.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxy.cs @@ -4,10 +4,10 @@ namespace Semmle.Extraction.CSharp.DependencyFetching { - public interface IDependabotProxy : IDisposable + public interface IRegistryProxy : IDisposable { /// - /// The full address of the Dependabot proxy, if available. + /// The full address of the Registry proxy, if available. /// string Address { get; } @@ -27,7 +27,7 @@ public interface IDependabotProxy : IDisposable string? CertificatePath { get; } /// - /// The certificate used for the Dependabot proxy. + /// The certificate used for the Registry proxy. /// X509Certificate2? Certificate { get; } } diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxyConfiguration.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxyConfiguration.cs similarity index 64% rename from csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxyConfiguration.cs rename to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxyConfiguration.cs index c67ee4fc39df..520edfd7fb77 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxyConfiguration.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxyConfiguration.cs @@ -2,18 +2,18 @@ namespace Semmle.Extraction.CSharp.DependencyFetching { - public interface IDependabotProxyConfiguration + public interface IRegistryProxyConfiguration { - // The host of the Dependabot proxy, if available. + // The host of the Registry proxy, if available. string? Host { get; } - // The port of the Dependabot proxy, if available. + // The port of the Registry proxy, if available. string? Port { get; } - // The certificate of the Dependabot proxy, if available. + // The certificate of the Registry proxy, if available. string? Certificate { get; } - // The list of package registries that are configured for the proxy, if any. + // The list of package registries that are configured for the Registry proxy, if any. // The value of the environment variable should be a JSON array of objects, such as: // [ { "type": "nuget_feed", "url": "https://nuget.pkg.github.com/org/index.json" } ] string? RegistryURLs { get; } diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs index f62105f2b482..fee72034781f 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs @@ -32,7 +32,7 @@ public NugetPackageRestorer( IFileProvider fileProvider, FileContent fileContent, IDotNet dotnet, - IDependabotProxy? dependabotProxy, + IRegistryProxy? registryProxy, IDiagnosticsWriter diagnosticsWriter, ILogger logger, ICompilationInfoContainer compilationInfoContainer) @@ -47,7 +47,7 @@ public NugetPackageRestorer( PackageDirectory = new DependencyDirectory("packages", "package", logger); legacyPackageDirectory = new DependencyDirectory("legacypackages", "legacy package", logger); missingPackageDirectory = new DependencyDirectory("missingpackages", "missing package", logger); - feedManager = new FeedManager(logger, dotnet, dependabotProxy, fileProvider); + feedManager = new FeedManager(logger, dotnet, registryProxy, fileProvider); } public string? TryRestore(string package) diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxy.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxy.cs similarity index 84% rename from csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxy.cs rename to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxy.cs index 8229a3da1375..ea2203891e37 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxy.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxy.cs @@ -10,7 +10,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching { - public class DependabotProxy : IDependabotProxy + public class RegistryProxy : IRegistryProxy { /// /// Represents configurations for package registries. @@ -65,13 +65,13 @@ public class RegistryConfig public X509Certificate2? Certificate { get; private set; } - private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, TemporaryDirectory tempWorkingDirectory) + private RegistryProxy(IRegistryProxyConfiguration config, ILogger logger, TemporaryDirectory tempWorkingDirectory) { Address = $"http://{config.Host}:{config.Port}"; if (!string.IsNullOrWhiteSpace(config.Certificate)) { - var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".dependabot-proxy")); + var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".registry-proxy")); Directory.CreateDirectory(certDirPath.FullName); CertificatePath = Path.Join(certDirPath.FullName, "proxy.crt"); @@ -81,7 +81,7 @@ private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, Te writer.Write(config.Certificate); writer.Close(); - logger.LogInfo($"Stored Dependabot proxy certificate at {CertificatePath}"); + logger.LogInfo($"Stored Registry proxy certificate at {CertificatePath}"); Certificate = X509Certificate2.CreateFromPem(config.Certificate); } @@ -127,37 +127,37 @@ private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, Te } } - internal static IDependabotProxy? Make(ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory) + internal static IRegistryProxy? Make(ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory) { // Setting HTTP(S)_PROXY and SSL_CERT_FILE have no effect on Windows or macOS, - // but we would still end up using the Dependabot proxy to check for feed reachability. + // but we would still end up using the Registry proxy to check for feed reachability. // This would result in us discovering that the feeds are reachable, but `dotnet` would // fail to connect to them. To prevent this from happening, we do not initialise an - // instance of `DependabotProxy` on those platforms. + // instance of `RegistryProxy` on those platforms. if (SystemBuildActions.Instance.IsWindows() || SystemBuildActions.Instance.IsMacOs()) { return null; } - return Make(new DependabotProxyConfiguration(), logger, diagnosticsWriter, tempWorkingDirectory); + return Make(new RegistryProxyConfiguration(), logger, diagnosticsWriter, tempWorkingDirectory); } /// - /// Creates an instance of the Dependabot proxy using the specified configuration. + /// Creates an instance of the Registry proxy using the specified configuration. /// Returns null if the proxy cannot be created. /// This overload is exposed primarily to enable platform-independent unit testing. /// - internal static IDependabotProxy? Make( - IDependabotProxyConfiguration proxyConfig, ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory) + internal static IRegistryProxy? Make( + IRegistryProxyConfiguration proxyConfig, ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory) { if (string.IsNullOrWhiteSpace(proxyConfig.Host) || string.IsNullOrWhiteSpace(proxyConfig.Port)) { - logger.LogDebug("No Dependabot proxy credentials are configured."); + logger.LogDebug("No Registry proxy credentials are configured."); return null; } - var result = new DependabotProxy(proxyConfig, logger, tempWorkingDirectory); - logger.LogInfo($"Dependabot proxy configured at {result.Address}"); + var result = new RegistryProxy(proxyConfig, logger, tempWorkingDirectory); + logger.LogInfo($"Registry proxy configured at {result.Address}"); // Emit a diagnostic for the discovered private registries, so that it is easy // for users to see that they were picked up. diff --git a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxyConfiguration.cs b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxyConfiguration.cs similarity index 87% rename from csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxyConfiguration.cs rename to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxyConfiguration.cs index 2d81f94aea2c..aeb7e665b62f 100644 --- a/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxyConfiguration.cs +++ b/csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxyConfiguration.cs @@ -2,7 +2,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching { - public class DependabotProxyConfiguration : IDependabotProxyConfiguration + public class RegistryProxyConfiguration : IRegistryProxyConfiguration { public string? Host { get; } = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyHost); diff --git a/csharp/extractor/Semmle.Extraction.Tests/FeedManager.cs b/csharp/extractor/Semmle.Extraction.Tests/FeedManager.cs index 2fdecd570954..d812f008c43b 100644 --- a/csharp/extractor/Semmle.Extraction.Tests/FeedManager.cs +++ b/csharp/extractor/Semmle.Extraction.Tests/FeedManager.cs @@ -9,7 +9,7 @@ namespace Semmle.Extraction.Tests { - public class DependabotProxyStub : IDependabotProxy + public class RegistryProxyStub : IRegistryProxy { public string Address { get; } = ""; public ImmutableHashSet RegistryURLs { get; } = ["https://example.com/registry1", "https://example.com/registry2"]; @@ -20,7 +20,7 @@ public class DependabotProxyStub : IDependabotProxy public void Dispose() { } } - public class DependabotProxyStubWithBaseUrls : IDependabotProxy + public class RegistryProxyStubWithBaseUrls : IRegistryProxy { public string Address { get; } = ""; public ImmutableHashSet RegistryURLs { get; } = ["https://example.com/registry1", "https://example.com/registry2", "https://example.com/base1", "https://example.com/base2"]; @@ -79,16 +79,16 @@ private static FeedManager MakeFeedManager() { var logger = new LoggerStub(); var dotnet = new DotNetStub([], [], ["E https://feed.from/config"], ["E https://feed.from/folder1", "E https://feed.from/folder2", "D https://feed.from/folder3"]); - var dependabotProxy = new DependabotProxyStub(); + var registryProxy = new RegistryProxyStub(); var fileProvider = new FileProviderStub(); var feedManagerIo = new FeedManagerIOStub(["https://example.com/registry1", "https://feed.from/folder2"]); - return new FeedManager(logger, dotnet, dependabotProxy, fileProvider, feedManagerIo); + return new FeedManager(logger, dotnet, registryProxy, fileProvider, feedManagerIo); } /// /// Verify that `FeedManager` correctly computes the explicit feeds using feeds discovered in nuget.config files and /// private registries. - /// See the initialization of `DotNetStub` and `DependabotProxyStub` in `MakeFeedManager` for the feeds configured + /// See the initialization of `DotNetStub` and `RegistryProxyStub` in `MakeFeedManager` for the feeds configured /// to be returned and classified as explicit feeds. /// [Fact] @@ -132,7 +132,7 @@ public void TestInheritedFeeds() /// /// Verify that `FeedManager` correctly computes all feeds using feeds discovered in nuget.config files, private registries, /// and the environment. - /// See the initialization of `DotNetStub` and `DependabotProxyStub` in `MakeFeedManager` for the feeds configured + /// See the initialization of `DotNetStub` and `RegistryProxyStub` in `MakeFeedManager` for the feeds configured /// to be returned and included in all feeds. /// [Fact] @@ -270,7 +270,7 @@ public void TestDefaultFeedsNugetOrg() /// /// Verify that `FeedManager` correctly computes the default feeds and reachable default feeds /// when private registries are configured to replace the default feeds. - /// See the initialization of `DependabotProxyStubWithBaseUrls` for the feeds configured to replace the default feeds. + /// See the initialization of `RegistryProxyStubWithBaseUrls` for the feeds configured to replace the default feeds. /// [Fact] public void TestDefaultFeedsPrivateRegistries() @@ -278,10 +278,10 @@ public void TestDefaultFeedsPrivateRegistries() // Setup var logger = new LoggerStub(); var dotnet = new DotNetStub([], [], [], []); - var dependabotProxy = new DependabotProxyStubWithBaseUrls(); + var registryProxy = new RegistryProxyStubWithBaseUrls(); var fileProvider = new FileProviderStub(); var feedManagerIo = new FeedManagerIOStub(["https://example.com/registry2", "https://example.com/base1"]); - var feedManager = new FeedManager(logger, dotnet, dependabotProxy, fileProvider, feedManagerIo); + var feedManager = new FeedManager(logger, dotnet, registryProxy, fileProvider, feedManagerIo); // Execute var defaultFeeds = feedManager.DefaultFeeds; @@ -312,10 +312,10 @@ public void TestNugetOrgNotReplaced() // Setup var logger = new LoggerStub(); var dotnet = new DotNetStub([], [], [], ["E https://api.nuget.org/v3/index.json"]); - var dependabotProxy = new DependabotProxyStub(); + var registryProxy = new RegistryProxyStub(); var fileProvider = new FileProviderStub(); var feedManagerIo = new FeedManagerIOStub(["https://example.com/registry2", "https://example.com/base1"]); - var feedManager = new FeedManager(logger, dotnet, dependabotProxy, fileProvider, feedManagerIo); + var feedManager = new FeedManager(logger, dotnet, registryProxy, fileProvider, feedManagerIo); // Execute var explicitFeeds = feedManager.ExplicitFeeds; @@ -337,7 +337,7 @@ public void TestNugetOrgNotReplaced() /// /// Verify that `FeedManager` correctly computes the explicit and all feeds when https://api.nuget.org/v3/index.json and /// related NuGet.org URLs are replaced by private registries configured to replace the base feeds. - /// See the initialization of `DependabotProxyStubWithBaseUrls` for the feeds configured as default replacements. + /// See the initialization of `RegistryProxyStubWithBaseUrls` for the feeds configured as default replacements. /// [Fact] public void TestNugetOrgReplacement() @@ -345,10 +345,10 @@ public void TestNugetOrgReplacement() // Setup var logger = new LoggerStub(); var dotnet = new DotNetStub([], [], ["E https://www.nuget.org/api/v2/"], ["E https://api.nuget.org/v3/index.json"]); - var dependabotProxy = new DependabotProxyStubWithBaseUrls(); + var registryProxy = new RegistryProxyStubWithBaseUrls(); var fileProvider = new FileProviderStub(); var feedManagerIo = new FeedManagerIOStub(["https://example.com/registry2", "https://example.com/base1"]); - var feedManager = new FeedManager(logger, dotnet, dependabotProxy, fileProvider, feedManagerIo); + var feedManager = new FeedManager(logger, dotnet, registryProxy, fileProvider, feedManagerIo); // Execute var explicitFeeds = feedManager.ExplicitFeeds; diff --git a/csharp/extractor/Semmle.Extraction.Tests/DependabotProxy.cs b/csharp/extractor/Semmle.Extraction.Tests/RegistryProxy.cs similarity index 67% rename from csharp/extractor/Semmle.Extraction.Tests/DependabotProxy.cs rename to csharp/extractor/Semmle.Extraction.Tests/RegistryProxy.cs index 71c3943fe8fe..e3cd1743593f 100644 --- a/csharp/extractor/Semmle.Extraction.Tests/DependabotProxy.cs +++ b/csharp/extractor/Semmle.Extraction.Tests/RegistryProxy.cs @@ -6,7 +6,7 @@ namespace Semmle.Extraction.Tests { - public class DependabotConfigurationStub : IDependabotProxyConfiguration + public class RegistryConfigurationStub : IRegistryProxyConfiguration { public string? Host { get; set; } public string? Port { get; set; } @@ -20,23 +20,23 @@ public void AddEntry(Semmle.Util.DiagnosticMessage entry) { } public void Dispose() { } } - public class DependabotProxyTests + public class RegistryProxyTests { private static TemporaryDirectory MakeTemporaryDirectory() { - var tmp = Path.Join(Path.GetTempPath(), "DependabotProxyTests", Guid.NewGuid().ToString()); + var tmp = Path.Join(Path.GetTempPath(), "RegistryProxyTests", Guid.NewGuid().ToString()); return new TemporaryDirectory(tmp, "testing", new LoggerStub()); } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case where the port is not specified. - /// In this case, the registry proxy should not be created. + /// Verify that the Registry proxy correctly handles the case where the port is not specified. + /// In this case, the Registry proxy should not be created. /// [Fact] - public void TestDependabotProxyNoPort() + public void TestRegistryProxyNoPort() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Host = "localhost", Port = "", @@ -44,28 +44,28 @@ public void TestDependabotProxyNoPort() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.Null(proxy); } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case where the host is not specified. - /// In this case, the registry proxy should not be created. + /// Verify that the Registry proxy correctly handles the case where the host is not specified. + /// In this case, the Registry proxy should not be created. /// [Fact] - public void TestDependabotProxyNoHost() + public void TestRegistryProxyNoHost() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", }; // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.Null(proxy); @@ -105,14 +105,14 @@ public void TestDependabotProxyNoHost() """; /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case + /// Verify that the Registry proxy correctly handles the case /// where the port, host, and certificate are specified. /// [Fact] - public void TestDependabotProxyCertificate() + public void TestRegistryProxyCertificate() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", Host = "localhost", @@ -121,7 +121,7 @@ public void TestDependabotProxyCertificate() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.NotNull(proxy); @@ -131,15 +131,15 @@ public void TestDependabotProxyCertificate() } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case - /// where the RegistryURLs environment variable is not a valid JSON list. - /// In this case, the registry proxy should be created, but the list of private registries should be empty. + /// Verify that the Registry proxy correctly handles the case where the RegistryURLs environment variable + /// is not a valid JSON list. + /// In this case, the Registry proxy should be created, but the list of private registries should be empty. /// [Fact] - public void TestDependabotRegistryUrlsParseError() + public void TestRegistryProxyUrlsParseError() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", Host = "localhost", @@ -148,7 +148,7 @@ public void TestDependabotRegistryUrlsParseError() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.NotNull(proxy); @@ -157,15 +157,15 @@ public void TestDependabotRegistryUrlsParseError() } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case - /// where the RegistryURLs environment variable is a valid JSON list with a single entry. - /// In this case, the registry proxy should be created, and the list of private registries should contain the single entry. + /// Verify that the Registry proxy correctly handles the case where the RegistryURLs environment variable + /// is a valid JSON list with a single entry. + /// In this case, the Registry proxy should be created, and the list of private registries should contain the single entry. /// [Fact] - public void TestDependabotRegistryUrlsSingle() + public void TestRegistryProxyUrlsSingle() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", Host = "localhost", @@ -174,7 +174,7 @@ public void TestDependabotRegistryUrlsSingle() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.NotNull(proxy); @@ -185,17 +185,17 @@ public void TestDependabotRegistryUrlsSingle() } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case - /// where the RegistryURLs environment variable is a valid JSON list with multiple entries, but only one of them - /// is of type "nuget_feed", which is relevant for C#. - /// In this case, the registry proxy should be created, and the list of private registries should + /// Verify that the Registry proxy correctly handles the case where the RegistryURLs environment variable + /// is a valid JSON list with multiple entries, but only one of them is of type "nuget_feed", which is + /// relevant for C#. + /// In this case, the Registry proxy should be created, and the list of private registries should /// contain only the entry of type "nuget_feed". /// [Fact] - public void TestDependabotRegistryUrls3() + public void TestRegistryProxyUrls3() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", Host = "localhost", @@ -204,7 +204,7 @@ public void TestDependabotRegistryUrls3() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.NotNull(proxy); @@ -215,17 +215,16 @@ public void TestDependabotRegistryUrls3() } /// - /// The purpose of this test is to verify that the registry proxy correctly handles the case - /// where the RegistryURLs environment variable is a valid JSON list with multiple entries and one of them - /// is configured to replace the base feeds. - /// In this case, the registry proxy should be created, and the list of private registries should contain all + /// Verify that the Registry proxy correctly handles the case where the RegistryURLs environment variable + /// is a valid JSON list with multiple entries and one of them is configured to replace the base feeds. + /// In this case, the Registry proxy should be created, and the list of private registries should contain all /// entries, while the list of base registries should contain only the entry that replaces the base feeds. /// [Fact] - public void TestDependabotRegistryUrlsReplacesBase() + public void TestRegistryProxyUrlsReplacesBase() { // Setup - var config = new DependabotConfigurationStub + var config = new RegistryConfigurationStub { Port = "8080", Host = "localhost", @@ -234,7 +233,7 @@ public void TestDependabotRegistryUrlsReplacesBase() // Execute using var tempWorkingDirectory = MakeTemporaryDirectory(); - using var proxy = DependabotProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); + using var proxy = RegistryProxy.Make(config, new LoggerStub(), new DiagnosticsWriterStub(), tempWorkingDirectory); // Verify Assert.NotNull(proxy);