mirror of
https://github.com/github/codeql.git
synced 2026-02-11 20:51:06 +01:00
Add EmitPrivateRegistryUsed
This commit is contained in:
@@ -568,3 +568,24 @@ func EmitExtractionFailedForProjects(path []string) {
|
||||
noLocation,
|
||||
)
|
||||
}
|
||||
|
||||
func EmitPrivateRegistryUsed(writer DiagnosticsWriter, configs []string) {
|
||||
lines := []string{}
|
||||
|
||||
for i := range configs {
|
||||
lines = append(lines, fmt.Sprintf("* %s", configs[i]))
|
||||
}
|
||||
|
||||
emitDiagnosticTo(
|
||||
writer,
|
||||
"go/autobuilder/analysis-using-private-registries",
|
||||
"Go extraction used private package registries",
|
||||
fmt.Sprintf(
|
||||
"Go was extracted using the following private package registrie%s:\n\n%s\n",
|
||||
plural(len(lines), "", "s"),
|
||||
strings.Join(lines, "\n")),
|
||||
severityNote,
|
||||
fullVisibility,
|
||||
noLocation,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -83,3 +83,24 @@ func Test_EmitCannotFindPackages_Actions(t *testing.T) {
|
||||
// Custom build command suggestion
|
||||
assert.Contains(t, d.MarkdownMessage, "If any of the packages are already present in the repository")
|
||||
}
|
||||
|
||||
func Test_EmitPrivateRegistryUsed(t *testing.T) {
|
||||
writer := newMemoryDiagnosticsWriter()
|
||||
|
||||
testItems := []string{
|
||||
"* https://github.com/github/example (Git Source)",
|
||||
"* https://example.com/goproxy (GOPROXY Server)",
|
||||
}
|
||||
|
||||
EmitPrivateRegistryUsed(writer, testItems)
|
||||
|
||||
assert.Len(t, writer.diagnostics, 1, "Expected one diagnostic to be emitted")
|
||||
|
||||
d := writer.diagnostics[0]
|
||||
assert.Equal(t, d.Source.Id, "go/autobuilder/analysis-using-private-registries")
|
||||
assert.Equal(t, d.Severity, string(severityNote))
|
||||
|
||||
for i := range testItems {
|
||||
assert.Contains(t, d.MarkdownMessage, testItems[i])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user