Choose the sites an agent may fetch
Block sites outright, or allow only the sites you list. Blocked beats allowed, and a list of allowed sites refuses every other site.
Works with: Claude Code through WebFetch, and Hermes Agent through web_extract when you add its own site rules. Supported hosts has the detail for each agent.
Steps
1. Start from your current policy
isonapse hook policy export my-policy.luaThis writes your active policy to
my-policy.lua. Copy the rules you want from the example below into it. If the file already has a section of the same name, add the lines to that section.2. Check that it loads
isonapse hook policy check my-policy.luaThis loads the file the way Isonapse does and names any file or folder pattern that can never match. It changes nothing.
3. Make it active
isonapse hook policy activate my-policy.luaThe terminal shows the exact change, and one approval with your login password makes it active. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.
4. Undo it
isonapse hook policy revisionsisonapse hook policy rollback <revision>The first lists earlier policies; the second restores one, with one approval and the password you log in to this computer with. Use a plain terminal window that runs no agent, such as macOS Terminal or Ghostty.
What it does not do
- These example site rules name Claude Code's
WebFetch. To cover Hermes Agent'sweb_extract, add separate site rules fortool:web_extract;WebFetchrules do not carry over. Hermesweb_extracttakes one valid HTTP(S) URL per call. A batch, even for one site, or an empty or uninspectable URL list is refused in Normal and Enforce; Profile reports what it would refuse. Send one URL per call. Atool:WebFetchblocked-site rule can also refuse a blocked host visibly named by shellcurl; its allowed-site list does not limit shell commands. These checks do not confine network traffic. - Do not add a block-everything list next to a list of allowed sites: blocked beats allowed, so no site would be left.
The policy
The whole example, 03-domain-rules.lua, from the examples Isonapse publishes.
-- 03-domain-rules.lua — domain allowlist + blocklist for HTTP egress.
--
-- Two fields, evaluated in this order:
--
-- 1. `blocked_domains[<cap>]` — if the target domain matches any
-- pattern here, DENY immediately. Blocked beats allowed.
-- 2. `allowed_domains[<cap>]` — if the list is non-empty for this
-- capability, the target must match at least one entry, otherwise
-- DENY. An empty/absent allowlist means "no allowlist restriction
-- for this capability" — the action falls through.
--
-- Glob shapes the matcher understands:
--
-- - `example.com` — exact match on the whole domain
-- - `*.example.com` — any subdomain (and `example.com` itself)
-- - `*` — every domain
-- - `*.production.*`, `api.*`, `*internal` — `*` matches any run of
-- characters; the pattern is anchored at both ends, so `prod` does
-- NOT match `prod.internal`.
--
-- To express "only these hosts", write the allowlist alone — a non-empty
-- `allowed_domains` list already denies everything it does not name.
-- Do NOT add `blocked_domains = { "*" }` alongside it: blocked beats
-- allowed, so the catch-all denies the allowlist too and the capability
-- becomes unusable. (Earlier releases treated a bare `*` as matching
-- nothing, so that combination looked like it worked.)
--
-- Try it:
-- * tool:WebFetch -> https://api.example.com/x -> PERMIT (matches allowlist)
-- * tool:WebFetch -> https://docs.example.com/y -> PERMIT (*.example.com)
-- * tool:WebFetch -> https://evil.example.com/z -> DENY (blocklist hits first)
-- * tool:WebFetch -> https://other.example/w -> DENY (allowlist excludes)
return {
policy_version = "domain-rules-v1",
-- Blocked first. Even though *.example.com is allowed below, the
-- evil.example.com subdomain is denied because blocked > allowed.
blocked_domains = {
["tool:WebFetch"] = {
"evil.example.com",
"*.malware.test",
},
},
-- Then allowed. Non-empty list = whitelist mode for this capability.
-- A capability with NO entry here is unrestricted (use blocked_domains
-- alone, or combine with blocked_capabilities for a hard floor).
allowed_domains = {
["tool:WebFetch"] = {
"*.example.com",
"api.internal",
"docs.internal",
},
},
}
Stuck? Help finds the message you see.