Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cleanup] Remove Deprecated math/rand.Seed Usage #2675

Closed
wants to merge 2 commits into from

Conversation

orangekame3
Copy link

@orangekame3 orangekame3 commented Oct 3, 2023

Issue

#2650

Description

This commit removes the use of the deprecated math/rand.Seed method.

Checked

▼make test

gopass [ fix/issue-2650][🐹 v1.21.0]
❯ make test
>> BUILD, version = 1.15.8/ecf31ca3, output = gopass [OK]
>> TEST, "fast-mode": race detector off
     ok  	github.com/gopasspw/gopass	0.050s
     ?   	github.com/gopasspw/gopass/helpers/changelog	[no test files]
     ?   	github.com/gopasspw/gopass/helpers/man	[no test files]
     ?   	github.com/gopasspw/gopass/helpers/msipkg	[no test files]
     ?   	github.com/gopasspw/gopass/helpers/postrel	[no test files]
     ?   	github.com/gopasspw/gopass/helpers/release	[no test files]
     ok  	github.com/gopasspw/gopass/internal/action	3.087s
     ok  	github.com/gopasspw/gopass/internal/action/exit	0.001s
     ok  	github.com/gopasspw/gopass/internal/action/pwgen	0.004s
     ok  	github.com/gopasspw/gopass/internal/audit	0.028s
     ok  	github.com/gopasspw/gopass/internal/backend	0.038s
     ?   	github.com/gopasspw/gopass/internal/backend/crypto	[no test files]
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/age	0.029s
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/gpg	0.001s
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/gpg/cli	0.012s
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/gpg/colons	0.001s
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/gpg/gpgconf	0.001s
     ok  	github.com/gopasspw/gopass/internal/backend/crypto/plain	0.001s
     ?   	github.com/gopasspw/gopass/internal/backend/storage	[no test files]
     ?   	github.com/gopasspw/gopass/internal/backend/storage/fossilfs	[no test files]
     ok  	github.com/gopasspw/gopass/internal/backend/storage/fs	0.251s
     ok  	github.com/gopasspw/gopass/internal/backend/storage/gitfs	0.037s
     ok  	github.com/gopasspw/gopass/internal/cache	1.102s
     ?   	github.com/gopasspw/gopass/internal/cache/ghssh	[no test files]
     ok  	github.com/gopasspw/gopass/internal/completion/fish	0.002s
     ok  	github.com/gopasspw/gopass/internal/completion/zsh	0.002s
     ok  	github.com/gopasspw/gopass/internal/config	0.037s
     ok  	github.com/gopasspw/gopass/internal/config/legacy	0.031s
     ok  	github.com/gopasspw/gopass/internal/create	0.030s
     ok  	github.com/gopasspw/gopass/internal/cui	0.003s
     ok  	github.com/gopasspw/gopass/internal/diff	0.001s
     ok  	github.com/gopasspw/gopass/internal/editor	0.004s
     ?   	github.com/gopasspw/gopass/internal/env	[no test files]
     ?   	github.com/gopasspw/gopass/internal/hashsum	[no test files]
     ?   	github.com/gopasspw/gopass/internal/hook	[no test files]
     ok  	github.com/gopasspw/gopass/internal/notify	0.001s
     ok  	github.com/gopasspw/gopass/internal/out	0.001s
     ok  	github.com/gopasspw/gopass/internal/pwschemes/argon2i	0.468s
     ok  	github.com/gopasspw/gopass/internal/pwschemes/argon2id	0.731s
     ok  	github.com/gopasspw/gopass/internal/pwschemes/bcrypt	0.376s
     ?   	github.com/gopasspw/gopass/internal/queue	[no test files]
     ok  	github.com/gopasspw/gopass/internal/recipients	0.001s
     ?   	github.com/gopasspw/gopass/internal/reminder	[no test files]
     ok  	github.com/gopasspw/gopass/internal/set	0.001s
     ok  	github.com/gopasspw/gopass/internal/store	0.001s
     ok  	github.com/gopasspw/gopass/internal/store/leaf	2.847s
     ?   	github.com/gopasspw/gopass/internal/store/mockstore	[no test files]
     ?   	github.com/gopasspw/gopass/internal/store/mockstore/inmem	[no test files]
     ok  	github.com/gopasspw/gopass/internal/store/root	0.036s
     ok  	github.com/gopasspw/gopass/internal/tpl	0.846s
     ok  	github.com/gopasspw/gopass/internal/tree	0.001s
     ok  	github.com/gopasspw/gopass/internal/updater	0.003s
     ok  	github.com/gopasspw/gopass/pkg/appdir	0.002s
     ok  	github.com/gopasspw/gopass/pkg/clipboard	0.377s
     ok  	github.com/gopasspw/gopass/pkg/ctxutil	0.003s
     ok  	github.com/gopasspw/gopass/pkg/debug	0.001s
     ok  	github.com/gopasspw/gopass/pkg/fsutil	0.234s
     ok  	github.com/gopasspw/gopass/pkg/gitconfig	0.002s
     ?   	github.com/gopasspw/gopass/pkg/gopass	[no test files]
     ok  	github.com/gopasspw/gopass/pkg/gopass/api	0.029s
     ?   	github.com/gopasspw/gopass/pkg/gopass/apimock	[no test files]
     ok  	github.com/gopasspw/gopass/pkg/gopass/secrets	0.026s
     ok  	github.com/gopasspw/gopass/pkg/gopass/secrets/secparse	0.001s
     ok  	github.com/gopasspw/gopass/pkg/otp	0.005s
     ?   	github.com/gopasspw/gopass/pkg/pinentry/cli	[no test files]
     ok  	github.com/gopasspw/gopass/pkg/protect	0.001s
     ok  	github.com/gopasspw/gopass/pkg/pwgen	0.015s
     ok  	github.com/gopasspw/gopass/pkg/pwgen/pwrules	0.002s
     ok  	github.com/gopasspw/gopass/pkg/pwgen/xkcdgen	0.001s
     ok  	github.com/gopasspw/gopass/pkg/qrcon	0.001s
     ok  	github.com/gopasspw/gopass/pkg/tempfile	0.001s
     ok  	github.com/gopasspw/gopass/pkg/termio	0.002s

