Skip to content

Commit 8922f41

Browse files
committed
Require read-only runtime cache delegates
1 parent c0ed700 commit 8922f41

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

controllers/container_image/runtime_cache/resources.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ func Validate(cache v1alpha2.RuntimeCacheScanner) error {
442442
if !strings.HasPrefix(delegate.HostPath, "/") {
443443
return fmt.Errorf("containers.runtimeCache.delegates[%s].hostPath must be absolute", delegate.Name)
444444
}
445+
if delegate.ReadOnly != nil && !*delegate.ReadOnly {
446+
return fmt.Errorf("containers.runtimeCache.delegates[%s].readOnly must be true", delegate.Name)
447+
}
445448
}
446449
return nil
447450
}

controllers/container_image/runtime_cache/resources_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ func TestValidateRuntimeCache(t *testing.T) {
6060
cfg.Delegates[0].HostPath = "relative.sock"
6161
assert.ErrorContains(t, Validate(cfg), "hostPath must be absolute")
6262

63+
cfg = runtimeCacheAuditConfig().Spec.Containers.RuntimeCache
64+
cfg.Delegates[0].ReadOnly = ptr.To(false)
65+
assert.ErrorContains(t, Validate(cfg), "readOnly must be true")
66+
6367
cfg = runtimeCacheAuditConfig().Spec.Containers.RuntimeCache
6468
cfg.Delegates[0].Name = strings.Repeat("a", 64)
6569
assert.ErrorContains(t, Validate(cfg), "must be a valid DNS label")

0 commit comments

Comments
 (0)