Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
C#: Set environment variables for proxy for calls to dotnet
  • Loading branch information
mbg committed Dec 5, 2024
commit 6cd5711313c9e47f39845b24051e6ecaee5df519
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