Skip to content

Commit

Permalink
add comment to explain use of math/rand package in lifetime_watcher (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Wilson authored Mar 14, 2023
1 parent ed08e45 commit a2dbd31
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/lifetime_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())))
}

Expand Down

0 comments on commit a2dbd31

Please sign in to comment.