Compare commits

..

3 Commits

Author SHA1 Message Date
Donal McBreen
559bb3667b WIP 2025-03-03 15:52:50 +00:00
Donal McBreen
f87bcf5bc6 Merge pull request #1413 from basecamp/dependabot/bundler/bundler-fd41ac4d62
Bump rack from 3.1.8 to 3.1.10 in the bundler group across 1 directory
2025-03-03 14:49:37 +00:00
dependabot[bot]
32ab72089a Bump rack from 3.1.8 to 3.1.10 in the bundler group across 1 directory
Bumps the bundler group with 1 update in the / directory: [rack](https://github.com/rack/rack).


Updates `rack` from 3.1.8 to 3.1.10
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v3.1.8...v3.1.10)

---
updated-dependencies:
- dependency-name: rack
  dependency-type: indirect
  dependency-group: bundler
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-12 19:26:36 +00:00
3 changed files with 53 additions and 2 deletions

View File

@@ -101,7 +101,7 @@ GEM
date
stringio
racc (1.8.1)
rack (3.1.8)
rack (3.1.10)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)

View File

@@ -4,9 +4,36 @@ class Kamal::Secrets::Dotenv::InlineCommandSubstitution
::Dotenv::Parser.substitutions.map! { |sub| sub == ::Dotenv::Substitutions::Command ? self : sub }
end
# Improved version of Dotenv::Substitutions::Command's INTERPOLATED_SHELL_COMMAND
# Handles:
# $(echo 'foo)')
# $(echo "foo)")
# $(echo foo\))
# $(echo "foo\")")
# $(echo foo\\)
# $(echo 'foo'"'"')')
INTERPOLATED_SHELL_COMMAND = /
(?<backslash>\\)? # (1) Optional backslash (escaped '$')
\$ # (2) Match a literal '$' (start of command)
(?<cmd> # (3) Capture the command within '$()' as 'cmd'
\( # (4) Require an opening parenthesis '('
(?: # (5) Match either:
[^()\\'"]+ # - Any non-parens, non-escape, non-quotes (normal chars)
| \\ (?!\)) . # - Escaped character (e.g., `\(`, `\'`, `\"`), but **not** `\)` alone
| \\\\ \) # - Special case: Match `\\)` as a literal `\)`
| '(?:[^'\\]* (?:\\.[^'\\]*)*)' # - Single-quoted strings with escaped quotes (`\'`)
| "(?:[^"\\]* (?:\\.[^"\\]*)*)" # - Double-quoted strings with escaped quotes (`\"`)
| '(?:[^']*)' (?:"[^"]*")* # - Single-quoted, followed by optional mixed double-quoted parts
| "(?:[^"]*)" (?:'[^']*')* # - Double-quoted, followed by optional mixed single-quoted parts
| \g<cmd> # - Nested `$()` expressions (recursive call)
)* # (6) Repeat to allow full parsing
\) # (7) Require a closing parenthesis ')'
)
/x
def call(value, _env, overwrite: false)
# Process interpolated shell commands
value.gsub(Dotenv::Substitutions::Command.singleton_class::INTERPOLATED_SHELL_COMMAND) do |*|
value.gsub(INTERPOLATED_SHELL_COMMAND) do |*|
# Eliminate opening and closing parentheses
command = $LAST_MATCH_INFO[:cmd][1..-2]

View File

@@ -34,6 +34,30 @@ class SecretsTest < ActiveSupport::TestCase
end
end
test "secret with open bracket" do
with_test_secrets("secrets" => "SECRET1=$(echo 'foo)')") do
assert_equal "foo)", Kamal::Secrets.new["SECRET1"]
end
end
test "secret with close bracket" do
with_test_secrets("secrets" => "SECRET1=$(echo 'foo(')") do
assert_equal "foo(", Kamal::Secrets.new["SECRET1"]
end
end
test "secret with escaped quote" do
with_test_secrets("secrets" => "SECRET1=$(echo \"foo\\\")") do
assert_equal "foo", Kamal::Secrets.new["SECRET1"]
end
end
test "secret with escaped single quote" do
with_test_secrets("secrets" => "SECRET1= $(echo 'foo'\"'\"'bar')") do
assert_equal "foo'bar", Kamal::Secrets.new["SECRET1"]
end
end
test "destinations" do
with_test_secrets("secrets.dest" => "SECRET=DEF", "secrets" => "SECRET=ABC", "secrets-common" => "SECRET=GHI\nSECRET2=JKL") do
assert_equal "ABC", Kamal::Secrets.new["SECRET"]