-
Notifications
You must be signed in to change notification settings - Fork 1.7k
C#: Automatically use configured private registry feeds #18850
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 1 commit
6b2f348
63d5517
11efb55
726123c
0db6a26
6b15f77
a8dde15
9560593
b6c74fe
284f612
51874b8
7a92a72
d564529
92eab47
4448369
7cea2ad
d2b88ae
4d3b024
73ca2eb
be95d33
fe1c098
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
using System.Security.Cryptography.X509Certificates; | ||
using Semmle.Util; | ||
using Semmle.Util.Logging; | ||
using Newtonsoft.Json; | ||
|
||
namespace Semmle.Extraction.CSharp.DependencyFetching | ||
{ | ||
|
@@ -86,6 +87,39 @@ public struct RegistryConfig | |
result.Certificate = X509Certificate2.CreateFromPem(cert); | ||
} | ||
|
||
// Try to obtain the list of private registry URLs. | ||
var registryURLs = Environment.GetEnvironmentVariable(EnvironmentVariableNames.ProxyURLs); | ||
|
||
if (!string.IsNullOrWhiteSpace(registryURLs)) | ||
{ | ||
try | ||
{ | ||
// The value of the environment variable should be a JSON array of objects, such as: | ||
// [ { "type": "nuget_feed", "url": "https://nuget.pkg.github.com/org/index.json" } ] | ||
var array = JsonConvert.DeserializeObject<List<RegistryConfig>>(registryURLs); | ||
if (array != null) | ||
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. Do we expect the array to be null? Should we log if it is 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. The main reason for the check is just to make sure we don't work with a |
||
{ | ||
foreach (RegistryConfig config in array) | ||
{ | ||
// The array contains all configured private registries, not just ones for C#. | ||
// We ignore the non-C# ones here. | ||
if (!config.Type.Equals("nuget_feed")) | ||
{ | ||
logger.LogDebug($"Ignoring registry at '{config.URL}' since it is not of type 'nuget_feed'."); | ||
continue; | ||
} | ||
|
||
logger.LogInfo($"Found private registry at '{config.URL}'"); | ||
result.RegistryURLs.Add(config.URL); | ||
} | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
logger.LogError($"Unable to parse '{EnvironmentVariableNames.ProxyURLs}': {ex.Message}"); | ||
} | ||
|
||
} | ||
|
||
return result; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.