mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
C#: Add more logging to DependabotProxy
This commit is contained in:
@@ -22,7 +22,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
/// </summary>
|
||||
internal bool IsConfigured => !string.IsNullOrEmpty(this.Address);
|
||||
|
||||
internal DependabotProxy(TemporaryDirectory tempWorkingDirectory)
|
||||
internal DependabotProxy(ILogger logger, TemporaryDirectory tempWorkingDirectory)
|
||||
{
|
||||
// Obtain and store the address of the Dependabot proxy, if available.
|
||||
this.host = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyHost);
|
||||
@@ -30,26 +30,32 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
|
||||
if (string.IsNullOrWhiteSpace(host) || string.IsNullOrWhiteSpace(port))
|
||||
{
|
||||
logger.LogInfo("No Dependabot proxy credentials are configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
this.Address = $"http://{this.host}:{this.port}";
|
||||
logger.LogInfo($"Dependabot proxy configured at {this.Address}");
|
||||
|
||||
// Obtain and store the proxy's certificate, if available.
|
||||
var cert = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyCertificate);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(cert))
|
||||
{
|
||||
logger.LogInfo("No certificate configured for Dependabot proxy.");
|
||||
return;
|
||||
}
|
||||
|
||||
var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".dependabot-proxy"));
|
||||
Directory.CreateDirectory(certDirPath.FullName);
|
||||
|
||||
this.certFile = new FileInfo(Path.Join(certDirPath.FullName, "proxy.crt"));
|
||||
var certFilePath = Path.Join(certDirPath.FullName, "proxy.crt");
|
||||
this.certFile = new FileInfo(certFilePath);
|
||||
|
||||
using var writer = this.certFile.CreateText();
|
||||
writer.Write(cert);
|
||||
|
||||
logger.LogInfo($"Stored Dependabot proxy certificate at {certFilePath}");
|
||||
}
|
||||
|
||||
internal void ApplyProxy(ILogger logger, ProcessStartInfo startInfo)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
public DotNetCliInvoker(ILogger logger, string exec, TemporaryDirectory tempWorkingDirectory)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.proxy = new DependabotProxy(tempWorkingDirectory);
|
||||
this.proxy = new DependabotProxy(logger, tempWorkingDirectory);
|
||||
this.Exec = exec;
|
||||
logger.LogInfo($"Using .NET CLI executable: '{Exec}'");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user