Skip to content

Automate browser based workflows with AI

Classify flag evaluability in the SDK's pre-filter order (follow-up to #16461) (#8386)

Aaron Perezfddaaf0589b5
diff --git a/skyvern/forge/sdk/workflow/code_block_safety.py b/skyvern/forge/sdk/workflow/code_block_safety.py
index 6eb3f7e91..97c437fea 100644
--- a/skyvern/forge/sdk/workflow/code_block_safety.py
+++ b/skyvern/forge/sdk/workflow/code_block_safety.py
@@ -553,17 +553,13 @@ def is_safe_code(
) -> None:
"""Reject imports, private members, and known escape hatches.
- Leaves bare builtin names like `globals`/`locals` unblocked here; whether that's
- reachable is runner-dependent, not a blanket invariant. The legacy in-process exec path
- (CodeBlock.build_safe_vars) and the sidecar's non-sandboxed runner never bind
- globals/locals into `__builtins__`, so a bare call raises NameError. Only the
- OS-sandboxed subprocess child binds them, and there `globals()` returns the full live
- exec-globals dict -- private injected helpers and unreferenced parameters included, not
- just the code's own free variables -- so that runner's actual boundary is the OS sandbox
- plus stdout/stderr redaction (see tests/cloud/test_codeblock_parameter_redaction_core.py),
- not this checker. is_safe_script_code blocks the bare names because it validates a real
- importlib-loaded module with the genuine `__builtins__` attached and no sandbox
- underneath.
+ Leaves bare builtin names like `globals`/`locals` unblocked here; the caller decides
+ whether and how those (and any other) builtins are bound in the dict it execs the
+ validated code against, and owns making sure nothing reachable through that dict is an
+ escape. The legacy in-process path (CodeBlock.build_safe_vars) never binds them, so a bare
+ call there raises NameError. is_safe_script_code instead blocks the bare names outright,
+ because it validates a real importlib-loaded module with the genuine `__builtins__`
+ attached and no sandbox underneath.
"""
tree = ast.parse(textwrap.dedent(code))
_validate_tree(