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.
- package/README.md +193 -185
- package/core/README.md +2 -2
- package/core/agent/README.md +2 -1
- package/core/agent/agent_artifacts.py +8 -6
- package/core/agent/agent_eval.py +136 -54
- package/core/agent/agent_execution.py +218 -52
- package/core/agent/agent_orchestrator.py +14 -8
- package/core/agent/agent_targets.py +8 -2
- package/core/agent/feature_baseline.py +150 -0
- package/core/assets/README.md +3 -2
- package/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- package/core/assets/axe-core/LICENSE.txt +362 -0
- package/core/assets/axe-core/UPSTREAM.md +10 -0
- package/core/assets/axe-core/axe.min.js +12 -0
- package/core/assets/bugx-hero-en.svg +74 -0
- package/core/assets/bugx-hero-zh.svg +74 -0
- package/core/assets/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/codex.png +0 -0
- package/core/assets/dsh.png +0 -0
- package/core/assets/webui-chatgpt.jpg +0 -0
- package/core/assets/webui-session.jpg +0 -0
- package/core/assets/webui-skills.jpg +0 -0
- package/core/assets/webui-studio.jpg +0 -0
- package/core/assets/webui-zcode.jpg +0 -0
- package/core/assets/zcode.png +0 -0
- package/core/audit_packs/README.md +2 -0
- package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
- package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
- package/core/audit_packs/pitfalls/go_backend.json +66 -0
- package/core/audit_packs/pitfalls/java_spring.json +64 -0
- package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
- package/core/audit_packs/pitfalls/python_web.json +82 -0
- package/core/autonomous_cve/SPEC.md +1 -1
- package/core/autonomous_cve/attack_graph_store.py +152 -106
- package/core/autonomous_cve/behavior_graph.py +8 -2
- package/core/autonomous_cve/verifier.py +4 -1
- package/core/bugx.md +1 -1
- package/core/bugx_paths.py +43 -8
- package/core/cli-help.txt +66 -0
- package/core/cloud_sync/SPEC.md +1 -1
- package/core/cloud_sync/cloud_client.py +81 -11
- package/core/cloud_sync/cloud_onboard.py +42 -1
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -15
- package/core/cloud_sync/network_transport.py +24 -3
- package/core/cloud_sync/sensitive_filter.py +2 -2
- package/core/cloud_sync/sync_push.py +12 -10
- package/core/contracts/AGENT_GUIDE.md +6 -9
- package/core/contracts/README.md +2 -2
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/contracts/engine_gap_contracts.py +86 -3
- package/core/coverage/coverage_discovery.py +599 -29
- package/core/coverage/coverage_evidence.py +47 -0
- package/core/coverage/coverage_forensics.py +9 -0
- package/core/coverage/coverage_validate.py +6 -1
- package/core/dev_harness/SPEC.md +1 -1
- package/core/engine-integrity.json +670 -442
- package/core/fuzzing/concurrency_fuzzer.py +53 -0
- package/core/fuzzing/differential_oracle.py +562 -27
- package/core/fuzzing/fuzz_input.py +109 -6
- package/core/fuzzing/stateful_fuzzer.py +72 -0
- package/core/governance/secret_redactor.py +22 -10
- package/core/host_acp/SPEC.md +1 -1
- package/core/host_acp/__init__.py +4 -4
- package/core/host_acp/claude.py +59 -1
- package/core/host_acp/cline.py +64 -1
- package/core/host_acp/codex.py +56 -1
- package/core/host_acp/dsh.py +59 -1
- package/core/host_acp/opencode.py +56 -1
- package/core/host_acp/pi.py +59 -1
- package/core/host_acp/zcode.py +59 -1
- package/core/host_runtime/SPEC.md +1 -1
- package/core/host_runtime/adapters.py +1 -1
- package/core/host_runtime/cline.py +13 -0
- package/core/host_runtime/host_evaluators.py +44 -4
- package/core/host_runtime/host_probe.py +1 -1
- package/core/host_runtime/host_provider_arbitrator.py +116 -62
- package/core/host_runtime/host_registry.py +15 -8
- package/core/host_runtime/mcp_registry_gate.py +12 -1
- package/core/host_runtime/pi.py +102 -0
- package/core/host_runtime/provider_facts.py +66 -0
- package/core/hosts/SPEC.md +1 -1
- package/core/hosts/__init__.py +6 -2
- package/core/hosts/_dsh_usage.py +1 -1
- package/core/hosts/base.py +32 -4
- package/core/hosts/claude.py +55 -0
- package/core/hosts/cline.py +6 -2
- package/core/hosts/codex.py +58 -0
- package/core/hosts/dsh.py +9 -1
- package/core/hosts/opencode.py +6 -6
- package/core/hosts/pi.py +159 -2
- package/core/infra/README.md +4 -2
- package/core/infra/__init__.py +2 -0
- package/core/infra/build_info.py +22 -3
- package/core/infra/client_metadata.py +1 -1
- package/core/infra/json_utils.py +22 -0
- package/core/launch_phases/README.md +6 -3
- package/core/launch_phases/SPEC.md +1 -1
- package/core/launch_phases/common.py +21 -2
- package/core/launch_phases/finding_confirm_phase.py +170 -5
- package/core/launch_phases/finding_settlement.py +188 -1
- package/core/launch_phases/judge_phase.py +69 -12
- package/core/launch_phases/orchestrator_controls.py +11 -7
- package/core/launch_phases/post_coverage_sync.py +9 -2
- package/core/launch_phases/post_phase.py +144 -8
- package/core/launch_phases/post_receipt.py +12 -1
- package/core/launch_phases/pre_phase.py +3 -3
- package/core/launch_phases/pre_recon_scout.py +66 -36
- package/core/launch_phases/pre_state_builder.py +23 -176
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +129 -58
- package/core/launch_phases/semantic_recon.py +545 -0
- package/core/launch_phases/session_runtime.py +56 -9
- package/core/launch_phases/startup_gates.py +36 -8
- package/core/launch_phases/startup_interaction.py +68 -12
- package/core/launch_phases/startup_version_gate.py +13 -3
- package/core/launch_phases/supervisor_bridge.py +46 -17
- package/core/launch_phases/supervisor_coverage.py +8 -2
- package/core/launch_phases/supervisor_degraded.py +1 -9
- package/core/launch_phases/verify_loop.py +767 -0
- package/core/launch_phases/worker_barriers.py +15 -5
- package/core/launch_phases/worker_orchestrator.py +105 -25
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -1
- package/core/ledger/SPEC.md +1 -1
- package/core/ledger/_facade.py +2 -1
- package/core/ledger/archive_ops.py +60 -2
- package/core/ledger/cli.py +6 -1
- package/core/ledger/export_ops.py +6 -1
- package/core/ledger/finding_confirmation.py +48 -6
- package/core/ledger/finding_lifecycle.py +428 -5
- package/core/ledger/finding_verification.py +555 -10
- package/core/ledger/fp_ledger.py +255 -0
- package/core/ledger/incidents.py +10 -4
- package/core/ledger/patterns.py +10 -7
- package/core/ledger/receipt_contract.py +17 -1
- package/core/ledger/sync_ops.py +21 -16
- package/core/ledger/tool_experience.py +2 -1
- package/core/ledger/verify_life.py +88 -17
- package/core/locales/en-US.json +2 -2
- package/core/locales/zh-CN.json +2 -2
- package/core/mcp_handlers/SPEC.md +1 -1
- package/core/mcp_handlers/base.py +23 -3
- package/core/mcp_handlers/channel_lifecycle.py +85 -30
- package/core/mcp_handlers/retrieval_handlers.py +11 -1
- package/core/mcp_handlers/rpc_server.py +6 -1
- package/core/mcp_handlers/supervisor_handlers.py +32 -6
- package/core/mcp_handlers/tool_table.py +15 -0
- package/core/mcp_runtime_support/environment.py +0 -38
- package/core/mcp_runtime_support/verifier.py +0 -52
- package/core/metadata.txt +2 -3
- package/core/planning/README.md +2 -1
- package/core/planning/domain_router.py +4 -2
- package/core/planning/dynamic_flow_analyzer.py +219 -14
- package/core/planning/judge_pipeline.py +87 -4
- package/core/planning/prompt_harness.py +57 -15
- package/core/planning/prompt_policy_engine.py +386 -0
- package/core/planning/spec_harvester.py +4 -4
- package/core/probes/INTERFACE.md +11 -1
- package/core/probes/SPEC.md +11 -1
- package/core/probes/__init__.py +46 -40
- package/core/probes/android_probe.py +177 -9
- package/core/probes/codebase_memory_probe.py +57 -0
- package/core/probes/desktop_probe.py +104 -0
- package/core/probes/differential_probe.py +99 -21
- package/core/probes/efficiency_probe.py +64 -0
- package/core/probes/ios_binary_probe.py +105 -1
- package/core/probes/memory_probe.py +66 -0
- package/core/probes/miniprogram_probe.py +75 -13
- package/core/probes/mobile_probe.py +215 -30
- package/core/probes/native_probe.py +88 -0
- package/core/probes/openwiki_probe.py +70 -0
- package/core/probes/pattern_probe.py +106 -0
- package/core/probes/platform_probe.py +81 -0
- package/core/probes/probe_registry.py +108 -7
- package/core/probes/sast_fixture_corpus.py +340 -0
- package/core/probes/sast_probe.py +553 -52
- package/core/probes/sast_rules.py +668 -28
- package/core/probes/sca_scanner.py +48 -0
- package/core/probes/ui_accessibility.py +149 -0
- package/core/probes/ui_audit.py +513 -0
- package/core/probes/ui_contract.py +273 -0
- package/core/probes/ui_evidence.py +212 -0
- package/core/probes/ui_measurements.py +314 -0
- package/core/probes/ui_repair.py +250 -0
- package/core/probes/ui_review.py +133 -0
- package/core/probes/ui_storybook.py +107 -0
- package/core/probes/ui_tokens.py +185 -0
- package/core/probes/ui_visual_diff.py +131 -0
- package/core/probes/web_probe.py +373 -18
- package/core/project_profiler/SPEC.md +1 -1
- package/core/project_profiler/arbitrator.py +6 -1
- package/core/project_profiler/detector.py +8 -1
- package/core/project_profiler/strategy.py +51 -15
- package/core/prompts/README.md +4 -2
- package/core/prompts/command_routing_en.md +2 -2
- package/core/prompts/command_routing_zh.md +2 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_repair.md +1 -1
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- package/core/repair/README.md +1 -1
- package/core/repair/l7_repair_loop.py +1 -4
- package/core/repair/rsi_fixer.py +4 -4
- package/core/repair/rsi_loop.py +1 -3
- package/core/repair/rsi_repair.py +7 -7
- package/core/repair/rsi_scope.py +27 -8
- package/core/report_engine/SPEC.md +1 -1
- package/core/report_engine/attestation.py +8 -4
- package/core/report_engine/finding_report.py +2 -1
- package/core/report_engine/models.py +7 -9
- package/core/report_engine/report_share.py +0 -8
- package/core/report_engine/sast_bridge.py +2 -2
- package/core/report_engine/server.py +18 -8
- package/core/report_engine/web-conformance.md +123 -18
- package/core/report_engine/web_conformance.py +21 -52
- package/core/retrieval/README.md +2 -1
- package/core/retrieval/SPEC.md +1 -1
- package/core/retrieval/code_analyzer.py +50 -14
- package/core/retrieval/context_assembler.py +7 -1
- package/core/retrieval/knowledge_sync.py +108 -14
- package/core/retrieval/pitfall_packs.py +277 -0
- package/core/retrieval/symbol_index.py +25 -6
- package/core/retrieval/universal_code_matcher.py +234 -49
- package/core/runtime/README.md +1 -1
- package/core/runtime/bugx_logging.py +78 -7
- package/core/runtime/fixture_solidify.py +5 -10
- package/core/runtime/global_telemetry.py +20 -0
- package/core/runtime/incident_eval.py +1 -1
- package/core/runtime/model_runner.py +4 -41
- package/core/runtime/platform_adapter.py +2 -2
- package/core/runtime/prep_validate.py +4 -2
- package/core/runtime/project_settings.py +2 -1
- package/core/runtime/scenario_eval.py +50 -8
- package/core/skills/bugx_docs_mcp_server.py +3 -1
- package/core/skills/bugx_mcp_server.py +29 -2
- package/core/skills/tools_kb.py +1 -1
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/SPEC.md +1 -1
- package/core/supervisor/budget_governor.py +503 -9
- package/core/supervisor/checkpoint_pipeline.py +248 -6
- package/core/supervisor/checkpoint_sync.py +13 -0
- package/core/supervisor/claim_events.py +1 -1
- package/core/supervisor/finding_workflow.py +22 -5
- package/core/supervisor/lease_manager.py +1 -1
- package/core/supervisor/lifecycle_blocks.py +6 -1
- package/core/supervisor/rejection_remedies.py +52 -5
- package/core/supervisor/serial_authorization.py +48 -4
- package/core/supervisor/task_scheduler.py +2 -2
- package/core/supervisor/worker_checkpoint.py +8 -1
- package/core/supervisor/worker_runtime.py +8 -2
- package/core/supervisor_types/worker_claim.py +9 -0
- package/core/webui/README.md +1 -1
- package/core/webui/SPEC.md +2 -1
- package/core/webui/adapters/claude.py +5 -1
- package/core/webui/adapters/cline.py +10 -2
- package/core/webui/adapters/codex.py +5 -1
- package/core/webui/adapters/dsh.py +5 -1
- package/core/webui/docs_session_service.py +2 -2
- package/core/webui/mcp_inspector.py +11 -7
- package/core/webui/static/00-base.css +1060 -0
- package/core/webui/static/01-monitoring.css +802 -0
- package/core/webui/static/02-header-actions.css +321 -0
- package/core/webui/static/03-trigger-popover.css +697 -0
- package/core/webui/static/04-composer.css +628 -0
- package/core/webui/static/05-skills-center.css +878 -0
- package/core/webui/static/06-mcp-center.css +623 -0
- package/core/webui/static/07-skill-detail.css +265 -0
- package/core/webui/static/08-files-management.css +167 -0
- package/core/webui/static/09-files-center.css +386 -0
- package/core/webui/static/10-icons.css +105 -0
- package/core/webui/static/11-project-options.css +185 -0
- package/core/webui/static/12-profile-tab.css +383 -0
- package/core/webui/static/design-tokens.css +113 -0
- package/core/webui/static/index.html +14 -1
- package/core/webui/workspace_service.py +1 -1
- package/docs/07_distribution/01_README_NPM.md +193 -185
- package/ecosystem/integrations/README.md +1 -1
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +4 -4
- package/ecosystem/integrations/opencode/mcp-lock.json +14 -6
- package/ecosystem/integrations/opencode/opencode.json +23 -12
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/connector-meta.json +1 -1
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +37 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -2
- package/interfaces/cli/bugx_cli/cli.py +172 -69
- package/interfaces/cli/bugx_cli/commands/advisory.py +1 -1
- package/interfaces/cli/bugx_cli/commands/agent.py +461 -134
- package/interfaces/cli/bugx_cli/commands/audit.py +10 -9
- package/interfaces/cli/bugx_cli/commands/autonomous.py +1 -1
- package/interfaces/cli/bugx_cli/commands/cloud.py +31 -22
- package/interfaces/cli/bugx_cli/commands/doctor.py +449 -204
- package/interfaces/cli/bugx_cli/commands/interaction.py +5 -1
- package/interfaces/cli/bugx_cli/commands/knowledge.py +5 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +3 -3
- package/interfaces/cli/bugx_cli/commands/plugin.py +58 -23
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +7 -7
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +2 -1
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +1 -1
- package/interfaces/cli/bugx_cli/commands/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/report.py +2 -6
- package/interfaces/cli/bugx_cli/commands/system.py +524 -169
- package/interfaces/cli/bugx_cli/common.py +21 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +29 -54
- package/interfaces/cli/bugx_cli/hosts/registry.py +8 -6
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +157 -27
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +35 -16
- package/interfaces/cli/bugx_cli/infra/host_sync.py +11 -8
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +76 -5
- package/interfaces/cli/bugx_cli/infra/security.py +13 -6
- package/package.json +30 -15
- package/pyproject.toml +60 -9
- package/scripts/ensure-python.mjs +7 -7
- package/scripts/sync-version.mjs +10 -21
- package/scripts/test-npm-wrapper.mjs +1 -1
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/webui/static/project-settings.css +0 -6458
- package/docs/07_distribution/README.md +0 -16
- package/docs/README.md +0 -121
- package/interfaces/README.md +0 -143
- package/interfaces/bin/README.md +0 -35
- package/interfaces/cli/README.md +0 -90
- package/scripts/README.md +0 -118
package/core/probes/web_probe.py
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
13
|
import contextlib
|
|
14
|
+
import hashlib
|
|
14
15
|
import json
|
|
15
16
|
import os
|
|
16
17
|
import re
|
|
@@ -20,7 +21,7 @@ import time
|
|
|
20
21
|
import urllib.error
|
|
21
22
|
import urllib.request
|
|
22
23
|
from pathlib import Path
|
|
23
|
-
from typing import Any, Mapping, Sequence
|
|
24
|
+
from typing import Any, Callable, Mapping, Sequence
|
|
24
25
|
|
|
25
26
|
try:
|
|
26
27
|
from .base import BaseProbe
|
|
@@ -73,7 +74,11 @@ class WebDynamicProbe(BaseProbe):
|
|
|
73
74
|
return "web_dynamic_probe"
|
|
74
75
|
|
|
75
76
|
def is_available(self) -> bool:
|
|
76
|
-
"""AUDIT-04: 极速探活 (<5ms,零阻塞)。
|
|
77
|
+
"""AUDIT-04: 极速探活 (<5ms,零阻塞)。
|
|
78
|
+
|
|
79
|
+
降级契约:布尔返回值受 BaseProbe 布尔契约约束(execute_probe 以真值
|
|
80
|
+
判定是否降级);(bool, detail) 明细结构见模块级 ``check_availability()``。
|
|
81
|
+
"""
|
|
77
82
|
if shutil.which("playwright") is not None:
|
|
78
83
|
return True
|
|
79
84
|
try:
|
|
@@ -225,8 +230,21 @@ class WebDynamicProbe(BaseProbe):
|
|
|
225
230
|
url: str,
|
|
226
231
|
actions: Sequence[dict[str, Any]] | None = None,
|
|
227
232
|
timeout: float = 10.0,
|
|
233
|
+
*,
|
|
234
|
+
screenshot_path: str | Path | None = None,
|
|
235
|
+
viewport: Mapping[str, int] | None = None,
|
|
228
236
|
) -> dict[str, Any]:
|
|
229
|
-
"""执行 Playwright
|
|
237
|
+
"""执行 Playwright 动作并返回可复核的动态证据。
|
|
238
|
+
|
|
239
|
+
``actions`` 支持 ``click``、``fill``、``press``、``select_option``、
|
|
240
|
+
``wait_for``、``wait``、``screenshot`` 七种显式动作。动作失败直接抛出,
|
|
241
|
+
不把未执行的浏览器旅程伪装成成功;``screenshot_path`` 用于保存动作完成后的
|
|
242
|
+
默认截图,调用方应把过程文件放在仓库外的临时目录。
|
|
243
|
+
|
|
244
|
+
返回值固定包含页面、DOM、无障碍快照、控制台、失败请求和截图摘要,供
|
|
245
|
+
``web_conformance.py`` 或外部视觉分析绑定页面、视口、浏览器版本与复现步骤。
|
|
246
|
+
受 AUDIT-02 资源池并发限制保护。
|
|
247
|
+
"""
|
|
230
248
|
with self.browser_slot(timeout=timeout):
|
|
231
249
|
if not self.is_available():
|
|
232
250
|
raise RuntimeError("Playwright is not installed in current environment")
|
|
@@ -236,17 +254,280 @@ class WebDynamicProbe(BaseProbe):
|
|
|
236
254
|
|
|
237
255
|
with playwright.sync_api.sync_playwright() as p:
|
|
238
256
|
browser = p.chromium.launch(headless=True)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
257
|
+
try:
|
|
258
|
+
normalized_viewport: dict[str, int] | None = None
|
|
259
|
+
if viewport is not None:
|
|
260
|
+
try:
|
|
261
|
+
normalized_viewport = {
|
|
262
|
+
"width": int(viewport["width"]),
|
|
263
|
+
"height": int(viewport["height"]),
|
|
264
|
+
}
|
|
265
|
+
except (KeyError, TypeError, ValueError) as exc:
|
|
266
|
+
raise ValueError(
|
|
267
|
+
"viewport must contain integer width and height"
|
|
268
|
+
) from exc
|
|
269
|
+
if any(value <= 0 for value in normalized_viewport.values()):
|
|
270
|
+
raise ValueError("viewport width and height must be positive")
|
|
271
|
+
|
|
272
|
+
page = browser.new_page(viewport=normalized_viewport)
|
|
273
|
+
return self.capture_browser_page(
|
|
274
|
+
page, url, actions=actions, timeout=timeout,
|
|
275
|
+
screenshot_path=screenshot_path, browser_version=browser.version,
|
|
276
|
+
)
|
|
277
|
+
finally:
|
|
278
|
+
browser.close()
|
|
279
|
+
|
|
280
|
+
@staticmethod
|
|
281
|
+
def capture_browser_page(
|
|
282
|
+
page: Any,
|
|
283
|
+
url: str,
|
|
284
|
+
*,
|
|
285
|
+
browser_version: str,
|
|
286
|
+
actions: Sequence[dict[str, Any]] | None = None,
|
|
287
|
+
timeout: float = 10.0,
|
|
288
|
+
screenshot_path: str | Path | None = None,
|
|
289
|
+
screenshot_full_page: bool = True,
|
|
290
|
+
screenshot_masks: Sequence[str] = (),
|
|
291
|
+
wait_until: str = "load",
|
|
292
|
+
after_navigation: Callable[[Any], None] | None = None,
|
|
293
|
+
inspect_page: Callable[[Any], Mapping[str, Any] | None] | None = None,
|
|
294
|
+
) -> dict[str, Any]:
|
|
295
|
+
"""Capture a caller-owned Playwright page after navigation and explicit actions."""
|
|
296
|
+
console_messages: list[dict[str, Any]] = []
|
|
297
|
+
page_errors: list[str] = []
|
|
298
|
+
request_failures: list[dict[str, Any]] = []
|
|
299
|
+
http_errors: list[dict[str, Any]] = []
|
|
300
|
+
screenshots: list[dict[str, Any]] = []
|
|
301
|
+
|
|
302
|
+
page.on(
|
|
303
|
+
"console",
|
|
304
|
+
lambda message: console_messages.append({
|
|
305
|
+
"type": message.type,
|
|
306
|
+
"text": message.text,
|
|
307
|
+
"location": message.location,
|
|
308
|
+
}),
|
|
309
|
+
)
|
|
310
|
+
page.on("pageerror", lambda error: page_errors.append(str(error)))
|
|
311
|
+
page.on(
|
|
312
|
+
"requestfailed",
|
|
313
|
+
lambda request: request_failures.append({
|
|
314
|
+
"url": request.url,
|
|
315
|
+
"method": request.method,
|
|
316
|
+
"failure": request.failure,
|
|
317
|
+
}),
|
|
318
|
+
)
|
|
319
|
+
page.on(
|
|
320
|
+
"response",
|
|
321
|
+
lambda response: http_errors.append({
|
|
322
|
+
"url": response.url,
|
|
323
|
+
"status": response.status,
|
|
324
|
+
"method": response.request.method,
|
|
325
|
+
}) if response.status >= 400 else None,
|
|
326
|
+
)
|
|
327
|
+
|
|
328
|
+
response = page.goto(url, timeout=int(timeout * 1000), wait_until=wait_until)
|
|
329
|
+
if after_navigation is not None:
|
|
330
|
+
after_navigation(page)
|
|
331
|
+
|
|
332
|
+
def capture_screenshot(
|
|
333
|
+
target: str | Path,
|
|
334
|
+
*,
|
|
335
|
+
full_page: bool = True,
|
|
336
|
+
) -> dict[str, Any]:
|
|
337
|
+
path = Path(target).expanduser().resolve()
|
|
338
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
339
|
+
masks = [page.locator(f"css={selector}").filter(visible=True)
|
|
340
|
+
for selector in screenshot_masks]
|
|
341
|
+
mask_counts = {selector: item.count()
|
|
342
|
+
for selector, item in zip(screenshot_masks, masks, strict=True)}
|
|
343
|
+
image = page.screenshot(path=str(path), full_page=full_page, mask=masks, caret="hide")
|
|
344
|
+
record = {
|
|
345
|
+
"path": str(path),
|
|
346
|
+
"full_page": full_page,
|
|
347
|
+
"sha256": hashlib.sha256(image).hexdigest(),
|
|
348
|
+
"mask_counts": mask_counts,
|
|
349
|
+
}
|
|
350
|
+
screenshots.append(record)
|
|
351
|
+
return record
|
|
352
|
+
|
|
353
|
+
applied_actions: list[dict[str, Any]] = []
|
|
354
|
+
for index, action in enumerate(actions or ()):
|
|
355
|
+
if not isinstance(action, Mapping):
|
|
356
|
+
raise TypeError(f"browser action {index} must be an object")
|
|
357
|
+
action_type = str(
|
|
358
|
+
action.get("type") or action.get("action") or ""
|
|
359
|
+
).strip().lower()
|
|
360
|
+
selector = action.get("selector")
|
|
361
|
+
action_timeout = int(
|
|
362
|
+
float(action.get("timeout", timeout)) * 1000
|
|
363
|
+
)
|
|
364
|
+
if action_timeout <= 0:
|
|
365
|
+
raise ValueError(f"browser action {index} timeout must be positive")
|
|
366
|
+
|
|
367
|
+
if action_type == "click":
|
|
368
|
+
if not isinstance(selector, str) or not selector:
|
|
369
|
+
raise ValueError(f"browser action {index} click requires selector")
|
|
370
|
+
page.locator(selector).click(timeout=action_timeout)
|
|
371
|
+
elif action_type == "fill":
|
|
372
|
+
if not isinstance(selector, str) or not selector:
|
|
373
|
+
raise ValueError(f"browser action {index} fill requires selector")
|
|
374
|
+
value = action.get("value")
|
|
375
|
+
if value is None:
|
|
376
|
+
raise ValueError(f"browser action {index} fill requires value")
|
|
377
|
+
page.locator(selector).fill(str(value), timeout=action_timeout)
|
|
378
|
+
elif action_type == "press":
|
|
379
|
+
key = action.get("key")
|
|
380
|
+
if not isinstance(key, str) or not key:
|
|
381
|
+
raise ValueError(f"browser action {index} press requires key")
|
|
382
|
+
if selector:
|
|
383
|
+
page.locator(str(selector)).press(key, timeout=action_timeout)
|
|
384
|
+
else:
|
|
385
|
+
page.keyboard.press(key)
|
|
386
|
+
elif action_type == "select_option":
|
|
387
|
+
if not isinstance(selector, str) or not selector:
|
|
388
|
+
raise ValueError(
|
|
389
|
+
f"browser action {index} select_option requires selector"
|
|
390
|
+
)
|
|
391
|
+
option = action.get("value")
|
|
392
|
+
if option is None:
|
|
393
|
+
option = action.get("label")
|
|
394
|
+
if option is None:
|
|
395
|
+
raise ValueError(
|
|
396
|
+
f"browser action {index} select_option requires value or label"
|
|
397
|
+
)
|
|
398
|
+
if "label" in action:
|
|
399
|
+
page.locator(selector).select_option(
|
|
400
|
+
label=str(action["label"]), timeout=action_timeout
|
|
401
|
+
)
|
|
402
|
+
else:
|
|
403
|
+
page.locator(selector).select_option(
|
|
404
|
+
value=str(option), timeout=action_timeout
|
|
405
|
+
)
|
|
406
|
+
elif action_type == "wait_for":
|
|
407
|
+
if not isinstance(selector, str) or not selector:
|
|
408
|
+
raise ValueError(f"browser action {index} wait_for requires selector")
|
|
409
|
+
state = str(action.get("state", "visible"))
|
|
410
|
+
if state not in {"attached", "detached", "visible", "hidden"}:
|
|
411
|
+
raise ValueError(f"unsupported wait_for state: {state}")
|
|
412
|
+
page.locator(selector).wait_for(
|
|
413
|
+
state=state, timeout=action_timeout
|
|
414
|
+
)
|
|
415
|
+
elif action_type == "wait":
|
|
416
|
+
duration_ms = int(action.get("ms", 0))
|
|
417
|
+
if duration_ms < 0:
|
|
418
|
+
raise ValueError(f"browser action {index} wait ms must be non-negative")
|
|
419
|
+
page.wait_for_timeout(duration_ms)
|
|
420
|
+
elif action_type == "screenshot":
|
|
421
|
+
target = action.get("path")
|
|
422
|
+
if not isinstance(target, (str, Path)) or not str(target):
|
|
423
|
+
raise ValueError(f"browser action {index} screenshot requires path")
|
|
424
|
+
applied_actions.append({
|
|
425
|
+
"index": index,
|
|
426
|
+
"type": action_type,
|
|
427
|
+
"screenshot": capture_screenshot(
|
|
428
|
+
target, full_page=bool(action.get("full_page", True))
|
|
429
|
+
),
|
|
430
|
+
})
|
|
431
|
+
continue
|
|
432
|
+
else:
|
|
433
|
+
raise ValueError(
|
|
434
|
+
f"unsupported browser action type at index {index}: {action_type!r}"
|
|
435
|
+
)
|
|
436
|
+
action_record: dict[str, Any] = {
|
|
437
|
+
"index": index,
|
|
438
|
+
"type": action_type,
|
|
439
|
+
}
|
|
440
|
+
if selector:
|
|
441
|
+
action_record["selector"] = str(selector)
|
|
442
|
+
if action_type == "press":
|
|
443
|
+
action_record["key"] = str(action["key"])
|
|
444
|
+
if action_type == "fill":
|
|
445
|
+
action_record["value_length"] = len(str(action["value"]))
|
|
446
|
+
applied_actions.append(action_record)
|
|
447
|
+
|
|
448
|
+
inspection = inspect_page(page) if inspect_page is not None else None
|
|
449
|
+
if screenshot_path is not None:
|
|
450
|
+
capture_screenshot(screenshot_path, full_page=screenshot_full_page)
|
|
451
|
+
|
|
452
|
+
title = page.title()
|
|
453
|
+
content = page.content()
|
|
454
|
+
try:
|
|
455
|
+
aria_snapshot = page.locator("body").aria_snapshot(
|
|
456
|
+
timeout=int(timeout * 1000)
|
|
457
|
+
)
|
|
458
|
+
aria_error = None
|
|
459
|
+
except Exception as exc:
|
|
460
|
+
aria_snapshot = None
|
|
461
|
+
aria_error = str(exc)
|
|
462
|
+
dom_metrics = page.evaluate(
|
|
463
|
+
"""
|
|
464
|
+
() => {
|
|
465
|
+
const active = document.activeElement;
|
|
466
|
+
const named = (node) => Boolean(
|
|
467
|
+
node.getAttribute('aria-label') ||
|
|
468
|
+
node.getAttribute('aria-labelledby') ||
|
|
469
|
+
node.getAttribute('title') ||
|
|
470
|
+
(node.textContent || '').trim()
|
|
471
|
+
);
|
|
472
|
+
const focusable = document.querySelectorAll(
|
|
473
|
+
'a[href],button,input,textarea,select,[tabindex]:not([tabindex="-1"])'
|
|
474
|
+
);
|
|
475
|
+
const buttons = Array.from(document.querySelectorAll('button'));
|
|
476
|
+
const rootStyles = getComputedStyle(document.documentElement);
|
|
477
|
+
const customProperties = Array.from(rootStyles)
|
|
478
|
+
.filter((name) => name.startsWith('--'))
|
|
479
|
+
.sort();
|
|
480
|
+
return {
|
|
481
|
+
body_text_length: (document.body?.innerText || '').length,
|
|
482
|
+
focusable_count: focusable.length,
|
|
483
|
+
unnamed_button_count: buttons.filter((button) => !named(button)).length,
|
|
484
|
+
custom_property_count: customProperties.length,
|
|
485
|
+
custom_properties: customProperties,
|
|
486
|
+
horizontal_overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,
|
|
487
|
+
scroll_width: document.documentElement.scrollWidth,
|
|
488
|
+
client_width: document.documentElement.clientWidth,
|
|
489
|
+
scroll_height: document.documentElement.scrollHeight,
|
|
490
|
+
client_height: document.documentElement.clientHeight,
|
|
491
|
+
active_element: active ? {
|
|
492
|
+
tag: active.tagName.toLowerCase(),
|
|
493
|
+
id: active.id || null,
|
|
494
|
+
role: active.getAttribute('role'),
|
|
495
|
+
} : null,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
"""
|
|
499
|
+
)
|
|
500
|
+
return {
|
|
501
|
+
"success": True,
|
|
502
|
+
"title": title,
|
|
503
|
+
"content_length": len(content),
|
|
504
|
+
"url": page.url,
|
|
505
|
+
"http_status": response.status if response is not None else None,
|
|
506
|
+
"browser": {
|
|
507
|
+
"engine": "chromium",
|
|
508
|
+
"version": browser_version,
|
|
509
|
+
},
|
|
510
|
+
"viewport": page.viewport_size,
|
|
511
|
+
"actions": applied_actions,
|
|
512
|
+
**({"inspection": inspection} if inspection is not None else {}),
|
|
513
|
+
"evidence": {
|
|
514
|
+
"dom": {
|
|
515
|
+
"sha256": hashlib.sha256(content.encode("utf-8")).hexdigest(),
|
|
247
516
|
"content_length": len(content),
|
|
248
|
-
"
|
|
249
|
-
}
|
|
517
|
+
"metrics": dom_metrics,
|
|
518
|
+
},
|
|
519
|
+
"accessibility": {
|
|
520
|
+
"available": aria_snapshot is not None,
|
|
521
|
+
"snapshot": aria_snapshot,
|
|
522
|
+
"error": aria_error,
|
|
523
|
+
},
|
|
524
|
+
"console": console_messages,
|
|
525
|
+
"page_errors": page_errors,
|
|
526
|
+
"request_failures": request_failures,
|
|
527
|
+
"http_errors": http_errors,
|
|
528
|
+
"screenshots": screenshots,
|
|
529
|
+
},
|
|
530
|
+
}
|
|
250
531
|
|
|
251
532
|
def run_dynamic(
|
|
252
533
|
self,
|
|
@@ -311,10 +592,15 @@ class WebDynamicProbe(BaseProbe):
|
|
|
311
592
|
context: dict[str, Any] | None = None,
|
|
312
593
|
**kwargs: Any,
|
|
313
594
|
) -> dict[str, Any]:
|
|
314
|
-
"""AUDIT-04: 优雅降级为静态 Web 资产结构与 DOM XSS 汇聚点审计。
|
|
595
|
+
"""AUDIT-04: 优雅降级为静态 Web 资产结构与 DOM XSS 汇聚点审计。
|
|
596
|
+
|
|
597
|
+
降级契约:输出与成功路径(run_dynamic,status="ok")**可区分**——
|
|
598
|
+
status="degraded" + degraded=True + degraded_reason,绝不伪装成正常动态发包结果。
|
|
599
|
+
"""
|
|
315
600
|
path = Path(target)
|
|
316
601
|
findings: list[dict[str, Any]] = []
|
|
317
602
|
scanned_files = 0
|
|
603
|
+
read_errors: list[str] = []
|
|
318
604
|
|
|
319
605
|
files_to_scan: list[Path] = []
|
|
320
606
|
if path.is_file():
|
|
@@ -324,11 +610,12 @@ class WebDynamicProbe(BaseProbe):
|
|
|
324
610
|
files_to_scan.extend(path.glob(f"**/{ext}"))
|
|
325
611
|
|
|
326
612
|
for file_path in files_to_scan[:100]: # 限制扫描文件数防卡死
|
|
327
|
-
scanned_files += 1
|
|
328
613
|
try:
|
|
329
614
|
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
|
330
|
-
except
|
|
615
|
+
except OSError as exc:
|
|
616
|
+
read_errors.append(f"{file_path}: {exc}")
|
|
331
617
|
continue
|
|
618
|
+
scanned_files += 1
|
|
332
619
|
|
|
333
620
|
for pattern, rule_id in self.DOM_XSS_PATTERNS:
|
|
334
621
|
matches = re.finditer(pattern, content)
|
|
@@ -343,17 +630,85 @@ class WebDynamicProbe(BaseProbe):
|
|
|
343
630
|
"message": f"Detected potential unescaped DOM XSS sink: {m.group(0)}",
|
|
344
631
|
})
|
|
345
632
|
|
|
633
|
+
analyzed = scanned_files > 0
|
|
634
|
+
if analyzed:
|
|
635
|
+
degraded_reason = (
|
|
636
|
+
"playwright_unavailable" if not self.is_available() else "static_mode_forced"
|
|
637
|
+
)
|
|
638
|
+
else:
|
|
639
|
+
degraded_reason = "web_assets_not_found"
|
|
640
|
+
|
|
346
641
|
return {
|
|
347
|
-
"success":
|
|
348
|
-
"status": "
|
|
642
|
+
"success": analyzed,
|
|
643
|
+
"status": "degraded",
|
|
644
|
+
"degraded": True,
|
|
645
|
+
"degraded_reason": degraded_reason,
|
|
349
646
|
"probe_mode": "static_degraded",
|
|
350
647
|
"findings": findings,
|
|
351
648
|
"evidence": {
|
|
352
649
|
"scanned_files": scanned_files,
|
|
353
650
|
"findings_count": len(findings),
|
|
651
|
+
"read_errors": read_errors,
|
|
354
652
|
},
|
|
355
653
|
"metadata": {
|
|
356
654
|
"target": str(target),
|
|
357
655
|
"degraded_mode": "static_dom_xss_analysis",
|
|
358
656
|
},
|
|
359
657
|
}
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
def check_availability() -> dict[str, Any]:
|
|
661
|
+
"""降级契约:Web 审计能力结构化探活明细((bool, detail) 的结构化形态)。
|
|
662
|
+
|
|
663
|
+
机械探测 Playwright CLI / Python 包是否可用(<5ms,零阻塞、零子进程);
|
|
664
|
+
原始 HTTP 发包模式仅依赖标准库,恒可用。DEGRADED 时浏览器通道必须走
|
|
665
|
+
``WebDynamicProbe.run_static_degraded``,禁止伪装成动态审计结果。
|
|
666
|
+
"""
|
|
667
|
+
cli_path = shutil.which("playwright")
|
|
668
|
+
try:
|
|
669
|
+
import importlib.util
|
|
670
|
+
|
|
671
|
+
spec_ready = importlib.util.find_spec("playwright") is not None
|
|
672
|
+
except Exception:
|
|
673
|
+
spec_ready = False
|
|
674
|
+
browser_ready = bool(cli_path or spec_ready)
|
|
675
|
+
checks = [
|
|
676
|
+
{
|
|
677
|
+
"name": "playwright-cli",
|
|
678
|
+
"ok": cli_path is not None,
|
|
679
|
+
"required": False,
|
|
680
|
+
"detail": cli_path or "未找到 playwright CLI",
|
|
681
|
+
},
|
|
682
|
+
{
|
|
683
|
+
"name": "playwright-python",
|
|
684
|
+
"ok": spec_ready,
|
|
685
|
+
"required": True,
|
|
686
|
+
"detail": "playwright 包可导入" if spec_ready else "未安装 playwright Python 包(pip install playwright && playwright install chromium)",
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
"name": "raw-http",
|
|
690
|
+
"ok": True,
|
|
691
|
+
"required": False,
|
|
692
|
+
"detail": "标准库 urllib 原始发包通道恒可用",
|
|
693
|
+
},
|
|
694
|
+
]
|
|
695
|
+
return {
|
|
696
|
+
"name": "web_dynamic_probe",
|
|
697
|
+
"status": "READY" if browser_ready else "DEGRADED",
|
|
698
|
+
"available": browser_ready,
|
|
699
|
+
"detail": (
|
|
700
|
+
"Playwright 无头浏览器通道可用"
|
|
701
|
+
if browser_ready
|
|
702
|
+
else "Playwright 不可用:浏览器动态通道降级为静态 DOM/资产分析(原始 HTTP 发包仍可用)"
|
|
703
|
+
),
|
|
704
|
+
"checks": checks,
|
|
705
|
+
"capabilities": (
|
|
706
|
+
["headless_browser", "raw_http", "browser_instance_pool"]
|
|
707
|
+
if browser_ready
|
|
708
|
+
else ["raw_http"]
|
|
709
|
+
),
|
|
710
|
+
"fallbacks": {} if browser_ready else {
|
|
711
|
+
"audit": "WebDynamicProbe.run_static_degraded(静态 DOM XSS 汇聚点分析)",
|
|
712
|
+
},
|
|
713
|
+
"warnings": [],
|
|
714
|
+
}
|
|
@@ -24,5 +24,5 @@ strategy = compile_audit_strategy(profile)
|
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## 5. Maintenance & Verification
|
|
27
|
-
-
|
|
27
|
+
- Verification is performed with short-lived tests outside the repository; no persistent `tests/` registry is retained.
|
|
28
28
|
- Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/project_profiler --write`.
|
|
@@ -258,7 +258,12 @@ class LLMProfileArbitrator:
|
|
|
258
258
|
tmp_prompt.write_text(content, encoding="utf-8")
|
|
259
259
|
cmd = host_registry.build_recon_scout_command(active_host, self.root, tmp_prompt)
|
|
260
260
|
if not cmd:
|
|
261
|
-
|
|
261
|
+
# 宿主声称支持侦察却给不出可执行命令,按「无 LLM 环境」
|
|
262
|
+
# 降级返回二元组。本函数其余所有分支(engine_dir /
|
|
263
|
+
# offline / cache / 异常)都返回二元组,调用方 detector.py
|
|
264
|
+
# 直接 `x, y = arbitrate(...)`;返回 None 会让整个
|
|
265
|
+
# detect_project_profile 抛 TypeError 崩溃。
|
|
266
|
+
return candidate_fixtures, heuristic_forms
|
|
262
267
|
|
|
263
268
|
child_env = os.environ.copy()
|
|
264
269
|
child_env["BUGX_RECON_SCOUT_ACTIVE"] = "1"
|
|
@@ -271,6 +271,7 @@ def detect_project_profile(root: str | os.PathLike[str], *, file_limit: int = DE
|
|
|
271
271
|
cached.pop("observed_at", None)
|
|
272
272
|
cached["generated_at"] = time.time()
|
|
273
273
|
return cached
|
|
274
|
+
cache_corrupt = False
|
|
274
275
|
if cache_file is not None and private_profile_cache(cache_file):
|
|
275
276
|
try:
|
|
276
277
|
cached_data = json.loads(cache_file.read_text(encoding="utf-8"))
|
|
@@ -280,7 +281,9 @@ def detect_project_profile(root: str | os.PathLike[str], *, file_limit: int = DE
|
|
|
280
281
|
cached_data["generated_at"] = time.time()
|
|
281
282
|
return cached_data
|
|
282
283
|
except Exception:
|
|
283
|
-
|
|
284
|
+
# F-RSI-20261115-292: 缓存损坏不得静默吞掉后重新生成;留下结构化、
|
|
285
|
+
# 可区分信号,与 strategy 的 review_parse_status 对齐。
|
|
286
|
+
cache_corrupt = True
|
|
284
287
|
|
|
285
288
|
try:
|
|
286
289
|
scanner = sca_module()()
|
|
@@ -385,6 +388,10 @@ def detect_project_profile(root: str | os.PathLike[str], *, file_limit: int = DE
|
|
|
385
388
|
)
|
|
386
389
|
except (OSError, ValueError):
|
|
387
390
|
pass
|
|
391
|
+
if cache_corrupt:
|
|
392
|
+
# 该字段在 profile_hash 计算与缓存落盘之后附加:不污染 profile_hash、
|
|
393
|
+
# 不写回缓存,仅本次「缓存损坏→重新生成」运行可见,下游可据此区分。
|
|
394
|
+
profile["profile_cache_status"] = "corrupt_recovered"
|
|
388
395
|
return profile
|
|
389
396
|
|
|
390
397
|
|
|
@@ -110,6 +110,45 @@ def classify_profile(profile: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
110
110
|
return res
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
_SEMANTIC_REVIEW_REL = Path(".bugx") / "state" / "l1-semantic-review.json"
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _load_semantic_review(profile: Mapping[str, Any]) -> tuple[Any, str]:
|
|
117
|
+
"""读取 L1 语义评审文件,并显式报告「为何使用/未使用」。
|
|
118
|
+
|
|
119
|
+
返回 ``(review, parse_status)``,``parse_status`` 取值:
|
|
120
|
+
|
|
121
|
+
* ``ok`` —— 文件存在且解析为评审对象;
|
|
122
|
+
* ``failed`` —— 文件存在但 JSON 解码失败,或内容不是评审对象;
|
|
123
|
+
* ``absent`` —— 根本没有评审文件(合法态)。
|
|
124
|
+
|
|
125
|
+
F-RSI-20261115-292:解析失败绝不能被悄悄折叠成 ``absent``,否则下游
|
|
126
|
+
无法区分「有文件但坏了」与「无评审」。profile 内嵌的 ``semantic_review``
|
|
127
|
+
仅作为内容回退源,不会抹掉磁盘文件已记录的 ``failed`` 状态。
|
|
128
|
+
"""
|
|
129
|
+
review: Any = None
|
|
130
|
+
parse_status = "absent"
|
|
131
|
+
root_candidate = profile.get("root") or profile.get("project_root")
|
|
132
|
+
if root_candidate:
|
|
133
|
+
rev_path = Path(root_candidate) / _SEMANTIC_REVIEW_REL
|
|
134
|
+
if rev_path.is_file():
|
|
135
|
+
try:
|
|
136
|
+
loaded = json.loads(rev_path.read_text(encoding="utf-8"))
|
|
137
|
+
except Exception:
|
|
138
|
+
loaded = None
|
|
139
|
+
parse_status = "failed"
|
|
140
|
+
if parse_status != "failed":
|
|
141
|
+
if isinstance(loaded, Mapping):
|
|
142
|
+
review = loaded
|
|
143
|
+
parse_status = "ok"
|
|
144
|
+
else:
|
|
145
|
+
# 文件存在但内容不是评审对象(null / 列表 / 标量等)
|
|
146
|
+
parse_status = "failed"
|
|
147
|
+
if review is None and isinstance(profile.get("semantic_review"), Mapping):
|
|
148
|
+
review = profile["semantic_review"]
|
|
149
|
+
return review, parse_status
|
|
150
|
+
|
|
151
|
+
|
|
113
152
|
def compile_audit_strategy(profile: Mapping[str, Any]) -> dict[str, Any]:
|
|
114
153
|
"""Compile classification facts into the small plan consumed by workers."""
|
|
115
154
|
classification = profile.get("classification")
|
|
@@ -171,20 +210,13 @@ def compile_audit_strategy(profile: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
171
210
|
recommend("supply-chain", f"{signal.get('id')} 命中 {signal.get('package')} 版本候选", signal.get("evidence_refs") or [])
|
|
172
211
|
break
|
|
173
212
|
|
|
174
|
-
review =
|
|
175
|
-
|
|
176
|
-
if
|
|
177
|
-
|
|
178
|
-
rev_path = Path(root_candidate) / ".bugx" / "state" / "l1-semantic-review.json"
|
|
179
|
-
if rev_path.is_file():
|
|
180
|
-
review = json.loads(rev_path.read_text(encoding="utf-8"))
|
|
181
|
-
except Exception:
|
|
182
|
-
pass
|
|
183
|
-
if not review and isinstance(profile.get("semantic_review"), Mapping):
|
|
184
|
-
review = profile.get("semantic_review")
|
|
213
|
+
review, review_parse_status = _load_semantic_review(profile)
|
|
214
|
+
verdict = review.get("audit_strategy_verdict") if isinstance(review, Mapping) else None
|
|
215
|
+
if not isinstance(verdict, Mapping):
|
|
216
|
+
verdict = {}
|
|
185
217
|
|
|
186
|
-
if review
|
|
187
|
-
strat_verdict =
|
|
218
|
+
if review is not None:
|
|
219
|
+
strat_verdict = verdict
|
|
188
220
|
missing_profiles = strat_verdict.get("missing_check_profiles") or []
|
|
189
221
|
for p in missing_profiles:
|
|
190
222
|
p_str = str(p)
|
|
@@ -239,8 +271,12 @@ def compile_audit_strategy(profile: Mapping[str, Any]) -> dict[str, Any]:
|
|
|
239
271
|
"unknowns": list(profile.get("unknowns") or [])[:MAX_FACTS],
|
|
240
272
|
"conflicts": list(profile.get("conflicts") or [])[:MAX_FACTS],
|
|
241
273
|
"version_lines": sorted(set(version_lines))[:24],
|
|
242
|
-
"ai_review_status": (
|
|
243
|
-
|
|
274
|
+
"ai_review_status": (
|
|
275
|
+
verdict.get("status", "none") if review is not None
|
|
276
|
+
else ("parse_failed" if review_parse_status == "failed" else "none")
|
|
277
|
+
),
|
|
278
|
+
"ai_priority_focus": verdict.get("priority_focus", []) if review is not None else [],
|
|
279
|
+
"review_parse_status": review_parse_status,
|
|
244
280
|
}
|
|
245
281
|
if profile.get("scale_estimation"):
|
|
246
282
|
payload["scale_estimation"] = dict(profile["scale_estimation"])
|
package/core/prompts/README.md
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
flowchart TD
|
|
11
11
|
P["core/prompts/"]
|
|
12
12
|
P --> RT["路由与调度<br/>l0_router.md<br/>command_routing_zh.md<br/>command_routing_en.md<br/>codex_dialog_dispatch.md"]
|
|
13
|
-
P --> ST["阶段指导 (stages/)<br/>stage_gate.md (前置门禁)<br/>stage_explore.md (探索侦察)<br/>stage_mutate.md (模糊变异)<br/>stage_repair.md (防御修复)"]
|
|
13
|
+
P --> ST["阶段指导 (stages/)<br/>stage_gate.md (前置门禁)<br/>stage_explore.md (探索侦察)<br/>stage_verify.md / stage_verify.defensive.md (独立盲审验证)<br/>stage_mutate.md (模糊变异)<br/>stage_repair.md (防御修复)"]
|
|
14
|
+
P --> PL["策略配置 (policies/)<br/>prompt_policies.json (声明式模型策略与风控降级)"]
|
|
14
15
|
P --> RL["防御规则 (rules/)<br/>anti_patterns.md (反模式特征)<br/>concurrency_rules.md (并发安全)<br/>memory_leak_rules.md (内存泄露)<br/>prompt_injection_defense.md (反注入)"]
|
|
15
16
|
```
|
|
16
17
|
|
|
@@ -25,7 +26,8 @@ flowchart TD
|
|
|
25
26
|
| `command_routing_zh.md` | 中文自然语言意图到 BugX CLI 命令的高精度意图映射规则库 |
|
|
26
27
|
| `l0_router.md` | L0 顶层意图分流器,识别用户意图属于常规审查、定向攻防、状态查看还是系统诊断 |
|
|
27
28
|
| `rules/` | 防御与审查硬红线规则集,包含 `anti_patterns.md`、`concurrency_rules.md`、`memory_leak_rules.md` 与 `prompt_injection_defense.md` |
|
|
28
|
-
| `stages/` | 攻防生命周期阶段指引模板库,涵盖 `stage_gate.md`、`stage_explore.md`、`stage_mutate.md` 与 `stage_repair.md` |
|
|
29
|
+
| `stages/` | 攻防生命周期阶段指引模板库,涵盖 `stage_gate.md`、`stage_explore.md`、`stage_verify.md`、`stage_verify.defensive.md`、`stage_mutate.md` 与 `stage_repair.md` |
|
|
30
|
+
| `policies/` | 声明式提示词策略配置目录(`prompt_policies.json`),定义 `standard` / `defensive_qa` / `strict_compliance`、模型路由与风控动态降级触发器 |
|
|
29
31
|
|
|
30
32
|
---
|
|
31
33
|
|
|
@@ -28,7 +28,7 @@ In the first second of receiving a task, classify which branch it belongs to:
|
|
|
28
28
|
- **Reproduction and Mutation**: `bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`
|
|
29
29
|
- **Supervisor and Concurrency**: `bugx supervisor status --root <ROOT>`
|
|
30
30
|
- **Telemetry and Logs**: `bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
|
|
31
|
-
- **Dual Reports and Preview**: `bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
|
|
31
|
+
- **Dual Reports and Preview**: `bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`
|
|
32
32
|
|
|
33
33
|
### 4. Compact Command Radar (41 Top-level Commands Classified Index)
|
|
34
34
|
To invoke any command below, inspect exact parameters dynamically via `bugx help <cmd>`; never guess:
|
|
@@ -39,4 +39,4 @@ To invoke any command below, inspect exact parameters dynamically via `bugx help
|
|
|
39
39
|
|
|
40
40
|
### 5. Mandatory Rules and Deprecated Command Redirection
|
|
41
41
|
- **Gate Blockage Forbids Destructive Repairs**: `FATAL_BLOCKED` must never be bypassed using `init`, `reset`, or `--force`; preserve logs and state first.
|
|
42
|
-
- **Deprecated Command Redirections**: `matrix` -> `bugx audit`; `console` -> `bugx report serve`; `watch` -> `bugx log --watch`; `test` is
|
|
42
|
+
- **Deprecated Command Redirections**: `matrix` -> `bugx audit`; `console` -> `bugx report serve`; `watch` -> `bugx log --watch`; `test` is not a public command. For development checks, create a minimal temporary verification script outside the repository or run tests owned by the target project, then delete the process file.
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
- **单点复现与变异**:`bugx test-generate --root <ROOT> --scope <PATH::SYM> --out <FILE>` / `bugx test-verify verify --scope <SCOPE>`
|
|
29
29
|
- **Supervisor 与并发排查**:`bugx supervisor status --root <ROOT>`
|
|
30
30
|
- **脱敏飞轮与日志**:`bugx telemetry inspect` / `bugx log --root <ROOT> --errors`
|
|
31
|
-
- **双轨报告与预览**:`bugx report both --eval-dir evals/oss --out evals/oss` / `bugx report serve --port 18991`
|
|
31
|
+
- **双轨报告与预览**:`bugx report both --eval-dir verification/evals/oss --out verification/evals/oss` / `bugx report serve --port 18991`
|
|
32
32
|
|
|
33
33
|
### 4. 紧凑型命令全景雷达(41 个顶层命令分类索引)
|
|
34
34
|
如需调用以下命令,通过 `bugx help <命令>` 动态获取具体参数与子命令,严禁盲猜:
|
|
@@ -39,4 +39,4 @@
|
|
|
39
39
|
|
|
40
40
|
### 5. 核心军规与废弃命令重定向
|
|
41
41
|
- **阻断不授权暴力修复**:`FATAL_BLOCKED` 严禁使用 `init`、`reset`、`--force` 绕过,先保留报告和日志。
|
|
42
|
-
- **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test`
|
|
42
|
+
- **废弃命令重定向**:`matrix` -> `bugx audit`;`console` -> `bugx report serve`;`watch` -> `bugx log --watch`;`test` 不是公共命令。开发验证请在仓库外生成最小临时验证脚本,或运行被测目标项目自带的测试,完成后删除过程文件。
|