ARTEX/db
BaaRai ca15063db7 fix(intercept): match block rules on the declared targets before any lookup
The target gate resolved each name through the cache before it matched the
asset block rules, so a call to a name that a name rule blocks still cost a
DNS lookup, and that query reached the name servers of the blocked domain.
URL rules (exact_url, fuzzy_url) were not evaluated at dispatch at all: the
gate passed no URL to the matcher, so they only applied to asset and intent
writes.

targetCheck.run now decides in this order, for a gated call:

1. URL rules, once per decision, on the URLs the call declares, as written.
2. Every block rule on the declared form of every target: the name as
   written, the IP literal, the range.
3. Only then resolution (names a derived exemption covers are still never
   resolved), and the block rules again on the resolved addresses.
4. Exemptions, pins and requests, unchanged.

A hit in 1 or 2 blocks with TARGET_RULE_BLOCKED and the same decided row as
any block, costs no lookup for any target of the call, and opens no request.

- intercept.extractDeclared returns the targets (ExtractTargets is now a thin
  wrapper, unchanged for its callers) and the URLs that name a target: the
  WebFetch url, and every URL token the command-string rules read in Bash,
  shell_open, Monitor, shell_send and the string leaves of other tools,
  including ExecuteExtraTool's inner call.
- The custom http tool's rendered URL and the URLs of a rendered command go to
  the same URL rules (gateRendered takes the URLs).
- Known limit, stated in the comments next to the matcher (db.matchOne) and
  at the dispatch match: URL rules match the declared string. exact_url misses
  any other spelling (case, percent-encoding, trailing slash, added query,
  /./), fuzzy_url misses an encoded substring, and a command can build its URL
  at run time. For a host, a domain, IP or CIDR rule is the one to write.

Unchanged: a tool-rule or judge deny still blocks before the gate is reached
(no extraction, no lookup, no request); asset block rules still win over an
allow and an ask; the gate off path does nothing; scripts stay advisory.

Tests:
- intercept: TestBlockRuleOnDeclaredNameNeedsNoLookup (exact_domain and
  fuzzy_domain; zero lookups, also for an unblocked name earlier in the same
  call), TestExtractDeclaredURLs, TestURLBlockRuleAtDispatch (WebFetch, Bash,
  MCP, ExecuteExtraTool, a pinned and an exempt host, a disabled rule, the
  rendered URL and command; zero lookups), TestExactURLRuleMatchesOnlyAsWritten
  (documents the limit).
- guard: TestBlockRuleWinsOverAllowAndAsk (name rule and URL rule, each over a
  rule allow, judge allow, rule ask and judge ask, real interceptor: blocked,
  no allow row, nobody asked, zero lookups). TestDenyRuleWinsBeforeTargetRequest
  now also covers a judge deny and asserts zero lookups with the real gate.
- server: TestBypass_CustomScriptToolTargetNotGated documents that a script
  tool's target, written in its stored code, is not visible to the gate: in a
  gated task the call is allowed and reaches the target with no lookup, no
  request and no row.
