Make capability objects first-class#205
Merged
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
ReadPath,WritePath,ConnectTCP,Import,CpuBudget, etc., directly to the runtime and have YAML remain a serialization of the same model.AuthoritySetto drive runtime enforcement and import/CPU wiring.Description
pyisolate/capabilities.py:Authority,ReadPath,WritePath,ConnectTCP,Import,CpuBudgetandAuthoritySet, and extended__all__exports so they are available from the top-level package. (seepyisolate/capabilities.py).Policyinpyisolate/policy/__init__.pywithcapabilitiesand agrant()API and implementedto_dict()/to_yaml()so object-based policies serialize to the same YAML shape as the DSL. Legacy helpers remain and are converted into the authority model (allow_fs→ read+write). (seepyisolate/policy/__init__.py).pyisolate/policy/compiler.pyto acceptread/writefilesystem rules,cpu_ms, and to emit acapabilitieslist in theSandboxPolicycontaining first-class capability objects. (seepyisolate/policy/compiler.py).pyisolate/runtime/thread.py: added (de)serialization for first-class authorities, computed anAuthoritySetfrom the union ofpolicyobjects and handed capabilities, and enforced read/write/connect checks using the authority model (_blocked_open,_guarded_connect, importer wiring and CPU budget resolution). (seepyisolate/runtime/thread.py).pyisolate/supervisor.py).POLICY.mdandAPI.mddescribing the object-based authority model and examples, plus new unit tests that cover object grants and serialization. (seePOLICY.md,API.md,tests/test_capabilities.py,tests/test_policy.py).Testing
pytest -q tests/test_capabilities.py tests/test_policy.py tests/test_policy_enforcement.pyand all tests passed (39 passed).python -m py_compileon the modified modules and they succeeded.bpftool, etc.); running the entire suite in this environment previously surfaced host/tooling-related failures (BPF compilation / stub manager differences) that are not related to the authority-model changes and should be validated in CI with the proper toolchain.Codex Task