Package com.tnsai.quality.sandbox
Interface NetPolicy
- All Known Implementing Classes:
NetPolicy.AllowList,NetPolicy.DenyAll,NetPolicy.Inherit
Network access policy applied to a sandbox (TNS-296).
Sealed so the framework can pattern-match on policy choice when
translating to backend-specific arguments (Docker --network,
Linux netns, WASM capability gates, …) and so an exhaustive switch
surfaces a build error if a new policy is added without backend
support.
Default = deny
The recommended sandbox stance is "no network". Most code-execution use cases (LLM-generated python, untrusted shell) don't need network access; granting it by default would silently widen the blast radius of a compromise.Use NetPolicy.AllowList to whitelist specific hosts, or
NetPolicy.Inherit when the sandbox runs trusted code that needs
unrestricted network (the caller still records the choice on the
SandboxSpec so audit consumers can flag it).
- Since:
- 0.10.0 (TNS-296)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordAllow only the listed hosts.static final recordNo network access.static final recordSandbox inherits the host's network. -
Method Summary
Static Methods
-
Method Details
-
denyAll
No outbound or inbound network access. The recommended default. -
allow
Allow access only to the listed hosts ("github.com","api.openai.com:443", …). Empty list means deny-all (callers that want deny-all should usedenyAll()explicitly for clarity). -
inherit
Sandbox inherits the host's network. Use sparingly — bypasses the framework's deny-by-default safety stance.
-