8000 C#: Add more logging to `DependabotProxy` · github/codeql@a107872 · GitHub
[go: up one dir, main page]

Skip to content

Commit a107872

Browse files
committed
C#: Add more logging to DependabotProxy
1 parent 81ea4e4 commit a107872

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,40 @@ internal class DependabotProxy
2222
/// </summary>
2323
internal bool IsConfigured => !string.IsNullOrEmpty(this.Address);
2424

25-
internal DependabotProxy(TemporaryDirectory tempWorkingDirectory)
25+
internal DependabotProxy(ILogger logger, TemporaryDirectory tempWorkingDirectory)
2626
{
2727
// Obtain and store the address of the Dependabot proxy, if available.
2828
this.host = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyHost);
2929
this.port = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyPort);
3030

3131
if (string.IsNullOrWhiteSpace(host) || string.IsNullOrWhiteSpace(port))
3232
{
33+
logger.LogInfo("No Dependabot proxy credentials are configured.");
3334
return;
3435
}
3536

3637
this.Address = $"http://{this.host}:{this.port}";
38+
logger.LogInfo($"Dependabot proxy configured at {this.Address}");
3739

3840
// Obtain and store the proxy's certificate, if available.
3941
var cert = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyCertificate);
4042

4143
if (string.IsNullOrWhiteSpace(cert))
4244
{
45+
logger.LogInfo("No certificate configured for Dependabot proxy.");
4346
return;
4447
}
4548

4649
var certDirPath = new DirectoryInfo(Path.Join(tempWorkingDirectory.DirInfo.FullName, ".dependabot-proxy"));
4750
Directory.CreateDirectory(certDirPath.FullName);
4851

49-
this.certFile = new FileInfo(Path.Join(certDirPath.FullName, "proxy.crt"));
52+
var certFilePath = Path.Join(certDirPath.FullName, "proxy.crt");
53+
this.certFile = new FileInfo(certFilePath);
5054

5155
using var writer = this.certFile.CreateText();
5256
writer.Write(cert);
57+
58+
logger.LogInfo($"Stored Dependabot proxy certificate at {certFilePath}");
5359
}
5460

5561
internal void ApplyProxy(ILogger logger, ProcessStartInfo startInfo)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ internal sealed class DotNetCliInvoker : IDotNetCliInvoker
1919
public DotNetCliInvoker(ILogger logger, string exec, TemporaryDirectory tempWorkingDirectory)
2020
{
2121
56CA this.logger = logger;
22-
this.proxy = new DependabotProxy(tempWorkingDirectory);
22+
this.proxy = new DependabotProxy(logger, tempWorkingDirectory);
2323
this.Exec = exec;
2424
logger.LogInfo($"Using .NET CLI executable: '{Exec}'");
2525
}

0 commit comments

Comments
 (0)
0