|
5 | 5 | using Semmle.Util; |
6 | 6 | using Semmle.Util.Logging; |
7 | 7 | using Newtonsoft.Json; |
| 8 | +using System.Linq; |
8 | 9 |
|
9 | 10 | namespace Semmle.Extraction.CSharp.DependencyFetching |
10 | 11 | { |
@@ -37,7 +38,8 @@ public record class RegistryConfig(string Type, string URL); |
37 | 38 | /// </summary> |
38 | 39 | internal X509Certificate2? Certificate { get; private set; } |
39 | 40 |
|
40 | | - internal static DependabotProxy? GetDependabotProxy(ILogger logger, TemporaryDirectory tempWorkingDirectory) |
| 41 | + internal static DependabotProxy? GetDependabotProxy( |
| 42 | + ILogger logger, IDiagnosticsWriter diagnosticsWriter, TemporaryDirectory tempWorkingDirectory) |
41 | 43 | { |
42 | 44 | // Setting HTTP(S)_PROXY and SSL_CERT_FILE have no effect on Windows or macOS, |
43 | 45 | // but we would still end up using the Dependabot proxy to check for feed reachability. |
@@ -112,6 +114,23 @@ public record class RegistryConfig(string Type, string URL); |
112 | 114 | } |
113 | 115 | } |
114 | 116 |
|
| 117 | + // Emit a diagnostic for the discovered private registries, so that it is easy |
| 118 | + // for users to see that they were picked up. |
| 119 | + if (result.RegistryURLs.Count > 0) |
| 120 | + { |
| 121 | + diagnosticsWriter.AddEntry(new DiagnosticMessage( |
| 122 | + Language.CSharp, |
| 123 | + "buildless/analysis-using-private-registries", |
| 124 | + severity: DiagnosticMessage.TspSeverity.Note, |
| 125 | + visibility: new DiagnosticMessage.TspVisibility(true, true, true), |
| 126 | + name: "C# extraction used private package registries", |
| 127 | + markdownMessage: string.Format( |
| 128 | + "C# was extracted using the following private package registries:\n\n{0}\n", |
| 129 | + string.Join("\n", result.RegistryURLs.Select(url => string.Format("- `{0}`", url))) |
| 130 | + ) |
| 131 | + )); |
| 132 | + } |
| 133 | + |
115 | 134 | return result; |
116 | 135 | } |
117 | 136 |
|
|
0 commit comments