From 4a2a1133fc84590994d149ad3f82eeb4c446b2f1 Mon Sep 17 00:00:00 2001 From: Vault Automation Date: Fri, 10 Apr 2026 10:04:46 -0400 Subject: [PATCH] Backport Add default ceiling policy into ce/main (#13821) --- command/base_predict_test.go | 2 +- command/policy_delete.go | 4 +- command/policy_delete_test.go | 2 +- command/policy_list_test.go | 2 +- command/policy_write_test.go | 4 +- http/sys_policy_test.go | 25 ++++---- .../templates/vault/cluster/policy/edit.hbs | 2 +- vault/core_metrics_test.go | 8 +-- vault/logical_system_test.go | 12 ++-- vault/policy_store.go | 27 ++++++++- vault/policy_store_test.go | 60 ++++++++++++++++--- 11 files changed, 107 insertions(+), 41 deletions(-) diff --git a/command/base_predict_test.go b/command/base_predict_test.go index 18c55eb6d9..27795ddfb5 100644 --- a/command/base_predict_test.go +++ b/command/base_predict_test.go @@ -455,7 +455,7 @@ func TestPredict_Policies(t *testing.T) { { "good_path", client, - []string{"default", "root"}, + []string{"default", "default-ceiling", "root"}, }, } diff --git a/command/policy_delete.go b/command/policy_delete.go index d3e241adc1..b7cb70c3ec 100644 --- a/command/policy_delete.go +++ b/command/policy_delete.go @@ -35,8 +35,8 @@ Usage: vault policy delete [options] NAME $ vault policy delete my-policy - Note that it is not possible to delete the "default" or "root" policies. - These are built-in policies. + Note that it is not possible to delete the "default", "default-ceiling", + or "root" policies. These are built-in policies. ` + c.Flags().Help() diff --git a/command/policy_delete_test.go b/command/policy_delete_test.go index 06068110b2..076e22a3ae 100644 --- a/command/policy_delete_test.go +++ b/command/policy_delete_test.go @@ -105,7 +105,7 @@ func TestPolicyDeleteCommand_Run(t *testing.T) { t.Fatal(err) } - list := []string{"default", "root"} + list := []string{"default", "default-ceiling", "root"} if !reflect.DeepEqual(policies, list) { t.Errorf("expected %q to be %q", policies, list) } diff --git a/command/policy_list_test.go b/command/policy_list_test.go index aec04c1b10..8a39cd7de6 100644 --- a/command/policy_list_test.go +++ b/command/policy_list_test.go @@ -80,7 +80,7 @@ func TestPolicyListCommand_Run(t *testing.T) { t.Errorf("expected %d to be %d", code, exp) } - expected := "default\nroot" + expected := "default\ndefault-ceiling\nroot" combined := ui.OutputWriter.String() + ui.ErrorWriter.String() if !strings.Contains(combined, expected) { t.Errorf("expected %q to contain %q", combined, expected) diff --git a/command/policy_write_test.go b/command/policy_write_test.go index 4a67f229a3..76b8997517 100644 --- a/command/policy_write_test.go +++ b/command/policy_write_test.go @@ -131,7 +131,7 @@ func TestPolicyWriteCommand_Run(t *testing.T) { t.Fatal(err) } - list := []string{"default", "my-policy", "root"} + list := []string{"default", "default-ceiling", "my-policy", "root"} if !reflect.DeepEqual(policies, list) { t.Errorf("expected %q to be %q", policies, list) } @@ -172,7 +172,7 @@ func TestPolicyWriteCommand_Run(t *testing.T) { t.Fatal(err) } - list := []string{"default", "my-policy", "root"} + list := []string{"default", "default-ceiling", "my-policy", "root"} if !reflect.DeepEqual(policies, list) { t.Errorf("expected %q to be %q", policies, list) } diff --git a/http/sys_policy_test.go b/http/sys_policy_test.go index c6924bc1ff..91880bb6a8 100644 --- a/http/sys_policy_test.go +++ b/http/sys_policy_test.go @@ -29,11 +29,11 @@ func TestSysPolicies(t *testing.T) { "auth": nil, "mount_type": "system", "data": map[string]interface{}{ - "policies": []interface{}{"default", "root"}, - "keys": []interface{}{"default", "root"}, + "policies": []interface{}{"default", "default-ceiling", "root"}, + "keys": []interface{}{"default", "default-ceiling", "root"}, }, - "policies": []interface{}{"default", "root"}, - "keys": []interface{}{"default", "root"}, + "policies": []interface{}{"default", "default-ceiling", "root"}, + "keys": []interface{}{"default", "default-ceiling", "root"}, } testResponseStatus(t, resp, 200) testResponseBody(t, resp, &actual) @@ -98,11 +98,11 @@ func TestSysWritePolicy(t *testing.T) { "auth": nil, "mount_type": "system", "data": map[string]interface{}{ - "policies": []interface{}{"default", "foo", "root"}, - "keys": []interface{}{"default", "foo", "root"}, + "policies": []interface{}{"default", "default-ceiling", "foo", "root"}, + "keys": []interface{}{"default", "default-ceiling", "foo", "root"}, }, - "policies": []interface{}{"default", "foo", "root"}, - "keys": []interface{}{"default", "foo", "root"}, + "policies": []interface{}{"default", "default-ceiling", "foo", "root"}, + "keys": []interface{}{"default", "default-ceiling", "foo", "root"}, } testResponseStatus(t, resp, 200) testResponseBody(t, resp, &actual) @@ -134,6 +134,7 @@ func TestSysDeletePolicy(t *testing.T) { // Also attempt to delete these since they should not be allowed (ignore // responses, if they exist later that's sufficient) resp = testHttpDelete(t, token, addr+"/v1/sys/policy/default") + resp = testHttpDelete(t, token, addr+"/v1/sys/policy/default-ceiling") resp = testHttpDelete(t, token, addr+"/v1/sys/policy/response-wrapping") resp = testHttpGet(t, token, addr+"/v1/sys/policy") @@ -148,11 +149,11 @@ func TestSysDeletePolicy(t *testing.T) { "auth": nil, "mount_type": "system", "data": map[string]interface{}{ - "policies": []interface{}{"default", "root"}, - "keys": []interface{}{"default", "root"}, + "policies": []interface{}{"default", "default-ceiling", "root"}, + "keys": []interface{}{"default", "default-ceiling", "root"}, }, - "policies": []interface{}{"default", "root"}, - "keys": []interface{}{"default", "root"}, + "policies": []interface{}{"default", "default-ceiling", "root"}, + "keys": []interface{}{"default", "default-ceiling", "root"}, } testResponseStatus(t, resp, 200) testResponseBody(t, resp, &actual) diff --git a/ui/app/templates/vault/cluster/policy/edit.hbs b/ui/app/templates/vault/cluster/policy/edit.hbs index 86616da842..3714dca9d1 100644 --- a/ui/app/templates/vault/cluster/policy/edit.hbs +++ b/ui/app/templates/vault/cluster/policy/edit.hbs @@ -24,7 +24,7 @@ {{#if (and (not-eq this.model.id "root") (or this.model.canUpdate this.model.canDelete))}} - {{#if (and (not-eq this.model.id "default") this.model.canDelete)}} + {{#if (and (not-eq this.model.id "default") (not-eq this.model.id "default-ceiling") this.model.canDelete)}}