Skip to content

Commit

Permalink
Add static check for Check interface
Browse files Browse the repository at this point in the history
Add a check in each of the checks to check for the check interface.

Signed-off-by: Brad P. Crochet <brad@redhat.com>
  • Loading branch information
bcrochet committed Aug 15, 2022
1 parent a33ea50 commit 786f9be
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions certification/internal/policy/container/base_on_ubi.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
pyxis "github.com/redhat-openshift-ecosystem/openshift-preflight/certification/pyxis"
)

var _ certification.Check = &BasedOnUBICheck{}

// BasedOnUBICheck evaluates if the provided image is based on the Red Hat Universal Base Image.
type BasedOnUBICheck struct {
LayerHashCheckEngine layerHashChecker
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_license.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const (

var errLicensesNotADir = errors.New("licenses is not a directory")

var _ certification.Check = &HasLicenseCheck{}

// HasLicenseCheck evaluates that the image contains a license definition available at
// /licenses.
type HasLicenseCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_modified_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &HasModifiedFilesCheck{}

// HasModifiedFilesCheck evaluates that no files from the base layer have been modified by
// subsequent layers by comparing the file list installed by Packages against the file list
// modified in subsequent layers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &HasNoProhibitedPackagesCheck{}

// HasProhibitedPackages evaluates that the image does not contain prohibited packages,
// which refers to packages that are not redistributable without an appropriate license.
type HasNoProhibitedPackagesCheck struct{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (

var requiredLabels = []string{"name", "vendor", "version", "release", "summary", "description"}

var _ certification.Check = &HasRequiredLabelsCheck{}

// HasRequiredLabelsCheck evaluates the image manifest to ensure that the appropriate metadata
// labels are present on the image asset as it exists in its current container registry.
type HasRequiredLabelsCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/has_unique_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification/internal/authn"
)

var _ certification.Check = &hasUniqueTagCheck{}

func NewHasUniqueTagCheck(dockercfg string) *hasUniqueTagCheck {
return &hasUniqueTagCheck{
dockercfg: dockercfg,
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/max_layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
acceptableLayerMax = 40
)

var _ certification.Check = &MaxLayersCheck{}

// UnderLayerMaxCheck ensures that the image has less layers in its assembly than a predefined maximum.
type MaxLayersCheck struct{}

Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/container/runs_as_nonroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &RunAsNonRootCheck{}

// RunAsNonRootCheck evaluates the image to determine that the runtime UID is not 0,
// which correlates to the root user.
type RunAsNonRootCheck struct{}
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/certified_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &certifiedImagesCheck{}

// imageFinder interface is used for testing. It represents the FindImagesByDigest
// function that is part of the Pyxis client.
type imageFinder interface {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/deployable_by_olm.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &DeployableByOlmCheck{}

type operatorData struct {
CatalogImage string
Channel string
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/related_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import (
"sigs.k8s.io/yaml"
)

var _ certification.Check = &RelatedImagesCheck{}

type RelatedImagesCheck struct{}

func (p *RelatedImagesCheck) Validate(ctx context.Context, imgRef certification.ImageReference) (bool, error) {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/scc_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/redhat-openshift-ecosystem/openshift-preflight/certification"
)

var _ certification.Check = &securityContextConstraintsInCSV{}

// securityContextConstraintsInCSV evaluates the csv and logs a message if a non default security context constraint is
// needed by the operator
type securityContextConstraintsInCSV struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ScorecardBasicSpecCheck{}

// ScorecardBasicSpecCheck evaluates the image to ensure it passes the operator-sdk
// scorecard check with the basic-check-spec-test suite selected.
type ScorecardBasicSpecCheck struct {
Expand Down
2 changes: 2 additions & 0 deletions certification/internal/policy/operator/scorecard_olm_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ScorecardOlmSuiteCheck{}

// ScorecardOlmSuiteCheck evaluates the image to ensure it passes the operator-sdk
// scorecard check with the olm suite selected.
type ScorecardOlmSuiteCheck struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
log "github.com/sirupsen/logrus"
)

var _ certification.Check = &ValidateOperatorBundleCheck{}

// ValidateOperatorBundleCheck evaluates the image and ensures that it passes bundle validation
// as executed by `operator-sdk bundle validate`
type ValidateOperatorBundleCheck struct {
Expand Down

0 comments on commit 786f9be

Please sign in to comment.