█

AI/TLDR

मुझे पिलाएं कॉफ़ी
मुझे एक कॉफ़ी पिलाएँ

Fence

किसी भी कमांड को container-free sandbox में लपेटें, जो डिफ़ॉल्ट रूप से network ब्लॉक करता है और सीमित करता है कि वह क्या लिख सकता है

Code Sandboxes & Isolationओपन सोर्स
भाषा
Go
लाइसेंस
Apache-2.0
$curl -fsSL https://cli.fencesandbox.com/install.sh | sh
संक्षेप में

Fence क्या है?

Fence किसी भी कमांड को container-free sandbox में लपेटें, जो डिफ़ॉल्ट रूप से network ब्लॉक करता है और सीमित करता है कि वह क्या लिख सकता है. यह Agents & Automation टूल्स की Code Sandboxes & Isolation श्रेणी में आता है; ओपन सोर्स है, Go में लिखा गया है और Apache-2.0 लाइसेंस के तहत है।

सारांश

Fence एक कमांड-लाइन टूल है जो किसी कमांड को sandbox में चलाता है, जहाँ डिफ़ॉल्ट रूप से network एक्सेस ब्लॉक रहता है और filesystem ऑपरेशन कॉन्फ़िगर किए जा सकने वाले नियमों के हिसाब से सीमित होते हैं। कमांड से पहले fence लगाएं — fence npm install, fence -- claude — और यह तब तक बाहरी network के बिना चलता है जब तक आप domains को allowlist न करें, और लिखना सिर्फ़ आपके चुने paths तक सीमित रहता है। यह semi-trusted code के लिए बना है: package installs, build scripts, CI jobs और अनजान repositories, जहाँ आप “चला कर देखो” के बजाय नियंत्रित side effects चाहते हैं।

यह जानबूझकर हल्का रखा गया है। Container या VM की जगह, Fence process-level operating-system primitives इस्तेमाल करता है: macOS पर sandbox-exec और Linux पर bubblewrap, और outbound traffic को proxy के ज़रिए फ़िल्टर किया जाता है ताकि domain allowlists लागू हो सकें। नियम fence.jsonc (या fence.json) फ़ाइल में रहते हैं, जिसे Fence मौजूदा डायरेक्टरी या उसके parents में खोजता है, और न मिलने पर ~/.config/fence के अंतर्गत user config पर लौटता है। Configs code जैसे built-in templates को extend कर सकते हैं, और fence config show inheritance chain और पूरी तरह resolved policy को JSON के रूप में दिखाता है।

Fence CLI coding agents के लिए permission manager के रूप में भी काम करता है। इसका code template Claude Code, Codex, Gemini CLI, OpenCode, Amp, Droid, GitHub Copilot और अन्य के साथ काम करने की सूची में है, और agent hooks किसी agent के shell tool calls को फिर से लिखकर fence -c के ज़रिए चला सकते हैं। प्रोजेक्ट अपनी सीमाओं के बारे में स्पष्ट है: यह सक्रिय रूप से दुर्भावनापूर्ण (malicious) कोड के लिए मज़बूत containment boundary नहीं है, यह CPU, memory या disk पर कोई सीमा नहीं लगाता, और किसी domain को allow करने का मतलब है कि कोड उस domain पर डेटा भेज सकता है। ज़्यादा मज़बूत isolation के लिए इसके docs Firecracker, gVisor या Kata Containers की ओर इशारा करते हैं। Fence को CLI या Go package के रूप में इस्तेमाल किया जा सकता है।

यह क्या करता है

  • Network isolation: डिफ़ॉल्ट रूप से सारा outbound traffic ब्लॉक रहता है, और config में domains को allowlist किया जा सकता है
  • Filesystem restrictions: read और write paths पर पाबंदी, साथ ही .git/hooks, shell startup files और IDE config directories जैसी फ़ाइलों में लिखने को ब्लॉक करने वाली built-in सुरक्षा
  • खतरनाक commands जैसे rm -rf /, git push या npm publish के लिए command blocking, और allowed hosts व commands की SSH filtering
  • Built-in templates, जिनमें CLI coding agents की सुरक्षा के लिए code और code-relaxed शामिल हैं, जिन्हें configs extend कर सकते हैं
  • Monitor mode (-m): blocked requests और violations को real time में लॉग करता है, चाहें तो अलग log file में
  • Cross-platform: macOS (sandbox-exec) और Linux (bubblewrap) पर चलता है, और CLI या Go library के रूप में इस्तेमाल किया जा सकता है

शुरू करें

CLI इंस्टॉल करें, देखें कि वह network call कैसे ब्लॉक करता है, फिर config फ़ाइल में ज़रूरी domains को allowlist करें और built-in template के साथ coding agent को लपेटें।

Fence इंस्टॉल करें

macOS या Linux पर install script इस्तेमाल करें, या macOS पर Homebrew। go install github.com/fencesandbox/fence/cmd/fence@latest भी काम करता है।

