From 45875c7e71478ef5754da57cbffa22f8c2dbdfbc Mon Sep 17 00:00:00 2001 From: Chris Capurso Date: Wed, 23 Feb 2022 17:08:52 -0500 Subject: [PATCH] prevent int64 overflow for default_lease_ttl and max_lease_ttl (#14206) * prevent int64 overflow for default_lease_ttl and max_lease_ttl * add changelog entry * wording change in changelog entry --- changelog/14206.txt | 4 ++++ command/server/config.go | 4 ++-- command/server/config_test_helpers.go | 4 ++-- command/server/test-fixtures/config3.hcl | 4 ++-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 changelog/14206.txt diff --git a/changelog/14206.txt b/changelog/14206.txt new file mode 100644 index 000000000..00c7cc100 --- /dev/null +++ b/changelog/14206.txt @@ -0,0 +1,4 @@ +```release-note:change +core: Changes the unit of `default_lease_ttl` and `max_lease_ttl` values returned by +the `/sys/config/state/sanitized` endpoint from nanoseconds to seconds. +``` diff --git a/command/server/config.go b/command/server/config.go index 45637d2e5..92a911185 100644 --- a/command/server/config.go +++ b/command/server/config.go @@ -831,8 +831,8 @@ func (c *Config) Sanitized() map[string]interface{} { "enable_ui": c.EnableUI, - "max_lease_ttl": c.MaxLeaseTTL, - "default_lease_ttl": c.DefaultLeaseTTL, + "max_lease_ttl": c.MaxLeaseTTL / time.Second, + "default_lease_ttl": c.DefaultLeaseTTL / time.Second, "cluster_cipher_suites": c.ClusterCipherSuites, diff --git a/command/server/config_test_helpers.go b/command/server/config_test_helpers.go index fc441048d..dc8f622d9 100644 --- a/command/server/config_test_helpers.go +++ b/command/server/config_test_helpers.go @@ -687,7 +687,7 @@ func testConfig_Sanitized(t *testing.T) { "cluster_addr": "top_level_cluster_addr", "cluster_cipher_suites": "", "cluster_name": "testcluster", - "default_lease_ttl": 10 * time.Hour, + "default_lease_ttl": (365 * 24 * time.Hour) / time.Second, "default_max_request_duration": 0 * time.Second, "disable_cache": true, "disable_clustering": false, @@ -718,7 +718,7 @@ func testConfig_Sanitized(t *testing.T) { }, "log_format": "", "log_level": "", - "max_lease_ttl": 10 * time.Hour, + "max_lease_ttl": (30 * 24 * time.Hour) / time.Second, "pid_file": "./pidfile", "plugin_directory": "", "seals": []interface{}{ diff --git a/command/server/test-fixtures/config3.hcl b/command/server/test-fixtures/config3.hcl index 1a4894d19..1023284e0 100644 --- a/command/server/test-fixtures/config3.hcl +++ b/command/server/test-fixtures/config3.hcl @@ -45,8 +45,8 @@ seal "awskms" { secret_key = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" } -max_lease_ttl = "10h" -default_lease_ttl = "10h" +max_lease_ttl = "30d" +default_lease_ttl = "365d" cluster_name = "testcluster" pid_file = "./pidfile" raw_storage_endpoint = true