This commit removes the use of the deprecated math/rand.Seed method.

Signed-off-by: Takafumi Miyanaga <miya.org.0309@gmail.com>
Signed-off-by: orangekame3 <miya.org.0309@gmail.com>
This commit fixes golangci-lint error.

```
Signed-off-by: orangekame3 <miya.org.0309@gmail.com>
@orangekame3
Copy link
Author

checked ⤵

gopass [ fix/issue-2650][🐹 v1.21.0][⏱ 2s]
❯ golangci-lint run

Copy link
Member

@AnomalRoil AnomalRoil left a comment

Choose a reason for hiding this comment

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

Just a few comments, should be fine to merge once fixed.

@@ -9,18 +9,18 @@ import (
"time"
)

var gr *rand.Rand
Copy link
Member

Choose a reason for hiding this comment

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

Could we maybe have a more explicit, longer variable name if this is a global variable?

Comment on lines -5 to +8
"crypto/rand"
crand "crypto/rand"
"fmt"
"io"
mrand "math/rand"
"math/rand"
Copy link
Member

Choose a reason for hiding this comment

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

This means now the whole file is using math/rand instead of crypto/rand when it's calling rand, that's a bad idea, makes code review too annoying.

crand.Reader = strings.NewReader("")
oldrand := gr
// if we seed math/rand with 1789, the first "random number" will be 42
gr = rand.New(rand.NewSource(1789))
Copy link
Member

Choose a reason for hiding this comment

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

Hence the global variable. I understand better why you need one below, but really its name should be more explicit.

@AnomalRoil AnomalRoil linked an issue Jan 19, 2024 that may be closed by this pull request
@dominikschulz
Copy link
Member

Due to the lack of activity I assume the author lost interest in this PR. As we can't merge it as-is I'm closing it.

Feel free to re-open once you have addressed the open comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[cleanup] Math/rand.Seed deprecated
3 participants