Repository navigation
C#: NuGet CLI proxy environment. #22752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
d62fae8
2f3f6df
36395a3
983d936
16ebfc8
2e0f0c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| using System; | ||
| using System.Collections.Immutable; | ||
| using System.Collections.Generic; | ||
| using System.Diagnostics; | ||
| using System.IO; | ||
| using System.Security.Cryptography.X509Certificates; | ||
| using Semmle.Util; | ||
|
|
@@ -36,6 +37,8 @@ public class RegistryConfig | |
|
|
||
| public string Address { get; } | ||
|
|
||
| private readonly ILogger logger; | ||
|
|
||
| /// <summary> | ||
| /// A dictionary mapping registry URLs to a boolean indicating whether they replace the base registry. | ||
| /// </summary> | ||
|
|
@@ -65,8 +68,9 @@ public class RegistryConfig | |
|
|
||
| public X509Certificate2? Certificate { get; private set; } | ||
|
|
||
| private RegistryProxy(IRegistryProxyConfiguration config, ILogger logger, TemporaryDirectory tempWorkingDirectory) | ||
| private RegistryProxy(IRegistryProxyConfiguration config, ILogger l, TemporaryDirectory tempWorkingDirectory) | ||
| { | ||
| logger = l; | ||
| Address = $"http://{config.Host}:{config.Port}"; | ||
|
|
||
| if (!string.IsNullOrWhiteSpace(config.Certificate)) | ||
|
|
@@ -179,6 +183,28 @@ private RegistryProxy(IRegistryProxyConfiguration config, ILogger logger, Tempor | |
| return result; | ||
| } | ||
|
|
||
| public void SetProcessEnvironment(ProcessStartInfo pi) | ||
| { | ||
| logger.LogDebug($"Configuring environment variables for the registry proxy at {Address}"); | ||
|
|
||
| pi.EnvironmentVariables["HTTP_PROXY"] = Address; | ||
| pi.EnvironmentVariables["HTTPS_PROXY"] = Address; | ||
|
|
||
| // Also set the lower case variants of the environment variables | ||
| // This might be needed on Linux systems. | ||
| pi.EnvironmentVariables["http_proxy"] = Address; | ||
| pi.EnvironmentVariables["https_proxy"] = Address; | ||
|
|
||
| if (CertificatePath != null) | ||
| { | ||
| pi.EnvironmentVariables["SSL_CERT_FILE"] = CertificatePath; | ||
| } | ||
| else | ||
| { | ||
| logger.LogDebug("No SSL certificate is configured for the registry proxy."); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: This makes sense to log when we are setting the value for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps, we should just log when it is set instead - just to avoid that it happens silently (then we always know whether it happens or not). |
||
| } | ||
|
|
||
| public void Dispose() | ||
| { | ||
| Certificate?.Dispose(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,4 @@ | ||||||
| --- | ||||||
| category: minorAnalysis | ||||||
| --- | ||||||
| * Proxy and certificate environment variables are now set for the subprocess that invokes the NuGet CLI, enabling it to access private registries during this part of the workflow. | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Change "Proxy" to "Private registry proxy" to disambiguate from ordinary proxies that may be configured on a system. Alternatively, since "private registries" are already mentioned in the last part of the note, restructure the sentence to emphasise that part. For example:
Suggested change
|
||||||
Uh oh!
There was an error while loading. Please reload this page.