2026-11-11 15:47:58 +01:00
..
activity_page_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
asset_dsl.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
asset_intercept.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
asset_intercept_match.go fix(intercept): match block rules on the declared targets before any lookup 2026-11-11 15:47:58 +01:00
asset_intercept_match_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
assets.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
assets_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
chat_mentions.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
commands.go fix: prevent OOM when archiving large tasks 2026-08-28 15:25:20 +08:00
companies.go db: report hidden asset count in malformed-ip warning suffix 2026-11-10 15:49:41 +01:00
companies_test.go db: report hidden asset count in malformed-ip warning suffix 2026-11-10 15:49:41 +01:00
company_lock_test.go feat(assets): add editable company and task scopes 2026-08-24 19:29:14 +08:00
company_scope.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
company_scope_consistency_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
company_scope_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
config.go feat(llm): optional custom User-Agent for LLM requests 2026-11-08 17:11:43 +01:00
config_max_tokens_test.go feat(llm): 模型配置新增输出上限,支持 max_completion_tokens 字段名 2026-08-31 12:20:31 -04:00
config_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
constants.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
constraints.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
conversation.go feat(intercept): target-gate schema, opt-in flag and approval requests (S3b 1.2-1.4) 2026-11-10 23:05:47 +01:00
conversation_pin_test.go feat(chat): add conversation pinning and rename controls 2026-08-24 19:29:38 +08:00
customtool_test.go chore: ARTEX 初始化 2026-07-26 04:27:45 -04:00
db.go feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) 2026-11-11 00:34:55 +01:00
db_test.go fix: prevent OOM when archiving large tasks 2026-08-28 15:25:20 +08:00
digest.go feat(digest): 探索图冷节点压缩(cold-digest) 2026-09-09 11:52:15 -04:00
exploration.go feat(engine): intent claim heartbeat, TTL and fencing token (S3c) 2026-11-10 17:45:11 +01:00
exploration_sources.go chore: sync upstream v0.3.6 changes 2026-08-28 14:03:07 +08:00
exploration_sources_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
exploration_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
exploration_tokens_test.go Merge upstream/main into codex/btw-side-question 2026-09-11 08:47:57 +08:00
export_test.go fix(intercept): judge decisions were stored as unknown (prefix case mismatch) 2026-11-09 12:22:46 +01:00
finding_assets.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
finding_assets_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
finding_retests.go feat(intercept): target-gate schema, opt-in flag and approval requests (S3b 1.2-1.4) 2026-11-10 23:05:47 +01:00
finding_retests_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
finding_retests_verification_test.go feat: a completed retest updates the verification state 2026-11-09 21:47:40 +01:00
finding_traffic.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
finding_traffic_archive.go feat: 支持漏洞关联多条流量证据 2026-09-10 13:03:20 +08:00
finding_traffic_archive_test.go feat: 支持漏洞关联多条流量证据 2026-09-10 13:03:20 +08:00
finding_verification.go feat: verified findings backend (S1) 2026-11-09 20:21:27 +01:00
findings.go feat: verification status badge, filter and note in the findings UI 2026-11-09 21:04:12 +01:00
findings_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
intent_admission.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
intent_claim_test.go feat(engine): intent claim heartbeat, TTL and fencing token (S3c) 2026-11-10 17:45:11 +01:00
intent_control_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
intent_delete_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
intercept.go feat: show and filter the decided_by actor in the approval records 2026-11-09 22:35:09 +01:00
intercept_decided_by_test.go feat: show and filter the decided_by actor in the approval records 2026-11-09 22:35:09 +01:00
intercept_detail.go feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) 2026-11-11 00:34:55 +01:00
intercept_detail_test.go feat: record which actor decided an intercept approval 2026-11-09 22:17:56 +01:00
intercept_execution.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
intercept_execution_test.go 精简动作审查输入并支持审批来源定位 (#125) 2026-09-15 23:51:37 +08:00
intercept_filter_test.go fix(intercept): judge decisions were stored as unknown (prefix case mismatch) 2026-11-09 12:22:46 +01:00
intercept_seed_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
intercept_source_test.go fix(intercept): judge decisions were stored as unknown (prefix case mismatch) 2026-11-09 12:22:46 +01:00
jsonb_clean_test.go fix(db): side_question checkpoint 入库前剥除 jsonb 不支持的 NUL 转义 2026-09-12 03:00:28 -04:00
lessons.go feat(rsi): evidence-gated lesson library in shadow mode 2026-10-21 14:25:35 +02:00
lessons_test.go feat(rsi): evidence-gated lesson library in shadow mode 2026-10-21 14:25:35 +02:00
llm_records_migrate_test.go feat(llmrec): 录制 LLM 请求/响应 HTTP 原文 2026-08-25 09:40:05 -04:00
llm_usage.go fix: cost ledger charges fresh input only (cache read is part of input tokens) 2026-10-12 08:53:20 +02:00
llmhealth.go feat(llm): add profile failover and pool health 2026-08-24 19:28:18 +08:00
llmretry.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
llmretry_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
logs.go chore: ARTEX 初始化 2026-07-26 04:27:45 -04:00
nkey.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
notification.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
notification_delivery.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
notification_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
schema.sql feat(intercept): target-gate schema, opt-in flag and approval requests (S3b 1.2-1.4) 2026-11-10 23:05:47 +01:00
settings.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
settings_insert_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
side_questions.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
side_questions_test.go fix(btw): 修复长对话上下文预算与旁路输入布局 2026-09-11 00:41:01 +08:00
skill_gaps.go feat(server): capability-gap report from skill misses 2026-10-19 00:33:08 +02:00
skill_usage.go 归档 2026-08-28 12:56:29 +08:00
skill_usage_test.go feat(skills): track usage and missing dependencies 2026-08-24 19:30:14 +08:00
target_pins.go feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) 2026-11-11 00:34:55 +01:00
target_pins_test.go feat(intercept): target extraction, resolver, exemptions and the gate in the hook (S3b 1.5-1.7) 2026-11-11 00:34:55 +01:00
task_archive_aggregate_stats.go 归档 2026-08-28 12:56:29 +08:00
task_archives.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_archives_restore.go feat(intercept): target-gate schema, opt-in flag and approval requests (S3b 1.2-1.4) 2026-11-10 23:05:47 +01:00
task_archives_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_assets.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_assets_context.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_assets_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_categories.go feat(tasks): 任务列表支持批量修改分类 2026-08-24 09:16:44 -04:00
task_categories_test.go feat(tasks): 任务列表支持批量修改分类 2026-08-24 09:16:44 -04:00
task_context.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_context_lock_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
task_context_unit_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_credentials.go feat(tasks): per-task test-account credentials 2026-10-09 14:28:08 +02:00
task_delete_concurrency_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
task_intercept.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_list_performance_test.go 修复BUG: 1、当存在较多任务时,系统会发生卡顿,加载对话或者加载界面时候存在明显卡顿,优化性能找出问题 2026-08-28 08:00:36 +08:00
task_metadata_test.go 1、将排序做到border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted里,无需单独做个button 2、指定重命名使用ICO,无需使用菜单 2026-08-25 14:56:15 +08:00
task_outcome.go feat(server): per-task outcome card for RSI baselines 2026-10-19 00:28:27 +02:00
task_queue_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
task_scope.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
task_scope_test.go fix(scope): add_task_scope 支持 host:port 目标,入库前剥端口 2026-08-09 09:09:59 -04:00
task_source_limit_test.go feat(tasks): add runtime controls and inherited context 2026-08-24 19:29:00 +08:00
task_templates.go feat: 任务模板支持预设分类与任务级拦截/允许规则 2026-09-19 09:27:03 -04:00
task_templates_test.go feat(tasks): add categories templates and batch controls 2026-08-24 19:29:46 +08:00
tasks.go feat(intercept): target-gate schema, opt-in flag and approval requests (S3b 1.2-1.4) 2026-11-10 23:05:47 +01:00
tasks_test.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
testmain_test.go feat: each test package runs on its own database 2026-10-12 18:43:29 +02:00
tool_usage.go 归档 2026-08-28 12:56:29 +08:00
tool_usage_test.go 抽屉优化 2026-08-25 12:05:26 +08:00
tools.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00
triggers.go Translate all Chinese text to English 2026-10-08 23:14:34 +02:00