command actions: restrict passing env vars

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-01-13 20:02:34 +01:00
parent 04fa242f57
commit e8c5f8ed81
3 changed files with 3 additions and 3 deletions

View File

@@ -1524,7 +1524,7 @@ func executeCommandRuleAction(c dataprovider.EventActionCommandConfig, params *E
cmd := exec.CommandContext(ctx, c.Cmd, args...)
cmd.Env = []string{}
for _, keyVal := range c.EnvVars {
if keyVal.Value == "$" {
if keyVal.Value == "$" && !strings.HasPrefix(strings.ToUpper(keyVal.Key), "SFTPGO_") {
val := os.Getenv(keyVal.Key)
if val == "" {
eventManagerLog(logger.LevelDebug, "empty value for environment variable %q", keyVal.Key)

View File

@@ -1008,7 +1008,7 @@
"command_help": "Absolute path of the command to execute",
"command_args": "Arguments",
"command_args_help": "Comma separated command arguments. Placeholders are supported",
"command_env_vars_help": "Placeholders are supported in values. Setting the name to \"$\" without quotes means retrieving the value from the environment",
"command_env_vars_help": "Placeholders are supported in values. Setting the value to \"$\" without quotes means retrieving the key from the environment excluding keys starting with SFTPGO_",
"email_recipients": "To",
"email_recipients_help": "Comma separated recipients. Placeholders are supported",
"email_bcc": "Bcc",

View File

@@ -1008,7 +1008,7 @@
"command_help": "Percorso assoluto del comando da eseguire",
"command_args": "Argomenti",
"command_args_help": "Argomenti del comando separati da virgole. I segnaposto sono supportati",
"command_env_vars_help": "I segnaposto sono supportati nei valori. Impostare il nome su \"$\" senza virgolette significa recuperare il valore dall'ambiente",
"command_env_vars_help": "I segnaposto sono supportati nei valori. Impostare il valore su \"$\" senza virgolette significa recuperare il nome dall'ambiente ad esclusione dei nomi che iniziano con SFTPGO_",
"email_recipients": "A",
"email_recipients_help": "Destinatari separati da virgole. I segnaposto sono supportati",
"email_bcc": "Ccn",