8000 Port msrc transformer to v6 by wagoodman · Pull Request #531 · anchore/grype-db · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Port msrc transformer to v6 #531

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

Merged
merged 1 commit into from
Mar 13, 2025
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
28 changes: 23 additions & 5 deletions pkg/process/processors/msrc_processor.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:dupl
package processors

import (
Expand All @@ -11,7 +12,7 @@ import (

// msrcProcessor defines the regular expression needed to signal what is supported
type msrcProcessor struct {
transformer data.MSRCTransformer
transformer any
}

// NewMSRCProcessor creates a new instance of msrcProcessor particular to MSRC
Expand All @@ -21,22 +22,39 @@ func NewMSRCProcessor(transformer data.MSRCTransformer) data.Processor {
}
}

// Process reads all entries in all metadata matching the supported schema and produces vulnerabilities and their corresponding metadata
func (p msrcProcessor) Process(reader io.Reader, _ provider.State) ([]data.Entry, error) {
func NewV2MSRCProcessor(transformer data.MSRCTransformerV2) data.Processor {
return &msrcProcessor{
transformer: transformer,
}
}

func (p msrcProcessor) Process(reader io.Reader, state provider.State) ([]data.Entry, error) {
var results []data.Entry

entries, err := unmarshal.MSRCVulnerabilityEntries(reader)
if err != nil {
return nil, err
}

var handle func(entry unmarshal.MSRCVulnerability) ([]data.Entry, error)
switch t := p.transformer.(type) {
case data.MSRCTransformer:
handle = func(entry unmarshal.MSRCVulnerability) ([]data.Entry, error) {
return t(entry)
}
case data.MSRCTransformerV2:
handle = func(entry unmarshal.MSRCVulnerability) ([]data.Entry, error) {
return t(entry, state)
}
}

for _, entry := range entries {
if entry.ID == "" {
if entry.IsEmpty() {
log.Warn("dropping empty MSRC entry")
continue
}

transformedEntries, err := p.transformer(entry)
transformedEntries, err := handle(entry)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/process/v6/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/anchore/grype-db/pkg/process/v6/transformers/epss"
"github.com/anchore/grype-db/pkg/process/v6/transformers/github"
"github.com/anchore/grype-db/pkg/process/v6/transformers/kev"
"github.com/anchore/grype-db/pkg/process/v6/transformers/msrc"
"github.com/anchore/grype-db/pkg/process/v6/transformers/nvd"
"github.com/anchore/grype-db/pkg/process/v6/transformers/os"
)
Expand Down Expand Up @@ -42,7 +43,7 @@ func NewConfig(options ...Option) Config {
func Processors(cfg Config) []data.Processor {
return []data.Processor{
processors.NewV2GitHubProcessor(github.Transform),
// processors.NewMSRCProcessor(msrc.Transform),
processors.NewV2MSRCProcessor(msrc.Transform),
processors.NewV2NVDProcessor(nvd.Transformer(cfg.NVD)),
processors.NewV2OSProcessor(os.Transform),
processors.NewV2KEVProcessor(kev.Transform),
Expand Down
194 changes: 194 additions & 0 deletions pkg/process/v6/transformers/msrc/test-fixtures/microsoft-msrc-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
[
{
"cvss": {
"base_score": 7.8,
"temporal_score": 7,
"vector": "CVSS:3.0/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H/E:P/RL:O/RC:C"
},
"fixed_in": [
{
"id": "4493470",
"is_first": true,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4493470",
"https://support.microsoft.com/help/4493470"
]
},
{
"id": "4494440",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4494440",
"https://support.microsoft.com/help/4494440"
]
},
{
"id": "4503267",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4503267",
"https://support.microsoft.com/en-us/help/4503267"
]
},
{
"id": "4507460",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4507460",
"https://support.microsoft.com/help/4507460"
]
},
{
"id": "4512517",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4512517",
"https://support.microsoft.com/help/4512517"
]
},
{
"id": "4516044",
"is_first": false,
"is_latest": true,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4516044",
"https://support.microsoft.com/help/4516044"
]
}
],
"id": "CVE-2019-0671",
"link": "https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2019-0671",
"product": {
"family": "Windows",
"id": "10852",
"name": "Windows 10 Version 1607 for 32-bit Systems"
},
"severity": "High",
"summary": "Microsoft Office Access Connectivity Engine Remote Code Execution Vulnerability",
"vulnerable": [
"4480961",
"4483229",
"4487026",
"4489882"
]
},
{
"cvss": {
"base_score": 4.4,
"temporal_score": 4,
"vector": "CVSS:3.0/AV:L/AC:H/PR:L/UI:R/S:U/C:N/I:N/A:H/E:P/RL:O/RC:C"
},
"fixed_in": [
{
"id": "4093119",
"is_first": true,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4093119"
]
},
{
"id": "4103723",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4103723"
]
},
{
"id": "4284880",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4284880"
]
},
{
"id": "4338814",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4338814"
]
},
{
"id": "4343887",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4343887"
]
},
{
"id": "4345418",
"is_first": false,
"is_latest": true,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4345418"
]
},
{
"id": "4457131",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4457131"
]
},
{
"id": "4462917",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4462917"
]
},
{
"id": "4467691",
"is_first": false,
"is_latest": false,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4467691"
]
},
{
"id": "4471321",
"is_first": false,
"is_latest": true,
"links": [
"https://catalog.update.microsoft.com/v7/site/Search.aspx?q=KB4471321"
]
}
],
"id": "CVE-2018-8116",
"link": "https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2018-8116",
"product": {
"family": "Windows",
"id": "10852",
"name": "Windows 10 Version 1607 for 32-bit Systems"
},
"severity": "Medium",
"summary": "Microsoft Graphics Component Denial of Service Vulnerability",
"vulnerable": [
"3213986",
"4013429",
"4015217",
"4019472",
"4022715",
"4025339",
"4034658",
"4038782",
"4041691",
"4048953",
"4053579",
"4056890",
"4074590",
"4088787"
]
}
]
Loading
0