Skip to content

Commit

Permalink
C#: Set environment variables for proxy for calls to dotnet
Browse files Browse the repository at this point in the history
  • Loading branch information
mbg committed Nov 19, 2024
1 parent b1828a8 commit 9731006
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Diagnostics;
using System.IO;
using Semmle.Util;
using Semmle.Util.Logging;

namespace Semmle.Extraction.CSharp.DependencyFetching
{
Expand Down Expand Up @@ -49,5 +51,17 @@ internal DependabotProxy(TemporaryDirectory tempWorkingDirectory)
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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ private ProcessStartInfo MakeDotnetStartInfo(string args, string? workingDirecto
// 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;
}

Expand Down

0 comments on commit 9731006

Please sign in to comment.