Repository navigation
feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) - #179
Merged
Merged
Conversation
… in the hook (S3b 1.5-1.7) The approval gate for asset targets now decides. It is opt-in per task and per conversation (target_gate, default off). With the flag off nothing is extracted, resolved, read or written, and every branch of the hook behaves as before. No UI. Extraction and normalisation (1.5) - intercept.NormalizeTarget: lower case, trailing dot, userinfo, IPv6 brackets, IPv4-mapped IPv6, decimal / hex / octal / short IPv4, percent- encoded host, punycode; port explicit, else the scheme default, else 0. - intercept.ExtractTargets: WebFetch url exactly; Bash, shell_open, Monitor (command) and shell_send (text) with the command-string rules (URL with a scheme, IP, IP:port, host:port, CIDR; a bare name is not a target); every string of the input for MCP tools, custom tools and any tool the gate does not know. ExecuteExtraTool is unwrapped to the inner tool. The platform's domain tools, the file tools and web_search have no target. - The fields are decoded as the tools decode them (key case, last duplicate), and a URL authority that reads differently quoted and unquoted yields both readings. Resolver, exemptions, gate decision (1.6) - Resolver interface, system implementation (A and AAAA), 3 s per lookup, positive answers cached 10 s per host with collapsed lookups, failures and empty answers never cached, always fresh when a request is raised. - Exemptions are exact host + port. Derived from the configuration (LLM gateways, search backend in use, platform proxies): computed on every call, never resolved, never voided. Stored (settings key target_gate_exempt_hosts, seeded once with the package sources): resolved, and void when any address is private, loopback, link-local, unspecified, unique-local, multicast or a metadata address. An entry in both origins counts as derived. A stored IP literal that can never be exempt does not apply. - GET / PUT /api/target-gate/exemptions and GET .../history. A change is validated (ValidateExemptionHost on the normalised host) and appended to target_gate_exemption_log in the transaction that stores it. - Interceptor.CheckTargets: asset block rules (global and of the task) on the name and its addresses, exemptions, resolution, pin lookup. A (host, 0) pin covers every port; a (host, 443) pin covers 443 only and never a target without a declared port; two pins are never merged. At most 5 unpinned targets per call. Codes: TARGET_RULE_BLOCKED, TARGET_RESOLVE_FAILED, TARGET_TOO_MANY, TARGET_GATE_UNAVAILABLE; none opens a request. - With the upstream egress proxy set every pin is name-only at call time, whatever name_only_effective says in its row. - An approval never pins zero addresses: the pin writer refuses a request that displays none (db.ErrTargetPinEmpty, 422 on the decide endpoint, the row stays pending) and RequestTargets does not open one. - Every block, and the first use per process of each exemption and of each pin version, is a decided row (decided_by system, decision_source target). The gate in the hook (1.7) - guard.applyIntercept: a deny by a rule or by the judge blocks first, before any target request exists; then CheckTargets; an allow is logged as before and does not satisfy the gate; an ask and an unpinned target share one request, and the classic ask is raised only when it was not merged. The call is checked again after the decisions, at most three passes. - The gate applies to every tool of a gated session, enabled for rules or not, and to the target-only guard of the planner and the main agent, which still records blocks only. - Target blocks have their own model-facing text, built from the code and the reason of the result. Not in this change: rendered targets of custom tools (1.8) and redirect targets (1.9). Subprocess paths stay advisory; the TestBypass_* tests document what the gate does not see.
Merged
usinfosec
pushed a commit
to usinfosec/ARTEX
that referenced
this pull request
Nov 17, 2026
…er-sort feat(traffic): 流量列表支持内容检索、路径/状态码/长度筛选与列排序 (BaaRai#177)
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.
Steps 1.5, 1.6 and 1.7 of the S3b phase 1 plan: the approval gate for asset targets now decides. Builds on #177 (hooks and scope) and #178 (schema, flag, requests).
The gate is opt-in per task and per conversation (
target_gate, default off). With the flag off nothing changes: no extraction, no DNS lookup, no store read. No UI in this phase.What it does
For a tool call of a gated session:
intercept.ExtractTargets): WebFetchurlexactly; Bash, shell_open, Monitor (command) and shell_send (text) with command-string rules (URLs with a scheme, IP literals, IP:port, host:port, CIDR); every string of the input for MCP tools, custom tools and any tool the gate does not know.ExecuteExtraToolis unwrapped to the inner tool. Targets are normalised to(kind, host, port).denyblocks first, before any target request exists.TARGET_RULE_BLOCKED.target_gate_exempt_hosts, seeded once with the package sources), resolved and void when any address is private, loopback, link-local, unspecified, unique-local, multicast or a metadata address.TARGET_RESOLVE_FAILED, no request.(host, 0)pin covers every port; a(host, 443)pin covers 443 only and never a target without a declared port; address sets of two pins are never merged.TARGET_TOO_MANY), merged with a pendingaskof a rule or of the judge when the call creates the row. Wait up to the scope's bound (300 s; 0 in the final settlement round).A rule
allow, a judgeallow, a timeout and an exemption never pin. OnlyDecideon a human click does.Owner conditions
global_proxyset every pin is name-only at call time, whatevername_only_effectivesays in the row:TestProxySetAfterApprovalNeitherBlocksNorAsks(hook, PostgreSQL),TestProxyTurnedOnAfterApprovalMakesPinNameOnly,TestUpstreamProxyMakesPinsNameOnlyAtCallTime.db.ErrTargetPinEmptyin the pin writer (the row stays pending, an existing pin is not re-issued),RequestTargetsrefuses to open such a request, the decide endpoint answers 422.TestTargetPinRefusesEmptyAddressList,TestApprovalNeverPinsEmptyAddressList,TestInterceptDecideRefusesEmptyPinOverHTTP.TestStoredExemptionVoidOnPrivateOrLoopback,TestSeededExemptionIsVoidOnPrivateAddress,TestStoredExemptionOnIPLiteral,TestDerivedExemptionNotVoidedByPrivateAddress,TestEntryInBothOriginsIsDerived.GET/PUT /api/target-gate/exemptions(andGET .../history): settings table, append-onlytarget_gate_exemption_logwritten in the same transaction,ValidateExemptionHoston the normalised host.TestTargetGateExemptionsAPI,TestExemptionChangeIsLogged.TestPinPortPrecedence.TestTargetOnlyGuardRecordsBlocksOnly.TestGateOffLeavesEveryBranchUnchanged,TestGateOffTouchesNothing,TestTargetGateConversationScope,TestTaskGuardsRunTargetGate.Not in this PR
httptool (needs a Norma tag).TestBypass_*tests document what the gate does not see.