Commit 7f5e83a69e

7f5e83a69eeffefd78652707c86e154f65621325

parent: d189296142

Verified · cmc ci/build: success ci/quality: success ci/test: success ci/vuln: success

cmc <hello@cleberg.net> · 2026-11-01 08:36 UTC

Dependency advisories: match imported packages, and dismissal

- A Go advisory whose OSV record names packages counts only when a Go
  file at the checked commit imports one of them, tests included,
  vendor and testdata left out. The files are read only when such an
  advisory matched. The rest are stored as not imported and named in
  the issue.
- repo deps dismiss <repo> <advisory>... --reason
  not-affected|wont-fix|dev-only, and repo deps reopen, by advisory id
  (migration 0084). Either rewrites the issue at once.
- The issue lists open advisories, counts dismissed ones, and closes
  when none are open. repo deps status and the settings page show the
  open, dismissed and not imported ones; the page can dismiss and
  reopen.

Closes #345

Layout: unified · split

.gitbay/wiki/Architecture/06-Data-and-Cryptography.org +1 −1
@@ -19,7 +19,7 @@ content (as confidential as the repository), *O* operational.
1919| Notifications | =notifications= (mail queue), =inbox=, =push_devices= (APNs token), =push_queue=, =mail_replies= (Message-IDs of posted replies) | P | device tokens sealed; looked up by SHA-256 |
2020| Signatures | =commit_signatures=, =settings.key_epoch= | O | verification cache |
2121| Audit and feed | =audit_log=, =events= | O, P | actor ids, pruned argv, fingerprints and IPs in some audit rows, a hash chain (=prev_hash=, =hash=) |
22| Dependencies | =dep_checks=, =dep_reports=, =dep_advisories= | O |
22| Dependencies | =dep_checks=, =dep_reports=, =dep_advisories=, =dep_advisory_dismissals= | O |
2323| Code scanning | =security_scans=, =security_findings=, =security_dismissals= | O | |
2424
2525Outside the database:
.gitbay/wiki/Parity.org +9
@@ -253,6 +253,7 @@ there shows the app's rendering rather than the one the web page shows.
253253| code scan ignores, rules | yes | yes | no |
254254| dependency checks on/off | yes | yes | yes |
255255| dependency status | yes | yes | yes |
256| advisory dismiss, reopen | yes | yes | no |
256257| delete, transfer | yes | yes | yes |
257258| rename | yes | yes | yes |
258259| release delete | yes | yes | yes |
@@ -295,6 +296,14 @@ under the toggle — last check, last error, the two tracking issues, and
295296the rows. The issues the worker opens, rewrites and closes are still the
296297copies every other surface reads.
297298
299A Go advisory whose OSV record names packages counts only when a Go
300file at the checked commit (tests included, =vendor= and =testdata=
301left out) imports one of them; the rest are listed as not imported.
302Imports through another module are not seen, which =govulncheck=
303covers. A writer can dismiss an advisory (=repo deps dismiss=, reason
304=not-affected=, =wont-fix= or =dev-only=) and reopen it; the issue
305lists open advisories only and closes when none are left.
306
298307The wiki row covers reading. A wiki lives at =.gitbay/wiki/= on the
299308default branch, so editing one is editing a file in the repository —
300309a push, or =repo commit-file= — and there is no wiki-specific edit row
.gitbay/wiki/Users.org +3
@@ -243,6 +243,9 @@ gitbay repo settings secret-scan-allow you/project 'testdata/**' # paths whose
243243gitbay repo secret-scan you/project # scan the whole history
244244gitbay repo security enable you/project # scheduled code scan, where the instance offers one
245245gitbay repo security status you/project # its findings, also kept in an issue
246gitbay repo deps status you/project # dependency updates and advisories
247gitbay repo deps dismiss you/project GO-2026-5932 --reason not-affected # or wont-fix, dev-only
248gitbay repo deps reopen you/project GO-2026-5932
246249gitbay repo security dismiss you/project 3f9a0c1d2e --reason false-positive # or wont-fix, test
247250gitbay repo security reopen you/project 3f9a0c1d2e
248251gitbay repo settings security-ignore you/project 'testdata/**' # paths set aside from the scan
cmd/gitbay/main.go +2
@@ -609,6 +609,8 @@ func repoCmd() *cobra.Command {
609609 pass("enable", passOpts{server: []string{"repo", "deps", "enable"}, needsRepo: true}),
610610 pass("disable", passOpts{server: []string{"repo", "deps", "disable"}, needsRepo: true}),
611611 pass("status", passOpts{server: []string{"repo", "deps", "status"}, needsRepo: true}),
612 pass("dismiss", passOpts{server: []string{"repo", "deps", "dismiss"}, needsRepo: true}),
613 pass("reopen", passOpts{server: []string{"repo", "deps", "reopen"}, needsRepo: true}),
612614 ),
613615 group("secret", "build secrets (values on stdin, injected into build env)",
614616 pass("set", passOpts{server: []string{"repo", "secret", "set"}, needsRepo: true, alwaysStdin: true, stdinWhat: "the secret value", stdinSecret: true}),
cmd/gitbay/summaries_gen.go +2
@@ -166,7 +166,9 @@ var summaries = map[string]string{
166166 "repo deploy-key list": "list deploy keys",
167167 "repo deploy-key remove": "remove a deploy key",
168168 "repo deps disable": "stop checking dependencies",
169 "repo deps dismiss": "dismiss dependency advisories, which then stay out of the issue",
169170 "repo deps enable": "check dependencies for updates and advisories",
171 "repo deps reopen": "take back dismissals of dependency advisories",
170172 "repo deps status": "show dependency check state",
171173 "repo diff": "the patch between two refs, from their merge base",
172174 "repo domain add": "claim a custom pages domain (verify with a DNS TXT record)",
internal/control/deps.go +140 −3
@@ -4,8 +4,11 @@ import (
44 "errors"
55 "fmt"
66 "io"
7 "slices"
78 "strconv"
9 "strings"
810
11 "gitbay.org/gitbay/internal/deps"
912 "gitbay.org/gitbay/internal/policy"
1013 "gitbay.org/gitbay/internal/protocol"
1114 "gitbay.org/gitbay/internal/store"
@@ -30,8 +33,24 @@ func init() {
3033 Usage: "repo deps status <owner/name>",
3134 Examples: []string{"repo deps status krz/gitbay"},
3235 ReadOnly: true, Run: runDepsStatus})
36 register(Command{Path: []string{"repo", "deps", "dismiss"},
37 Summary: "dismiss dependency advisories, which then stay out of the issue",
38 Usage: "repo deps dismiss <owner/name> <advisory>... --reason not-affected|wont-fix|dev-only",
39 Flags: []Flag{
40 {"--reason", "not-affected|wont-fix|dev-only", "why: does not apply, accepted, or only in development", ""},
41 },
42 Examples: []string{"repo deps dismiss krz/gitbay GO-2026-5932 --reason not-affected"},
43 Run: runDepsDismiss})
44 register(Command{Path: []string{"repo", "deps", "reopen"},
45 Summary: "take back dismissals of dependency advisories",
46 Usage: "repo deps reopen <owner/name> <advisory>...",
47 Examples: []string{"repo deps reopen krz/gitbay GO-2026-5932"},
48 Run: runDepsReopen})
3349}
3450
51// Reasons an advisory is dismissed for.
52var advisoryReasons = []string{"not-affected", "wont-fix", "dev-only"}
53
3554// DepsOut is what `repo deps status` emits: the check's state and what
3655// the last run found behind or matching an advisory. Named so the web
3756// decodes the same struct the command writes.
@@ -43,6 +62,11 @@ type DepsOut struct {
4362 AdvisoryIssueNumber int64 `json:"advisory_issue_number,omitempty"`
4463 Behind []DepBehind `json:"behind"`
4564 Advisories []DepAdvisory `json:"advisories"`
65 // Dismissed and NotImported are matching advisories left out of the
66 // issue: dismissed by a writer, or Go advisories for packages no file
67 // imports.
68 Dismissed []DepAdvisory `json:"dismissed"`
69 NotImported []DepAdvisory `json:"not_imported"`
4670}
4771
4872// DepBehind is one dependency with a newer release than the manifest pins.
@@ -62,6 +86,8 @@ type DepAdvisory struct {
6286 Summary string `json:"summary"`
6387 Severity string `json:"severity,omitempty"`
6488 Fixed string `json:"fixed,omitempty"`
89 Reason string `json:"reason,omitempty"`
90 By string `json:"dismissed_by,omitempty"`
6591}
6692
6793func runDepsEnable(c *Ctx, args []string) int {
@@ -127,15 +153,28 @@ func runDepsStatus(c *Ctx, args []string) int {
127153 if err != nil {
128154 return c.fail(protocol.ExitFailure, "%v", err)
129155 }
156 dismissed, err := c.Store.AdvisoryDismissals(repo.ID)
157 if err != nil {
158 return c.fail(protocol.ExitFailure, "%v", err)
159 }
130160 out := DepsOut{Enabled: true, LastCheck: check.LastCheck, LastError: check.LastError,
131161 IssueNumber: check.IssueNumber, AdvisoryIssueNumber: check.AdvisoryIssueNumber,
132 Behind: []DepBehind{}, Advisories: []DepAdvisory{}}
162 Behind: []DepBehind{}, Advisories: []DepAdvisory{}, Dismissed: []DepAdvisory{}, NotImported: []DepAdvisory{}}
133163 for _, r := range reports {
134164 out.Behind = append(out.Behind, DepBehind{r.Ecosystem, r.Name, r.Current, r.Latest})
135165 }
136166 for _, a := range advisories {
137 out.Advisories = append(out.Advisories,
138 DepAdvisory{a.Ecosystem, a.Name, a.Version, a.ID, a.Summary, a.Severity, a.Fixed})
167 o := DepAdvisory{Ecosystem: a.Ecosystem, Name: a.Name, Version: a.Version, ID: a.ID,
168 Summary: a.Summary, Severity: a.Severity, Fixed: a.Fixed}
169 switch d, ok := dismissed[a.ID]; {
170 case a.NotImported:
171 out.NotImported = append(out.NotImported, o)
172 case ok:
173 o.Reason, o.By = d.Reason, d.By
174 out.Dismissed = append(out.Dismissed, o)
175 default:
176 out.Advisories = append(out.Advisories, o)
177 }
139178 }
140179 return c.emitView(out, func(w io.Writer) {
141180 tracked, advised := "", ""
@@ -169,6 +208,22 @@ func runDepsStatus(c *Ctx, args []string) int {
169208 }
170209 tb.flush()
171210 }
211 if len(out.Dismissed) > 0 {
212 v.section("dismissed")
213 tb := c.table(w, "ADVISORY", "NAME", "REASON", "BY")
214 for _, a := range out.Dismissed {
215 tb.row(cText(a.ID), cRef(a.Name), cText(a.Reason), cText(a.By))
216 }
217 tb.flush()
218 }
219 if len(out.NotImported) > 0 {
220 v.section("not imported")
221 tb := c.table(w, "ADVISORY", "NAME", "VERSION")
222 for _, a := range out.NotImported {
223 tb.row(cText(a.ID), cRef(a.Name), cText(a.Version))
224 }
225 tb.flush()
226 }
172227 }, func() screen {
173228 state := []cell{cGlyph("ok"), cText("on")}
174229 if check.LastError != "" {
@@ -200,7 +255,89 @@ func runDepsStatus(c *Ctx, args []string) int {
200255 advised.rows = append(advised.rows, rowOf(cRef(a.Name), cMark(a.ID, sgrRed), cMeta(fix)))
201256 }
202257 s.sections = []section{behind, advised}
258 if len(out.Dismissed) > 0 {
259 gone := section{title: "Dismissed", n: len(out.Dismissed)}
260 for _, a := range out.Dismissed {
261 gone.rows = append(gone.rows, rowOf(cRef(a.Name), cText(a.ID), cState(a.Reason)))
262 }
263 s.sections = append(s.sections, gone)
264 }
265 if len(out.NotImported) > 0 {
266 aside := section{title: "Not imported", n: len(out.NotImported)}
267 for _, a := range out.NotImported {
268 aside.rows = append(aside.rows, rowOf(cRef(a.Name), cText(a.ID), cMeta(a.Version)))
269 }
270 s.sections = append(s.sections, aside)
271 }
203272 s.actions = []action{{"Deps", []string{"repo", "deps", "disable", repo.Path()}}}
273 if len(out.Advisories) > 0 {
274 s.actions = append(s.actions, action{"Deps", []string{"repo", "deps", "dismiss", repo.Path(), "<id>", "--reason", "<why>"}})
275 }
204276 return s
205277 })
206278}
279
280func runDepsDismiss(c *Ctx, args []string) int {
281 f, err := c.parseArgs(args, flagSpec{Values: []string{"--reason"}, MaxPos: -1, Usage: c.Cmd.Usage})
282 if err != nil {
283 return c.fail(protocol.ExitUsage, "%v", err)
284 }
285 if len(f.Pos) < 2 {
286 return c.usage()
287 }
288 reason := f.Value("--reason")
289 if !slices.Contains(advisoryReasons, reason) {
290 return c.fail(protocol.ExitUsage, "--reason is one of %s", strings.Join(advisoryReasons, ", "))
291 }
292 return changeAdvisoryDismissals(c, f.Pos[0], f.Pos[1:], func(repoID int64, ids []string) error {
293 return c.Store.DismissAdvisories(repoID, c.User.ID, ids, reason)
294 }, "dismissed")
295}
296
297func runDepsReopen(c *Ctx, args []string) int {
298 if len(args) < 2 {
299 return c.usage()
300 }
301 return changeAdvisoryDismissals(c, args[0], args[1:], c.Store.ReopenAdvisories, "reopened")
302}
303
304// changeAdvisoryDismissals checks advisory ids against the last check's
305// matches, applies change, and rewrites the issue to match. Writers may do
306// it, as for code scanning.
307func changeAdvisoryDismissals(c *Ctx, name string, ids []string, change func(int64, []string) error, verb string) int {
308 repo, code := resolveRepo(c, name, policy.CanWrite)
309 if code >= 0 {
310 return code
311 }
312 if _, err := c.Store.DepCheckFor(repo.ID); errors.Is(err, store.ErrNotFound) {
313 return c.fail(protocol.ExitFailure, "dependency checks are off on %s (repo deps enable %s)", repo.Path(), repo.Path())
314 } else if err != nil {
315 return c.fail(protocol.ExitFailure, "%v", err)
316 }
317 matched, err := c.Store.ReportedAdvisories(repo.ID)
318 if err != nil {
319 return c.fail(protocol.ExitFailure, "%v", err)
320 }
321 var known []string
322 for _, a := range matched {
323 known = append(known, a.ID)
324 }
325 var unique []string
326 for _, id := range ids {
327 if !slices.Contains(known, id) {
328 return c.fail(protocol.ExitNotFound, "no advisory %q in the last check", id)
329 }
330 if !slices.Contains(unique, id) {
331 unique = append(unique, id)
332 }
333 }
334 if err := change(repo.ID, unique); err != nil {
335 return c.fail(protocol.ExitFailure, "%v", err)
336 }
337 if err := deps.MaintainAdvisories(c.Store, c.Cfg, repo, matched, true, func() error { return nil }); err != nil {
338 return c.fail(protocol.ExitFailure, "%v", err)
339 }
340 return c.emit(map[string]any{verb: unique}, func(w io.Writer) {
341 fmt.Fprintf(w, "%s %d on %s\n", verb, len(unique), repo.Path())
342 })
343}
internal/control/stage3repo_test.go +55
@@ -350,3 +350,58 @@ func TestRepoDepsStatusAdvisories(t *testing.T) {
350350 }
351351 checkLegend(t, out)
352352}
353
354// Dismissing an advisory takes it out of the issue and closes the issue
355// once none are open; one nothing imports is listed apart; reopening brings
356// a dismissed one back.
357func TestRepoDepsDismiss(t *testing.T) {
358 st, repo, u, root := browseFixture(t)
359 p := repo.Path()
360 dispatchIn(t, st, u, root, "", "repo", "deps", "enable", p)
361 matched := []store.DepAdvisory{
362 {Ecosystem: "go", Name: "golang.org/x/net", Version: "v0.1.0", ID: "GO-2026-1", Summary: "reset flood"},
363 {Ecosystem: "go", Name: "golang.org/x/crypto", Version: "v0.58.0", ID: "GO-2026-5932", Summary: "openpgp", NotImported: true},
364 }
365 if err := st.ReplaceDepAdvisories(repo.ID, matched); err != nil {
366 t.Fatal(err)
367 }
368 c, out := runnerCtx(st, u.ID, root)
369 if code := runDepsDismiss(c, []string{p, "GO-2026-1", "--reason", "nope"}); code != protocol.ExitUsage {
370 t.Errorf("bad reason: %d %s", code, out)
371 }
372 c, out = runnerCtx(st, u.ID, root)
373 if code := runDepsDismiss(c, []string{p, "GO-9", "--reason", "not-affected"}); code != protocol.ExitNotFound {
374 t.Errorf("unknown advisory: %d %s", code, out)
375 }
376 // Reopen first so there is an issue to watch: a reopen of nothing
377 // dismissed still rewrites it.
378 c, out = runnerCtx(st, u.ID, root)
379 if code := runDepsReopen(c, []string{p, "GO-2026-1"}); code != protocol.ExitOK {
380 t.Fatalf("reopen: %d %s", code, out)
381 }
382 check, _ := st.DepCheckFor(repo.ID)
383 issue, _ := st.IssueByNumber(repo.ID, check.AdvisoryIssueNumber)
384 if issue.State != "open" || !strings.Contains(issue.Body, "GO-2026-1:") || !strings.Contains(issue.Body, "imports: GO-2026-5932") {
385 t.Fatalf("issue (%s):\n%s", issue.State, issue.Body)
386 }
387 c, out = runnerCtx(st, u.ID, root)
388 if code := runDepsDismiss(c, []string{p, "GO-2026-1", "--reason", "not-affected"}); code != protocol.ExitOK {
389 t.Fatalf("dismiss: %d %s", code, out)
390 }
391 if closed, _ := st.IssueByNumber(repo.ID, check.AdvisoryIssueNumber); closed.State != "closed" {
392 t.Errorf("issue with nothing open is %s", closed.State)
393 }
394 var got struct {
395 Data DepsOut `json:"data"`
396 }
397 json.Unmarshal([]byte(dispatchIn(t, st, u, root, "", "repo", "deps", "status", p, "--json")), &got)
398 if len(got.Data.Advisories) != 0 || len(got.Data.Dismissed) != 1 || got.Data.Dismissed[0].Reason != "not-affected" ||
399 len(got.Data.NotImported) != 1 || got.Data.NotImported[0].ID != "GO-2026-5932" {
400 t.Errorf("status = %+v", got.Data)
401 }
402 screen := atTerminalIn(t, st, u, root, "repo", "deps", "status", p)
403 if !strings.Contains(screen, "Dismissed (1)") || !strings.Contains(screen, "Not imported (1)") {
404 t.Errorf("screen:\n%s", screen)
405 }
406 checkLegend(t, screen)
407}
internal/deps/imports.go added +83
@@ -0,0 +1,83 @@
1package deps
2
3import (
4 "context"
5 "go/parser"
6 "go/token"
7 "strconv"
8 "strings"
9
10 "gitbay.org/gitbay/internal/gitutil"
11 "gitbay.org/gitbay/internal/store"
12)
13
14// maxGoFiles bounds the Go files read for their imports. A repository with
15// more is not judged: its Go advisories are all reported.
16const maxGoFiles = 5000
17
18// GoImports returns the packages the Go files at sha import, tests
19// included, outside vendor and testdata. ok is false when they could not
20// all be read.
21func GoImports(ctx context.Context, dir, sha string) (map[string]bool, bool) {
22 entries, err := gitutil.ListBlobs(ctx, dir, sha)
23 if err != nil {
24 return nil, false
25 }
26 var shas []string
27 for _, e := range entries {
28 if !strings.HasSuffix(e.Name, ".go") || underAny(e.Name, "vendor", "testdata") {
29 continue
30 }
31 shas = append(shas, e.SHA)
32 }
33 if len(shas) > maxGoFiles {
34 return nil, false
35 }
36 out := map[string]bool{}
37 fset := token.NewFileSet()
38 err = gitutil.CatBlobs(ctx, dir, shas, func(_ int, data []byte) bool {
39 f, err := parser.ParseFile(fset, "", data, parser.ImportsOnly)
40 if err != nil {
41 return true // a file that does not parse does not build either
42 }
43 for _, imp := range f.Imports {
44 if p, err := strconv.Unquote(imp.Path.Value); err == nil {
45 out[p] = true
46 }
47 }
48 return true
49 })
50 if err != nil {
51 return nil, false
52 }
53 return out, true
54}
55
56func underAny(path string, dirs ...string) bool {
57 for _, part := range strings.Split(path, "/") {
58 for _, d := range dirs {
59 if part == d {
60 return true
61 }
62 }
63 }
64 return false
65}
66
67// MarkNotImported sets NotImported on each Go advisory that names packages
68// none of which imported holds.
69func MarkNotImported(matched []store.DepAdvisory, imported map[string]bool) {
70 for i, a := range matched {
71 if a.Ecosystem != EcoGo || len(a.Imports) == 0 {
72 continue
73 }
74 used := false
75 for _, p := range a.Imports {
76 if imported[p] {
77 used = true
78 break
79 }
80 }
81 matched[i].NotImported = !used
82 }
83}
internal/deps/osv.go +24 −1
@@ -64,6 +64,11 @@ type osvVuln struct {
6464 Fixed string `json:"fixed"`
6565 } `json:"events"`
6666 } `json:"ranges"`
67 EcosystemSpecific struct {
68 Imports []struct {
69 Path string `json:"path"`
70 } `json:"imports"`
71 } `json:"ecosystem_specific"`
6772 } `json:"affected"`
6873 DatabaseSpecific struct {
6974 Severity string `json:"severity"`
@@ -98,7 +103,8 @@ func (c *Client) Advisories(ctx context.Context, found []Dep) ([]store.DepAdviso
98103 out = append(out, store.DepAdvisory{
99104 Ecosystem: d.Ecosystem, Name: d.Name, Version: d.Current, ID: v.ID,
100105 Summary: summarize(v), Severity: strings.ToLower(v.DatabaseSpecific.Severity),
101 Fixed: fixedAfter(v, osvEcosystems[d.Ecosystem], d.Name, d.Current),
106 Fixed: fixedAfter(v, osvEcosystems[d.Ecosystem], d.Name, d.Current),
107 Imports: importsOf(v, osvEcosystems[d.Ecosystem], d.Name),
102108 })
103109 }
104110 }
@@ -300,3 +306,20 @@ func fixedAfter(v osvVuln, ecosystem, name, current string) string {
300306 }
301307 return best
302308}
309
310// importsOf returns the packages of a module an advisory names, which Go
311// advisories carry and others do not.
312func importsOf(v osvVuln, ecosystem, name string) []string {
313 var out []string
314 for _, a := range v.Affected {
315 if a.Package.Ecosystem != ecosystem || a.Package.Name != name {
316 continue
317 }
318 for _, imp := range a.EcosystemSpecific.Imports {
319 if imp.Path != "" {
320 out = append(out, imp.Path)
321 }
322 }
323 }
324 return out
325}
internal/deps/osv_test.go +3 −2
@@ -55,7 +55,7 @@ func TestAdvisories(t *testing.T) {
5555 "affected":[{"package":{"ecosystem":"PyPI","name":"flask"},
5656 "ranges":[{"events":[{"introduced":"0"},{"fixed":"1.9.0"}]},{"events":[{"introduced":"2.0.0"},{"fixed":"2.3.2"}]},{"events":[{"introduced":"2.0.0"},{"fixed":"2.2.5"}]}]}]}`,
5757 "PYSEC-1": `{"id":"PYSEC-1","summary":"duplicate","aliases":["GHSA-aaaa"]}`,
58 "GO-2": `{"id":"GO-2","details":"First line.\nSecond line.","affected":[{"package":{"ecosystem":"Go","name":"golang.org/x/net"},"ranges":[{"events":[{"fixed":"0.7.0"}]}]}]}`,
58 "GO-2": `{"id":"GO-2","details":"First line.\nSecond line.","affected":[{"package":{"ecosystem":"Go","name":"golang.org/x/net"},"ranges":[{"events":[{"fixed":"0.7.0"}]}],"ecosystem_specific":{"imports":[{"path":"golang.org/x/net/http2"}]}}]}`,
5959 "GO-withdrawn": `{"id":"GO-withdrawn","withdrawn":"2026-01-01T00:00:00Z"}`,
6060 "GHSA-vapor": `{"id":"GHSA-vapor","summary":"no fix"}`,
6161 })
@@ -73,7 +73,8 @@ func TestAdvisories(t *testing.T) {
7373 if len(got) != 3 {
7474 t.Fatalf("advisories = %+v, want GO-2, GHSA-aaaa once, GHSA-vapor", got)
7575 }
76 if a := got[0]; a.ID != "GO-2" || a.Summary != "First line." || a.Fixed != "0.7.0" || a.Severity != "" {
76 if a := got[0]; a.ID != "GO-2" || a.Summary != "First line." || a.Fixed != "0.7.0" || a.Severity != "" ||
77 strings.Join(a.Imports, " ") != "golang.org/x/net/http2" {
7778 t.Errorf("go advisory = %+v", a)
7879 }
7980 // The alias is folded in, the summary's whitespace collapsed, and the
internal/deps/report.go +80 −12
@@ -5,6 +5,8 @@ import (
55 "sort"
66 "strings"
77
8 "gitbay.org/gitbay/internal/botissue"
9 "gitbay.org/gitbay/internal/config"
810 "gitbay.org/gitbay/internal/store"
911)
1012
@@ -53,15 +55,25 @@ func Body(branch string, reports []store.DepReport) string {
5355 return b.String()
5456}
5557
58// AdvisoryReport is what the advisories issue says: the advisories still
59// open, how many were dismissed, and the Go ones set aside because no file
60// imports the packages they name.
61type AdvisoryReport struct {
62 Repo, Branch string
63 Open []store.DepAdvisory
64 Dismissed int
65 NotImported []store.DepAdvisory
66}
67
5668// AdvisoryBody renders the advisories issue: a table per ecosystem, then
5769// each advisory's summary and link, which would make the table too wide to
58// read as plain text.
59func AdvisoryBody(branch string, matched []store.DepAdvisory) string {
70// read as plain text, then what is not listed.
71func AdvisoryBody(r AdvisoryReport) string {
6072 var b strings.Builder
6173 fmt.Fprintf(&b, "Dependencies resolved on `%s` match published advisories. "+
62 "This issue is kept up to date as that changes, and closed once none match.\n", branch)
74 "This issue is kept up to date as that changes, and closed once none are open.\n", r.Branch)
6375 byEco := map[string][]store.DepAdvisory{}
64 for _, a := range matched {
76 for _, a := range r.Open {
6577 byEco[a.Ecosystem] = append(byEco[a.Ecosystem], a)
6678 }
6779 for _, eco := range order {
@@ -76,18 +88,73 @@ func AdvisoryBody(branch string, matched []store.DepAdvisory) string {
7688 }
7789 b.WriteString(table(cells))
7890 }
79 b.WriteString("\n### Advisories\n\n")
80 seen := map[string]bool{}
81 for _, a := range matched {
82 if seen[a.ID] {
83 continue
91 if len(r.Open) > 0 {
92 b.WriteString("\n### Advisories\n\n")
93 seen := map[string]bool{}
94 for _, a := range r.Open {
95 if seen[a.ID] {
96 continue
97 }
98 seen[a.ID] = true
99 fmt.Fprintf(&b, "- %s: %s https://osv.dev/vulnerability/%s\n", a.ID, a.Summary, a.ID)
100 }
101 }
102 var notListed []string
103 if r.Dismissed > 0 {
104 notListed = append(notListed, fmt.Sprintf("%d dismissed", r.Dismissed))
105 }
106 if len(r.NotImported) > 0 {
107 var ids []string
108 for _, a := range r.NotImported {
109 ids = append(ids, fmt.Sprintf("%s (`%s`)", a.ID, a.Name))
84110 }
85 seen[a.ID] = true
86 fmt.Fprintf(&b, "- %s: %s https://osv.dev/vulnerability/%s\n", a.ID, a.Summary, a.ID)
111 notListed = append(notListed, "for Go packages no file here imports: "+strings.Join(ids, ", "))
112 }
113 if len(notListed) > 0 {
114 fmt.Fprintf(&b, "\nNot listed: %s. Imports through another module are not seen here. `repo deps status %s` shows them.\n",
115 strings.Join(notListed, "; "), r.Repo)
116 }
117 if len(r.Open) > 0 {
118 fmt.Fprintf(&b, "\nTo dismiss one: `repo deps dismiss %s <advisory> --reason not-affected|wont-fix|dev-only`.\n", r.Repo)
87119 }
88120 return b.String()
89121}
90122
123// MaintainAdvisories brings the advisories issue in line with a matching
124// set: the open ones listed, the dismissed and not imported ones counted,
125// closed when none are open.
126func MaintainAdvisories(st *store.Store, cfg config.Config, repo store.Repo, matched []store.DepAdvisory,
127 changed bool, save func() error) error {
128 check, err := st.DepCheckFor(repo.ID)
129 if err != nil {
130 return err
131 }
132 dismissed, err := st.AdvisoryDismissals(repo.ID)
133 if err != nil {
134 return err
135 }
136 r := AdvisoryReport{Repo: repo.Path(), Branch: repo.DefaultBranch}
137 for _, a := range matched {
138 switch {
139 case a.NotImported:
140 r.NotImported = append(r.NotImported, a)
141 case dismissed[a.ID].ID != "":
142 r.Dismissed++
143 default:
144 r.Open = append(r.Open, a)
145 }
146 }
147 return botissue.Maintain(st, cfg, repo, botissue.Tracked{
148 Title: AdvisoryTitle,
149 Number: check.AdvisoryIssueNumber,
150 Record: func(n int64) error { return st.SetDepAdvisoryIssue(repo.ID, n) },
151 Empty: len(r.Open) == 0,
152 Changed: changed,
153 Save: save,
154 Body: func() string { return AdvisoryBody(r) },
155 })
156}
157
91158// table pads every cell to its column, because the body is read twice: as
92159// a rendered table on the web, where the padding is ignored, and as the
93160// plain text of the notification mail, where it is the only thing keeping
@@ -145,7 +212,8 @@ func sameAdvisories(a, b []store.DepAdvisory) bool {
145212 }
146213 for i := range a {
147214 if a[i].Ecosystem != b[i].Ecosystem || a[i].Name != b[i].Name ||
148 a[i].Version != b[i].Version || a[i].ID != b[i].ID || a[i].Fixed != b[i].Fixed {
215 a[i].Version != b[i].Version || a[i].ID != b[i].ID || a[i].Fixed != b[i].Fixed ||
216 a[i].NotImported != b[i].NotImported {
149217 return false
150218 }
151219 }
internal/deps/report_test.go +21 −2
@@ -43,17 +43,36 @@ func TestBodyAlignsColumns(t *testing.T) {
4343}
4444
4545func TestAdvisoryBody(t *testing.T) {
46 body := AdvisoryBody("main", []store.DepAdvisory{
46 body := AdvisoryBody(AdvisoryReport{Repo: "krz/x", Branch: "main", Open: []store.DepAdvisory{
4747 {Ecosystem: EcoGo, Name: "golang.org/x/net", Version: "v0.1.0", ID: "GO-2", Summary: "HTTP/2 reset", Severity: "", Fixed: "0.7.0"},
4848 {Ecosystem: EcoPyPI, Name: "flask", Version: "2.0.0", ID: "GHSA-aaaa", Summary: "cookie leak", Severity: "high", Fixed: "2.2.5"},
49 })
49 }, Dismissed: 2, NotImported: []store.DepAdvisory{{Ecosystem: EcoGo, Name: "golang.org/x/crypto", ID: "GO-3"}}})
5050 for _, want := range []string{
5151 "| `golang.org/x/net` | v0.1.0 | GO-2 | | 0.7.0 |",
5252 "- GHSA-aaaa: cookie leak https://osv.dev/vulnerability/GHSA-aaaa",
5353 "### PyPI",
54 "Not listed: 2 dismissed; for Go packages no file here imports: GO-3 (`golang.org/x/crypto`).",
55 "repo deps dismiss krz/x <advisory>",
5456 } {
5557 if !strings.Contains(body, want) {
5658 t.Errorf("body missing %q:\n%s", want, body)
5759 }
5860 }
5961}
62
63// An advisory naming packages is set aside unless one of them is imported;
64// one naming none, or of another ecosystem, is left alone.
65func TestMarkNotImported(t *testing.T) {
66 matched := []store.DepAdvisory{
67 {Ecosystem: EcoGo, ID: "GO-1", Imports: []string{"golang.org/x/crypto/openpgp", "golang.org/x/crypto/openpgp/armor"}},
68 {Ecosystem: EcoGo, ID: "GO-2", Imports: []string{"golang.org/x/crypto/ssh"}},
69 {Ecosystem: EcoGo, ID: "GO-3"},
70 {Ecosystem: EcoNPM, ID: "GHSA-1", Imports: []string{"x"}},
71 }
72 MarkNotImported(matched, map[string]bool{"golang.org/x/crypto/ssh": true})
73 for i, want := range []bool{true, false, false, false} {
74 if matched[i].NotImported != want {
75 t.Errorf("%s: NotImported = %v", matched[i].ID, matched[i].NotImported)
76 }
77 }
78}
internal/deps/worker.go +15 −15
@@ -105,7 +105,7 @@ func (w *Worker) check(ctx context.Context, repo store.Repo) error {
105105 }
106106 return errors.Join(
107107 w.checkUpdates(ctx, repo, Scan(read)),
108 w.checkAdvisories(ctx, repo, Resolved(read, root)),
108 w.checkAdvisories(ctx, repo, dir, sha, Resolved(read, root)),
109109 )
110110}
111111
@@ -120,7 +120,10 @@ func (w *Worker) checkUpdates(ctx context.Context, repo store.Repo, found []Dep)
120120 return w.reconcile(repo, behind)
121121}
122122
123func (w *Worker) checkAdvisories(ctx context.Context, repo store.Repo, resolved []Dep) error {
123// checkAdvisories matches the resolved set against OSV. A Go advisory that
124// names packages counts only if a Go file at sha imports one of them; the
125// files are read only when such an advisory matched.
126func (w *Worker) checkAdvisories(ctx context.Context, repo store.Repo, dir, sha string, resolved []Dep) error {
124127 if len(resolved) == 0 {
125128 return w.reconcileAdvisories(repo, nil)
126129 }
@@ -128,6 +131,14 @@ func (w *Worker) checkAdvisories(ctx context.Context, repo store.Repo, resolved
128131 if err != nil {
129132 return fmt.Errorf("advisories: %w", err)
130133 }
134 for _, a := range matched {
135 if a.Ecosystem == EcoGo && len(a.Imports) > 0 {
136 if imported, ok := GoImports(ctx, dir, sha); ok {
137 MarkNotImported(matched, imported)
138 }
139 break
140 }
141 }
131142 return w.reconcileAdvisories(repo, matched)
132143}
133144
@@ -203,21 +214,10 @@ func (w *Worker) reconcile(repo store.Repo, behind []store.DepReport) error {
203214// reconcileAdvisories brings the advisories issue in line with what
204215// matches.
205216func (w *Worker) reconcileAdvisories(repo store.Repo, matched []store.DepAdvisory) error {
206 check, err := w.St.DepCheckFor(repo.ID)
207 if err != nil {
208 return err
209 }
210217 previous, err := w.St.ReportedAdvisories(repo.ID)
211218 if err != nil {
212219 return err
213220 }
214 return botissue.Maintain(w.St, w.Cfg, repo, botissue.Tracked{
215 Title: AdvisoryTitle,
216 Number: check.AdvisoryIssueNumber,
217 Record: func(n int64) error { return w.St.SetDepAdvisoryIssue(repo.ID, n) },
218 Empty: len(matched) == 0,
219 Changed: !sameAdvisories(previous, matched),
220 Save: func() error { return w.St.ReplaceDepAdvisories(repo.ID, matched) },
221 Body: func() string { return AdvisoryBody(repo.DefaultBranch, matched) },
222 })
221 return MaintainAdvisories(w.St, w.Cfg, repo, matched, !sameAdvisories(previous, matched),
222 func() error { return w.St.ReplaceDepAdvisories(repo.ID, matched) })
223223}
internal/deps/worker_test.go +71
@@ -2,6 +2,8 @@ package deps
22
33import (
44 "context"
5 "os"
6 "os/exec"
57 "path/filepath"
68 "strings"
79 "testing"
@@ -271,3 +273,72 @@ func TestReconcileAdvisoriesKeepsItsOwnIssue(t *testing.T) {
271273 t.Errorf("advisories left behind: %v", left)
272274 }
273275}
276
277// A Go advisory for packages nothing imports opens no issue, and one
278// alongside an open advisory is counted rather than listed.
279func TestReconcileAdvisoriesNotImported(t *testing.T) {
280 w, repo := testWorker(t)
281 aside := store.DepAdvisory{Ecosystem: EcoGo, Name: "golang.org/x/crypto", Version: "v0.58.0",
282 ID: "GO-2026-5932", Summary: "openpgp is unmaintained", NotImported: true}
283 if err := w.reconcileAdvisories(repo, []store.DepAdvisory{aside}); err != nil {
284 t.Fatal(err)
285 }
286 if check, _ := w.St.DepCheckFor(repo.ID); check.AdvisoryIssueNumber != 0 {
287 t.Fatalf("opened #%d for an advisory nothing imports", check.AdvisoryIssueNumber)
288 }
289 if kept, _ := w.St.ReportedAdvisories(repo.ID); len(kept) != 1 || !kept[0].NotImported {
290 t.Fatalf("stored %+v", kept)
291 }
292 open := store.DepAdvisory{Ecosystem: EcoGo, Name: "golang.org/x/net", Version: "v0.1.0", ID: "GO-2", Summary: "reset"}
293 if err := w.reconcileAdvisories(repo, []store.DepAdvisory{aside, open}); err != nil {
294 t.Fatal(err)
295 }
296 check, _ := w.St.DepCheckFor(repo.ID)
297 issue, _ := w.St.IssueByNumber(repo.ID, check.AdvisoryIssueNumber)
298 if !strings.Contains(issue.Body, "GO-2:") || strings.Contains(issue.Body, "- GO-2026-5932:") ||
299 !strings.Contains(issue.Body, "no file here imports: GO-2026-5932") {
300 t.Errorf("issue:\n%s", issue.Body)
301 }
302}
303
304// GoImports reads every Go file's imports, tests included, and leaves out
305// vendor and testdata.
306func TestGoImports(t *testing.T) {
307 dir := t.TempDir()
308 run := func(args ...string) string {
309 t.Helper()
310 cmd := exec.Command("git", args...)
311 cmd.Dir = dir
312 cmd.Env = append(os.Environ(), "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null",
313 "GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@example.test", "GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@example.test")
314 out, err := cmd.CombinedOutput()
315 if err != nil {
316 t.Fatalf("git %v: %v\n%s", args, err, out)
317 }
318 return strings.TrimSpace(string(out))
319 }
320 files := map[string]string{
321 "main.go": "package main\n\nimport (\n\t\"fmt\"\n\tx \"golang.org/x/crypto/ssh\"\n)\n",
322 "a_test.go": "package main\n\nimport \"golang.org/x/net/html\"\n",
323 "vendor/v/v.go": "package v\n\nimport \"golang.org/x/crypto/openpgp\"\n",
324 "testdata/t.go": "package t\n\nimport \"golang.org/x/crypto/openpgp/armor\"\n",
325 "broken.go": "this is not go",
326 }
327 for name, body := range files {
328 os.MkdirAll(filepath.Join(dir, filepath.Dir(name)), 0o755)
329 os.WriteFile(filepath.Join(dir, name), []byte(body), 0o644)
330 }
331 run("init", "-q", "-b", "main")
332 run("add", ".")
333 run("commit", "-q", "-m", "x")
334 got, ok := GoImports(context.Background(), dir, run("rev-parse", "HEAD"))
335 if !ok {
336 t.Fatal("not ok")
337 }
338 for p, want := range map[string]bool{"fmt": true, "golang.org/x/crypto/ssh": true, "golang.org/x/net/html": true,
339 "golang.org/x/crypto/openpgp": false, "golang.org/x/crypto/openpgp/armor": false} {
340 if got[p] != want {
341 t.Errorf("%s: %v", p, got[p])
342 }
343 }
344}
internal/httpd/depspage_test.go +28
@@ -74,3 +74,31 @@ func TestSettingsPageRendersSecurityTriage(t *testing.T) {
7474 }
7575 }
7676}
77
78// The advisories offer dismissal, the dismissed ones reopening, and the
79// ones nothing imports are named.
80func TestSettingsPageRendersAdvisoryTriage(t *testing.T) {
81 var sb strings.Builder
82 err := web.Render(&sb, "settings.html", settingsPage{
83 repoPage: testRepoPage(),
84 DepsEnabled: true,
85 Deps: control.DepsOut{
86 Enabled: true, LastCheck: "2026-11-01T04:02:00Z",
87 Advisories: []control.DepAdvisory{{Ecosystem: "go", Name: "golang.org/x/net", Version: "v0.1.0", ID: "GO-2026-1"}},
88 Dismissed: []control.DepAdvisory{{Ecosystem: "npm", Name: "undici", ID: "GHSA-x", Reason: "dev-only", By: "alice"}},
89 NotImported: []control.DepAdvisory{{Ecosystem: "go", Name: "golang.org/x/crypto", ID: "GO-2026-5932"}},
90 },
91 })
92 if err != nil {
93 t.Fatal(err)
94 }
95 page := sb.String()
96 for _, want := range []string{
97 `value="deps-dismiss"`, `name="advisory" value="GO-2026-1"`, `value="deps-reopen"`, `value="GHSA-x"`,
98 "dev-only", "by alice", "GO-2026-5932</a> (golang.org/x/crypto)",
99 } {
100 if !strings.Contains(page, want) {
101 t.Errorf("settings page does not show %q", want)
102 }
103 }
104}
internal/httpd/settings.go +4
@@ -169,6 +169,10 @@ func (s *Server) settingsSubmit(w http.ResponseWriter, r *http.Request, u store.
169169 verb = "enable"
170170 }
171171 argv = []string{"repo", "security", verb, repo}
172 case "deps-dismiss":
173 argv = []string{"repo", "deps", "dismiss", repo, v("advisory"), "--reason", v("reason")}
174 case "deps-reopen":
175 argv = []string{"repo", "deps", "reopen", repo, v("advisory")}
172176 case "security-dismiss":
173177 argv = []string{"repo", "security", "dismiss", repo, v("fingerprint"), "--reason", v("reason")}
174178 case "security-reopen":
internal/store/deps.go +75 −5
@@ -40,6 +40,12 @@ type DepAdvisory struct {
4040 Summary string
4141 Severity string
4242 Fixed string // the first release past Version that fixes it, if any
43 // NotImported marks a Go advisory whose packages no Go file in the
44 // repository imports; it is kept but not reported.
45 NotImported bool
46 // Imports are the packages the advisory names (Go), for deciding
47 // NotImported. Not stored.
48 Imports []string
4349}
4450
4551func (s *Store) EnableDepCheck(repoID int64) error {
@@ -166,7 +172,7 @@ func (s *Store) ReplaceDepReports(repoID int64, reports []DepReport) error {
166172
167173func (s *Store) ReportedAdvisories(repoID int64) ([]DepAdvisory, error) {
168174 rows, err := s.DB.Query(`
169 SELECT ecosystem, name, version, advisory_id, summary, severity, fixed FROM dep_advisories
175 SELECT ecosystem, name, version, advisory_id, summary, severity, fixed, not_imported FROM dep_advisories
170176 WHERE repo_id = ? ORDER BY ecosystem, name, version, advisory_id`, repoID)
171177 if err != nil {
172178 return nil, err
@@ -175,7 +181,7 @@ func (s *Store) ReportedAdvisories(repoID int64) ([]DepAdvisory, error) {
175181 var out []DepAdvisory
176182 for rows.Next() {
177183 var a DepAdvisory
178 if err := rows.Scan(&a.Ecosystem, &a.Name, &a.Version, &a.ID, &a.Summary, &a.Severity, &a.Fixed); err != nil {
184 if err := rows.Scan(&a.Ecosystem, &a.Name, &a.Version, &a.ID, &a.Summary, &a.Severity, &a.Fixed, &a.NotImported); err != nil {
179185 return nil, err
180186 }
181187 out = append(out, a)
@@ -196,11 +202,75 @@ func (s *Store) ReplaceDepAdvisories(repoID int64, advisories []DepAdvisory) err
196202 }
197203 for _, a := range advisories {
198204 if _, err := tx.Exec(`
199 INSERT INTO dep_advisories (repo_id, ecosystem, name, version, advisory_id, summary, severity, fixed)
200 VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
201 repoID, a.Ecosystem, a.Name, a.Version, a.ID, a.Summary, a.Severity, a.Fixed); err != nil {
205 INSERT INTO dep_advisories (repo_id, ecosystem, name, version, advisory_id, summary, severity, fixed, not_imported)
206 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
207 repoID, a.Ecosystem, a.Name, a.Version, a.ID, a.Summary, a.Severity, a.Fixed, a.NotImported); err != nil {
202208 return err
203209 }
204210 }
205211 return tx.Commit()
206212}
213
214// AdvisoryDismissal is an advisory a repository dismissed.
215type AdvisoryDismissal struct {
216 ID string
217 Reason string
218 By string // username, '' once the account is gone
219 CreatedAt string
220}
221
222// DismissAdvisories dismisses advisories by id, replacing the reason of
223// any already dismissed.
224func (s *Store) DismissAdvisories(repoID, byID int64, ids []string, reason string) error {
225 tx, err := s.DB.Begin()
226 if err != nil {
227 return err
228 }
229 defer tx.Rollback()
230 for _, id := range ids {
231 if _, err := tx.Exec(`
232 INSERT INTO dep_advisory_dismissals (repo_id, advisory_id, reason, by_id) VALUES (?, ?, ?, ?)
233 ON CONFLICT (repo_id, advisory_id) DO UPDATE SET reason = excluded.reason, by_id = excluded.by_id,
234 created_at = strftime('%Y-%m-%dT%H:%M:%fZ','now')`,
235 repoID, id, reason, byID); err != nil {
236 return err
237 }
238 }
239 return tx.Commit()
240}
241
242// ReopenAdvisories takes dismissals back.
243func (s *Store) ReopenAdvisories(repoID int64, ids []string) error {
244 tx, err := s.DB.Begin()
245 if err != nil {
246 return err
247 }
248 defer tx.Rollback()
249 for _, id := range ids {
250 if _, err := tx.Exec("DELETE FROM dep_advisory_dismissals WHERE repo_id = ? AND advisory_id = ?", repoID, id); err != nil {
251 return err
252 }
253 }
254 return tx.Commit()
255}
256
257// AdvisoryDismissals returns a repo's dismissals by advisory id.
258func (s *Store) AdvisoryDismissals(repoID int64) (map[string]AdvisoryDismissal, error) {
259 rows, err := s.DB.Query(`
260 SELECT d.advisory_id, d.reason, COALESCE(u.username, ''), d.created_at
261 FROM dep_advisory_dismissals d LEFT JOIN users u ON u.id = d.by_id
262 WHERE d.repo_id = ?`, repoID)
263 if err != nil {
264 return nil, err
265 }
266 defer rows.Close()
267 out := map[string]AdvisoryDismissal{}
268 for rows.Next() {
269 var d AdvisoryDismissal
270 if err := rows.Scan(&d.ID, &d.Reason, &d.By, &d.CreatedAt); err != nil {
271 return nil, err
272 }
273 out[d.ID] = d
274 }
275 return out, rows.Err()
276}
internal/store/migrations/0084_dep_advisory_dismissals.down.sql added +2
@@ -0,0 +1,2 @@
1ALTER TABLE dep_advisories DROP COLUMN not_imported;
2DROP TABLE dep_advisory_dismissals;
internal/store/migrations/0084_dep_advisory_dismissals.up.sql added +14
@@ -0,0 +1,14 @@
1-- An advisory a repository dismissed, by id, so it stays dismissed across
2-- checks. Kept while checks are off, as code scanning dismissals are.
3CREATE TABLE dep_advisory_dismissals (
4 repo_id INTEGER NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
5 advisory_id TEXT NOT NULL,
6 reason TEXT NOT NULL,
7 by_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
8 created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%fZ','now')),
9 PRIMARY KEY (repo_id, advisory_id)
10);
11
12-- A Go advisory naming packages none of the repository's Go files import.
13-- Kept so status can say what was set aside, but not reported.
14ALTER TABLE dep_advisories ADD COLUMN not_imported INTEGER NOT NULL DEFAULT 0;
internal/web/templates/settings.html +22 −2
@@ -308,15 +308,35 @@
308308{{end}}</table></div>
309309{{else}}<p class="none">Nothing behind{{if not .Deps.LastCheck}} — the first check has not run yet{{end}}.</p>{{end}}
310310{{if .Deps.Advisories}}<div class="tablewrap"><table class="keys">
311<tr class="cols"><th scope="col">dependency</th><th scope="col">version</th><th scope="col">advisory</th><th scope="col">fixed in</th></tr>
311<tr class="cols"><th scope="col">dependency</th><th scope="col">version</th><th scope="col">advisory</th><th scope="col">fixed in</th><th scope="col"><span class="vh">dismiss</span></th></tr>
312312{{range .Deps.Advisories}}<tr>
313313 <td class="mono">{{.Ecosystem}} {{.Name}}</td>
314314 <td class="mono">{{.Version}}</td>
315315 <td class="mono"><a href="https://osv.dev/vulnerability/{{.ID}}">{{.ID}}</a></td>
316316 <td class="mono">{{.Fixed}}</td>
317 <td><form method="post" action="{{$base}}" class="inline">
318 <input type="hidden" name="field" value="deps-dismiss">
319 <input type="hidden" name="advisory" value="{{.ID}}">
320 <select name="reason" aria-label="Reason"><option value="not-affected">Not affected</option><option value="wont-fix">Won't fix</option><option value="dev-only">Development only</option></select>
321 <button type="submit">Dismiss</button>
322 </form></td>
317323</tr>
318324{{end}}</table></div>
319{{else if .Deps.LastCheck}}<p class="none">No known advisories.</p>{{end}}
325{{else if .Deps.LastCheck}}<p class="none">No open advisories.</p>{{end}}
326{{if .Deps.NotImported}}<p class="meta">Not imported by any Go file here, so not reported:{{range .Deps.NotImported}} <a href="https://osv.dev/vulnerability/{{.ID}}">{{.ID}}</a> ({{.Name}}){{end}}. Imports through another module are not seen.</p>{{end}}
327{{if .Deps.Dismissed}}<h3>Dismissed advisories</h3><div class="tablewrap"><table class="keys">
328<tr class="cols"><th scope="col">dependency</th><th scope="col">advisory</th><th scope="col">reason</th><th scope="col"><span class="vh">reopen</span></th></tr>
329{{range .Deps.Dismissed}}<tr>
330 <td class="mono">{{.Ecosystem}} {{.Name}}</td>
331 <td class="mono"><a href="https://osv.dev/vulnerability/{{.ID}}">{{.ID}}</a></td>
332 <td>{{.Reason}}{{if .By}} <span class="meta">by {{.By}}</span>{{end}}</td>
333 <td><form method="post" action="{{$base}}" class="inline">
334 <input type="hidden" name="field" value="deps-reopen">
335 <input type="hidden" name="advisory" value="{{.ID}}">
336 <button type="submit">Reopen</button>
337 </form></td>
338</tr>
339{{end}}</table></div>{{end}}
320340{{end}}
321341</section>
322342