shellvsexec.adoc 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. = Shell vs Exec
  2. OliveTin supports two different methods to run commands: `shell` and `exec`. The difference between these two is that "shell" accepts a single string and runs it via the system shell (`sh -c` on Unix; `cmd /C` on Windows). Exec passes an argument vector directly to the operating system without invoking a shell.
  3. * **Shell** is more flexible, because it allows you to chain commands (eg, using &&) and redirect or pipe output (eg: ">" or "|").
  4. * **Exec** is more secure, because it does not invoke a shell, and thus avoids shell injection attacks.
  5. Shell can be safe and secure with simple argument types (like `ascii_identifier`), but some argument types like `url` can contain characters such as `/`, `:`, `?`, and `&` which can lead to shell injection vulnerabilities while still being a valid URL.
  6. OliveTin blocks unsafe argument types from being used with `shell:` (for example `url`, `email`, `password`, `regex:...`, and raw string types). See xref:args/types.adoc#shell-blocked-arg-types[Types that cannot be used with shell]. Prefer `exec:` when in doubt.
  7. [#shell-entity-env-trust]
  8. == Entity and `.Env` values are not shell-sanitized
  9. User-supplied **argument** values are type-checked (and some types are blocked with `shell`) to reduce shell injection risk. That protection does **not** apply to:
  10. * Entity fields — `{{ .CurrentEntity.field }}` (and legacy forms such as `{{ server.hostname }}`)
  11. * Process environment — `{{ .Env.VAR_NAME }}`
  12. Those values are substituted into `shell` / `shellAfterCompleted` as-is. OliveTin assumes they are **server-controlled** (entity files and the OliveTin process environment under the operator's control). The author of the config is responsible for ensuring that data is trustworthy, or for using `exec` and careful quoting when it might not be.
  13. Webhooks cannot use `shell:` or `shellAfterCompleted`; webhook-triggered actions must use `exec:` only. See xref:action_execution/onwebhook.adoc[Execute on webhook].
  14. The way that you specify these two types of execution is different - `shell` expects a single string, while `exec` expects a list of strings (the first being the command, the rest being the arguments).
  15. [source,yaml]
  16. .Using Shell
  17. ----
  18. actions:
  19. - title: List files
  20. shell: ls -l /some/directory
  21. ----
  22. [source,yaml]
  23. .Using Exec
  24. ----
  25. actions:
  26. - title: List files
  27. exec:
  28. - ls
  29. - -l
  30. - /some/directory
  31. ----
  32. When in doubt, prefer `exec` over `shell` for better security. Shell was added in both OliveTin 3k and OliveTin 2k in October 2025.
  33. == What's Next?
  34. Now that you understand execution methods, continue building your actions:
  35. * xref:action_buttons/create_your_first.adoc[Create your first action] - Build a simple action to get started
  36. * xref:args/intro.adoc[Add arguments to actions] - Make actions interactive with user input
  37. * xref:action_execution/oncron.adoc[Schedule actions] - Set up automated execution
  38. * xref:action_execution/onwebhook.adoc[Trigger via webhooks] - Integrate with external systems
  39. * xref:security/concepts.adoc[Configure security] - Secure your actions with authentication and authorization
  40. * xref:action_examples/intro.adoc[Browse examples] - See real-world action configurations