internal/worker: improve issue template
Change-Id: I9580828d3bb06d25812285b7a657c11d13fbe9f8
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/372183
Trust: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
diff --git a/internal/worker/worker.go b/internal/worker/worker.go
index 3c24a27..f2c40b3 100644
--- a/internal/worker/worker.go
+++ b/internal/worker/worker.go
@@ -263,10 +263,11 @@
}
err := issueTemplate.Execute(&b, issueTemplateData{
Heading: fmt.Sprintf(
- "One or more of the reference URLs in [%s](%s/tree/%s/%s) refers to a Go module.",
- r.ID, gitrepo.CVEListRepoURL, r.CommitHash, r.Path),
+ "In [%s](%s/tree/%s/%s), the reference URL [%s](%s) (and possibly others) refers to something in Go.",
+ r.ID, gitrepo.CVEListRepoURL, r.CommitHash, r.Path, r.Module, r.Module),
Description: desc,
CVERecord: r,
+ Pre: "```",
})
if err != nil {
return "", err
@@ -277,12 +278,14 @@
type issueTemplateData struct {
Heading string
Description string
+ Pre string // markdown string for a <pre> block
*store.CVERecord
}
var issueTemplate = template.Must(template.New("issue").Parse(`
-{{.Heading}}
+{{- .Heading}}
+{{.Pre}}
module: {{.Module}}
package:
stdlib:
@@ -302,4 +305,5 @@
pr:
context:
-
+{{.Pre}}
`))
diff --git a/internal/worker/worker_test.go b/internal/worker/worker_test.go
index 03f8220..58c1585 100644
--- a/internal/worker/worker_test.go
+++ b/internal/worker/worker_test.go
@@ -160,29 +160,29 @@
if err != nil {
t.Fatal(err)
}
- want := `
- One or more of the reference URLs in [ID1](https://github.com/CVEProject/cvelist/tree//) refers to a Go module.
+ want := `In [ID1](https://github.com/CVEProject/cvelist/tree//), the reference URL [aModule](aModule) (and possibly others) refers to something in Go.
- module: aModule
- package:
- stdlib:
- versions:
- - introduced:
- - fixed:
- description: |
- a description
+` + "```" + `
+module: aModule
+package:
+stdlib:
+versions:
+ - introduced:
+ - fixed:
+description: |
+ a description
- cve: ID1
- credit:
- symbols:
- -
- published:
- links:
- commit:
- pr:
- context:
- -
-`
+cve: ID1
+credit:
+symbols:
+ -
+published:
+links:
+ commit:
+ pr:
+ context:
+ -
+` + "```\n"
if diff := cmp.Diff(unindent(want), got); diff != "" {
t.Errorf("mismatch (-want, +got):\n%s", diff)
}