Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
generate random string fn
Maidul Islam385afdfcf8fe
diff --git a/cli/packages/util/constants.go b/cli/packages/util/constants.goindex 432b1cb826..1f9ec0c659 100644--- a/cli/packages/util/constants.go+++ b/cli/packages/util/constants.go@@ -38,8 +38,7 @@ const (SERVICE_TOKEN_IDENTIFIER = "service-token"UNIVERSAL_AUTH_TOKEN_IDENTIFIER = "universal-auth-token"- // akhilmhdh: @depreciated remove in version v0.30- INFISICAL_BACKUP_SECRET = "infisical-backup-secrets"+ INFISICAL_BACKUP_SECRET = "infisical-backup-secrets" // akhilmhdh: @depreciated remove in version v0.30INFISICAL_BACKUP_SECRET_ENCRYPTION_KEY = "infisical-backup-secret-encryption-key")diff --git a/cli/packages/util/helper.go b/cli/packages/util/helper.goindex 9ce8c4a1d0..69a310efae 100644--- a/cli/packages/util/helper.go+++ b/cli/packages/util/helper.go@@ -5,6 +5,7 @@ import ("crypto/sha256""encoding/base64""fmt"+ "math/rand""os""os/exec""path"@@ -25,6 +26,8 @@ type DecodedSymmetricEncryptionDetails = struct {Key []byte}+const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"+func GetBase64DecodedSymmetricEncryptionDetails(key string, cipher string, IV string, tag string) (DecodedSymmetricEncryptionDetails, error) {cipherx, err := base64.StdEncoding.DecodeString(cipher)if err != nil {@@ -287,3 +290,11 @@ func GetCmdFlagOrEnv(cmd *cobra.Command, flag, envName string) (string, error) {}return value, nil}++func GenerateRandomString(length int) string {+ b := make([]byte, length)+ for i := range b {+ b[i] = charset[rand.Intn(len(charset))]+ }+ return string(b)+}diff --git a/cli/packages/util/keyringwrapper.go b/cli/packages/util/keyringwrapper.goindex 0652719065..9c8211a3c1 100644--- a/cli/packages/util/keyringwrapper.go+++ b/cli/packages/util/keyringwrapper.go@@ -4,7 +4,6 @@ import ("encoding/base64""fmt"- "github.com/manifoldco/promptui""github.com/rs/zerolog/log""github.com/zalando/go-keyring")@@ -32,17 +31,9 @@ func SetValueInKeyring(key, value string) error {configFile, _ := GetConfigFile()if configFile.VaultBackendPassphrase == "" {- PrintWarning("System keyring could not be used, falling back to `file` vault for sensitive data storage.")- passphrasePrompt := promptui.Prompt{- Label: "Enter the passphrase to use for keyring encryption",- }- passphrase, err := passphrasePrompt.Run()- if err != nil {- return err- }-- encodedPassphrase := base64.StdEncoding.EncodeToString([]byte(passphrase))+ encodedPassphrase := base64.StdEncoding.EncodeToString([]byte(GenerateRandomString(10))) // generate random passphraseconfigFile.VaultBackendPassphrase = encodedPassphrase+ configFile.VaultBackendType = VAULT_BACKEND_FILE_MODEerr = WriteConfigFile(&configFile)if err != nil {return err@@ -64,13 +55,7 @@ func GetValueInKeyring(key string) (string, error) {if err != nil {PrintErrorAndExit(1, err, "Unable to get current vault. Tip: run [infisical reset] then try again")}-- value, err := keyring.Get(currentVaultBackend, MAIN_KEYRING_SERVICE, key)-- if err != nil {- value, err = keyring.Get(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key)- }- return value, err+ return keyring.Get(currentVaultBackend, MAIN_KEYRING_SERVICE, key)}@@ -80,11 +65,5 @@ func DeleteValueInKeyring(key string) error {return err}- err = keyring.Delete(currentVaultBackend, MAIN_KEYRING_SERVICE, key)-- if err != nil {- err = keyring.Delete(VAULT_BACKEND_FILE_MODE, MAIN_KEYRING_SERVICE, key)- }-- return err+ return keyring.Delete(currentVaultBackend, MAIN_KEYRING_SERVICE, key)}diff --git a/docs/cli/commands/vault.mdx b/docs/cli/commands/vault.mdxindex 803af127f7..b09513c345 100644--- a/docs/cli/commands/vault.mdx+++ b/docs/cli/commands/vault.mdx@@ -30,8 +30,5 @@ description: "Change the vault type in Infisical"## Description-To safeguard your login details when using the CLI, Infisical places them in a system vault or an encrypted text file, protected by a passphrase that only the user knows.--<Tip>To avoid constantly entering your passphrase when using the `file` vault type, use the `infisical vault set file --passphrase <your-passphrase>` CLI command to specify your password once.</Tip>-+To safeguard your login details when using the CLI, Infisical attempts to store them in a system keyring. If a system keyring cannot be found on your machine, the data is stored in a config file.