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

feat(redhat): support EUS, AUS CPE scan for GetUnfixedCvesRedhat #107

Merged
merged 2 commits into from
Feb 2, 2022
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
1 change: 1 addition & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type DB interface {
InsertMicrosoft([]models.MicrosoftCVE, []models.MicrosoftProduct) error
}

// Option :
type Option struct {
RedisTimeout time.Duration
}
Expand Down
14 changes: 12 additions & 2 deletions db/redhat.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package db
import (
"errors"
"fmt"
"strings"
"time"

pb "github.com/cheggaaa/pb/v3"
"github.com/inconshreveable/log15"
"github.com/spf13/viper"
"github.com/vulsio/gost/models"
"github.com/vulsio/gost/util"
"golang.org/x/xerrors"
"gorm.io/gorm"
)
Expand Down Expand Up @@ -86,9 +88,17 @@ func (r *RDBDriver) GetRedhatMulti(cveIDs []string) (map[string]models.RedhatCVE
}

// GetUnfixedCvesRedhat gets the unfixed CVEs.
func (r *RDBDriver) GetUnfixedCvesRedhat(major, pkgName string, ignoreWillNotFix bool) (map[string]models.RedhatCVE, error) {
func (r *RDBDriver) GetUnfixedCvesRedhat(version, pkgName string, ignoreWillNotFix bool) (map[string]models.RedhatCVE, error) {
m := map[string]models.RedhatCVE{}
cpe := fmt.Sprintf("cpe:/o:redhat:enterprise_linux:%s", major)
var cpe string
if strings.HasSuffix(version, "-eus") {
cpe = fmt.Sprintf("cpe:/o:redhat:rhel_eus:%s", strings.TrimSuffix(version, "-eus"))
} else if strings.HasSuffix(version, "-aus") {
cpe = fmt.Sprintf("cpe:/o:redhat:rhel_aus:%s", strings.TrimSuffix(version, "-aus"))
} else {
cpe = fmt.Sprintf("cpe:/o:redhat:enterprise_linux:%s", util.Major(version))
}

pkgStats := []models.RedhatPackageState{}

// https://access.redhat.com/documentation/en-us/red_hat_security_data_api/0.1/html-single/red_hat_security_data_api/index#cve_format
Expand Down