Skip to content

feat(libbeat): use math/rand/v2 and drop seed init#42025

Merged
kruskall merged 13 commits intoelastic:mainfrom
kruskall:feat/use-rand-v2
Jan 28, 2025
Merged

feat(libbeat): use math/rand/v2 and drop seed init#42025
kruskall merged 13 commits intoelastic:mainfrom
kruskall:feat/use-rand-v2

Conversation

@kruskall
Copy link
Copy Markdown
Member

Proposed commit message

Since go 1.20 the rand package automatically seeds the global random number generator with a random value.

remove deprecate methods and use rand v2 api in libbeat

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

Since go 1.20 the rand package automatically seeds
the global random number generator with a random value.

remove deprecate methods and use rand v2 api in libbeat
@kruskall kruskall requested a review from a team as a code owner December 12, 2024 22:20
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Dec 12, 2024
@botelastic
Copy link
Copy Markdown

botelastic bot commented Dec 12, 2024

This pull request doesn't have a Team:<team> label.

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 12, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @kruskall? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 12, 2024

backport-8.x has been added to help with the transition to the new branch 8.x.
If you don't need it please use backport-skip label and remove the backport-8.x label.

@mergify mergify bot added the backport-8.x Automated backport to the 8.x branch with mergify label Dec 12, 2024
@kruskall kruskall requested a review from a team as a code owner December 12, 2024 22:28
Comment on lines -186 to -195
func init() {
initRand()
}

// initRand initializes the runtime random number generator seed using
// global, shared cryptographically strong pseudo random number generator.
//
// On linux Reader might use getrandom(2) or /udev/random. On windows systems
// CryptGenRandom is used.
func initRand() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for removing this. Even without the v2 changes this was unsound.

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
@kruskall kruskall enabled auto-merge (squash) January 28, 2025 00:47
@kruskall kruskall merged commit 12c36bd into elastic:main Jan 28, 2025
@kruskall kruskall deleted the feat/use-rand-v2 branch January 28, 2025 02:13
mergify bot pushed a commit that referenced this pull request Jan 28, 2025
* feat(libbeat): use math/rand/v2 and drop seed init

Since go 1.20 the rand package automatically seeds
the global random number generator with a random value.

remove deprecate methods and use rand v2 api in libbeat

* ci: bump golangci-lint to fix errors

* ci(golangci): remove skip-go-installation option

it was removed in v4

* Update golangci-lint.yml

* Update golangci-lint.yml

* Update golangci-lint.yml

* lint: replace rand with t tempdir

* Update client_integration_test.go

* lint: fix linter issues

* lint: fix linter issues

* Apply suggestions from code review

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>

---------

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
(cherry picked from commit 12c36bd)
rdner pushed a commit that referenced this pull request Feb 14, 2025
* feat(libbeat): use math/rand/v2 and drop seed init

Since go 1.20 the rand package automatically seeds
the global random number generator with a random value.

remove deprecate methods and use rand v2 api in libbeat

* ci: bump golangci-lint to fix errors

* ci(golangci): remove skip-go-installation option

it was removed in v4

* Update golangci-lint.yml

* Update golangci-lint.yml

* Update golangci-lint.yml

* lint: replace rand with t tempdir

* Update client_integration_test.go

* lint: fix linter issues

* lint: fix linter issues

* Apply suggestions from code review

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>

---------

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
(cherry picked from commit 12c36bd)

Co-authored-by: kruskall <99559985+kruskall@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.x Automated backport to the 8.x branch with mergify needs_team Indicates that the issue/PR needs a Team:* label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants