mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 14:50:55 +03:00
EventManager: allow to define the allowed system commands
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -2395,6 +2395,17 @@ func TestEventActionValidation(t *testing.T) {
|
||||
_, resp, err = httpdtest.AddEventAction(action, http.StatusBadRequest)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(resp), "invalid command args")
|
||||
action.Options.CmdConfig.Args = nil
|
||||
// restrict commands
|
||||
if runtime.GOOS == osWindows {
|
||||
dataprovider.EnabledActionCommands = []string{"C:\\cmd.exe"}
|
||||
} else {
|
||||
dataprovider.EnabledActionCommands = []string{"/bin/sh"}
|
||||
}
|
||||
_, resp, err = httpdtest.AddEventAction(action, http.StatusBadRequest)
|
||||
assert.NoError(t, err)
|
||||
assert.Contains(t, string(resp), "is not allowed")
|
||||
dataprovider.EnabledActionCommands = nil
|
||||
|
||||
action.Type = dataprovider.ActionTypeEmail
|
||||
_, resp, err = httpdtest.AddEventAction(action, http.StatusBadRequest)
|
||||
|
||||
Reference in New Issue
Block a user