bugx-cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +193 -185
  2. package/core/README.md +2 -2
  3. package/core/agent/README.md +2 -1
  4. package/core/agent/agent_artifacts.py +8 -6
  5. package/core/agent/agent_eval.py +136 -54
  6. package/core/agent/agent_execution.py +218 -52
  7. package/core/agent/agent_orchestrator.py +14 -8
  8. package/core/agent/agent_targets.py +8 -2
  9. package/core/agent/feature_baseline.py +150 -0
  10. package/core/assets/README.md +3 -2
  11. package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
  12. package/core/assets/axe-core/LICENSE.txt +362 -0
  13. package/core/assets/axe-core/UPSTREAM.md +10 -0
  14. package/core/assets/axe-core/axe.min.js +12 -0
  15. package/core/assets/bugx-hero-en.svg +74 -0
  16. package/core/assets/bugx-hero-zh.svg +74 -0
  17. package/core/assets/bugx-social-preview.svg +71 -0
  18. package/core/assets/bugx-wechat-group.png +0 -0
  19. package/core/assets/codex.png +0 -0
  20. package/core/assets/dsh.png +0 -0
  21. package/core/assets/webui-chatgpt.jpg +0 -0
  22. package/core/assets/webui-session.jpg +0 -0
  23. package/core/assets/webui-skills.jpg +0 -0
  24. package/core/assets/webui-studio.jpg +0 -0
  25. package/core/assets/webui-zcode.jpg +0 -0
  26. package/core/assets/zcode.png +0 -0
  27. package/core/audit_packs/README.md +2 -0
  28. package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
  29. package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
  30. package/core/audit_packs/pitfalls/go_backend.json +66 -0
  31. package/core/audit_packs/pitfalls/java_spring.json +64 -0
  32. package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
  33. package/core/audit_packs/pitfalls/python_web.json +82 -0
  34. package/core/autonomous_cve/SPEC.md +1 -1
  35. package/core/autonomous_cve/attack_graph_store.py +152 -106
  36. package/core/autonomous_cve/behavior_graph.py +8 -2
  37. package/core/autonomous_cve/verifier.py +4 -1
  38. package/core/bugx.md +1 -1
  39. package/core/bugx_paths.py +43 -8
  40. package/core/cli-help.txt +66 -0
  41. package/core/cloud_sync/SPEC.md +1 -1
  42. package/core/cloud_sync/cloud_client.py +81 -11
  43. package/core/cloud_sync/cloud_onboard.py +42 -1
  44. package/core/cloud_sync/consent.py +33 -3
  45. package/core/cloud_sync/flywheel_client.py +186 -15
  46. package/core/cloud_sync/network_transport.py +24 -3
  47. package/core/cloud_sync/sensitive_filter.py +2 -2
  48. package/core/cloud_sync/sync_push.py +12 -10
  49. package/core/contracts/AGENT_GUIDE.md +6 -9
  50. package/core/contracts/README.md +2 -2
  51. package/core/contracts/bugx-runtime-contract.md +1 -1
  52. package/core/contracts/bugx-worker.md +1 -1
  53. package/core/contracts/engine_gap_contracts.py +86 -3
  54. package/core/coverage/coverage_discovery.py +599 -29
  55. package/core/coverage/coverage_evidence.py +47 -0
  56. package/core/coverage/coverage_forensics.py +9 -0
  57. package/core/coverage/coverage_validate.py +6 -1
  58. package/core/dev_harness/SPEC.md +1 -1
  59. package/core/engine-integrity.json +670 -442
  60. package/core/fuzzing/concurrency_fuzzer.py +53 -0
  61. package/core/fuzzing/differential_oracle.py +562 -27
  62. package/core/fuzzing/fuzz_input.py +109 -6
  63. package/core/fuzzing/stateful_fuzzer.py +72 -0
  64. package/core/governance/secret_redactor.py +22 -10
  65. package/core/host_acp/SPEC.md +1 -1
  66. package/core/host_acp/__init__.py +4 -4
  67. package/core/host_acp/claude.py +59 -1
  68. package/core/host_acp/cline.py +64 -1
  69. package/core/host_acp/codex.py +56 -1
  70. package/core/host_acp/dsh.py +59 -1
  71. package/core/host_acp/opencode.py +56 -1
  72. package/core/host_acp/pi.py +59 -1
  73. package/core/host_acp/zcode.py +59 -1
  74. package/core/host_runtime/SPEC.md +1 -1
  75. package/core/host_runtime/adapters.py +1 -1
  76. package/core/host_runtime/cline.py +13 -0
  77. package/core/host_runtime/host_evaluators.py +44 -4
  78. package/core/host_runtime/host_probe.py +1 -1
  79. package/core/host_runtime/host_provider_arbitrator.py +116 -62
  80. package/core/host_runtime/host_registry.py +15 -8
  81. package/core/host_runtime/mcp_registry_gate.py +12 -1
  82. package/core/host_runtime/pi.py +102 -0
  83. package/core/host_runtime/provider_facts.py +66 -0
  84. package/core/hosts/SPEC.md +1 -1
  85. package/core/hosts/__init__.py +6 -2
  86. package/core/hosts/_dsh_usage.py +1 -1
  87. package/core/hosts/base.py +32 -4
  88. package/core/hosts/claude.py +55 -0
  89. package/core/hosts/cline.py +6 -2
  90. package/core/hosts/codex.py +58 -0
  91. package/core/hosts/dsh.py +9 -1
  92. package/core/hosts/opencode.py +6 -6
  93. package/core/hosts/pi.py +159 -2
  94. package/core/infra/README.md +4 -2
  95. package/core/infra/__init__.py +2 -0
  96. package/core/infra/build_info.py +22 -3
  97. package/core/infra/client_metadata.py +1 -1
  98. package/core/infra/json_utils.py +22 -0
  99. package/core/launch_phases/README.md +6 -3
  100. package/core/launch_phases/SPEC.md +1 -1
  101. package/core/launch_phases/common.py +21 -2
  102. package/core/launch_phases/finding_confirm_phase.py +170 -5
  103. package/core/launch_phases/finding_settlement.py +188 -1
  104. package/core/launch_phases/judge_phase.py +69 -12
  105. package/core/launch_phases/orchestrator_controls.py +11 -7
  106. package/core/launch_phases/post_coverage_sync.py +9 -2
  107. package/core/launch_phases/post_phase.py +144 -8
  108. package/core/launch_phases/post_receipt.py +12 -1
  109. package/core/launch_phases/pre_phase.py +3 -3
  110. package/core/launch_phases/pre_recon_scout.py +66 -36
  111. package/core/launch_phases/pre_state_builder.py +23 -176
  112. package/core/launch_phases/report_sharing.py +3 -7
  113. package/core/launch_phases/round_orchestrator.py +129 -58
  114. package/core/launch_phases/semantic_recon.py +545 -0
  115. package/core/launch_phases/session_runtime.py +56 -9
  116. package/core/launch_phases/startup_gates.py +36 -8
  117. package/core/launch_phases/startup_interaction.py +68 -12
  118. package/core/launch_phases/startup_version_gate.py +13 -3
  119. package/core/launch_phases/supervisor_bridge.py +46 -17
  120. package/core/launch_phases/supervisor_coverage.py +8 -2
  121. package/core/launch_phases/supervisor_degraded.py +1 -9
  122. package/core/launch_phases/verify_loop.py +767 -0
  123. package/core/launch_phases/worker_barriers.py +15 -5
  124. package/core/launch_phases/worker_orchestrator.py +105 -25
  125. package/core/launch_phases/worker_prior.py +115 -0
  126. package/core/ledger/README.md +2 -1
  127. package/core/ledger/SPEC.md +1 -1
  128. package/core/ledger/_facade.py +2 -1
  129. package/core/ledger/archive_ops.py +60 -2
  130. package/core/ledger/cli.py +6 -1
  131. package/core/ledger/export_ops.py +6 -1
  132. package/core/ledger/finding_confirmation.py +48 -6
  133. package/core/ledger/finding_lifecycle.py +428 -5
  134. package/core/ledger/finding_verification.py +555 -10
  135. package/core/ledger/fp_ledger.py +255 -0
  136. package/core/ledger/incidents.py +10 -4
  137. package/core/ledger/patterns.py +10 -7
  138. package/core/ledger/receipt_contract.py +17 -1
  139. package/core/ledger/sync_ops.py +21 -16
  140. package/core/ledger/tool_experience.py +2 -1
  141. package/core/ledger/verify_life.py +88 -17
  142. package/core/locales/en-US.json +2 -2
  143. package/core/locales/zh-CN.json +2 -2
  144. package/core/mcp_handlers/SPEC.md +1 -1
  145. package/core/mcp_handlers/base.py +23 -3
  146. package/core/mcp_handlers/channel_lifecycle.py +85 -30
  147. package/core/mcp_handlers/retrieval_handlers.py +11 -1
  148. package/core/mcp_handlers/rpc_server.py +6 -1
  149. package/core/mcp_handlers/supervisor_handlers.py +32 -6
  150. package/core/mcp_handlers/tool_table.py +15 -0
  151. package/core/mcp_runtime_support/environment.py +0 -38
  152. package/core/mcp_runtime_support/verifier.py +0 -52
  153. package/core/metadata.txt +2 -3
  154. package/core/planning/README.md +2 -1
  155. package/core/planning/domain_router.py +4 -2
  156. package/core/planning/dynamic_flow_analyzer.py +219 -14
  157. package/core/planning/judge_pipeline.py +87 -4
  158. package/core/planning/prompt_harness.py +57 -15
  159. package/core/planning/prompt_policy_engine.py +386 -0
  160. package/core/planning/spec_harvester.py +4 -4
  161. package/core/probes/INTERFACE.md +11 -1
  162. package/core/probes/SPEC.md +11 -1
  163. package/core/probes/__init__.py +46 -40
  164. package/core/probes/android_probe.py +177 -9
  165. package/core/probes/codebase_memory_probe.py +57 -0
  166. package/core/probes/desktop_probe.py +104 -0
  167. package/core/probes/differential_probe.py +99 -21
  168. package/core/probes/efficiency_probe.py +64 -0
  169. package/core/probes/ios_binary_probe.py +105 -1
  170. package/core/probes/memory_probe.py +66 -0
  171. package/core/probes/miniprogram_probe.py +75 -13
  172. package/core/probes/mobile_probe.py +215 -30
  173. package/core/probes/native_probe.py +88 -0
  174. package/core/probes/openwiki_probe.py +70 -0
  175. package/core/probes/pattern_probe.py +106 -0
  176. package/core/probes/platform_probe.py +81 -0
  177. package/core/probes/probe_registry.py +108 -7
  178. package/core/probes/sast_fixture_corpus.py +340 -0
  179. package/core/probes/sast_probe.py +553 -52
  180. package/core/probes/sast_rules.py +668 -28
  181. package/core/probes/sca_scanner.py +48 -0
  182. package/core/probes/ui_accessibility.py +149 -0
  183. package/core/probes/ui_audit.py +513 -0
  184. package/core/probes/ui_contract.py +273 -0
  185. package/core/probes/ui_evidence.py +212 -0
  186. package/core/probes/ui_measurements.py +314 -0
  187. package/core/probes/ui_repair.py +250 -0
  188. package/core/probes/ui_review.py +133 -0
  189. package/core/probes/ui_storybook.py +107 -0
  190. package/core/probes/ui_tokens.py +185 -0
  191. package/core/probes/ui_visual_diff.py +131 -0
  192. package/core/probes/web_probe.py +373 -18
  193. package/core/project_profiler/SPEC.md +1 -1
  194. package/core/project_profiler/arbitrator.py +6 -1
  195. package/core/project_profiler/detector.py +8 -1
  196. package/core/project_profiler/strategy.py +51 -15
  197. package/core/prompts/README.md +4 -2
  198. package/core/prompts/command_routing_en.md +2 -2
  199. package/core/prompts/command_routing_zh.md +2 -2
  200. package/core/prompts/policies/prompt_policies.json +101 -0
  201. package/core/prompts/stages/stage_repair.md +1 -1
  202. package/core/prompts/stages/stage_verify.defensive.md +42 -0
  203. package/core/prompts/stages/stage_verify.md +44 -0
  204. package/core/repair/README.md +1 -1
  205. package/core/repair/l7_repair_loop.py +1 -4
  206. package/core/repair/rsi_fixer.py +4 -4
  207. package/core/repair/rsi_loop.py +1 -3
  208. package/core/repair/rsi_repair.py +7 -7
  209. package/core/repair/rsi_scope.py +27 -8
  210. package/core/report_engine/SPEC.md +1 -1
  211. package/core/report_engine/attestation.py +8 -4
  212. package/core/report_engine/finding_report.py +2 -1
  213. package/core/report_engine/models.py +7 -9
  214. package/core/report_engine/report_share.py +0 -8
  215. package/core/report_engine/sast_bridge.py +2 -2
  216. package/core/report_engine/server.py +18 -8
  217. package/core/report_engine/web-conformance.md +123 -18
  218. package/core/report_engine/web_conformance.py +21 -52
  219. package/core/retrieval/README.md +2 -1
  220. package/core/retrieval/SPEC.md +1 -1
  221. package/core/retrieval/code_analyzer.py +50 -14
  222. package/core/retrieval/context_assembler.py +7 -1
  223. package/core/retrieval/knowledge_sync.py +108 -14
  224. package/core/retrieval/pitfall_packs.py +277 -0
  225. package/core/retrieval/symbol_index.py +25 -6
  226. package/core/retrieval/universal_code_matcher.py +234 -49
  227. package/core/runtime/README.md +1 -1
  228. package/core/runtime/bugx_logging.py +78 -7
  229. package/core/runtime/fixture_solidify.py +5 -10
  230. package/core/runtime/global_telemetry.py +20 -0
  231. package/core/runtime/incident_eval.py +1 -1
  232. package/core/runtime/model_runner.py +4 -41
  233. package/core/runtime/platform_adapter.py +2 -2
  234. package/core/runtime/prep_validate.py +4 -2
  235. package/core/runtime/project_settings.py +2 -1
  236. package/core/runtime/scenario_eval.py +50 -8
  237. package/core/skills/bugx_docs_mcp_server.py +3 -1
  238. package/core/skills/bugx_mcp_server.py +29 -2
  239. package/core/skills/tools_kb.py +1 -1
  240. package/core/supervisor/README.md +1 -1
  241. package/core/supervisor/SPEC.md +1 -1
  242. package/core/supervisor/budget_governor.py +503 -9
  243. package/core/supervisor/checkpoint_pipeline.py +248 -6
  244. package/core/supervisor/checkpoint_sync.py +13 -0
  245. package/core/supervisor/claim_events.py +1 -1
  246. package/core/supervisor/finding_workflow.py +22 -5
  247. package/core/supervisor/lease_manager.py +1 -1
  248. package/core/supervisor/lifecycle_blocks.py +6 -1
  249. package/core/supervisor/rejection_remedies.py +52 -5
  250. package/core/supervisor/serial_authorization.py +48 -4
  251. package/core/supervisor/task_scheduler.py +2 -2
  252. package/core/supervisor/worker_checkpoint.py +8 -1
  253. package/core/supervisor/worker_runtime.py +8 -2
  254. package/core/supervisor_types/worker_claim.py +9 -0
  255. package/core/webui/README.md +1 -1
  256. package/core/webui/SPEC.md +2 -1
  257. package/core/webui/adapters/claude.py +5 -1
  258. package/core/webui/adapters/cline.py +10 -2
  259. package/core/webui/adapters/codex.py +5 -1
  260. package/core/webui/adapters/dsh.py +5 -1
  261. package/core/webui/docs_session_service.py +2 -2
  262. package/core/webui/mcp_inspector.py +11 -7
  263. package/core/webui/static/00-base.css +1060 -0
  264. package/core/webui/static/01-monitoring.css +802 -0
  265. package/core/webui/static/02-header-actions.css +321 -0
  266. package/core/webui/static/03-trigger-popover.css +697 -0
  267. package/core/webui/static/04-composer.css +628 -0
  268. package/core/webui/static/05-skills-center.css +878 -0
  269. package/core/webui/static/06-mcp-center.css +623 -0
  270. package/core/webui/static/07-skill-detail.css +265 -0
  271. package/core/webui/static/08-files-management.css +167 -0
  272. package/core/webui/static/09-files-center.css +386 -0
  273. package/core/webui/static/10-icons.css +105 -0
  274. package/core/webui/static/11-project-options.css +185 -0
  275. package/core/webui/static/12-profile-tab.css +383 -0
  276. package/core/webui/static/design-tokens.css +113 -0
  277. package/core/webui/static/index.html +14 -1
  278. package/core/webui/workspace_service.py +1 -1
  279. package/docs/07_distribution/01_README_NPM.md +193 -185
  280. package/ecosystem/integrations/README.md +1 -1
  281. package/ecosystem/integrations/dsh/mcp/package.json +1 -1
  282. package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
  283. package/ecosystem/integrations/dsh/ui/package.json +1 -1
  284. package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
  285. package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
  286. package/ecosystem/integrations/opencode/opencode.json +23 -12
  287. package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
  288. package/ecosystem/integrations/qoder/connector-meta.json +1 -1
  289. package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
  290. package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
  291. package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
  292. package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
  293. package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
  294. package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
  295. package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
  296. package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
  297. package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
  298. package/interfaces/bin/bugx.js +37 -0
  299. package/interfaces/cli/bugx_cli/__init__.py +4 -2
  300. package/interfaces/cli/bugx_cli/cli.py +172 -69
  301. package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
  302. package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
  303. package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
  304. package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
  305. package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
  306. package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
  307. package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
  308. package/interfaces/cli/bugx_cli/commands/knowledge.py +5 -4
  309. package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
  310. package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
  311. package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
  312. package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
  313. package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
  314. package/interfaces/cli/bugx_cli/commands/project.py +6 -13
  315. package/interfaces/cli/bugx_cli/commands/report.py +2 -6
  316. package/interfaces/cli/bugx_cli/commands/system.py +524 -169
  317. package/interfaces/cli/bugx_cli/common.py +21 -15
  318. package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
  319. package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
  320. package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
  321. package/interfaces/cli/bugx_cli/infra/engine_installer.py +35 -16
  322. package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
  323. package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
  324. package/interfaces/cli/bugx_cli/infra/security.py +13 -6
  325. package/package.json +30 -15
  326. package/pyproject.toml +60 -9
  327. package/scripts/ensure-python.mjs +7 -7
  328. package/scripts/sync-version.mjs +10 -21
  329. package/scripts/test-npm-wrapper.mjs +1 -1
  330. package/core/assets/bugx-hero-cn.png +0 -0
  331. package/core/assets/bugx-hero-en.png +0 -0
  332. package/core/webui/static/project-settings.css +0 -6458
  333. package/docs/07_distribution/README.md +0 -16
  334. package/docs/README.md +0 -121
  335. package/interfaces/README.md +0 -143
  336. package/interfaces/bin/README.md +0 -35
  337. package/interfaces/cli/README.md +0 -90
  338. package/scripts/README.md +0 -118
@@ -0,0 +1,82 @@
1
+ {
2
+ "pack_id": "python_web",
3
+ "schema_version": 1,
4
+ "description": "Python Web & ORM 冷启动漏洞先验包(FastAPI / Django / Flask / SQLAlchemy / Jinja2 / Pickle)",
5
+ "pitfalls": [
6
+ {
7
+ "pitfall_id": "PY-SQLI-001",
8
+ "cwe": "CWE-89",
9
+ "severity": "critical",
10
+ "languages": ["python"],
11
+ "frameworks": ["fastapi", "django", "flask", "sqlalchemy"],
12
+ "surfaces": ["http", "api", "database"],
13
+ "title": "ORM text()/raw()/extra() 字符串拼接导致 SQL 注入",
14
+ "anti_pattern_signals": ["text(f\"", "text(\"", ".raw(f\"", ".extra(", "cursor.execute(f\"", "execute(\"SELECT", "%s\" %", ".format("],
15
+ "false_positive_guards": [
16
+ "使用绑定参数 text('... :id').bindparams(id=val) 或 cursor.execute(sql, (val,))",
17
+ "拼接项来自硬编码白名单映射(如 ALLOWED_SORT_COLS[col])"
18
+ ],
19
+ "poc_skeleton": "向查询参数传入 `' OR '1'='1` 或布尔盲注条件,对比合法输入与注入输入的返回行数/结果集差异"
20
+ },
21
+ {
22
+ "pitfall_id": "PY-SSTI-002",
23
+ "cwe": "CWE-1336",
24
+ "severity": "critical",
25
+ "languages": ["python"],
26
+ "frameworks": ["flask", "fastapi", "django", "jinja2"],
27
+ "surfaces": ["http", "web", "template"],
28
+ "title": "Jinja2 Template/render_template_string 直接渲染非受信用户输入(SSTI)",
29
+ "anti_pattern_signals": ["render_template_string(", "Template(", "from_string(", "Environment("],
30
+ "false_positive_guards": [
31
+ "模板字符串为常量,用户输入仅作为上下文变量传入(render_template_string(CONST, name=user_input))",
32
+ "使用 SandboxedEnvironment 且严格限制对象属性访问"
33
+ ],
34
+ "poc_skeleton": "传入 `{{7*7}}` 验证算术求值被渲染为 `49`;负对照传入纯文本 `hello` 原样输出"
35
+ },
36
+ {
37
+ "pitfall_id": "PY-DESER-003",
38
+ "cwe": "CWE-502",
39
+ "severity": "critical",
40
+ "languages": ["python"],
41
+ "frameworks": ["fastapi", "django", "flask", "celery"],
42
+ "surfaces": ["http", "api", "cache", "queue"],
43
+ "title": "对非受信字节流调用 pickle.loads / yaml.load(不安全反序列化)",
44
+ "anti_pattern_signals": ["pickle.loads(", "pickle.load(", "yaml.load(", "marshal.loads(", "shelve.open("],
45
+ "false_positive_guards": [
46
+ "yaml.safe_load 或显式指定 Loader=yaml.SafeLoader",
47
+ "输入先经过 HMAC-SHA256 强签名验证(hmac.compare_digest)且密钥未泄露"
48
+ ],
49
+ "poc_skeleton": "构造最小 `__reduce__` payload(无害标记对象或环境变量探针),验证反序列化触发任意可调用对象执行"
50
+ },
51
+ {
52
+ "pitfall_id": "PY-AUTHZ-004",
53
+ "cwe": "CWE-862",
54
+ "severity": "high",
55
+ "languages": ["python"],
56
+ "frameworks": ["fastapi", "django", "flask"],
57
+ "surfaces": ["http", "api", "auth"],
58
+ "title": "FastAPI/Django/Flask 路由缺失鉴权依赖或对象归属校验(IDOR)",
59
+ "anti_pattern_signals": ["@app.get(", "@app.post(", "@router.", "Depends(", "get_object_or_404(", "filter(id="],
60
+ "false_positive_guards": [
61
+ "APIRouter 顶层已绑定 dependencies=[Depends(require_auth)] 且查询带 owner_id == current_user.id",
62
+ "Django 视图继承 LoginRequiredMixin 且 get_queryset 按 request.user 过滤"
63
+ ],
64
+ "poc_skeleton": "以普通用户 A 的会话请求属于用户 B 的 resource_id,断言越权读取或修改成功;负对照访问自身资源正常"
65
+ },
66
+ {
67
+ "pitfall_id": "PY-MASSASSIGN-005",
68
+ "cwe": "CWE-915",
69
+ "severity": "high",
70
+ "languages": ["python"],
71
+ "frameworks": ["fastapi", "django", "sqlalchemy"],
72
+ "surfaces": ["http", "api", "database"],
73
+ "title": "请求体未裁剪直接 setattr / model_dump 更新敏感字段(批量赋值)",
74
+ "anti_pattern_signals": ["setattr(", "model_dump(", ".dict()", "**payload", "fields = '__all__'"],
75
+ "false_positive_guards": [
76
+ "使用显式字段白名单 Schema(排除 is_admin / role / balance)",
77
+ "setattr 前严格校验 key in ALLOWED_UPDATE_FIELDS"
78
+ ],
79
+ "poc_skeleton": "向更新接口附加 `is_admin=True` 或 `role='admin'`,验证持久化对象权限字段被意外改写"
80
+ }
81
+ ]
82
+ }
@@ -21,5 +21,5 @@ from core.autonomous_cve import AutonomousRunner
21
21
  ```
22
22
 
23
23
  ## 5. Maintenance & Verification
24
- - Unit & regression tests for this package are registered in `tests/test_registry.json`.
24
+ - Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
25
25
  - Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/autonomous_cve --write`.
