Skip to content

Commit b377d1b

Browse files
MaineK00nCopilot
andcommitted
feat(extract/microsoft): derive Supersedes field from SupersededBy
- Add DeriveSupersedes to pkg/extract/microsoft/util, inverting SupersededBy to populate Supersedes at both KB-level and Update-level - Add Supersedes field to KB and Update types - Refactor bulletin, cvrf, msuc, wsusscn2 extractors to use DeriveSupersedes - msuc/wsusscn2 use a two-pass approach: write SupersededBy in pass 1, read all KB files and derive Supersedes in pass 2 - Add TestDeriveSupersedes covering KB-level, Update-level, edge cases Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 27a5cbe commit b377d1b

23 files changed

Lines changed: 535 additions & 41 deletions

File tree

pkg/extract/microsoft/bulletin/bulletin.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import (
3232
vulnerabilityContentTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/data/vulnerability/content"
3333
datasourceTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/datasource"
3434
repositoryTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/datasource/repository"
35-
sourceTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/source"
3635
microsoftkbTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/microsoftkb"
3736
microsoftkbSupersededByTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/microsoftkb/supersededby"
37+
sourceTypes "github.com/MaineK00n/vuls-data-update/pkg/extract/types/source"
3838
"github.com/MaineK00n/vuls-data-update/pkg/extract/util"
3939
utilgit "github.com/MaineK00n/vuls-data-update/pkg/extract/util/git"
4040
utiljson "github.com/MaineK00n/vuls-data-update/pkg/extract/util/json"
@@ -564,6 +564,7 @@ func (e extractor) extract(rows []bulletin.Bulletin) ([]dataTypes.Data, []micros
564564
},
565565
})
566566
}
567+
microsoftutil.DeriveSupersedes(kbs)
567568

568569
return datas, kbs, nil
569570
}

pkg/extract/microsoft/bulletin/testdata/golden/microsoftkb/4014xxx/4014329.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"products": [
55
"Adobe Flash Player on Windows 10 Version 1511 for x64-based Systems"
66
],
7+
"supersedes": [
8+
{
9+
"kb_id": "4010250"
10+
}
11+
],
712
"data_source": {
813
"id": "microsoft-bulletin",
914
"raws": [

pkg/extract/microsoft/bulletin/testdata/golden/microsoftkb/955xxx/955069.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"products": [
55
"Microsoft XML Core Services 3.0 on Microsoft Windows 2000 Service Pack 4"
66
],
7+
"supersedes": [
8+
{
9+
"kb_id": "936021"
10+
}
11+
],
712
"data_source": {
813
"id": "microsoft-bulletin",
914
"raws": [

pkg/extract/microsoft/cvrf/cvrf.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,9 @@ func (e extractor) extract(c cvrf.CVRF) ([]dataTypes.Data, []microsoftkbTypes.KB
307307
})
308308
}
309309

310-
return datas, slices.Collect(maps.Values(kbm)), nil
310+
kbs := slices.Collect(maps.Values(kbm))
311+
microsoftutil.DeriveSupersedes(kbs)
312+
return datas, kbs, nil
311313
}
312314
func collectProducts(pt cvrf.ProductTree) map[string]string {
313315
m := make(map[string]string)
@@ -2033,8 +2035,8 @@ func (e extractor) collectKBs(v cvrf.Vulnerability, products map[string]string,
20332035
// Mixed formats (e.g. "MS16-016, 3124280; MS16-097, 3178034") also exist;
20342036
// non-digit tokens (bulletin IDs) are filtered out by the isAllDigits check below.
20352037
var supKBIDs []string
2036-
for _, semiPart := range strings.Split(r.Supercedence, ";") {
2037-
for _, commaPart := range strings.Split(semiPart, ",") {
2038+
for semiPart := range strings.SplitSeq(r.Supercedence, ";") {
2039+
for commaPart := range strings.SplitSeq(semiPart, ",") {
20382040
supKBIDs = append(supKBIDs, strings.TrimSpace(commaPart))
20392041
}
20402042
}

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/3135xxx/3135456.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"Windows Server 2012 R2",
99
"Windows Server 2012 R2 (Server Core installation)"
1010
],
11+
"supersedes": [
12+
{
13+
"kb_id": "3087088"
14+
}
15+
],
1116
"data_source": {
1217
"id": "microsoft-cvrf",
1318
"raws": [

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/3147xxx/3147461.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
"products": [
55
"Windows 10 for x64-based Systems"
66
],
7+
"supersedes": [
8+
{
9+
"kb_id": "3140745"
10+
}
11+
],
712
"data_source": {
813
"id": "microsoft-cvrf",
914
"raws": [

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/5019xxx/5019964.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"Microsoft .NET Framework 3.5 AND 4.6.2/4.7/4.7.1/4.7.2 on Windows Server 2016",
88
"Microsoft .NET Framework 3.5 AND 4.6.2/4.7/4.7.1/4.7.2 on Windows Server 2016 (Server Core installation)"
99
],
10+
"supersedes": [
11+
{
12+
"kb_id": "5018411"
13+
}
14+
],
1015
"data_source": {
1116
"id": "microsoft-cvrf",
1217
"raws": [

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/5020xxx/5020687.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@
66
"Microsoft .NET Framework 4.8 on Windows 10 Version 21H2 for ARM64-based Systems",
77
"Microsoft .NET Framework 4.8 on Windows 10 Version 21H2 for x64-based Systems"
88
],
9+
"supersedes": [
10+
{
11+
"kb_id": "5017500"
12+
},
13+
{
14+
"kb_id": "5018545"
15+
},
16+
{
17+
"kb_id": "5018858"
18+
}
19+
],
920
"data_source": {
1021
"id": "microsoft-cvrf",
1122
"raws": [

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/5027xxx/5027536.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"Microsoft .NET Framework 3.5 AND 4.8 on Windows Server 2019",
99
"Microsoft .NET Framework 3.5 AND 4.8 on Windows Server 2019 (Server Core installation)"
1010
],
11+
"supersedes": [
12+
{
13+
"kb_id": "5022782"
14+
}
15+
],
1116
"data_source": {
1217
"id": "microsoft-cvrf",
1318
"raws": [

pkg/extract/microsoft/cvrf/testdata/golden/microsoftkb/5027xxx/5027543.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"Microsoft .NET Framework 3.0 Service Pack 2 on Windows Server 2008 for 32-bit Systems Service Pack 2",
88
"Microsoft .NET Framework 3.0 Service Pack 2 on Windows Server 2008 for x64-based Systems Service Pack 2"
99
],
10+
"supersedes": [
11+
{
12+
"kb_id": "5022734"
13+
}
14+
],
1015
"data_source": {
1116
"id": "microsoft-cvrf",
1217
"raws": [

0 commit comments

Comments
 (0)