Skip to content

Commit 9731006

Browse files
committed
C#: Set environment variables for proxy for calls to dotnet
1 parent b1828a8 commit 9731006

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
2+
using System.Diagnostics;
23
using System.IO;
34
using Semmle.Util;
5+
using Semmle.Util.Logging;
46

57
namespace Semmle.Extraction.CSharp.DependencyFetching
68
{
@@ -49,5 +51,17 @@ internal DependabotProxy(TemporaryDirectory tempWorkingDirectory)
4951
using var writer = this.certFile.CreateText();
5052
writer.Write(cert);
5153
}
54+
55+
internal void ApplyProxy(ILogger logger, ProcessStartInfo startInfo)
56+
{
57+
// If the proxy isn't configured, we have nothing to do.
58+
if (!this.IsConfigured) return;
59+
60+
logger.LogInfo($"Setting up Dependabot proxy at {this.Address}");
61+
62+
startInfo.EnvironmentVariables["HTTP_PROXY"] = this.Address;
63+
startInfo.EnvironmentVariables["HTTPS_PROXY"] = this.Address;
64+
startInfo.EnvironmentVariables["SSL_CERT_FILE"] = this.certFile?.FullName;
65+
}
5266
}
5367
}

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ private ProcessStartInfo MakeDotnetStartInfo(string args, string? workingDirecto
4444
// Configure the proxy settings, if applicable.
4545
this.proxy.ApplyProxy(this.logger, startInfo);
4646

47-
this.logger.LogInfo(startInfo.EnvironmentVariables["HTTP_PROXY"] ?? "");
48-
this.logger.LogInfo(startInfo.EnvironmentVariables["HTTPS_PROXY"] ?? "");
49-
this.logger.LogInfo(startInfo.EnvironmentVariables["SSL_CERT_FILE"] ?? "");
50-
5147
return startInfo;
5248
}
5349

0 commit comments

Comments
 (0)