fix: unquote environment variable passed to hook commands#410
fix: unquote environment variable passed to hook commands#410
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #410 +/- ##
==========================================
- Coverage 68.24% 68.21% -0.03%
==========================================
Files 218 218
Lines 18049 18051 +2
==========================================
- Hits 12318 12314 -4
- Misses 4578 4585 +7
+ Partials 1153 1152 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
💌 Notes on code for the amazing reviewers! I am also planning to follow up with testing notes before asking for particular review 🧪 ✨
| var cmdEnvVars = os.Environ() | ||
| cmdEnvVars = append(cmdEnvVars, goutils.MapToStringSlice(opts.Env, "")...) | ||
| for name, value := range opts.Env { | ||
| cmdEnvVars = append(cmdEnvVars, name+"="+value) |
There was a problem hiding this comment.
🔭 note: These values are set for both the default and message-boundaries protocols:
slack-cli/internal/hooks/shell.go
Lines 56 to 59 in 8056444
| // To avoid removing any environment variables that are set in the current environment, we first set the cmd.Env to the current environment. | ||
| // before adding any new environment variables. | ||
| var cmdEnvVars = os.Environ() | ||
| cmdEnvVars = append(cmdEnvVars, goutils.MapToStringSlice(sdkManagedConnectionStartHookOpts.Env, "")...) |
There was a problem hiding this comment.
🏁 note: I understand the MapToStringSlice utilities to be useful in escaping command line arguments but we might not need this with the direct environment variable value setting in commands.
🏆 ramble: This implementation in localserver is the other find of a direct call to the hooks command executor so shares the change!
Changelog
Summary
This PR fixes an issue where environment variables were set with double quotes surrounding values:
slack-cli/internal/goutils/map.go
Lines 23 to 39 in 8056444
📚 Reference: https://pkg.go.dev/os/exec#Cmd
Requirements