Skip to content

Commit a79e645

Browse files
authored
Merge pull request #22542 from michaelnebel/csharp/dependabottoregistryrename
C#: Rename Dependabot to Registry and update log messages.
2 parents 74c434f + d33b157 commit a79e645

13 files changed

Lines changed: 103 additions & 104 deletions

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependencyManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public sealed partial class DependencyManager : IDisposable, ICompilationInfoCon
2727
private readonly ILogger logger;
2828
private readonly IDiagnosticsWriter diagnosticsWriter;
2929
private readonly NugetPackageRestorer nugetPackageRestorer;
30-
private readonly IDependabotProxy? dependabotProxy;
30+
private readonly IRegistryProxy? registryProxy;
3131
private readonly IDotNet dotnet;
3232
private readonly FileContent fileContent;
3333
private readonly IFileProvider fileProvider;
@@ -106,11 +106,11 @@ void exitCallback(int ret, string msg, bool silent)
106106
return BuildScript.Success;
107107
}).Run(SystemBuildActions.Instance, startCallback, exitCallback);
108108

109-
dependabotProxy = DependabotProxy.Make(logger, diagnosticsWriter, tempWorkingDirectory);
109+
registryProxy = RegistryProxy.Make(logger, diagnosticsWriter, tempWorkingDirectory);
110110

111111
try
112112
{
113-
this.dotnet = DotNet.Make(logger, dotnetPath, tempWorkingDirectory, dependabotProxy);
113+
this.dotnet = DotNet.Make(logger, dotnetPath, tempWorkingDirectory, registryProxy);
114114
runtimeLazy = new Lazy<Runtime>(() => new Runtime(dotnet));
115115
}
116116
catch
@@ -119,7 +119,7 @@ void exitCallback(int ret, string msg, bool silent)
119119
throw;
120120
}
121121

122-
nugetPackageRestorer = new NugetPackageRestorer(fileProvider, fileContent, dotnet, dependabotProxy, diagnosticsWriter, logger, this);
122+
nugetPackageRestorer = new NugetPackageRestorer(fileProvider, fileContent, dotnet, registryProxy, diagnosticsWriter, logger, this);
123123

124124
var dllLocations = fileProvider.Dlls.Select(x => new AssemblyLookupLocation(x)).ToHashSet();
125125
dllLocations.UnionWith(nugetPackageRestorer.Restore());
@@ -544,7 +544,7 @@ private void AnalyseProject(FileInfo project)
544544
public void Dispose()
545545
{
546546
nugetPackageRestorer?.Dispose();
547-
dependabotProxy?.Dispose();
547+
registryProxy?.Dispose();
548548
if (cleanupTempWorkingDirectory)
549549
{
550550
tempWorkingDirectory?.Dispose();

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ private DotNet(IDotNetCliInvoker dotnetCliInvoker, ILogger logger, bool runDotne
3131
}
3232
}
3333

34-
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) { }
34+
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) { }
3535

3636
internal static IDotNet Make(IDotNetCliInvoker dotnetCliInvoker, ILogger logger, bool runDotnetInfo) => new DotNet(dotnetCliInvoker, logger, runDotnetInfo);
3737

38-
public static IDotNet Make(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IDependabotProxy? dependabotProxy) => new DotNet(logger, dotNetPath, tempWorkingDirectory, dependabotProxy);
38+
public static IDotNet Make(ILogger logger, string? dotNetPath, TemporaryDirectory tempWorkingDirectory, IRegistryProxy? registryProxy) => new DotNet(logger, dotNetPath, tempWorkingDirectory, registryProxy);
3939

