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 4
4
using System . Security . Cryptography . X509Certificates ;
5
5
using Semmle . Util ;
6
6
using Semmle . Util . Logging ;
7
+ using Newtonsoft . Json ;
7
8
8
9
namespace Semmle . Extraction . CSharp . DependencyFetching
9
10
{
@@ -86,6 +87,39 @@ public struct RegistryConfig
86
87
result . Certificate = X509Certificate2 . CreateFromPem ( cert ) ;
87
88
}
88
89
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
+
89
123
return result ;
90
124
}
91
125
You can’t perform that action at this time.
0 commit comments