Skip to content

Commit

Permalink
fix(gost/windows): ignore other products that do not have KBs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n committed Oct 23, 2024
1 parent 030b2e0 commit b919a2f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
9 changes: 8 additions & 1 deletion gost/microsoft.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ func (ms Microsoft) detect(r *models.ScanResult, cve gostmodels.MicrosoftCVE, ap
var ps []gostmodels.MicrosoftProduct
for _, p := range cve.Products {
if len(p.KBs) == 0 {
ps = append(ps, p)
switch {
case p.Name == r.Release:
ps = append(ps, p)
case strings.HasPrefix(p.Name, "Microsoft Edge"):
ps = append(ps, p)
default:
}
continue
}

Expand Down Expand Up @@ -271,6 +277,7 @@ func (ms Microsoft) detect(r *models.ScanResult, cve gostmodels.MicrosoftCVE, ap
FixState: "unknown",
})
default:
return nil, xerrors.Errorf("unexpected product. expected: %q, actual: %q", []string{r.Release, "Microsoft Edge"}, p.Name)
}
continue
}
Expand Down
19 changes: 18 additions & 1 deletion gost/microsoft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func TestMicrosoft_detect(t *testing.T) {
},
},
{
name: "microsoft other product",
name: "microsoft other product not support",
args: args{
r: &models.ScanResult{
Family: constant.Windows,
Expand Down Expand Up @@ -427,6 +427,23 @@ func TestMicrosoft_detect(t *testing.T) {
},
},
},
{
name: "microsoft other product not support2",
args: args{
r: &models.ScanResult{
Family: constant.Windows,
Release: "Windows Server 2016",
},
cve: gostmodels.MicrosoftCVE{
CveID: "ADV200001",
Products: []gostmodels.MicrosoftProduct{
{
Name: "Internet Explorer 11 on Windows Server 2016",
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit b919a2f

Please sign in to comment.