Repository: aquasecurity/starboard
Pull request #607 (2021-05-27 16:18:17)

refactor: Move Trivy config utilities to trivy package
Signed-off-by: Daniel Pacak <pacak.daniel@gmail.com>

codecov[bot]: # [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity) Report
> Merging [#607](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity) (198878b) into [main](https://codecov.io/gh/aquasecurity/starboard/commit/e3756601d0b17611cd02ff3512a4019b78321b39?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity) (e375660) will **decrease** coverage by `24.95%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/aquasecurity/starboard/pull/607/graphs/tree.svg?width=650&height=150&src=pr&token=qqTGKAJ0Wb&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity)](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity)

```diff
@@             Coverage Diff             @@
##             main     #607       +/-   ##
===========================================
- Coverage   68.81%   43.85%   -24.96%     
===========================================
  Files          58       42       -16     
  Lines        4377     3728      -649     
===========================================
- Hits         3012     1635     -1377     
- Misses       1021     1994      +973     
+ Partials      344       99      -245     
```


| [Impacted Files](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity) | Coverage Δ | |
|---|---|---|
| [pkg/plugin/trivy/plugin.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL3BsdWdpbi90cml2eS9wbHVnaW4uZ28=) | `84.62% <100.00%> (-0.55%)` | :arrow_down: |
| [pkg/starboard/config.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL3N0YXJib2FyZC9jb25maWcuZ28=) | `76.96% <100.00%> (-1.84%)` | :arrow_down: |
| [pkg/kubehunter/scanner.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL2t1YmVodW50ZXIvc2Nhbm5lci5nbw==) | `0.00% <0.00%> (-80.51%)` | :arrow_down: |
| [pkg/plugin/factory.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL3BsdWdpbi9mYWN0b3J5Lmdv) | `0.00% <0.00%> (-80.49%)` | :arrow_down: |
| [pkg/configauditreport/scanner.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL2NvbmZpZ2F1ZGl0cmVwb3J0L3NjYW5uZXIuZ28=) | `0.00% <0.00%> (-70.77%)` | :arrow_down: |
| [pkg/vulnerabilityreport/scanner.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL3Z1bG5lcmFiaWxpdHlyZXBvcnQvc2Nhbm5lci5nbw==) | `0.00% <0.00%> (-70.54%)` | :arrow_down: |
| [pkg/operator/controller/vulnerabilityreport.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL29wZXJhdG9yL2NvbnRyb2xsZXIvdnVsbmVyYWJpbGl0eXJlcG9ydC5nbw==) | `0.00% <0.00%> (-68.86%)` | :arrow_down: |
| [pkg/kube/runnable\_job.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL2t1YmUvcnVubmFibGVfam9iLmdv) | `0.00% <0.00%> (-64.39%)` | :arrow_down: |
| [pkg/operator/controller/configauditreport.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL29wZXJhdG9yL2NvbnRyb2xsZXIvY29uZmlnYXVkaXRyZXBvcnQuZ28=) | `0.00% <0.00%> (-63.43%)` | :arrow_down: |
| [pkg/kubehunter/model.go](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity#diff-cGtnL2t1YmVodW50ZXIvbW9kZWwuZ28=) | `0.00% <0.00%> (-61.54%)` | :arrow_down: |
| ... and [31 more](https://codecov.io/gh/aquasecurity/starboard/pull/607/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity). Last update [e375660...198878b](https://codecov.io/gh/aquasecurity/starboard/pull/607?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aquasecurity).


Patch:
diff --git a/pkg/plugin/trivy/plugin.go b/pkg/plugin/trivy/plugin.go
index 26e244d..e54c430 100644
--- a/pkg/plugin/trivy/plugin.go
+++ b/pkg/plugin/trivy/plugin.go
@@ -4,6 +4,7 @@ import (
 	"encoding/json"
 	"fmt"
 	"io"
+	"strings"
 
 	"github.com/aquasecurity/starboard/pkg/apis/aquasecurity/v1alpha1"
 	"github.com/aquasecurity/starboard/pkg/docker"
@@ -37,13 +38,64 @@ type plugin struct {
 	config      Config
 }
 
+const (
+	keyTrivyMode      = "trivy.mode"
+	keyTrivyServerURL = "trivy.serverURL"
+)
+
+// Mode describes mode in which Trivy client operates.
+type Mode string
+
+const (
+	Standalone   Mode = "Standalone"
+	ClientServer Mode = "ClientServer"
+)
+
 // Config defines configuration params for the Trivy vulnerabilityreport.Plugin.
-type Config interface {
-	GetTrivyImageRef() (string, error)
-	GetTrivyMode() (starboard.TrivyMode, error)
-	GetTrivyServerURL() (string, error)
-	GetTrivyInsecureRegistries() map[string]bool
-	TrivyIgnoreFileExists() bool
+type Config struct {
+	starboard.ConfigData
+}
+
+func (c Config) GetImageRef() (string, error) {
+	return c.GetRequiredData("trivy.imageRef")
+}
+
+func (c Config) GetMode() (Mode, error) {
+	var ok bool
+	var value string
+	if value, ok = c.ConfigData[keyTrivyMode]; !ok {
+		return "", fmt.Errorf("property %s not set", keyTrivyMode)
+	}
+
+	switch Mode(value) {
+	case Standalone:
+		return Standalone, nil
+	case ClientServer:
+		return ClientServer, nil
+	}
+
+	return "", fmt.Errorf("invalid value (%s) of %s; allowed values (%s, %s)",
+		value, keyTrivyMode, Standalone, ClientServer)
+}
+
+func (c Config) GetServerURL() (string, error) {
+	return c.ConfigData.GetRequiredData(keyTrivyServerURL)
+}
+
+func (c Config) IgnoreFileExists() bool {
+	_, ok := c.ConfigData["trivy.ignoreFile"]
+	return ok
+}
+
+func (c Config) GetInsecureRegistries() map[string]bool {
+	insecureRegistries := make(map[string]bool)
+	for key, val := range c.ConfigData {
+		if strings.HasPrefix(key, "trivy.insecureRegistry.") {
+			insecureRegistries[val] = true
+		}
+	}
+
+	return insecureRegistries
 }
 
 // NewPlugin constructs a new vulnerabilityreport.Plugin, which is using an
@@ -54,23 +106,23 @@ type Config interface {
 //
 // The starboard.ClientServer mode is usually more performant, however it
 // requires a Trivy server accessible at the configurable URL.
-func NewPlugin(clock ext.Clock, idGenerator ext.IDGenerator, config Config) vulnerabilityreport.Plugin {
+func NewPlugin(clock ext.Clock, idGenerator ext.IDGenerator, config starboard.ConfigData) vulnerabilityreport.Plugin {
 	return &plugin{
 		clock:       clock,
 		idGenerator: idGenerator,
-		config:      config,
+		config:      Config{ConfigData: config},
 	}
 }
 
 func (s *plugin) GetScanJobSpec(_ starboard.PluginContext, spec corev1.PodSpec, credentials map[string]docker.Auth) (corev1.PodSpec, []*corev1.Secret, error) {
-	mode, err := s.config.GetTrivyMode()
+	mode, err := s.config.GetMode()
 	if err != nil {
 		return corev1.PodSpec{}, nil, err
 	}
 	switch mode {
-	case starboard.Standalone:
+	case Standalone:
 		return s.getPodSpecForStandaloneMode(spec, credentials)
-	case starboard.ClientServer:
+	case ClientServer:
 		return s.getPodSpecForClientServerMode(spec, credentials)
 	default:
 		return corev1.PodSpec{}, nil, fmt.Errorf("unrecognized trivy mode: %v", mode)
@@ -116,7 +168,7 @@ func (s *plugin) getPodSpecForStandaloneMode(spec corev1.PodSpec, credentials ma
 		secrets = append(secrets, secret)
 	}
 
-	trivyImageRef, err := s.config.GetTrivyImageRef()
+	trivyImageRef, err := s.config.GetImageRef()
 	if err != nil {
 		return corev1.PodSpec{}, nil, err
 	}
@@ -214,7 +266,7 @@ func (s *plugin) getPodSpecForStandaloneMode(spec corev1.PodSpec, credentials ma
 		},
 	}
 
-	if s.config.TrivyIgnoreFileExists() {
+	if s.config.IgnoreFileExists() {
 		volumes = append(volumes, corev1.Volume{
 			Name: ignoreFileVolumeName,
 			VolumeSource: corev1.VolumeSource{
@@ -328,7 +380,7 @@ func (s *plugin) getPodSpecForStandaloneMode(spec corev1.PodSpec, credentials ma
 			},
 		}
 
-		if s.config.TrivyIgnoreFileExists() {
+		if s.config.IgnoreFileExists() {
 			env = append(env, corev1.EnvVar{
 				Name:  "TRIVY_IGNOREFILE",
 				Value: "/tmp/trivy/.trivyignore",
@@ -422,12 +474,12 @@ func (s *plugin) getPodSpecForClientServerMode(spec corev1.PodSpec, credentials
 	var volumeMounts []corev1.VolumeMount
 	var volumes []corev1.Volume
 
-	trivyImageRef, err := s.config.GetTrivyImageRef()
+	trivyImageRef, err := s.config.GetImageRef()
 	if err != nil {
 		return corev1.PodSpec{}, nil, err
 	}
 
-	trivyServerURL, err := s.config.GetTrivyServerURL()
+	trivyServerURL, err := s.config.GetServerURL()
 	if err != nil {
 		return corev1.PodSpec{}, nil, err
 	}
@@ -596,7 +648,7 @@ func (s *plugin) getPodSpecForClientServerMode(spec corev1.PodSpec, credentials
 			return corev1.PodSpec{}, nil, err
 		}
 
-		if s.config.TrivyIgnoreFileExists() {
+		if s.config.IgnoreFileExists() {
 			volumes = []corev1.Volume{
 				{
 					Name: ignoreFileVolumeName,
@@ -667,7 +719,7 @@ func (s *plugin) appendTrivyInsecureEnv(image string, env []corev1.EnvVar) ([]co
 		return nil, err
 	}
 
-	insecureRegistries := s.config.GetTrivyInsecureRegistries()
+	insecureRegistries := s.config.GetInsecureRegistries()
 	if insecureRegistries[ref.Context().RegistryStr()] {
 		env = append(env, corev1.EnvVar{
 			Name:  "TRIVY_INSECURE",
@@ -707,7 +759,7 @@ func (s *plugin) ParseVulnerabilityReportData(_ starboard.PluginContext, imageRe
 		return v1alpha1.VulnerabilityScanResult{}, err
 	}
 
-	trivyImageRef, err := s.config.GetTrivyImageRef()
+	trivyImageRef, err := s.config.GetImageRef()
 	if err != nil {
 		return v1alpha1.VulnerabilityScanResult{}, err
 	}
diff --git a/pkg/starboard/config.go b/pkg/starboard/config.go
index 2292a8c..9f9a7bd 100644
--- a/pkg/starboard/config.go
+++ b/pkg/starboard/config.go
@@ -237,20 +237,9 @@ const (
 	Conftest Scanner = "Conftest"
 )
 
-// TrivyMode describes mode in which Trivy client operates.
-type TrivyMode string
-
-const (
-	Standalone   TrivyMode = "Standalone"
-	ClientServer TrivyMode = "ClientServer"
-)
-
 const (
 	keyVulnerabilityReportsScanner = "vulnerabilityReports.scanner"
 	keyConfigAuditReportsScanner   = "configAuditReports.scanner"
-
-	keyTrivyMode      = "trivy.mode"
-	keyTrivyServerURL = "trivy.serverURL"
 )
 
 // ConfigData holds Starboard configuration settings as a set
@@ -272,7 +261,7 @@ func GetDefaultConfig() ConfigData {
 
 		"trivy.severity": "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL",
 		"trivy.imageRef": "docker.io/aquasec/trivy:0.16.0",
-		keyTrivyMode:     string(Standalone),
+		"trivy.mode":     "Standalone",
 
 		"kube-bench.imageRef":  "docker.io/aquasec/kube-bench:0.5.0",
 		"kube-hunter.imageRef": "docker.io/aquasec/kube-hunter:0.4.1",
@@ -340,28 +329,6 @@ func (c ConfigData) GetConfigAuditReportsScanner() (Scanner, error) {
 		value, keyConfigAuditReportsScanner, Polaris, Conftest)
 }
 
-func (c ConfigData) GetTrivyImageRef() (string, error) {
-	return c.getRequiredProperty("trivy.imageRef")
-}
-
-func (c ConfigData) GetTrivyMode() (TrivyMode, error) {
-	var ok bool
-	var value string
-	if value, ok = c[keyTrivyMode]; !ok {
-		return "", fmt.Errorf("property %s not set", keyTrivyMode)
-	}
-
-	switch TrivyMode(value) {
-	case Standalone:
-		return Standalone, nil
-	case ClientServer:
-		return ClientServer, nil
-	}
-
-	return "", fmt.Errorf("invalid value (%s) of %s; allowed values (%s, %s)",
-		value, keyTrivyMode, Standalone, ClientServer)
-}
-
 func (c ConfigData) GetScanJobAnnotations() (map[string]string, error) {
 	scanJobAnnotationsStr, found := c[AnnotationScanJobAnnotations]
 	if !found || strings.TrimSpace(scanJobAnnotationsStr) == "" {
@@ -381,33 +348,12 @@ func (c ConfigData) GetScanJobAnnotations() (map[string]string, error) {
 	return scanJobAnnotationsMap, nil
 }
 
-func (c ConfigData) GetTrivyServerURL() (string, error) {
-	return c.getRequiredProperty(keyTrivyServerURL)
-}
-
-func (c ConfigData) TrivyIgnoreFileExists() bool {
-	_, ok := c["trivy.ignoreFile"]
-
-	return ok
-}
-
-func (c ConfigData) GetTrivyInsecureRegistries() map[string]bool {
-	insecureRegistries := make(map[string]bool)
-	for key, val := range c {
-		if strings.HasPrefix(key, "trivy.insecureRegistry.") {
-			insecureRegistries[val] = true
-		}
-	}
-
-	return insecureRegistries
-}
-
 func (c ConfigData) GetKubeBenchImageRef() (string, error) {
-	return c.getRequiredProperty("kube-bench.imageRef")
+	return c.GetRequiredData("kube-bench.imageRef")
 }
 
 func (c ConfigData) GetKubeHunterImageRef() (string, error) {
-	return c.getRequiredProperty("kube-hunter.imageRef")
+	return c.GetRequiredData("kube-hunter.imageRef")
 }
 
 func (c ConfigData) GetKubeHunterQuick() (bool, error) {
@@ -421,7 +367,7 @@ func (c ConfigData) GetKubeHunterQuick() (bool, error) {
 	return val == "true", nil
 }
 
-func (c ConfigData) getRequiredProperty(key string) (string, error) {
+func (c ConfigData) GetRequiredData(key string) (string, error) {
 	var ok bool
 	var value string
 	if value, ok = c[key]; !ok {


Test patch:
diff --git a/pkg/plugin/trivy/plugin_test.go b/pkg/plugin/trivy/plugin_test.go
index 97cff3f..eb0bb33 100644
--- a/pkg/plugin/trivy/plugin_test.go
+++ b/pkg/plugin/trivy/plugin_test.go
@@ -24,6 +24,157 @@ var (
 	fixedClock = ext.NewFixedClock(fixedTime)
 )
 
+func TestConfig_GetImageRef(t *testing.T) {
+	testCases := []struct {
+		name             string
+		configData       trivy.Config
+		expectedError    string
+		expectedImageRef string
+	}{
+		{
+			name:          "Should return error",
+			configData:    trivy.Config{starboard.ConfigData{}},
+			expectedError: "property trivy.imageRef not set",
+		},
+		{
+			name: "Should return image reference from config data",
+			configData: trivy.Config{starboard.ConfigData{
+				"trivy.imageRef": "gcr.io/aquasecurity/trivy:0.8.0",
+			}},
+			expectedImageRef: "gcr.io/aquasecurity/trivy:0.8.0",
+		},
+	}
+
+	for _, tc := range testCases {
+		t.Run(tc.name, func(t *testing.T) {
+			imageRef, err := tc.configData.GetImageRef()
+			if tc.expectedError != "" {
+				require.EqualError(t, err, tc.expectedError)
+			} else {
+				require.NoError(t, err)
+				assert.Equal(t, tc.expectedImageRef, imageRef)
+			}
+		})
+	}
+}
+
+func TestConfig_GetMode(t *testing.T) {
+	testCases := []struct {
+		name          string
+		configData    trivy.Config
+		expectedError string
+		expectedMode  trivy.Mode
+	}{
+		{
+			name: "Should return Standalone",
+			configData: trivy.Config{starboard.ConfigData{
+				"trivy.mode": "Standalone",
+			}},
+			expectedMode: trivy.Standalone,
+		},
+		{
+			name: "Should return ClientServer",
+			configData: trivy.Config{starboard.ConfigData{
+				"trivy.mode": "ClientServer",
+			}},
+			expectedMode: trivy.ClientServer,
+		},
+		{
+			name:          "Should return error when value is not set",
+			configData:    trivy.Config{starboard.ConfigData{}},
+			expectedError: "property trivy.mode not set",
+		},
+		{
+			name: "Should return error when value is not allowed",
+			configData: trivy.Config{starboard.ConfigData{
+				"trivy.mode": "P2P",
+			}},
+			expectedError: "invalid value (P2P) of trivy.mode; allowed values (Standalone, ClientServer)",
+		},
+	}
+	for _, tc := range testCases {
+		t.Run(tc.name, func(t *testing.T) {
+			mode, err := tc.configData.GetMode()
+			if tc.expectedError != "" {
+				require.EqualError(t, err, tc.expectedError)
+			} else {
+				require.NoError(t, err)
+				assert.Equal(t, tc.expectedMode, mode)
+			}
+		})
+	}
+}
+
+func TestConfig_IgnoreFileExists(t *testing.T) {
+	testCases := []struct {
+		name           string
+		configData     trivy.Config
+		expectedOutput bool
+	}{
+		{
+			name: "Should return false",
+			configData: trivy.Config{starboard.ConfigData{
+				"foo": "bar",
+			}},
+			expectedOutput: false,
+		},
+		{
+			name: "Should return true",
+			configData: trivy.Config{starboard.ConfigData{
+				"foo": "bar",
+				"trivy.ignoreFile": `# Accept the risk
+CVE-2018-14618
+
+# No impact in our settings
+CVE-2019-1543`,
+			}},
+			expectedOutput: true,
+		},
+	}
+
+	for _, tc := range testCases {
+		t.Run(tc.name, func(t *testing.T) {
+			exists := tc.configData.IgnoreFileExists()
+			assert.Equal(t, tc.expectedOutput, exists)
+		})
+	}
+}
+
+func TestConfig_GetInsecureRegistries(t *testing.T) {
+	testCases := []struct {
+		name           string
+		configData     trivy.Config
+		expectedOutput map[string]bool
+	}{
+		{
+			name: "Should return nil map when there is no key with trivy.insecureRegistry. prefix",
+			configData: trivy.Config{starboard.ConfigData{
+				"foo": "bar",
+			}},
+			expectedOutput: make(map[string]bool),
+		},
+		{
+			name: "Should return insecure registries in map",
+			configData: trivy.Config{starboard.ConfigData{
+				"foo":                                "bar",
+				"trivy.insecureRegistry.pocRegistry": "poc.myregistry.harbor.com.pl",
+				"trivy.insecureRegistry.qaRegistry":  "qa.registry.aquasec.com",
+			}},
+			expectedOutput: map[string]bool{
+				"poc.myregistry.harbor.com.pl": true,
+				"qa.registry.aquasec.com":      true,
+			},
+		},
+	}
+
+	for _, tc := range testCases {
+		t.Run(tc.name, func(t *testing.T) {
+			insecureRegistries := tc.configData.GetInsecureRegistries()
+			assert.Equal(t, tc.expectedOutput, insecureRegistries)
+		})
+	}
+}
+
 func TestScanner_GetScanJobSpec(t *testing.T) {
 
 	testCases := []struct {
@@ -39,7 +190,7 @@ func TestScanner_GetScanJobSpec(t *testing.T) {
 			name: "Standalone mode without insecure registry",
 			config: starboard.ConfigData{
 				"trivy.imageRef": "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":     string(starboard.Standalone),
+				"trivy.mode":     string(trivy.Standalone),
 			},
 			workloadSpec: corev1.PodSpec{
 				Containers: []corev1.Container{
@@ -282,7 +433,7 @@ func TestScanner_GetScanJobSpec(t *testing.T) {
 			name: "Standalone mode with insecure registry",
 			config: starboard.ConfigData{
 				"trivy.imageRef":                     "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":                         string(starboard.Standalone),
+				"trivy.mode":                         string(trivy.Standalone),
 				"trivy.insecureRegistry.pocRegistry": "poc.myregistry.harbor.com.pl",
 			},
 			workloadSpec: corev1.PodSpec{
@@ -529,7 +680,7 @@ func TestScanner_GetScanJobSpec(t *testing.T) {
 			name: "Standalone mode with trivyignore file",
 			config: starboard.ConfigData{
 				"trivy.imageRef": "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":     string(starboard.Standalone),
+				"trivy.mode":     string(trivy.Standalone),
 				"trivy.ignoreFile": `# Accept the risk
 CVE-2018-14618
 
@@ -802,7 +953,7 @@ CVE-2019-1543`,
 			name: "ClientServer mode without insecure registry",
 			config: starboard.ConfigData{
 				"trivy.imageRef":  "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":      string(starboard.ClientServer),
+				"trivy.mode":      string(trivy.ClientServer),
 				"trivy.serverURL": "http://trivy.trivy:4954",
 			},
 			workloadSpec: corev1.PodSpec{
@@ -974,7 +1125,7 @@ CVE-2019-1543`,
 			name: "ClientServer mode with insecure registry",
 			config: starboard.ConfigData{
 				"trivy.imageRef":                     "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":                         string(starboard.ClientServer),
+				"trivy.mode":                         string(trivy.ClientServer),
 				"trivy.serverURL":                    "http://trivy.trivy:4954",
 				"trivy.insecureRegistry.pocRegistry": "poc.myregistry.harbor.com.pl",
 			},
@@ -1151,7 +1302,7 @@ CVE-2019-1543`,
 			name: "ClientServer mode with trivyignore file",
 			config: starboard.ConfigData{
 				"trivy.imageRef":  "docker.io/aquasec/trivy:0.14.0",
-				"trivy.mode":      string(starboard.ClientServer),
+				"trivy.mode":      string(trivy.ClientServer),
 				"trivy.serverURL": "http://trivy.trivy:4954",
 				"trivy.ignoreFile": `# Accept the risk
 CVE-2018-14618
diff --git a/pkg/starboard/config_test.go b/pkg/starboard/config_test.go
index 8c4e11e..5595d1d 100644
--- a/pkg/starboard/config_test.go
+++ b/pkg/starboard/config_test.go
@@ -49,40 +49,6 @@ func TestGetVersionFromImageRef(t *testing.T) {
 	}
 }
 
-func TestConfigData_GetTrivyImageRef(t *testing.T) {
-	testCases := []struct {
-		name             string
-		configData       starboard.ConfigData
-		expectedError    string
-		expectedImageRef string
-	}{
-		{
-			name:          "Should return error",
-			configData:    starboard.ConfigData{},
-			expectedError: "property trivy.imageRef not set",
-		},
-		{
-			name: "Should return image reference from config data",
-			configData: starboard.ConfigData{
-				"trivy.imageRef": "gcr.io/aquasecurity/trivy:0.8.0",
-			},
-			expectedImageRef: "gcr.io/aquasecurity/trivy:0.8.0",
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			imageRef, err := tc.configData.GetTrivyImageRef()
-			if tc.expectedError != "" {
-				require.EqualError(t, err, tc.expectedError)
-			} else {
-				require.NoError(t, err)
-				assert.Equal(t, tc.expectedImageRef, imageRef)
-			}
-		})
-	}
-}
-
 func TestConfigData_GetKubeBenchImageRef(t *testing.T) {
 	testCases := []struct {
 		name             string
@@ -244,53 +210,6 @@ func TestConfigData_GetVulnerabilityReportsScanner(t *testing.T) {
 	}
 }
 
-func TestConfigData_GetTrivyMode(t *testing.T) {
-	testCases := []struct {
-		name          string
-		configData    starboard.ConfigData
-		expectedError string
-		expectedMode  starboard.TrivyMode
-	}{
-		{
-			name: "Should return Standalone",
-			configData: starboard.ConfigData{
-				"trivy.mode": "Standalone",
-			},
-			expectedMode: starboard.Standalone,
-		},
-		{
-			name: "Should return ClientServer",
-			configData: starboard.ConfigData{
-				"trivy.mode": "ClientServer",
-			},
-			expectedMode: starboard.ClientServer,
-		},
-		{
-			name:          "Should return error when value is not set",
-			configData:    starboard.ConfigData{},
-			expectedError: "property trivy.mode not set",
-		},
-		{
-			name: "Should return error when value is not allowed",
-			configData: starboard.ConfigData{
-				"trivy.mode": "P2P",
-			},
-			expectedError: "invalid value (P2P) of trivy.mode; allowed values (Standalone, ClientServer)",
-		},
-	}
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			mode, err := tc.configData.GetTrivyMode()
-			if tc.expectedError != "" {
-				require.EqualError(t, err, tc.expectedError)
-			} else {
-				require.NoError(t, err)
-				assert.Equal(t, tc.expectedMode, mode)
-			}
-		})
-	}
-}
-
 func TestConfigManager_Read(t *testing.T) {
 	clientset := fake.NewSimpleClientset(
 		&corev1.ConfigMap{
@@ -570,41 +489,6 @@ func TestConfigManager_Delete(t *testing.T) {
 	})
 }
 
-func TestConfigData_GetTrivyInsecureRegistries(t *testing.T) {
-	testCases := []struct {
-		name           string
-		configData     starboard.ConfigData
-		expectedOutput map[string]bool
-	}{
-		{
-			name: "Should return nil map when there is no key with trivy.insecureRegistry. prefix",
-			configData: starboard.ConfigData{
-				"foo": "bar",
-			},
-			expectedOutput: make(map[string]bool),
-		},
-		{
-			name: "Should return insecure registries in map",
-			configData: starboard.ConfigData{
-				"foo":                                "bar",
-				"trivy.insecureRegistry.pocRegistry": "poc.myregistry.harbor.com.pl",
-				"trivy.insecureRegistry.qaRegistry":  "qa.registry.aquasec.com",
-			},
-			expectedOutput: map[string]bool{
-				"poc.myregistry.harbor.com.pl": true,
-				"qa.registry.aquasec.com":      true,
-			},
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			insecureRegistries := tc.configData.GetTrivyInsecureRegistries()
-			assert.Equal(t, tc.expectedOutput, insecureRegistries)
-		})
-	}
-}
-
 func TestGetScanJobTolerations(t *testing.T) {
 	testCases := []struct {
 		name        string
@@ -674,41 +558,6 @@ func TestGetScanJobTolerations(t *testing.T) {
 	}
 }
 
-func TestConfigData_TrivyIgnoreFileExists(t *testing.T) {
-	testCases := []struct {
-		name           string
-		configData     starboard.ConfigData
-		expectedOutput bool
-	}{
-		{
-			name: "Should return false",
-			configData: starboard.ConfigData{
-				"foo": "bar",
-			},
-			expectedOutput: false,
-		},
-		{
-			name: "Should return true",
-			configData: starboard.ConfigData{
-				"foo": "bar",
-				"trivy.ignoreFile": `# Accept the risk
-CVE-2018-14618
-
-# No impact in our settings
-CVE-2019-1543`,
-			},
-			expectedOutput: true,
-		},
-	}
-
-	for _, tc := range testCases {
-		t.Run(tc.name, func(t *testing.T) {
-			exists := tc.configData.TrivyIgnoreFileExists()
-			assert.Equal(t, tc.expectedOutput, exists)
-		})
-	}
-}
-
 func TestGetScanJobAnnotations(t *testing.T) {
 	testCases := []struct {
 		name        string