Skip to content

Minor update for Istio scanning #1013

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 2 commits into from
Nov 14, 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
3 changes: 2 additions & 1 deletion api/v1/convert/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ func IstioVulnerabilities(vStr string, istioVulns []types.Vuln) []*v1.Vulnerabil
}

link := stringutils.OrDefault(istioVuln.Link, "https://istio.io/latest/news/security/")
// Fixedby version is needed for response and isAffected has already been checked
_, fixedBy, err := istioutil.IsAffected(v, istioVuln)
if err != nil {
log.Errorf("unable to get fixedBy for %s: %istioVuln", istioVuln.Name, err)
log.Errorf("unable to get fixedBy for %s: %v", istioVuln.Name, err)
continue
}

Expand Down
10 changes: 5 additions & 5 deletions istio/cache/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ type cacheImpl struct {
}

func (c *cacheImpl) GetVulnsByVersion(vStr string) []types.Vuln {
c.cacheRWLock.RLock()
defer c.cacheRWLock.RUnlock()

var vulns []types.Vuln
v, err := version.NewVersion(vStr)
if err != nil {
log.Infof("Failed to get version: %s", vStr)
return nil
}
c.cacheRWLock.RLock()
defer c.cacheRWLock.RUnlock()

for _, vuln := range c.cache {
isAffected, _, error := istioutil.IsAffected(v, vuln)
if error != nil {
isAffected, _, err := istioutil.IsAffected(v, vuln)
if err != nil {
continue
}
if isAffected {
Expand Down
3 changes: 2 additions & 1 deletion pkg/istioutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"github.com/stackrox/istio-cves/types"
)

// IsAffected gets the fixed-by version for vStr in Istion vuln.
// IsAffected returns whether the given version of Istio is affected by the given vulnerability.
// If it is, then the fixed-by version is returned as well.
func IsAffected(v *version.Version, vuln types.Vuln) (bool, string, error) {
for _, affected := range vuln.Affected {
constraint, err := version.NewConstraint(affected.Range)
Expand Down