From fc5855ff28aa4ee8b61c710c2fa3892f6c5fe7c1 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Sat, 18 Oct 2025 15:03:02 -0400 Subject: [PATCH 1/2] feat: Add hexadecimal secret generation Closes #695 --- pkg/secret/secret.go | 2 ++ pkg/secret/secret_test.go | 6 ++++++ pkg/secret/testdir/.env.sample | 1 + pkg/secret/testdir/compose.yaml | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/pkg/secret/secret.go b/pkg/secret/secret.go index 6f5103e7..b84aa295 100644 --- a/pkg/secret/secret.go +++ b/pkg/secret/secret.go @@ -188,6 +188,8 @@ func ReadSecretsConfig(appEnvPath string, composeFiles []string, stackName strin // resolveCharset sets the passgen Alphabet required for a secret func resolveCharset(input string) string { switch strings.ToLower(input) { + case "hex": + return passgen.AlphabetNumericAmbiguous + "abcdef" case "special": return passgen.AlphabetSpecial case "safespecial": diff --git a/pkg/secret/secret_test.go b/pkg/secret/secret_test.go index 67d344ae..728a12ff 100644 --- a/pkg/secret/secret_test.go +++ b/pkg/secret/secret_test.go @@ -48,6 +48,12 @@ func TestReadSecretsConfig(t *testing.T) { assert.Equal(t, "v1", secretsFromConfig["test_pass_six"].Version) assert.Equal(t, 0, secretsFromConfig["test_pass_six"].Length) assert.Equal(t, "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!@#$%^&*_-+=", secretsFromConfig["test_pass_six"].Charset) + + // Has a length modifier and a charset=hex modifier + assert.Equal(t, "test_example_com_test_pass_seven_v1", secretsFromConfig["test_pass_seven"].RemoteName) + assert.Equal(t, "v1", secretsFromConfig["test_pass_seven"].Version) + assert.Equal(t, 32, secretsFromConfig["test_pass_seven"].Length) + assert.Equal(t, "0123456789abcdef", secretsFromConfig["test_pass_seven"].Charset) } func TestReadSecretsConfigWithLongDomain(t *testing.T) { diff --git a/pkg/secret/testdir/.env.sample b/pkg/secret/testdir/.env.sample index 104e4bb7..023ced3e 100644 --- a/pkg/secret/testdir/.env.sample +++ b/pkg/secret/testdir/.env.sample @@ -4,3 +4,4 @@ SECRET_TEST_PASS_THREE_VERSION=v2 SECRET_TEST_PASS_FOUR_VERSION=v1 # length=12 charset=default,safespecial SECRET_TEST_PASS_FIVE_VERSION=v1 # length=12 charset=default,special SECRET_TEST_PASS_SIX_VERSION=v1 # charset=default,special +SECRET_TEST_PASS_SEVEN_VERSION=v1 # length=32 charset=hex diff --git a/pkg/secret/testdir/compose.yaml b/pkg/secret/testdir/compose.yaml index 2f3ccf26..1bf642f6 100644 --- a/pkg/secret/testdir/compose.yaml +++ b/pkg/secret/testdir/compose.yaml @@ -11,6 +11,7 @@ services: - test_pass_four - test_pass_five - test_pass_six + - test_pass_seven secrets: test_pass_one: @@ -31,3 +32,6 @@ secrets: test_pass_six: external: true name: ${STACK_NAME}_test_pass_six_${SECRET_TEST_PASS_SIX_VERSION} + test_pass_seven: + external: true + name: ${STACK_NAME}_test_pass_seven_${SECRET_TEST_PASS_SEVEN_VERSION} -- 2.49.0 From 0dc5c307af6783ef3220a5006f98972011dd4ca8 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Sat, 18 Oct 2025 16:03:11 -0400 Subject: [PATCH 2/2] chore: update i18n --- pkg/i18n/locales/abra.pot | 10 +++++----- pkg/i18n/locales/es.po | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/i18n/locales/abra.pot b/pkg/i18n/locales/abra.pot index a7933ab8..7965127d 100644 --- a/pkg/i18n/locales/abra.pot +++ b/pkg/i18n/locales/abra.pot @@ -7,7 +7,7 @@ msgid "" msgstr "Project-Id-Version: \n" "Report-Msgid-Bugs-To: EMAIL\n" - "POT-Creation-Date: 2025-10-01 21:13+0200\n" + "POT-Creation-Date: 2025-10-18 16:03-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -201,7 +201,7 @@ msgstr "" msgid "%s OVERVIEW" msgstr "" -#: ./cli/server/add.go:127 ./pkg/secret/secret.go:233 ./pkg/secret/secret.go:253 ./pkg/server/server.go:21 +#: ./cli/server/add.go:127 ./pkg/secret/secret.go:235 ./pkg/secret/secret.go:255 ./pkg/server/server.go:21 #, c-format msgid "%s already exists" msgstr "" @@ -1847,7 +1847,7 @@ msgstr "" msgid "attempting to create client for %s" msgstr "" -#: ./pkg/secret/secret.go:222 +#: ./pkg/secret/secret.go:224 #, c-format msgid "attempting to generate and store %s on %s" msgstr "" @@ -3062,7 +3062,7 @@ msgstr "" msgid "generated %s" msgstr "" -#: ./pkg/secret/secret.go:278 +#: ./pkg/secret/secret.go:280 #, c-format msgid "generated and stored %v on %s" msgstr "" @@ -4857,7 +4857,7 @@ msgstr "" msgid "skipping domain checks, no DOMAIN=... configured" msgstr "" -#: ./pkg/secret/secret.go:217 +#: ./pkg/secret/secret.go:219 #, c-format msgid "skipping generation of %s (generate=false)" msgstr "" diff --git a/pkg/i18n/locales/es.po b/pkg/i18n/locales/es.po index 03f4c0ea..3ee15eef 100644 --- a/pkg/i18n/locales/es.po +++ b/pkg/i18n/locales/es.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: EMAIL\n" -"POT-Creation-Date: 2025-10-01 21:13+0200\n" +"POT-Creation-Date: 2025-10-18 16:03-0400\n" "PO-Revision-Date: 2025-09-04 08:14+0000\n" "Last-Translator: chasqui \n" "Language-Team: Spanish