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 c6f089585a
commit d6fda1ae72
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;
}
}
}