Skip to content

Commit

Permalink
api: add support for cveid and basescore (PROJQUAY-6698) (#125)
Browse files Browse the repository at this point in the history
* api: add support for cveid and basescore (PROJQUAY-6698)
* chore: update to go1.20
* api: update CRD schema
* chore: fix script permissions
* secscan: basescores only 1 decimal point
---------

Signed-off-by: Ross Bryan <[email protected]>
  • Loading branch information
arborite-rh committed Feb 26, 2024
1 parent 7e08b0a commit e0cd732
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 840 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.17 as builder
FROM --platform=$BUILDPLATFORM golang:1.20 as builder

ARG TARGETOS TARGETARCH
WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.codegen
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17
FROM golang:1.20

RUN go get -u k8s.io/code-generator || true && \
go get -u k8s.io/kube-openapi || true && \
Expand Down
2 changes: 2 additions & 0 deletions apis/secscan/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ type Feature struct {
NamespaceName string `json:"namespaceName,omitempty"`
Version string `json:"version,omitempty"`
Vulnerabilities []*Vulnerability `json:"vulnerabilities,omitempty"`
BaseScores []string `json:"basescores,omitempty"`
CVEIds []string `json:"cveids,omitempty"`
}

type Vulnerability struct {
Expand Down
10 changes: 10 additions & 0 deletions apis/secscan/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions bundle/imagemanifestvuln.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ spec:
metadata:
type: string
minLength: 1
basescores:
type: array
items:
type: string
cveids:
type: array
items:
type: string
status:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ spec:
metadata:
type: string
minLength: 1
basescores:
type: array
items:
type: string
cveids:
type: array
items:
type: string
status:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/quay/container-security-operator

go 1.17
go 1.20

require (
github.com/go-kit/kit v0.12.0
Expand Down Expand Up @@ -30,7 +30,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
Expand Down
838 changes: 2 additions & 836 deletions go.sum

Large diffs are not rendered by default.

Empty file modified hack/build.sh
100644 → 100755
Empty file.
Empty file modified hack/deploy.sh
100644 → 100755
Empty file.
Empty file modified hack/teardown.sh
100644 → 100755
Empty file.
11 changes: 11 additions & 0 deletions secscan/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package secscan

import (
"encoding/json"
"fmt"

secscanv1alpha1 "github.com/quay/container-security-operator/apis/secscan/v1alpha1"
"github.com/quay/container-security-operator/image"
Expand Down Expand Up @@ -51,18 +52,28 @@ type Feature struct {
Version string `json:"Version,omitempty"`
Vulnerabilities []*Vulnerability `json:"Vulnerabilities,omitempty"`
AddedBy string `json:"AddedBy,omitempty"`
BaseScores []float64 `json:"BaseScores,omitempty"`
CVEIds []string `json:"CVEIds,omitempty"`
}

func (f *Feature) ToSecscanFeature() *secscanv1alpha1.Feature {
vulnerabilities := []*secscanv1alpha1.Vulnerability{}
for _, v := range f.Vulnerabilities {
vulnerabilities = append(vulnerabilities, v.ToSecscanVulnerability())
}

var baseScores []string
for i := range f.BaseScores {
baseScores = append(baseScores, fmt.Sprintf("%.1f", f.BaseScores[i]))
}

return &secscanv1alpha1.Feature{
Name: f.Name,
VersionFormat: f.VersionFormat,
NamespaceName: f.NamespaceName,
Version: f.Version,
BaseScores: baseScores,
CVEIds: f.CVEIds,
Vulnerabilities: vulnerabilities,
}
}
Expand Down

0 comments on commit e0cd732

Please sign in to comment.