C#: Set environment variables for proxy for calls to dotnet

This commit is contained in:
Michael B. Gale
2024-11-19 13:23:05 +00:00
parent 8ca75602d8
commit 6cd5711313
2 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using Semmle.Util;
using Semmle.Util.Logging;
namespace Semmle.Extraction.CSharp.DependencyFetching
{
@@ -49,5 +51,17 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
using var writer = this.certFile.CreateText();
writer.Write(cert);
}
internal void ApplyProxy(ILogger logger, ProcessStartInfo startInfo)
{
// If the proxy isn't configured, we have nothing to do.
if (!this.IsConfigured) return;
logger.LogInfo($"Setting up Dependabot proxy at {this.Address}");
startInfo.EnvironmentVariables["HTTP_PROXY"] = this.Address;
startInfo.EnvironmentVariables["HTTPS_PROXY"] = this.Address;
startInfo.EnvironmentVariables["SSL_CERT_FILE"] = this.certFile?.FullName;
}
}
}

View File

@@ -44,10 +44,6 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
// Configure the proxy settings, if applicable.
this.proxy.ApplyProxy(this.logger, startInfo);
this.logger.LogInfo(startInfo.EnvironmentVariables["HTTP_PROXY"] ?? "");
this.logger.LogInfo(startInfo.EnvironmentVariables["HTTPS_PROXY"] ?? "");
this.logger.LogInfo(startInfo.EnvironmentVariables["SSL_CERT_FILE"] ?? "");
return startInfo;
}