Resolve named policies before sandbox spawn#200
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
str,dict, compiled policy objects,SandboxPolicy, andPolicyinputs for consistent behavior across APIs.Description
resolve_policy(...)inpyisolate/policy/__init__.pythat: resolves file paths and registered public names underpolicy/, parses compiled or dict policy inputs, convertsSandboxPolicy/CompiledPolicyto runtimePolicy, and raisesPolicyCompilerErrorfor unknown named strings. (pyisolate/policy/__init__.py)policy = resolve_policy(policy)early inSupervisor.spawnsoSandboxThreadalways receives a runtimePolicyobject. (pyisolate/supervisor.py)policyin the@sandboxdecorator and inPipelinestages before callingspawn. (pyisolate/sdk.py)policy/and document supported public names and resolution semantics inPOLICY.md(examples:stdlib.readonly,ml-inference,readonly-fs).resolve_policyfrom the package API and includeSandboxPolicy/CompiledPolicytypes where needed.Testing
pytest -q tests/test_policy.py::test_resolve_unknown_policy_fails_closed tests/test_policy.py::test_named_policy_applies_runtime_restrictions tests/test_sdk.pyand these tests passed.pytest -q tests/test_policy.py tests/test_policy_enforcement.py tests/test_sdk.pyand these suites passed.python -m py_compile pyisolate/policy/__init__.py pyisolate/supervisor.py pyisolate/sdk.pyand ranblackon changed files; both succeeded.pytest -q) was attempted but the run failed due to an unrelated test that injects a stubbedpyisolate.bpf.managerintosys.modulesthat does not accept themode=signature used by the supervisor; this is a test-environment interaction and not caused by the resolver changes. All added tests for policy resolution passed.Codex Task