Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(osv): move aliases to related field #1047

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/advisory/osv.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ func BuildOSVDataset(_ context.Context, opts OSVOptions) error {
continue
}

// Note: The OSV data should include our advisory ID itself among the listed aliases.
aliases := append([]string{adv.ID}, adv.Aliases...)
// Note: The OSV data should include our advisory ID itself among the listed
// related vulnerability IDs.
related := append([]string{adv.ID}, adv.Aliases...)
Comment on lines +151 to +153

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
I just wanted to ask why you include the advisory's own ID in its related (or aliases) field.
It seems a bit odd to make a record link to itself, but it seem like an intentional decision?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was my understanding in the beginning to add that as is. maybe i got that wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it sounded like this was feedback from the OSV team — originally we didn't add in the ID itself to this collection. Happy to remove it if it's not needed! 🧹


affecteds := make([]models.Affected, 0, len(affectedPackages))
for _, pkg := range affectedPackages {
Expand All @@ -161,7 +162,7 @@ func BuildOSVDataset(_ context.Context, opts OSVOptions) error {

entry := models.Vulnerability{
ID: adv.ID,
Aliases: aliases,
Related: related,
Affected: affecteds,
Modified: advisoryLastUpdated,
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-37qj-pjrf-fmrw.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2022-09-15T02:40:18Z",
"id": "CGA-37qj-pjrf-fmrw",
"aliases": [
"related": [
"CGA-37qj-pjrf-fmrw",
"CVE-2020-8927"
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-5f5c-53mg-6p2v.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2023-05-04T14:34:34Z",
"id": "CGA-5f5c-53mg-6p2v",
"aliases": [
"related": [
"CGA-5f5c-53mg-6p2v",
"GHSA-33pg-m6jh-5237"
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-6mjr-v678-c6gm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2023-02-07T16:50:17Z",
"id": "CGA-6mjr-v678-c6gm",
"aliases": [
"related": [
"CGA-6mjr-v678-c6gm",
"CVE-2022-4450"
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-gg4h-ppqq-vf35.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2023-05-04T14:34:34Z",
"id": "CGA-gg4h-ppqq-vf35",
"aliases": [
"related": [
"CGA-gg4h-ppqq-vf35",
"GHSA-6wrf-mxfj-pf5p"
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-mm7m-x6cw-5fg4.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2023-04-08T16:32:54Z",
"id": "CGA-mm7m-x6cw-5fg4",
"aliases": [
"related": [
"CGA-mm7m-x6cw-5fg4",
"CVE-2023-0466"
],
Expand Down
2 changes: 1 addition & 1 deletion pkg/advisory/testdata/osv/expected/CGA-vj68-6p3f-8xmr.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"modified": "2023-03-28T14:54:27Z",
"id": "CGA-vj68-6p3f-8xmr",
"aliases": [
"related": [
"CGA-vj68-6p3f-8xmr",
"CVE-2023-0465"
],
Expand Down