Skip to main content

core.script.run_python

Execute a Python script.

Inputs

script
string
required
Python script to execute. Must contain at least one function. If multiple functions are defined, one must be named ‘main’. Returns the output of the function.
allow_network
boolean
Whether to allow network access during script execution. Default is False. Note: package installation always has network access.Default: false.
dependencies
array[string] | null
Optional list of Python package dependencies to install via pip. Packages are cached between executions for performance.Default: null.
env_vars
map[string, string] | null
Environment variables to set in the sandbox. Use this to inject secrets or configuration.Default: null.
inputs
object | null
Input data passed as function arguments to the main function. Keys must match the parameter names in the function signature. Missing parameters will receive None.Default: null.
timeout_seconds
integer
Maximum execution time in seconds. Default is 300 seconds (5 minutes).Default: 300.

Examples

Enrich a payload
- ref: normalize_findings
  action: core.script.run_python
  args:
    inputs:
      findings: ${{ TRIGGER.findings }}
    script: |
      def main(findings):
          return [
              {
                  "id": finding["id"],
                  "severity": str(finding["severity"]).lower(),
              }
              for finding in findings
          ]
    timeout_seconds: 60