fix: Sandbox Allow network bind for npx (#151)

* feat: Add support for network bind

* chore: Add comments for bwrap sandbox
This commit is contained in:
Abhisek Datta
2026-02-04 15:32:47 +05:30
committed by GitHub
parent f90fa0e6a5
commit 3778d4d1f3
5 changed files with 111 additions and 0 deletions
@@ -555,6 +555,22 @@ func (t *seatbeltPolicyTranslator) translateNetwork(policy *sandbox.SandboxPolic
sb.WriteString("\n")
// Network bind rules for local listening
if utils.SafelyGetValue(policy.AllowNetworkBind) {
sb.WriteString(";; Local network bind (localhost only)\n")
sb.WriteString("(allow network-bind (local ip \"localhost:*\"))\n")
sb.WriteString("(allow network* (local ip \"localhost:*\"))\n")
}
for _, addr := range policy.Network.AllowBind {
sb.WriteString(fmt.Sprintf("(allow network-bind (local ip \"%s\"))\n", addr))
sb.WriteString(fmt.Sprintf("(allow network* (local ip \"%s\"))\n", addr))
}
if utils.SafelyGetValue(policy.AllowNetworkBind) || len(policy.Network.AllowBind) > 0 {
sb.WriteString("\n")
}
return nil
}