Skip to content

Commit d707b2a

Browse files
committed
internal/report: add YAML field "source"
Adds a new field, source, which holds metadata about the original source of the report. For now, it is either a CVE, a GHSA, or the Go team. This is not required and is not published to OSV, but will assist in our automation efforts. Change-Id: Ief5ea6eca35d8799655b3a86e7a22cf8ff49d4e5 Reviewed-on: https://go-review.googlesource.com/c/vulndb/+/576999 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent bbf0d71 commit d707b2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+162
-27
lines changed

cmd/vulnreport/create.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"fmt"
1212
"strconv"
1313
"strings"
14+
"time"
1415

1516
"golang.org/x/vulndb/cmd/vulnreport/log"
1617
"golang.org/x/vulndb/internal/cveclient"
@@ -210,13 +211,7 @@ func reportFromAliases(ctx context.Context, id, modulePath string, aliases []str
210211
}
211212
} else {
212213
log.Infof("no alias found, creating basic report for %s", id)
213-
r = &report.Report{
214-
ID: id,
215-
Modules: []*report.Module{
216-
{
217-
Module: modulePath,
218-
},
219-
}}
214+
r = basicReport(id, modulePath)
220215
}
221216

222217
// Ensure all source aliases are added to the report.
@@ -248,6 +243,11 @@ func reportFromAliases(ctx context.Context, id, modulePath string, aliases []str
248243
}
249244
}
250245

246+
if r.Source != nil {
247+
now := time.Now()
248+
r.Source.Created = &now
249+
}
250+
251251
return r, nil
252252
}
253253

@@ -344,6 +344,9 @@ func basicReport(id, modulePath string) *report.Report {
344344
Module: modulePath,
345345
},
346346
},
347+
Source: &report.Source{
348+
ID: report.SourceGoTeam,
349+
},
347350
}
348351
}
349352

internal/genericosv/report.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ func (osv *Entry) ToReport(goID string, pc *proxy.Client) *report.Report {
2828
ID: goID,
2929
Summary: report.Summary(osv.Summary),
3030
Description: report.Description(osv.Details),
31+
Source: &report.Source{
32+
ID: osv.ID,
33+
},
3134
}
3235
addAlias := func(alias string) {
3336
switch {

internal/genericosv/testdata/yaml/GHSA-28r2-q6m8-9hpx.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ references:
4040
- web: https://github.com/hashicorp/go-getter/releases
4141
notes:
4242
- lint: 'summary: too long (found 115 characters, want <=100)'
43+
source:
44+
id: GHSA-28r2-q6m8-9hpx

internal/genericosv/testdata/yaml/GHSA-33m6-q9v5-62r7.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ notes:
5959
- lint: 'modules[0] "github.com/apptainer/sif": 2 versions do not exist: 1.2.1-0.20180103161547-0ef6afb2f6cd, 1.2.1-0.20180404165556-75cca531ea76'
6060
- lint: 'modules[1] "github.com/satori/go.uuid": vulnerable_at: 1.2.0 is not inside vulnerable range'
6161
- lint: 'summary: must begin with a capital letter'
62+
source:
63+
id: GHSA-33m6-q9v5-62r7

internal/genericosv/testdata/yaml/GHSA-3hwm-922r-47hw.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ references:
2222
- web: https://github.com/42Atomys/stud42/commit/a70bfc72fba721917bf681d72a58093fb9deee17
2323
notes:
2424
- lint: 'modules[0] "atomys.codes/stud42": version 0.23.0 does not exist'
25+
source:
26+
id: GHSA-3hwm-922r-47hw

internal/genericosv/testdata/yaml/GHSA-3wq5-3f56-v5xc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ references:
2727
notes:
2828
- lint: 'modules[0] "github.com/mattermost/mattermost-server": 6 versions do not exist: 7.1.0, 7.1.6, 7.7.0, 7.7.2, 7.8.0, 7.8.1'
2929
- lint: 'modules[1] "github.com/mattermost/mattermost-server/v6": version 7.1.6 does not exist'
30+
source:
31+
id: GHSA-3wq5-3f56-v5xc

internal/genericosv/testdata/yaml/GHSA-54q4-74p3-mgcw.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ notes:
2121
- lint: 'modules[0] "github.com/zhaojh329/rttys": unsupported_versions: found 1 (want none)'
2222
- lint: 'modules[0] "github.com/zhaojh329/rttys": version 4.0.0 does not exist'
2323
- lint: 'summary: must begin with a capital letter'
24+
source:
25+
id: GHSA-54q4-74p3-mgcw

internal/genericosv/testdata/yaml/GHSA-5m6c-jp6f-2vcv.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ references:
2222
notes:
2323
- lint: 'description: possible markdown formatting (found ### )'
2424
- lint: 'modules[0] "github.com/oauth2-proxy/oauth2-proxy": 2 versions do not exist: 5.1.1, 6.0.0'
25+
source:
26+
id: GHSA-5m6c-jp6f-2vcv

internal/genericosv/testdata/yaml/GHSA-627p-rr78-99rj.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@ notes:
7171
- lint: 'modules[0] "github.com/concourse/concourse": 4 versions do not exist: 6.3.0, 6.3.1, 6.4.0, 6.4.1'
7272
- lint: 'modules[1] "github.com/concourse/dex": 4 versions do not exist: 6.3.0, 6.3.1, 6.4.0, 6.4.1'
7373
- lint: 'summary: too long (found 115 characters, want <=100)'
74+
source:
75+
id: GHSA-627p-rr78-99rj

internal/genericosv/testdata/yaml/GHSA-66p8-j459-rq63.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@ notes:
4646
- lint: 'description: possible markdown formatting (found [`GHSA-p8r3-83r8-jwj5`](https://github.com/pterodactyl/wings/security/advisories/GHSA-p8r3-83r8-jwj5))'
4747
- lint: 'description: possible markdown formatting (found `GHSA-p8r3-83r8-jwj5`)'
4848
- lint: 'summary: too long (found 163 characters, want <=100)'
49+
source:
50+
id: GHSA-66p8-j459-rq63

0 commit comments

Comments
 (0)