Skip to content

Commit 5d5a7b6

Browse files
author
Per Goncalves da Silva
committed
fix ups
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 3ee156d commit 5d5a7b6

File tree

1 file changed

+16
-6
lines changed
  • internal/operator-controller/rukpak/render/registryv1/validators

1 file changed

+16
-6
lines changed

internal/operator-controller/rukpak/render/registryv1/validators/validator.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,12 +265,12 @@ func CheckWebhookNameIsDNS1123SubDomain(rv1 *bundle.RegistryV1) []error {
265265
return errs
266266
}
267267

268-
// unsupportedWebhookRuleAPIGroups contain the API groups that are unsupported for webhook configuration rules in OLMv1
269-
var unsupportedWebhookRuleAPIGroups = sets.New("olm.operatorframework.io", "*")
268+
// forbiddenWebhookRuleAPIGroups contain the API groups that are forbidden for webhook configuration rules in OLMv1
269+
var forbiddenWebhookRuleAPIGroups = sets.New("olm.operatorframework.io", "*")
270270

271-
// unsupportedAdmissionRegistrationResources contain the resources that are unsupported for webhook configuration rules
271+
// forbiddenAdmissionRegistrationResources contain the resources that are forbidden for webhook configuration rules
272272
// for the admissionregistration.k8s.io api group
273-
var unsupportedAdmissionRegistrationResources = sets.New(
273+
var forbiddenAdmissionRegistrationResources = sets.New(
274274
"*",
275275
"mutatingwebhookconfiguration",
276276
"mutatingwebhookconfigurations",
@@ -279,6 +279,16 @@ var unsupportedAdmissionRegistrationResources = sets.New(
279279
)
280280

281281
// CheckWebhookRules ensures webhook rules do not reference forbidden API groups or resources in line with OLMv0 behavior
282+
// The following are forbidden, rules targeting:
283+
// - all API groups (i.e. '*')
284+
// - OLMv1 API group (i.e. 'olm.operatorframework.io')
285+
// - all resources under the 'admissionregistration.k8s.io' API group
286+
// - the 'ValidatingWebhookConfiguration' resource under the 'admissionregistration.k8s.io' API group
287+
// - the 'MutatingWebhookConfiguration' resource under the 'admissionregistration.k8s.io' API group
288+
//
289+
// These boundaries attempt to reduce the blast radius of faulty webhooks and avoid deadlocks preventing the user
290+
// from deleting OLMv1 resources installing and managing the faulty webhook, or deleting faulty admission webhook
291+
// configurations.
282292
// See https://github.com/operator-framework/operator-lifecycle-manager/blob/ccf0c4c91f1e7673e87f3a18947f9a1f88d48438/pkg/controller/install/webhook.go#L19
283293
// for more details
284294
func CheckWebhookRules(rv1 *bundle.RegistryV1) []error {
@@ -291,12 +301,12 @@ func CheckWebhookRules(rv1 *bundle.RegistryV1) []error {
291301
webhookName := wh.GenerateName
292302
for _, rule := range wh.Rules {
293303
for _, apiGroup := range rule.APIGroups {
294-
if unsupportedWebhookRuleAPIGroups.Has(apiGroup) {
304+
if forbiddenWebhookRuleAPIGroups.Has(apiGroup) {
295305
errs = append(errs, fmt.Errorf("webhook %q contains forbidden rule: admission webhook rules cannot reference API group %q", webhookName, apiGroup))
296306
}
297307
if apiGroup == "admissionregistration.k8s.io" {
298308
for _, resource := range rule.Resources {
299-
if unsupportedAdmissionRegistrationResources.Has(strings.ToLower(resource)) {
309+
if forbiddenAdmissionRegistrationResources.Has(strings.ToLower(resource)) {
300310
errs = append(errs, fmt.Errorf("webhook %q contains forbidden rule: admission webhook rules cannot reference resource %q for API group %q", webhookName, resource, apiGroup))
301311
}
302312
}

0 commit comments

Comments
 (0)