4040
private static void HandleRetryExitCode143(string dotnet, int attempt, ILogger logger)
4141
{

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DotNetCliInvoker.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1212
internal sealed class DotNetCliInvoker : IDotNetCliInvoker
1313
{
1414
private readonly ILogger logger;
15-
private readonly IDependabotProxy? proxy;
15+
private readonly IRegistryProxy? proxy;
1616

1717
public string Exec { get; }
1818

19-
public DotNetCliInvoker(ILogger logger, string exec, IDependabotProxy? dependabotProxy)
19+
public DotNetCliInvoker(ILogger logger, string exec, IRegistryProxy? registryProxy)
2020
{
2121
this.logger = logger;
22-
this.proxy = dependabotProxy;
22+
this.proxy = registryProxy;
2323
this.Exec = exec;
2424
logger.LogInfo($"Using .NET CLI executable: '{Exec}'");
2525
}
@@ -46,7 +46,7 @@ private ProcessStartInfo MakeDotnetStartInfo(List<string> args, string? workingD
4646
// Configure the proxy settings, if applicable.
4747
if (this.proxy != null)
4848
{
49-
logger.LogDebug($"Configuring environment variables for the Dependabot proxy at {this.proxy.Address}");
49+
logger.LogDebug($"Configuring environment variables for the registry proxy at {this.proxy.Address}");
5050

5151
startInfo.EnvironmentVariables["HTTP_PROXY"] = this.proxy.Address;
5252
startInfo.EnvironmentVariables["HTTPS_PROXY"] = this.proxy.Address;

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/EnvironmentVariableNames.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ internal static class EnvironmentVariableNames
7575
public const string DiagnosticDir = "CODEQL_EXTRACTOR_CSHARP_DIAGNOSTIC_DIR";
7676

7777
/// <summary>
78-
/// Specifies the hostname of the Dependabot proxy.
78+
/// Specifies the hostname of the registry proxy.
7979
/// </summary>
8080
public const string ProxyHost = "CODEQL_PROXY_HOST";
8181

8282
/// <summary>
83-
/// Specifies the hostname of the Dependabot proxy.
83+
/// Specifies the port of the registry proxy.
8484
/// </summary>
8585
public const string ProxyPort = "CODEQL_PROXY_PORT";
8686

8787
/// <summary>
88-
/// Contains the certificate used by the Dependabot proxy.
88+
/// Contains the certificate used by the registry proxy.
8989
/// </summary>
9090
public const string ProxyCertificate = "CODEQL_PROXY_CA_CERTIFICATE";
9191

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManager.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ internal sealed partial class FeedManager : IDisposable
8989
/// </summary>
9090
public ImmutableHashSet<string> ReachableDefaultFeeds => lazyReachableDefaultFeeds.Value;
9191

92-
public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotProxy, IFileProvider fileProvider, IFeedManagerIO feedManagerIo)
92+
public FeedManager(ILogger logger, IDotNet dotnet, IRegistryProxy? registryProxy, IFileProvider fileProvider, IFeedManagerIO feedManagerIo)
9393
{
9494
this.logger = logger;
9595
this.dotnet = dotnet;
9696
this.fileProvider = fileProvider;
9797
this.feedManagerIo = feedManagerIo;
98-
privateRegistryFeeds = dependabotProxy?.RegistryURLs ?? [];
98+
privateRegistryFeeds = registryProxy?.RegistryURLs ?? [];
9999
HasPrivateRegistryFeeds = privateRegistryFeeds.Count > 0;
100-
privateRegistryBaseFeeds = dependabotProxy?.RegistryBaseURLs ?? [];
100+
privateRegistryBaseFeeds = registryProxy?.RegistryBaseURLs ?? [];
101101
hasPrivateRegistryBaseFeeds = privateRegistryBaseFeeds.Count > 0;
102102

103103
DefaultFeeds = hasPrivateRegistryBaseFeeds
@@ -122,8 +122,8 @@ public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotP
122122
lazyReachableDefaultFeeds = new Lazy<ImmutableHashSet<string>>(() => CheckSpecifiedFeeds(DefaultFeeds));
123123
}
124124

125-
public FeedManager(ILogger logger, IDotNet dotnet, IDependabotProxy? dependabotProxy, IFileProvider fileProvider)
126-
: this(logger, dotnet, dependabotProxy, fileProvider, new FeedManagerIO(logger, dependabotProxy))
125+
public FeedManager(ILogger logger, IDotNet dotnet, IRegistryProxy? registryProxy, IFileProvider fileProvider)
126+
: this(logger, dotnet, registryProxy, fileProvider, new FeedManagerIO(logger, registryProxy))
127127
{
128128
}
129129

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/FeedManagerIO.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1313
public class FeedManagerIO : IFeedManagerIO
1414
{
1515
private readonly ILogger logger;
16-
private readonly IDependabotProxy? dependabotProxy;
16+
private readonly IRegistryProxy? registryProxy;
1717

18-
public FeedManagerIO(ILogger logger, IDependabotProxy? dependabotProxy)
18+
public FeedManagerIO(ILogger logger, IRegistryProxy? registryProxy)
1919
{
2020
this.logger = logger;
21-
this.dependabotProxy = dependabotProxy;
21+
this.registryProxy = registryProxy;
2222
}
2323

2424
public string? GetDirectoryName(string path)
@@ -43,13 +43,13 @@ public bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount)
4343
{
4444
logger.LogInfo($"Checking if NuGet feed '{feed}' is reachable...");
4545

46-
// Configure the HttpClient to be aware of the Dependabot Proxy, if used.
46+
// Configure the HttpClient to be aware of the registry proxy, if used.
4747
HttpClientHandler httpClientHandler = new();
48-
if (dependabotProxy != null)
48+
if (registryProxy != null)
4949
{
50-
httpClientHandler.Proxy = new WebProxy(dependabotProxy.Address);
50+
httpClientHandler.Proxy = new WebProxy(registryProxy.Address);
5151

52-
if (dependabotProxy.Certificate != null)
52+
if (registryProxy.Certificate != null)
5353
{
5454
httpClientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, _) =>
5555
{
@@ -60,11 +60,11 @@ public bool IsFeedReachable(string feed, int timeoutMilliSeconds, int tryCount)
6060
: chain is null
6161
? "chain"
6262
: "certificate";
63-
logger.LogWarning($"Dependabot proxy certificate validation failed due to missing {msg}");
63+
logger.LogWarning($"Registry proxy certificate validation failed due to missing {msg}");
6464
return false;
6565
}
6666
chain.ChainPolicy.TrustMode = X509ChainTrustMode.CustomRootTrust;
67-
chain.ChainPolicy.CustomTrustStore.Add(dependabotProxy.Certificate);
67+
chain.ChainPolicy.CustomTrustStore.Add(registryProxy.Certificate);
6868
return chain.Build(cert);
6969
};
7070
}

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxy.cs renamed to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace Semmle.Extraction.CSharp.DependencyFetching
66
{
7-
public interface IDependabotProxy : IDisposable
7+
public interface IRegistryProxy : IDisposable
88
{
99
/// <summary>
10-
/// The full address of the Dependabot proxy, if available.
10+
/// The full address of the registry proxy, if available.
1111
/// </summary>
1212
string Address { get; }
1313

@@ -27,7 +27,7 @@ public interface IDependabotProxy : IDisposable
2727
string? CertificatePath { get; }
2828

2929
/// <summary>
30-
/// The certificate used for the Dependabot proxy.
30+
/// The certificate used for the registry proxy.
3131
/// </summary>
3232
X509Certificate2? Certificate { get; }
3333
}

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IDependabotProxyConfiguration.cs renamed to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/IRegistryProxyConfiguration.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22

33
namespace Semmle.Extraction.CSharp.DependencyFetching
44
{
5-
public interface IDependabotProxyConfiguration
5+
public interface IRegistryProxyConfiguration
66
{
7-
// The host of the Dependabot proxy, if available.
7+
// The host of the registry proxy, if available.
88
string? Host { get; }
99

10-
// The port of the Dependabot proxy, if available.
10+
// The port of the registry proxy, if available.
1111
string? Port { get; }
1212

13-
// The certificate of the Dependabot proxy, if available.
13+
// The certificate of the registry proxy, if available.
1414
string? Certificate { get; }
1515

16-
// The list of package registries that are configured for the proxy, if any.
16+
// The list of package registries that are configured for the registry proxy, if any.
1717
// The value of the environment variable should be a JSON array of objects, such as:
1818
// [ { "type": "nuget_feed", "url": "https://nuget.pkg.github.com/org/index.json" } ]
1919
string? RegistryURLs { get; }

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/NugetPackageRestorer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public NugetPackageRestorer(
3232
IFileProvider fileProvider,
3333
FileContent fileContent,
3434
IDotNet dotnet,
35-
IDependabotProxy? dependabotProxy,
35+
IRegistryProxy? registryProxy,
3636
IDiagnosticsWriter diagnosticsWriter,
3737
ILogger logger,
3838
ICompilationInfoContainer compilationInfoContainer)
@@ -47,7 +47,7 @@ public NugetPackageRestorer(
4747
PackageDirectory = new DependencyDirectory("packages", "package", logger);
4848
legacyPackageDirectory = new DependencyDirectory("legacypackages", "legacy package", logger);
4949
missingPackageDirectory = new DependencyDirectory("missingpackages", "missing package", logger);
50-
feedManager = new FeedManager(logger, dotnet, dependabotProxy, fileProvider);
50+
feedManager = new FeedManager(logger, dotnet, registryProxy, fileProvider);
5151
}
5252

5353
public string? TryRestore(string package)

csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/DependabotProxy.cs renamed to csharp/extractor/Semmle.Extraction.CSharp.DependencyFetching/RegistryProxy.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Semmle.Extraction.CSharp.DependencyFetching
1212
{
13-
public class DependabotProxy : IDependabotProxy
13+
public class RegistryProxy : IRegistryProxy
1414
{
1515
/// <summary>
1616
/// Represents configurations for package registries.
@@ -65,13 +65,13 @@ public class RegistryConfig
6565

6666
public X509Certificate2? Certificate { get; private set; }
6767

68-
private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, TemporaryDirectory tempWorkingDirectory)
68+
private RegistryProxy(IRegistryProxyConfiguration config, ILogger logger, TemporaryDirectory tempWorkingDirectory)
6969
{
7070
Address = $"http://{config.Host}:{config.Port}";
7171

7272
if (!string.IsNullOrWhiteSpace(config.Certificate))
7373
{
74-
var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".dependabot-proxy"));
74+
var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".registry-proxy"));
7575
Directory.CreateDirectory(certDirPath.FullName);
7676

7777
CertificatePath = Path.Join(certDirPath.FullName, "proxy.crt");
@@ -81,7 +81,7 @@ private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, Te
8181
writer.Write(config.Certificate);
8282
writer.Close();
8383

84-
logger.LogInfo($"Stored Dependabot proxy certificate at {CertificatePath}");
84+
logger.LogInfo($"Stored registry proxy certificate at {CertificatePath}");
8585

8686
Certificate = X509Certificate2.CreateFromPem(config.Certificate);
8787
}
@@ -127,37 +127,37 @@ private DependabotProxy(IDependabotProxyConfiguration config, ILogger logger, Te
127127
}
128128
}
129129

130-
internal static IDependabotProxy? Make(ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory)
130+
internal static IRegistryProxy? Make(ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory)
131131
{
132132
// Setting HTTP(S)_PROXY and SSL_CERT_FILE have no effect on Windows or macOS,
133-
// but we would still end up using the Dependabot proxy to check for feed reachability.
133+
// but we would still end up using the registry proxy to check for feed reachability.
134134
// This would result in us discovering that the feeds are reachable, but `dotnet` would
135135
// fail to connect to them. To prevent this from happening, we do not initialise an
136-
// instance of `DependabotProxy` on those platforms.
136+
// instance of `RegistryProxy` on those platforms.
137137
if (SystemBuildActions.Instance.IsWindows() || SystemBuildActions.Instance.IsMacOs())
138138
{
139139
return null;
140140
}
141141

142-
return Make(new DependabotProxyConfiguration(), logger, diagnosticsWriter, tempWorkingDirectory);
142+
return Make(new RegistryProxyConfiguration(), logger, diagnosticsWriter, tempWorkingDirectory);
143143
}
144144

145145
/// <summary>
146-
/// Creates an instance of the Dependabot proxy using the specified configuration.
146+
/// Creates an instance of the registry proxy using the specified configuration.
147147
/// Returns null if the proxy cannot be created.
148148
/// This overload is exposed primarily to enable platform-independent unit testing.
149149
/// </summary>
150-
internal static IDependabotProxy? Make(
151-
IDependabotProxyConfiguration proxyConfig, ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory)
150+
internal static IRegistryProxy? Make(
151+
IRegistryProxyConfiguration proxyConfig, ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory)
152152
{
153153
if (string.IsNullOrWhiteSpace(proxyConfig.Host) || string.IsNullOrWhiteSpace(proxyConfig.Port))
154154
{
155-
logger.LogDebug("No Dependabot proxy credentials are configured.");
155+
logger.LogDebug("No registry proxy credentials are configured.");
156156
return null;
157157
}
158158

159-
var result = new DependabotProxy(proxyConfig, logger, tempWorkingDirectory);
160-
logger.LogInfo($"Dependabot proxy configured at {result.Address}");
159+
var result = new RegistryProxy(proxyConfig, logger, tempWorkingDirectory);
160+
logger.LogInfo($"Registry proxy configured at {result.Address}");
161161

162162
// Emit a diagnostic for the discovered private registries, so that it is easy
163163
// for users to see that they were picked up.

0 commit comments

Comments
 (0)