File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 44using System . Security . Cryptography . X509Certificates ;
55using Semmle . Util ;
66using Semmle . Util . Logging ;
7+ using Newtonsoft . Json ;
78
89namespace Semmle . Extraction . CSharp . DependencyFetching
910{
@@ -86,6 +87,39 @@ public struct RegistryConfig
8687 result . Certificate = X509Certificate2 . CreateFromPem ( cert ) ;
8788 }
8889
90+ // Try to obtain the list of private registry URLs.
91+ var registryURLs = Environment . GetEnvironmentVariable ( EnvironmentVariableNames . ProxyURLs ) ;
92+
93+ if ( ! string . IsNullOrWhiteSpace ( registryURLs ) )
94+ {
95+ try
96+ {
97+ // The value of the environment variable should be a JSON array of objects, such as:
98+ // [ { "type": "nuget_feed", "url": "https://nuget.pkg.github.com/org/index.json" } ]
99+ var array = JsonConvert . DeserializeObject < List < RegistryConfig > > ( registryURLs ) ;
100+ if ( array != null )
101+ {
102+ foreach ( RegistryConfig config in array )
103+ {
104+ // The array contains all configured private registries, not just ones for C#.
105+ // We ignore the non-C# ones here.
106+ if ( ! config . Type . Equals ( "nuget_feed" ) )
107+ {
108+ logger . LogDebug ( $ "Ignoring registry at '{ config . URL } ' since it is not of type 'nuget_feed'.") ;
109+ continue ;
110+ }
111+
112+ logger . LogInfo ( $ "Found private registry at '{ config . URL } '") ;
113+ result . RegistryURLs . Add ( config . URL ) ;
114+ }
115+ }
116+ }
117+ catch ( Exception ex )
118+ {
119+ logger . LogError ( $ "Unable to parse '{ EnvironmentVariableNames . ProxyURLs } ': { ex . Message } ") ;
120+ }
121+ }
122+
89123 return result ;
90124 }
91125
You can’t perform that action at this time.
0 commit comments