-
Notifications
You must be signed in to change notification settings - Fork 8
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
[Security Hardened Shoot Cluster] Rule 1002 implementation #433
base: main
Are you sure you want to change the base?
[Security Hardened Shoot Cluster] Rule 1002 implementation #433
Conversation
} else if kind == gardencorev1beta1constants.CloudProfileReferenceKindNamespacedCloudProfile { | ||
namespacedCloudProfile = &gardencorev1beta1.NamespacedCloudProfile{ObjectMeta: v1.ObjectMeta{Name: cloudProfileName, Namespace: r.ShootNamespace}} | ||
if err := r.Client.Get(ctx, client.ObjectKeyFromObject(namespacedCloudProfile), namespacedCloudProfile); err != nil { | ||
return rule.Result(r, rule.ErroredCheckResult(err.Error(), rule.NewTarget("name", cloudProfileName, "namespace", r.ShootNamespace, "kind", "NamespacedCloudProfile"))), nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return rule.Result(r, rule.ErroredCheckResult(err.Error(), rule.NewTarget("name", cloudProfileName, "namespace", r.ShootNamespace, "kind", "NamespacedCloudProfile"))), nil | |
return rule.Result(r, rule.ErroredCheckResult(err.Error(), rule.NewTarget("name", cloudProfileName, "namespace", r.ShootNamespace, "kind", gardencorev1beta1constants.CloudProfileReferenceKindNamespacedCloudProfile))), nil |
} | ||
} | ||
|
||
return []string{string(core.ClassificationSupported)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we directly use the Classification type?
if version.Classification == nil { | ||
return rule.FailedCheckResult("Worker group uses image with unclassified image.", target), true | ||
} else if slices.Contains(r.acceptedClassifications(imageName), string(*version.Classification)) { | ||
return rule.PassedCheckResult("Worker group has accepted image.", target.With("classification", string(*version.Classification))), true | ||
} else { | ||
return rule.FailedCheckResult("Worker group has not accepted image.", target.With("classification", string(*version.Classification))), true | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use a switch
return rule.ErroredCheckResult("image version not found in namespacedCloudProfile", target) | ||
} | ||
|
||
func (r *Rule1002) checkCloudProfile( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not needed if only used in one place
return rule.Result(r, checkResults...), nil | ||
} | ||
|
||
func (r *Rule1002) checkImageVersion( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be removed?
example/config/garden.yaml
Outdated
# - name: image-name | ||
# expectedClassifications: | ||
# - supported | ||
# - supported |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate rows. Probably a typo
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #430
Special notes for your reviewer:
Release note: