mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
add comment to explain use of math/rand package in lifetime_watcher (#19533)
This commit is contained in:
@@ -147,6 +147,13 @@ func (c *Client) NewLifetimeWatcher(i *LifetimeWatcherInput) (*LifetimeWatcher,
|
||||
|
||||
random := i.Rand
|
||||
if random == nil {
|
||||
// NOTE:
|
||||
// Rather than a cryptographically secure random number generator (RNG),
|
||||
// the default behavior uses the math/rand package. The random number is
|
||||
// used to introduce a slight jitter when calculating the grace period
|
||||
// for a monitored secret monitoring. This is intended to stagger renewal
|
||||
// requests to the Vault server, but in a semi-predictable way, so there
|
||||
// is no need to use a cryptographically secure RNG.
|
||||
random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user