Skip to content

fix: remove __import__ from sandbox builtins in policy-as-code agent#1340

Open
vnykmshr wants to merge 1 commit intogoogle:mainfrom
vnykmshr:fix/remove-import-from-sandbox-builtins
Open

fix: remove __import__ from sandbox builtins in policy-as-code agent#1340
vnykmshr wants to merge 1 commit intogoogle:mainfrom
vnykmshr:fix/remove-import-from-sandbox-builtins

Conversation

@vnykmshr
Copy link
Copy Markdown

Fixes #1339

Removes __import__ from the sandbox builtins dict. The AST validator catches direct calls but not subscript-style access via the builtins dict.

json/re/datetime are already injected into the sandbox namespace so import statements aren't needed in generated code.

Test added.

The restricted builtins dict included the real __import__ function,
bypassing the AST validator via subscript access.
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.

__import__ available in policy-as-code sandbox builtins

1 participant