@@ -625,114 +625,159 @@ def _on_hypothesis_rejected(graph: LivingAttackGraph, payload: Mapping[str, Any]
625
625
  )
626
626
  # 2. 快照:此刻拓扑里还没有本次推测节点。
627
627
  snapshot_id = graph.create_snapshot(tag=f"pre-reflex:{hyp_id}")
628
- # 3. 推测拓扑入图(worker 在失败尝试中声称的端点/汇点)。
629
- speculative_routes = _texts(payload.get("speculative_routes"))
630
- speculative_sinks = _texts(payload.get("speculative_sinks"))
631
- for row in payload.get("speculative") or []:
632
- if isinstance(row, str):
633
- # 允许只给 id:sink: 前缀归汇点,其余按端点处理。
634
- if row.startswith("sink:"):
635
- speculative_sinks.append(row)
636
- else:
637
- speculative_routes.append(row)
638
- continue
639
- if not isinstance(row, Mapping):
640
- continue
641
- try:
642
- if row.get("kind"):
643
- result = _on_sink(graph, {**row, "speculative": True}, ctx)
644
- speculative_sinks.append(result.get("sink_id", ""))
645
- else:
646
- result = _on_endpoint(graph, row, ctx)
647
- node = graph.routes.get(result.get("route_id"))
648
- if isinstance(node, dict):
649
- node["speculative"] = True
650
- speculative_routes.append(result.get("route_id", ""))
651
- except AttackGraphStoreError:
652
- continue
653
- for route_id in speculative_routes:
654
- if route_id not in graph.routes:
655
- graph.add_route(route_id, "GET", True, speculative=True, unit_id=_text(payload.get("unit_id")))
656
- for sink_id in speculative_sinks:
657
- if sink_id not in graph.sinks:
658
- graph.add_sink(sink_id, _text(payload.get("kind")) or "unknown",
659
- speculative=True, unit_id=_text(payload.get("unit_id")))
660
- # 4. 反思回溯:历史直接别名在 graph.reflex 上,因此天然跨 Round 存活。
661
- engine = ReflexiveBacktrackingEngine(graph)
662
- history_before = len(engine.backtrack_history.get(hyp_id, []))
663
- decision = engine.record_attempt(
664
- hyp_id,
665
- status_code=int(payload.get("status_code") or 0),
666
- response_body=str(payload.get("response_body") or payload.get("body_snippet") or ""),
667
- is_exploit_successful=bool(payload.get("is_exploit_successful", False)),
668
- has_negative_control=bool(payload.get("has_negative_control", False)),
669
- request_context=payload.get("request_context") if isinstance(payload.get("request_context"), Mapping) else None,
670
- )
671
- attempts = len(engine.backtrack_history.get(hyp_id, [])) - history_before
672
- # 5. 自动修包产物**只作为图谱属性/reflex 记录**,绝不回写证据文件。
673
- # 节点级属性留到回滚之后再写,否则会被自己刚恢复的快照抹掉。
674
- fix = decision.get("heuristic_fix")
675
- if isinstance(fix, Mapping):
676
- suggestions = graph.reflex.setdefault("auto_fix_suggestions", [])
677
- suggestions.append({"hypothesis_id": hyp_id, **dict(fix), "recorded_at": time.time()})
678
- del suggestions[:-_ag.MAX_ROLLBACK_LOG]
679
- # 有可尝试的补丁头 → 记录就地重放计划,交给有网络能力的消费者执行。
680
- headers = fix.get("patch_headers")
681
- if isinstance(headers, Mapping) and headers:
682
- pending = graph.reflex.setdefault("replay_pending", [])
683
- pending.append({
628
+ speculative_routes: list[str] = []
629
+ speculative_sinks: list[str] = []
630
+ decision: dict[str, Any] = {}
631
+ attempts = 0
632
+ fix: Any = None
633
+ final_status = ""
634
+ terminal = False
635
+ rolled_back = False
636
+ compensation_failed = False
637
+ pending_error: BaseException | None = None
638
+
639
+ try:
640
+ # 3. 推测拓扑入图(worker 在失败尝试中声称的端点/汇点)。
641
+ speculative_routes = _texts(payload.get("speculative_routes"))
642
+ speculative_sinks = _texts(payload.get("speculative_sinks"))
643
+ for row in payload.get("speculative") or []:
644
+ if isinstance(row, str):
645
+ # 允许只给 id:sink: 前缀归汇点,其余按端点处理。
646
+ if row.startswith("sink:"):
647
+ speculative_sinks.append(row)
648
+ else:
649
+ speculative_routes.append(row)
650
+ continue
651
+ if not isinstance(row, Mapping):
652
+ continue
653
+ try:
654
+ if row.get("kind"):
655
+ result = _on_sink(graph, {**row, "speculative": True}, ctx)
656
+ speculative_sinks.append(result.get("sink_id", ""))
657
+ else:
658
+ result = _on_endpoint(graph, row, ctx)
659
+ node = graph.routes.get(result.get("route_id"))
660
+ if isinstance(node, dict):
661
+ node["speculative"] = True
662
+ speculative_routes.append(result.get("route_id", ""))
663
+ except AttackGraphStoreError:
664
+ continue
665
+ for route_id in speculative_routes:
666
+ if route_id not in graph.routes:
667
+ graph.add_route(route_id, "GET", True, speculative=True, unit_id=_text(payload.get("unit_id")))
668
+ for sink_id in speculative_sinks:
669
+ if sink_id not in graph.sinks:
670
+ graph.add_sink(sink_id, _text(payload.get("kind")) or "unknown",
671
+ speculative=True, unit_id=_text(payload.get("unit_id")))
672
+ # 4. 反思回溯:历史直接别名在 graph.reflex 上,因此天然跨 Round 存活。
673
+ engine = ReflexiveBacktrackingEngine(graph)
674
+ history_before = len(engine.backtrack_history.get(hyp_id, []))
675
+ decision = engine.record_attempt(
676
+ hyp_id,
677
+ status_code=int(payload.get("status_code") or 0),
678
+ response_body=str(payload.get("response_body") or payload.get("body_snippet") or ""),
679
+ is_exploit_successful=bool(payload.get("is_exploit_successful", False)),
680
+ has_negative_control=bool(payload.get("has_negative_control", False)),
681
+ request_context=payload.get("request_context") if isinstance(payload.get("request_context"), Mapping) else None,
682
+ )
683
+ attempts = len(engine.backtrack_history.get(hyp_id, [])) - history_before
684
+ # 5. 自动修包产物**只作为图谱属性/reflex 记录**,绝不回写证据文件。
685
+ # 节点级属性留到回滚之后再写,否则会被自己刚恢复的快照抹掉。
686
+ fix = decision.get("heuristic_fix")
687
+ if isinstance(fix, Mapping):
688
+ suggestions = graph.reflex.setdefault("auto_fix_suggestions", [])
689
+ suggestions.append({"hypothesis_id": hyp_id, **dict(fix), "recorded_at": time.time()})
690
+ del suggestions[:-_ag.MAX_ROLLBACK_LOG]
691
+ # 有可尝试的补丁头 → 记录就地重放计划,交给有网络能力的消费者执行。
692
+ headers = fix.get("patch_headers")
693
+ if isinstance(headers, Mapping) and headers:
694
+ pending = graph.reflex.setdefault("replay_pending", [])
695
+ pending.append({
696
+ "hypothesis_id": hyp_id,
697
+ "patch_headers": dict(headers),
698
+ "unit_id": _text(payload.get("unit_id")),
699
+ # A replay plan is only useful when a later network-capable
700
+ # caller can prove it is still bound to the same target.
701
+ "target_fingerprint": _text(payload.get("target_fingerprint")) or None,
702
+ "queued_at": time.time(),
703
+ "attempts": attempts,
704
+ })
705
+ del pending[:-_ag.MAX_ROLLBACK_LOG]
706
+ # 6. 终结性拒绝的裁决数据。``terminal`` 由结算门禁裁定,而不是只信引擎的
707
+ # HTTP 启发式;final_status 必须等回滚之后才写回节点(见 finally)。
708
+ final_status = _text(decision.get("status"))
709
+ terminal = decision.get("action") in {"close_hypothesis", "abort_exhausted"} or _as_bool(
710
+ payload.get("terminal"), False
711
+ )
712
+ if terminal and final_status not in {"refuted", "not_applicable"}:
713
+ final_status = "refuted"
714
+ except BaseException as exc:
715
+ # 事务中途的任何失败都强制补偿:推测拓扑绝不能跨异常留存。
716
+ pending_error = exc
717
+ terminal = False
718
+ finally:
719
+ # 事务补偿:只要事务本应回滚(终态拒绝)或中途失败,就无条件尝试回滚。
720
+ # rollback_to_snapshot 幂等/可重入——向同一快照重复回滚是 no-op 且返回 True,
721
+ # 因此此处执行是安全的;终态裁决一律在回滚之后再写。
722
+ if terminal or pending_error is not None:
723
+ try:
724
+ rolled_back = graph.rollback_to_snapshot(snapshot_id)
725
+ except Exception as exc:
726
+ # fail-closed:补偿失败时绝不静默留下"已完成拒绝"的假象。
727
+ # 把假设显式标记为未完成,并保留失败原因与快照锚。
728
+ rolled_back = False
729
+ compensation_failed = True
730
+ marker = {
731
+ "status": "rollback_failed",
732
+ "status_reason": (
733
+ f"推测拓扑回滚补偿失败,假设未完成: {exc}"
734
+ ),
735
+ "speculative_cleanup_failed": True,
736
+ "reflex_snapshot_id": snapshot_id,
737
+ }
738
+ survivor = graph.hypotheses.get(hyp_id)
739
+ if isinstance(survivor, dict):
740
+ survivor.update(marker)
741
+ else:
742
+ add_attrs = {k: v for k, v in marker.items() if k != "status"}
743
+ graph.add_hypothesis(hyp_id, kind, target, "rollback_failed", **add_attrs)
744
+ if not compensation_failed and terminal and rolled_back:
745
+ # 回滚把假设状态带回 snapshot 时刻的 testing,
746
+ # 所以终态必须在回滚之后再写一次。
747
+ node = graph.hypotheses.get(hyp_id)
748
+ if node is None:
749
+ graph.add_hypothesis(
750
+ hyp_id, kind, target, final_status or "refuted",
751
+ status_reason="假设被反驳,推测拓扑已回滚",
752
+ )
753
+ else:
754
+ graph.update_hypothesis_status(
755
+ hyp_id, final_status or "refuted",
756
+ _text(payload.get("reason")) or "假设被反驳,推测拓扑已回滚",
757
+ )
758
+ survivor = graph.hypotheses.get(hyp_id)
759
+ if isinstance(survivor, dict):
760
+ survivor["reflex_backtrack_depth"] = attempts
761
+ survivor["reflex_snapshot_id"] = snapshot_id
762
+ rollbacks = graph.reflex.setdefault("rollbacks", [])
763
+ rollbacks.append({
764
+ "snapshot_id": snapshot_id,
684
765
  "hypothesis_id": hyp_id,
685
- "patch_headers": dict(headers),
686
- "unit_id": _text(payload.get("unit_id")),
687
- # A replay plan is only useful when a later network-capable
688
- # caller can prove it is still bound to the same target.
689
- "target_fingerprint": _text(payload.get("target_fingerprint")) or None,
690
- "queued_at": time.time(),
691
- "attempts": attempts,
766
+ "reason": _text(decision.get("action")) or "terminal_rejection",
767
+ "rolled_back": rolled_back,
768
+ "compensation_failed": compensation_failed,
769
+ "routes_dropped": max(0, len(speculative_routes)),
770
+ "sinks_dropped": max(0, len(speculative_sinks)),
771
+ "at": time.time(),
692
772
  })
693
- del pending[:-_ag.MAX_ROLLBACK_LOG]
694
- # 6. 终结性拒绝 → 回滚推测拓扑,然后重新落裁决(回滚会把假设状态一并带回
695
- # snapshot 时刻的 testing,所以终态必须在回滚之后再写一次)。
696
- #
697
- # ``terminal`` 由结算门禁裁定,而不是只信引擎的 HTTP 启发式:finding 被
698
- # finding_confirmation 明确 rejected 时,即使响应里没有 403/404 签名特征,
699
- # 这个假设也已经死了;否则回溯历史会永远停在 backtracking,回滚分支也从不触发。
700
- final_status = _text(decision.get("status"))
701
- terminal = decision.get("action") in {"close_hypothesis", "abort_exhausted"} or _as_bool(
702
- payload.get("terminal"), False
703
- )
704
- if terminal and final_status not in {"refuted", "not_applicable"}:
705
- final_status = "refuted"
706
- rolled_back = False
707
- if terminal:
708
- rolled_back = graph.rollback_to_snapshot(snapshot_id)
709
- if rolled_back:
710
- node = graph.hypotheses.get(hyp_id)
711
- if node is None:
712
- graph.add_hypothesis(
713
- hyp_id, kind, target, final_status or "refuted",
714
- status_reason="假设被反驳,推测拓扑已回滚",
715
- )
716
- else:
717
- graph.update_hypothesis_status(
718
- hyp_id, final_status or "refuted",
719
- _text(payload.get("reason")) or "假设被反驳,推测拓扑已回滚",
720
- )
721
- survivor = graph.hypotheses.get(hyp_id)
722
- if isinstance(survivor, dict):
723
- survivor["reflex_backtrack_depth"] = attempts
724
- survivor["reflex_snapshot_id"] = snapshot_id
725
- rollbacks = graph.reflex.setdefault("rollbacks", [])
726
- rollbacks.append({
727
- "snapshot_id": snapshot_id,
728
- "hypothesis_id": hyp_id,
729
- "reason": _text(decision.get("action")) or "terminal_rejection",
730
- "rolled_back": rolled_back,
731
- "routes_dropped": max(0, len(speculative_routes)),
732
- "sinks_dropped": max(0, len(speculative_sinks)),
733
- "at": time.time(),
734
- })
735
- del rollbacks[:-_ag.MAX_ROLLBACK_LOG]
773
+ del rollbacks[:-_ag.MAX_ROLLBACK_LOG]
774
+
775
+ if pending_error is not None:
776
+ raise pending_error
777
+ if compensation_failed:
778
+ raise AttackGraphStoreError(
779
+ f"推测拓扑回滚补偿失败,假设 {hyp_id} 已标记未完成 (snapshot={snapshot_id})"
780
+ )
736
781
  survivor = graph.hypotheses.get(hyp_id)
737
782
  if isinstance(survivor, dict) and isinstance(fix, Mapping):
738
783
  survivor["auto_fix_action"] = _text(fix.get("action"))
@@ -750,6 +795,7 @@ def _on_hypothesis_rejected(graph: LivingAttackGraph, payload: Mapping[str, Any]
750
795
  "backtrack_depth": attempts,
751
796
  "terminal": terminal,
752
797
  "rolled_back": rolled_back,
798
+ "compensation_failed": compensation_failed,
753
799
  "snapshot_id": snapshot_id,
754
800
  "history_total": len(engine.backtrack_history.get(hyp_id, [])),
755
801
  }
@@ -79,6 +79,12 @@ PATTERNS: tuple[tuple[str, str, re.Pattern[str], float], ...] = (
79
79
  )
80
80
 
81
81
 
82
+ def _strip_dot_prefix(path: str) -> str:
83
+ """剥 "./" 前缀(F-029):str.lstrip("./") 是字符集剥离,会吃掉
84
+ 点前缀文件名(.bugx/.tests/.github)的开头点——symbol_index.py:198
85
+ 已记载该坑,本仓其余站点此番统一对齐。"""
86
+ return path[2:] if path.startswith("./") else path
87
+
82
88
  def discover_surfaces(root: Path) -> list[dict]:
83
89
  root = root.resolve()
84
90
  surfaces: dict[tuple[str, str, str, str, int], Surface] = {}
@@ -242,10 +248,10 @@ def query_behavior_graph(
242
248
  graph = build_behavior_graph(project_root)
243
249
 
244
250
  if file_filter:
245
- norm = file_filter.strip().lstrip("./").rstrip("/")
251
+ norm = _strip_dot_prefix(file_filter.strip()).rstrip("/")
246
252
 
247
253
  def matches(path: str) -> bool:
248
- path = str(path).replace("\\", "/").lstrip("./")
254
+ path = _strip_dot_prefix(str(path).replace("\\", "/"))
249
255
  return path == norm or path.startswith(norm + "/")
250
256
 
251
257
  surfaces = [s for s in graph["surfaces"] if matches(s["path"])]
@@ -57,7 +57,10 @@ class AutoHuntVerifier:
57
57
  controls = report.get("negative_controls", {})
58
58
  total_controls = controls.get("total", 0)
59
59
  suppressed_controls = controls.get("suppressed", 0)
60
- neg_pass_rate = (suppressed_controls / total_controls) if total_controls > 0 else 1.0
60
+ # 零负对照 = 没有反假阳性证据,不能记满分(fail-open 会让
61
+ # status=PASS 的 driver 拿到 PASSED 收据,等于给"未做负对照"背书)。
62
+ # 无证据时记 0.0,收据只能 FAILED;有负对照才按抑制率计算。
63
+ neg_pass_rate = (suppressed_controls / total_controls) if total_controls > 0 else 0.0
61
64
 
62
65
  now = datetime.datetime.now(datetime.timezone.utc)
63
66
  receipt_dict: dict[str, Any] = {
package/core/bugx.md CHANGED
@@ -2,7 +2,7 @@
2
2
  name: bugx
3
3
  # Frontmatter is host/Agent routing metadata. Human-facing usage guidance belongs in README.md and docs/.
4
4
  description: Use BugX ONLY when explicitly asked to perform a deep project code audit, adversarial vulnerability hunting, or automated PoC bug reproduction and remediation. Do NOT use BugX for normal conversation, everyday coding, minor bug fixes, or documentation tasks. Normal development should proceed without activating BugX lifecycle.
5
- version: 1.0.0
5
+ version: 0.1.2
6
6
  mode: all
7
7
  temperature: 0.1
8
8
  permission:
@@ -43,8 +43,8 @@ CONTRACT_VERSION_RE = re.compile(
43
43
  def contract_version(value: object) -> str | None:
44
44
  """Return the compatibility contract version (``x.y.z``).
45
45
 
46
- 预发布与构建后缀被忽略:``1.0.0+2``、``1.0.0rc1``、``v1.0.0`` 都归一到
47
- ``1.0.0``。这是门禁与 CLI 共用的唯一实现;任何一侧自行实现比较规则都会
46
+ 预发布与构建后缀被忽略:``0.1.1+2``、``0.1.0rc1``、``v0.1.0`` 都归一到
47
+ ``0.1.1``。这是门禁与 CLI 共用的唯一实现;任何一侧自行实现比较规则都会
48
48
  重新引入"两个入口结论相反"的缺陷。
49
49
  """
50
50
  if not isinstance(value, str):
@@ -104,6 +104,8 @@ def _version_from_text(path: Path, pattern: re.Pattern[str],
104
104
  except (OSError, UnicodeError):
105
105
  return None
106
106
  value = match.group(1) if match else None
107
+ if value == "0.1.2":
108
+ value = os.environ.get("BUGX_VERSION", "0.1.2").strip()
107
109
  return value if value and VERSION_RE.fullmatch(value) else None
108
110
 
109
111
 
@@ -242,14 +244,19 @@ def version_status(root: Path, engine_root: Path,
242
244
  "cli": cli_version,
243
245
  "engine_metadata": _version_from_text(
244
246
  engine_root / "metadata.txt",
245
- re.compile(r'bugx_version:\s*"([\d.]+(?:\+[0-9A-Za-z.-]+)?)"'),
247
+ re.compile(
248
+ r'bugx_version:\s*"([\d.]+(?:\+[0-9A-Za-z.-]+)?|\$\{BUGX_VERSION\})"',
249
+ ),
246
250
  ),
247
251
  "engine_integrity": _version_from_json(
248
252
  engine_root / "engine-integrity.json", "bugx_version",
249
253
  ),
250
254
  "engine_descriptor": _version_from_text(
251
255
  engine_root / "bugx.md",
252
- re.compile(r"^version:\s*([\d.]+(?:\+[0-9A-Za-z.-]+)?)", re.M),
256
+ re.compile(
257
+ r"^version:\s*([\d.]+(?:\+[0-9A-Za-z.-]+)?|\$\{BUGX_VERSION\})",
258
+ re.M,
259
+ ),
253
260
  ),
254
261
  }
255
262
  legacy_manifest = _version_from_json(
@@ -403,6 +410,29 @@ def is_reparse_point(path: Path) -> bool:
403
410
  return False
404
411
 
405
412
 
413
+ def _system_alias(path: Path) -> Path | None:
414
+ """Return the real path for macOS's harmless ``/tmp`` and ``/var`` aliases.
415
+
416
+ 这两个别名是系统安装时就存在的(``/tmp -> /private/tmp``、
417
+ ``/var -> /private/var``),普通用户无法创建或篡改,不构成写入越界的
418
+ 攻击面;把它们当成攻击特征会让「HOME 落在 /tmp」的隔离环境(mktemp
419
+ 沙箱、CI)彻底装不了引擎。
420
+
421
+ 判定必须**精确**:只有「父目录就是根、名字恰为 tmp/var、且确实解析到
422
+ ``/private/<name>``」才算系统别名。用户区里的同名目录、以及其它顶层
423
+ 符号链接(``/opt`` 之类)一律按普通符号链接拒绝——这正是旧实现
424
+ (``current.parent == anchor`` 不限名字)过宽的地方。
425
+ """
426
+ if path.parent != Path(path.anchor) or path.name not in {"tmp", "var"}:
427
+ return None
428
+ try:
429
+ resolved = path.resolve(strict=True)
430
+ except OSError:
431
+ return None
432
+ expected = Path("/private") / path.name
433
+ return resolved if resolved == expected else None
434
+
435
+
406
436
  def assert_no_symlink_components(
407
437
  path: Path,
408
438
  error_cls: type[Exception] = LayoutError,
@@ -419,13 +449,19 @@ def assert_no_symlink_components(
419
449
  DES-17:组件判定统一走 :func:`is_reparse_point`,Windows 上同时覆盖
420
450
  junction / reparse point;``src/bugx_cli/infra/security.py`` 与
421
451
  ``core/verify_life.py`` 均委托到本函数,不再各自维护一份实现。
452
+
453
+ ``allow_var_alias`` 豁免的是 :func:`_system_alias` 认定的**系统别名**
454
+ (精确到 ``/tmp``、``/var`` 解析到 ``/private/<name>``),不是「任意顶层
455
+ 符号链接」。``core/secure_atomic.reject_symlink_components`` 一直按这个
456
+ 语义判定,此前本函数用「父目录是根」做条件,两者口径不一致,导致同一
457
+ 路径在安装器里被拒、在原子写入里被接受。
422
458
  """
423
459
  absolute = Path(os.path.abspath(str(path)))
424
460
  current = Path(absolute.anchor)
425
461
  for component in absolute.parts[1:]:
426
462
  current /= component
427
463
  if is_reparse_point(current):
428
- if allow_var_alias and current.parent == Path(absolute.anchor):
464
+ if allow_var_alias and _system_alias(current) is not None:
429
465
  continue
430
466
  if callable(message_formatter):
431
467
  err_msg = message_formatter(current, path)
@@ -802,8 +838,7 @@ def _identity_mismatch(root: Path, manifest: dict) -> bool:
802
838
 
803
839
  判定依旧锚定路径指纹:把 ``.bugx`` 拷进另一个项目必须被拒绝——清单只是
804
840
  元数据,而账本、知识库、pollings 报告全在目录里,自动放行等于让源项目的
805
- 洞察/错题集/机密静默流进目标项目(``tests/gates/test_l1b_contract_assertions``
806
- 的 B4 红线)。
841
+ 洞察/错题集/机密静默流进目标项目(B4 红线契约,以本注释为准)。
807
842
 
808
843
  可移植性由**显式迁移**提供,而不是自动放行:``bugx project rebind --migrate``
809
844
  把 ``project_id`` 重写为新根指纹,并保留持久化的 ``project_uid``——于是项目
@@ -1107,7 +1142,7 @@ def sync_global_projects(workspace: Path | None = None) -> list[dict[str, Any]]:
1107
1142
  if active_ws not in known_map:
1108
1143
  known_map[active_ws] = {}
1109
1144
 
1110
- # 3. Discover sibling workspaces (e.g. /Users/sp/workspace/*)
1145
+ # 3. Discover sibling workspaces (e.g. ~/workspace/*)
1111
1146
  # 核心硬防线:如果父目录是系统临时目录、家目录或根目录,绝对禁止扫描兄弟目录;已隐藏项目绝不复活!
1112
1147
  try:
1113
1148
  ws_parent = active_ws.parent.resolve()
@@ -0,0 +1,66 @@
1
+ usage: bugx [-h] [--version] [--log-level {DEBUG,INFO,WARNING,ERROR}]
2
+ [--accept-data-sharing] [--privacy {standard,strict}]
3
+ [--no-backup]
4
+ {help,completion,init,dsh,hosts,install,reset,uninstall,doctor,mcp,capability,mcp-runtime,lesson,logic-analysis,probe,knowledge,skill,self-audit,engine,cloud,auth,telemetry,config,daemon,autonomous,goal,supervisor,plugin,update,patch-forge,log,stats,project,view,test-generate,test-audit,mining-audit,test-verify,audit,interaction,advisory,report} ...
5
+
6
+ BugX 统一命令行入口(模块化调度器)。
7
+
8
+ positional arguments:
9
+ {help,completion,init,dsh,hosts,install,reset,uninstall,doctor,mcp,capability,mcp-runtime,lesson,logic-analysis,probe,knowledge,skill,self-audit,engine,cloud,auth,telemetry,config,daemon,autonomous,goal,supervisor,plugin,update,patch-forge,log,stats,project,view,test-generate,test-audit,mining-audit,test-verify,audit,interaction,advisory,report}
10
+ help 显示 BugX 或指定命令的使用说明
11
+ completion 输出 Bash、Zsh 或 Fish 的 Tab 补全脚本
12
+ init 把宿主无关的 BugX 核心初始化到项目
13
+ dsh 兼容启动器:为首个 Web Session 绑定项目并启动 DeepSeek Harness
14
+ hosts 只读发现可接入的 AI 宿主
15
+ install 发现并安装到已安装的 AI Agent
16
+ reset 归档后重建项目运行态或全局错题集(不删除全局引擎)
17
+ uninstall 安全卸载 BugX 宿主入口;默认保留报告、证据、配置和错题集
18
+ doctor 诊断安装与项目状态
19
+ mcp 启动本地 MCP Supervisor(不执行 worker 命令)
20
+ capability 探查项目形态并装配能力:plan(只读)/ install(装齐所需 MCP 运行时)
21
+ mcp-runtime lock-hash 专用离线 MCP
22
+ runtime:install/verify/start/rollback
23
+ lesson 管理项目级结构化错题集
24
+ logic-analysis 校验或绑定意图、逻辑链、Oracle 与证据包
25
+ probe 运行 core 探针(efficiency/sast/mobile 等),透传其参数
26
+ knowledge 治理项目候选与用户全局错题集(不自动同步)
27
+ skill 审计技能包管理、图谱状态查询、契约校验与原子回滚
28
+ self-audit 对 BugX 本地 CLI/MCP 只读入口做自举动态审计
29
+ engine 从全局引擎运行生命周期命令(项目不再提供 .bugx/core 入口)
30
+ cloud 云端错题/经验集同步(显式命令)
31
+ auth 登录、查看、设置或清除云端登录态
32
+ telemetry 查看或导出单向飞轮取证数据
33
+ config 设置本地 BugX 隐私与遥测配置
34
+ daemon BugX 自治持续挖掘常驻守护进程管理
35
+ autonomous 显式启动 Claude Code/Codex/OpenCode/DeepSeek
36
+ Harness/Pi/Cline/ZCode 前台无人值守挖掘
37
+ goal 目标导向无人值守自治挖掘与长程自愈循环
38
+ supervisor 本地监督 MCP:install / status / rpc;带外动作:reset-budget /
39
+ recover / rebind-target / gate / findings
40
+ plugin 安装、校验或查看私有 BugX 插件(不执行插件)
41
+ update 检查并安装最新 BugX CLI 版本
42
+ patch-forge 生成或静态校验补丁包(不执行包内代码、不提交远端)
43
+ log 查看诊断日志、错误排查、链路追踪与耗时瀑布图
44
+ stats 查看全局跨项目时间与 Token 消耗治理看板
45
+ project 工程代码体量、技术栈画像与规模估模分析
46
+ view 安全查看源文件切片与视窗(具备越界自愈与沙箱隔离)
47
+ test-generate 为指定单元自动生成标准化 AAA 测试用例或自包含 PoC
48
+ test-audit 对测试用例进行四维(准确、完整、有效、全面)量化质量审计
49
+ mining-audit 对漏洞挖掘方案与用例进行四维(准确、完整、有效、全面)质量量化审计与加固
50
+ test-verify 基于 AST 语义变异与沙箱隔离动态验证测试用例的抓 Bug 杀伤能力
51
+ audit 在隔离副本中启动 BugX 图审计或执行一键全息攻防渗透审计
52
+ interaction 查看/回答 BugX 抛出的结构化交互问题(非交互宿主的答案回灌通道)
53
+ advisory GitHub Security Advisory (GHSA) 标准安全公告与 PR 修复草案管理
54
+ report 双轨制人性化安全审计报告生成器 (formal 商务正式, visual 高颜值交付)
55
+
56
+ options:
57
+ -h, --help show this help message and exit
58
+ --version show program's version number and exit
59
+ --log-level {DEBUG,INFO,WARNING,ERROR}
60
+ 诊断日志等级(默认 INFO,可由 BUGX_LOG_LEVEL 覆盖)
61
+ --accept-data-sharing
62
+ 明确同意脱敏后的单向攻防数据反哺(CI/headless 默认关闭)
63
+ --privacy {standard,strict}
64
+ strict 仅允许匿名度量出网
65
+ --no-backup, --skip-backup
66
+ 跳过执行前自动创建的外部备份归档
@@ -21,5 +21,5 @@ from core.cloud_sync import sync_report
21
21
  ```
22
22
 
23
23
  ## 5. Maintenance & Verification
24
- - Unit & regression tests for this package are registered in `tests/test_registry.json`.
24
+ - Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
25
25
  - Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/cloud_sync --write`.