Skip to content

Add support for run.shell task#268

Open
mcruzdev wants to merge 1 commit into
serverlessworkflow:mainfrom
mcruzdev:issue-246
Open

Add support for run.shell task#268
mcruzdev wants to merge 1 commit into
serverlessworkflow:mainfrom
mcruzdev:issue-246

Conversation

@mcruzdev

Copy link
Copy Markdown

Many thanks for submitting your Pull Request ❤️!

What this PR does / why we need it:

Implements the RunTask.shell process defined by the Serverless Workflow DSL. Adds a shell runner that evaluates the command, environment and arguments (as runtime expressions), executes it via sh -c, and returns output according to the return policy (stdout, stderr, code, all, none).

  • Add return to RunTaskConfiguration with oneof validation
  • Wire RunTask into the task runner dispatch
  • Support both ordered array and map forms for shell arguments via the RunArguments model (array form preserves order)
  • Set the command environment via cmd.Env instead of mutating the parent process global environment

Closes #246

Special notes for reviewers:

Additional information (if needed):

Implements the RunTask.shell process defined by the Serverless Workflow
DSL. Adds a shell runner that evaluates the command, environment and
arguments (as runtime expressions), executes it via `sh -c`, and returns
output according to the `return` policy (stdout, stderr, code, all, none).

- Add `return` to RunTaskConfiguration with oneof validation
- Wire RunTask into the task runner dispatch
- Support both ordered array and map forms for shell arguments via the
  RunArguments model (array form preserves order)
- Set the command environment via cmd.Env instead of mutating the
  parent process global environment

Closes serverlessworkflow#246

Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
@mcruzdev mcruzdev requested a review from ricardozanini as a code owner June 27, 2026 01:29
@mcruzdev

Copy link
Copy Markdown
Author

Replaces #247

@ricardozanini ricardozanini left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionallity is correct, but there is a huge security flaw we can't merge before it's solved.

}

newCmd := func() *exec.Cmd {
cmd := exec.Command("sh", "-c", fullCmd.String())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do this directly, as it is a huge security flaw. These commands must run on an isolated process/shell without privileged access. If the workflow process is running with a user with privileged access (aka root), one can inject a script and destroy the environment.

I must do some research around this topic; we can't have a naive implementation for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add RunShell task support for running shell commands

2 participants