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

fix(registry-scanner): handle error for fips image #2149

Merged
merged 3 commits into from
Feb 11, 2025
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
2 changes: 1 addition & 1 deletion charts/registry-scanner/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Sysdig Registry Scanner
type: application
home: https://www.sysdig.com/
icon: https://avatars.githubusercontent.com/u/5068817?s=200&v=4
version: 1.6.8
version: 1.6.9
appVersion: 0.7.4
maintainers:
- name: sysdiglabs
2 changes: 1 addition & 1 deletion charts/registry-scanner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Use the following command to deploy:
helm upgrade --install registry-scanner \
--namespace sysdig-agent \
--create-namespace \
--version=1.6.8 \
--version=1.6.9 \
--set config.secureBaseURL=<SYSDIG_SECURE_URL> \
--set config.secureAPIToken=<SYSDIG_SECURE_API_TOKEN> \
--set config.secureSkipTLS=true \
Expand Down
5 changes: 4 additions & 1 deletion charts/registry-scanner/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ Allow overriding registry and repository for air-gapped environments
{{- define "registry-scanner.inlineScanImage" -}}
{{- if .Values.image.fips -}}
{{- if hasSuffix "-fips" .Values.config.scan.inlineScanImage -}}
{{- .Values.config.scan.inlineScanImage -}}
{{ fail "use `image.fips: true` instead of manually setting fips tag" }}
{{- end -}}
{{- if not .Values.config.scan.inlineScanImage -}}
{{- (include "registry-scanner.image" .) -}}
{{- else -}}
{{- .Values.config.scan.inlineScanImage -}}-fips
{{- end -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/registry-scanner/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ data:
limits:
memory: {{ .Values.config.scan.jobs.resources.limits.memory }}
temporaryVolumeSizeLimit: {{ .Values.config.scan.jobs.temporaryVolumeSizeLimit }}
{{- if .Values.config.scan.inlineScanImage }}
{{- if or .Values.config.scan.inlineScanImage .Values.image.fips }}
dbonino marked this conversation as resolved.
Show resolved Hide resolved
inlineScanImage: {{ include "registry-scanner.inlineScanImage" . }}
{{- end }}
{{- if .Values.imagePullSecrets }}
Expand Down
123 changes: 123 additions & 0 deletions charts/registry-scanner/tests/configmap_job_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
suite: Registry Scanner - configmap and job
templates:
- templates/configmap.yaml
- templates/job.yaml
tests:
- it: fips is requested without inlineScanImage set
set:
scanOnStart:
enabled: true
image:
fips: true
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.quay.io/sysdig/registry-scanner:job-0.7.4-fips\n"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "quay.io/sysdig/registry-scanner:job-0.7.4-fips$"
template: templates/job.yaml
- it: fips is requested with inlineScanImage set
set:
scanOnStart:
enabled: true
image:
fips: true
config.scan.inlineScanImage: bananas/foo:bar
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.bananas/foo:bar-fips\n"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "quay.io/sysdig/registry-scanner:job-0.7.4-fips$"
template: templates/job.yaml
- it: fips is requested with inlineScanImage set and custom image repo
set:
scanOnStart:
enabled: true
image:
registry: bananas
repository: foo
tag: bar
fips: true
config.scan.inlineScanImage: something/different:boo
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.something/different:boo-fips\n"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "bananas/foo:bar-fips$"
template: templates/job.yaml
- it: fips is requested with inlineScanImage already including fips, fails
set:
scanOnStart:
enabled: true
image:
registry: bananas
repository: foo
tag: bar
fips: true
config.scan.inlineScanImage: something/different:boo-fips
asserts:
- failedTemplate:
errorMessage: "use `image.fips: true` instead of manually setting fips tag"
template: templates/configmap.yaml
- it: fips is requested without inlineScanImage set and custom image repo
set:
scanOnStart:
enabled: true
image:
registry: bananas
repository: foo
tag: bar
fips: true
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.bananas/foo:bar-fips\n"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "bananas/foo:bar-fips$"
template: templates/job.yaml
- it: custom repo and it does not set inlineScanImage
set:
scanOnStart:
enabled: true
image:
registry: bananas
repository: foo
tag: bar
asserts:
- notMatchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "bananas/foo:bar$"
template: templates/job.yaml

- it: custom repo and custom inlineScanImage
set:
scanOnStart:
enabled: true
image:
registry: bananas
repository: foo
tag: bar
config.scan.inlineScanImage: something/different:boo-fips
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.something/different:boo-fips"
template: templates/configmap.yaml
- matchRegex:
path: spec.template.spec.containers[0].image
pattern: "bananas/foo:bar$"
template: templates/job.yaml
5 changes: 2 additions & 3 deletions charts/registry-scanner/tests/configmap_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,8 @@ tests:
fips: true
config.scan.inlineScanImage: foo:bar-fips
asserts:
- matchRegex:
path: data['config.yaml']
pattern: "scan:((.|\n)*)inlineScanImage:.foo:bar-fips\n"
- failedTemplate:
errorMessage: "use `image.fips: true` instead of manually setting fips tag"
- it: fips is NOT requested with inlineScanImage set
set:
scanOnStart:
Expand Down
Loading