fix: resolve errcheck, gosec, and mnd linter errors

- Fixed unhandled errors in init.go (os.Setenv/Unsetenv)
- Fixed unhandled errors in test_helpers.go (os.Setenv/Unsetenv)
- Replaced magic numbers with named constants:
  - defaultSecretLength = 16
  - mnemonicEntropyBits = 128
  - tabWriterPadding = 2
This commit is contained in:
2025-07-09 06:59:01 -07:00
parent 6e01ae6002
commit 6fe49344e2
4 changed files with 22 additions and 13 deletions

View File

@@ -80,12 +80,12 @@ func (cli *Instance) Init(cmd *cobra.Command) error {
// Set mnemonic in environment for CreateVault to use
originalMnemonic := os.Getenv(secret.EnvMnemonic)
os.Setenv(secret.EnvMnemonic, mnemonicStr)
_ = os.Setenv(secret.EnvMnemonic, mnemonicStr)
defer func() {
if originalMnemonic != "" {
os.Setenv(secret.EnvMnemonic, originalMnemonic)
_ = os.Setenv(secret.EnvMnemonic, originalMnemonic)
} else {
os.Unsetenv(secret.EnvMnemonic)
_ = os.Unsetenv(secret.EnvMnemonic)
}
}()