bashbash
curl -fsSL https://cli.fencesandbox.com/install.sh | sh

# or, on macOS
brew tap fencesandbox/tap
brew install fencesandbox/tap/fence

Linux की dependencies जोड़ें

Linux पर Fence को sandboxing के लिए bubblewrap और network bridging के लिए socat चाहिए। आमतौर पर root की ज़रूरत नहीं होती; fence --linux-features दिखाता है कि आपका environment क्या सपोर्ट करता है।

bashbash
# Ubuntu/Debian
sudo apt install bubblewrap socat

अपनी पहली sandboxed कमांड चलाएं

बिना config के हर outbound request ब्लॉक होती है, इसलिए यह CONNECT tunnel से 403 के साथ फ़ेल होगा। Compound shell commands के लिए -c इस्तेमाल करें।

bashbash
fence curl https://example.com
# curl: (56) CONNECT tunnel failed, response 403

fence -c "echo hello && ls -la"

Config में domains और writes को allowlist करें

fence config init एक starter config लिखता है जो code template को extend करता है। प्रोजेक्ट की fence.jsonc में उसके ऊपर allowed domains, writable paths और denied commands जोड़े जा सकते हैं।

jsonjson
{
  "$schema": "https://raw.githubusercontent.com/fencesandbox/fence/main/docs/schema/fence.schema.json",
  "extends": "code",
  "network": { "allowedDomains": ["private.company.com"] },
  "filesystem": { "allowWrite": ["."] },
  "command": { "deny": ["git push", "npm publish"] }
}

Coding agent को लपेटें और देखें कि वह क्या करने की कोशिश करता है

Agent को code template के तहत चलाएं, और monitor mode से ब्लॉक हुई requests देखें। Full-screen TUIs के लिए Fence के logs को फ़ाइल में भेजें और दूसरे terminal में उन्हें follow करें। Fence के flags को कमांड के flags से अलग करने के लिए -- इस्तेमाल करें।

bashbash
fence -t code -- claude

fence -m --fence-log-file /tmp/fence.log -- claude
tail -f /tmp/fence.log
Terminal recording of Claude Code running under Fence: asked to show ~/.netrc, it reports that it has no permission to read the file.
Under Fence, Claude Code is asked to read ~/.netrc and the sandbox denies the read.Fence README ↗

Dev server port expose करें

-p आपकी machine को sandbox के अंदर चल रहे server से connect करने देता है (127.0.0.1 पर bound), जबकि outbound network प्रतिबंधित रहता है।

bashbash
fence -p 3000 -c "npm run dev"

कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।

कब इस्तेमाल करें

  • अनजान repository में npm install, pip install या build script चलाना, जहाँ डिफ़ॉल्ट रूप से egress ब्लॉक हो और writes सिर्फ़ workspace तक सीमित हों
  • Claude Code, Codex या Gemini CLI जैसे CLI coding agents के चारों ओर tool-agnostic, defense-in-depth layer जोड़ना, जिसमें सभी के लिए एक ही policy हो
  • Reviewed sandbox config को एक बार commit करना और उन्हीं नियमों को developer machines और CI jobs पर लागू करना
  • Monitor mode से देखना कि कोई कमांड किन domains तक पहुँचने की कोशिश करता है, और फिर तय करना कि कौन से domains allow करने हैं

How Fence compares

Fence alongside other open-source code sandboxes & isolation tools AI/TLDR tracks, ranked by GitHub stars.

टूलस्टारयह क्या करता है
Daytona★ 71.2kAI-जनरेटेड कोड चलाने के लिए सुरक्षित, लचीले सैंडबॉक्स
NVIDIA NemoClaw★ 23.1kNVIDIA का रेफ़रेंस स्टैक, जिससे तीसरे-पक्ष के एजेंट OpenShell सैंडबॉक्स के अंदर चलाए जा सकते हैं
OpenShell★ 22.1kNVIDIA का ओपन सोर्स, नीति-आधारित sandbox रनटाइम, जो AI एजेंट्स के पूरे बेड़े को सुरक्षित रूप से चलाता है
OpenSandbox★ 18.1kAI-जनित कोड को अलग-अलग कंटेनर में चलाने वाला सामान्य-उद्देश्य सैंडबॉक्स प्लेटफ़ॉर्म
E2B★ 15.1kसुरक्षित, अलग-थलग cloud sandboxes में AI-generated कोड चलाएं
AX (Agent Executor)★ 15kGoogle का डिक्लेरेटिव ऑर्केस्ट्रेटर, जो Kubernetes क्लस्टर पर सैंडबॉक्स में अविश्वसनीय agent टास्क चलाता है
AWS Emulator★ 10.4kAWS APIs का मुफ़्त लोकल स्टैंड-इन, टेस्ट, CI और AI coding agents के लिए
Fence★ 1kकिसी भी कमांड को container-free sandbox में लपेटें, जो डिफ़ॉल्ट रूप से network ब्लॉक करता है और सीमित करता है कि वह क्या लिख सकता है