object: disallow unsafe OBC fields by default

Implement an allow list mechanism that disables potentially unsafe OBC
fields by default. OBC fields beyond `maxObjects` and `maxSize` don't
neatly fit into the OBC framework as it was originally envisioned and
implemented.

Some of the newly added configs could allow users to cause confusion for
themselves. Others might allow users to hijack others buckets. Some
might allow bricking the entire S3 store.

Out of an abundance of safety, allow-list the known-safe options by
default, and require administrators to enable potentially troublesome
options via the new operator-level config
`ROOK_OBC_ALLOW_ADDITIONAL_CONFIG_FIELDS`.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
This commit is contained in:
Blaine Gardner committed 2025-02-12 14:18:01 -07:00
1 parent 1cf0a83ead
commit 0e33536539
12 files changed
+164 -6

No files matched your search

@@ -20,6 +20,7 @@ import (
"context"
"fmt"
"reflect"
"slices"
"strconv"
"strings"
"time"
@@ -54,6 +55,9 @@ const (
enforceHostNetworkSettingName string = "ROOK_ENFORCE_HOST_NETWORK"
enforceHostNetworkDefaultValue string = "false"
obcAllowAdditionalConfigFieldsSettingName string = "ROOK_OBC_ALLOW_ADDITIONAL_CONFIG_FIELDS"
obcAllowAdditionalConfigFieldsDefaultValue string = "maxObjects,maxSize"
revisionHistoryLimitSettingName string = "ROOK_REVISION_HISTORY_LIMIT"
// UninitializedCephConfigError refers to the error message printed by the Ceph CLI when there is no ceph configuration file
@@ -90,6 +94,9 @@ var (
// loopDevicesAllowed indicates whether loop devices are allowed to be used
loopDevicesAllowed = false
revisionHistoryLimit *int32 = nil
// allowed OBC additional config fields
obcAllowAdditionalConfigFields = strings.Split(obcAllowAdditionalConfigFieldsDefaultValue, ",")
)
func DiscoveryDaemonEnabled(data map[string]string) bool {
@@ -159,6 +166,15 @@ func RevisionHistoryLimit() *int32 {
return revisionHistoryLimit
}
func SetObcAllowAdditionalConfigFields(data map[string]string) {
strval := k8sutil.GetValue(data, obcAllowAdditionalConfigFieldsSettingName, obcAllowAdditionalConfigFieldsDefaultValue)
obcAllowAdditionalConfigFields = strings.Split(strval, ",")
}
func ObcAdditionalConfigKeyIsAllowed(configField string) bool {
return slices.Contains(obcAllowAdditionalConfigFields, configField)
}
// canIgnoreHealthErrStatusInReconcile determines whether a status of HEALTH_ERR in the CephCluster can be ignored safely.
func canIgnoreHealthErrStatusInReconcile(cephCluster cephv1.CephCluster, controllerName string) bool {
// Get a list of all the keys causing the HEALTH_ERR status.