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
|
@@ -318,11 +318,105 @@ def check_availability() -> dict:
|
|
|
318
318
|
"status": "READY" if ready else "DEGRADED",
|
|
319
319
|
"checks": checks,
|
|
320
320
|
"capabilities": ["ios_binary_inspection"] if ready else [],
|
|
321
|
-
"fallbacks": {}
|
|
321
|
+
"fallbacks": {} if ready else {
|
|
322
|
+
"audit": "run_static_degraded(仅 Info.plist 静态审计,二进制层检查不执行)",
|
|
323
|
+
},
|
|
322
324
|
"warnings": [],
|
|
323
325
|
}
|
|
324
326
|
|
|
325
327
|
|
|
328
|
+
def is_available() -> tuple[bool, str]:
|
|
329
|
+
"""降级契约:机械探测 iOS 二进制审计前置条件(<5ms,零阻塞、零子进程)。
|
|
330
|
+
|
|
331
|
+
返回 (available, detail):codesign 与 otool 均在 PATH 才视为具备完整
|
|
332
|
+
二进制层审计能力;缺失时 detail 明确列出缺口与降级路径。
|
|
333
|
+
"""
|
|
334
|
+
missing: list[str] = []
|
|
335
|
+
found: list[str] = []
|
|
336
|
+
for name in ("codesign", "otool"):
|
|
337
|
+
path = shutil.which(name)
|
|
338
|
+
if path:
|
|
339
|
+
found.append(f"{name}={path}")
|
|
340
|
+
else:
|
|
341
|
+
missing.append(name)
|
|
342
|
+
if missing:
|
|
343
|
+
return False, (
|
|
344
|
+
f"缺少必需工具 {', '.join(missing)}:Mach-O/签名/entitlements 审计不可用,"
|
|
345
|
+
"降级为 run_static_degraded(仅 Info.plist 静态检查)"
|
|
346
|
+
)
|
|
347
|
+
return True, ";".join(found)
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
def run_static_degraded(root: Path | str) -> dict:
|
|
351
|
+
"""降级路径:codesign/otool 缺失时仅做标准库 Info.plist 静态审计。
|
|
352
|
+
|
|
353
|
+
降级契约:输出与成功路径(inspect(),status=READY)**可区分**——
|
|
354
|
+
status="degraded" + degraded=True + degraded_reason + checks_not_run,
|
|
355
|
+
绝不伪造二进制层结论(PIE/栈保护/cryptid/entitlements 一律标注未执行)。
|
|
356
|
+
"""
|
|
357
|
+
root = Path(root)
|
|
358
|
+
report: dict = {
|
|
359
|
+
"name": "ios_binary",
|
|
360
|
+
"status": "degraded",
|
|
361
|
+
"degraded": True,
|
|
362
|
+
"degraded_reason": "codesign/otool 不可用:二进制层检查未执行",
|
|
363
|
+
"target": str(root),
|
|
364
|
+
"success": False,
|
|
365
|
+
"findings": [],
|
|
366
|
+
"facts": {},
|
|
367
|
+
"notes": [],
|
|
368
|
+
"checks_not_run": [
|
|
369
|
+
"codesign-entitlements",
|
|
370
|
+
"otool-macho-header(PIE)",
|
|
371
|
+
"nm-undefined-symbols(stack-canary)",
|
|
372
|
+
"otool-load-commands(cryptid)",
|
|
373
|
+
"otool-linked-libraries(dylib-hijack)",
|
|
374
|
+
],
|
|
375
|
+
}
|
|
376
|
+
available, detail = is_available()
|
|
377
|
+
report["availability"] = {"available": available, "detail": detail}
|
|
378
|
+
if not root.exists():
|
|
379
|
+
report["notes"].append("目标路径不存在")
|
|
380
|
+
report["degraded_reason"] = "target_path_not_found"
|
|
381
|
+
return report
|
|
382
|
+
temp_dir: tempfile.TemporaryDirectory[str] | None = None
|
|
383
|
+
try:
|
|
384
|
+
target = root
|
|
385
|
+
if root.is_file() and root.suffix == ".ipa":
|
|
386
|
+
temp_dir = tempfile.TemporaryDirectory(prefix="bugx-ipa-degraded-")
|
|
387
|
+
with zipfile.ZipFile(root) as archive:
|
|
388
|
+
archive.extractall(temp_dir.name)
|
|
389
|
+
target = Path(temp_dir.name)
|
|
390
|
+
bundle = _find_app_bundle(target) if target.is_dir() else None
|
|
391
|
+
if bundle is None:
|
|
392
|
+
report["notes"].append("未找到 .app 包(需要 .ipa / .app 目录)")
|
|
393
|
+
report["degraded_reason"] = "app_bundle_not_found"
|
|
394
|
+
return report
|
|
395
|
+
info_plist = bundle / "Info.plist"
|
|
396
|
+
if not info_plist.is_file():
|
|
397
|
+
report["notes"].append("缺少 Info.plist:降级模式下无任何可执行检查")
|
|
398
|
+
report["degraded_reason"] = "info_plist_not_found"
|
|
399
|
+
return report
|
|
400
|
+
findings, facts = _info_plist_findings(_read_plist(info_plist), str(info_plist))
|
|
401
|
+
report["findings"].extend(findings)
|
|
402
|
+
report["facts"].update({k: v for k, v in facts.items() if v is not None})
|
|
403
|
+
report["facts"]["binary"] = None
|
|
404
|
+
report["notes"].append(
|
|
405
|
+
"降级模式:仅完成 Info.plist 静态检查;二进制加固属性全部未检查,"
|
|
406
|
+
"禁止据此声称已完成 iOS 二进制层审计"
|
|
407
|
+
)
|
|
408
|
+
report["success"] = True
|
|
409
|
+
return report
|
|
410
|
+
except (OSError, zipfile.BadZipFile, ValueError) as exc:
|
|
411
|
+
report["notes"].append(f"降级审计执行失败: {exc.__class__.__name__}: {exc}")
|
|
412
|
+
report["degraded_reason"] = "degraded_execution_failed"
|
|
413
|
+
report["success"] = False
|
|
414
|
+
return report
|
|
415
|
+
finally:
|
|
416
|
+
if temp_dir is not None:
|
|
417
|
+
temp_dir.cleanup()
|
|
418
|
+
|
|
419
|
+
|
|
326
420
|
def print_report(report: dict, as_json: bool = False) -> None:
|
|
327
421
|
if as_json:
|
|
328
422
|
print(json.dumps(report, ensure_ascii=False, indent=2))
|
|
@@ -350,13 +444,23 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
350
444
|
"--check-availability", action="store_true",
|
|
351
445
|
help="只检查宿主分析工具,不读取 --root 下的目标文件",
|
|
352
446
|
)
|
|
447
|
+
parser.add_argument(
|
|
448
|
+
"--static-degraded", action="store_true",
|
|
449
|
+
help="显式执行降级路径(仅 Info.plist 静态审计;输出 status=degraded,"
|
|
450
|
+
"绝不伪造二进制层结论)",
|
|
451
|
+
)
|
|
353
452
|
args = parser.parse_args(argv)
|
|
354
453
|
report = (
|
|
355
454
|
check_availability()
|
|
356
455
|
if args.check_availability
|
|
456
|
+
else run_static_degraded(Path(args.root).expanduser())
|
|
457
|
+
if args.static_degraded
|
|
357
458
|
else inspect(Path(args.root).expanduser())
|
|
358
459
|
)
|
|
359
460
|
print_report(report, as_json=args.json)
|
|
461
|
+
if args.static_degraded:
|
|
462
|
+
# 调用方显式要求降级模式:本身不是失败,输出已带 degraded 标记。
|
|
463
|
+
return 0
|
|
360
464
|
if report["status"] == "DEGRADED" and not args.allow_fallback:
|
|
361
465
|
return 2
|
|
362
466
|
return 0
|
|
@@ -322,5 +322,71 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
322
322
|
return 0 if all(report.ready for report in reports) else 1
|
|
323
323
|
|
|
324
324
|
|
|
325
|
+
_MEMORY_STACK_TOOLS: dict[str, tuple[str, ...]] = {
|
|
326
|
+
"native": ("clang", "gcc", "cc", "leaks", "heaptrack", "valgrind", "DrMemory", "devenv"),
|
|
327
|
+
"python": ("memray",),
|
|
328
|
+
"jvm": ("java", "jcmd", "jmap", "jfr"),
|
|
329
|
+
"electron": ("node", "npx", "npm"),
|
|
330
|
+
"android": ("adb",),
|
|
331
|
+
"apple": ("instruments", "xcrun", "leaks"),
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def is_available(target: str = "native") -> tuple[bool, str]:
|
|
336
|
+
"""降级契约:机械探活指定内存审计栈关键工具是否在 PATH(零子进程)。
|
|
337
|
+
|
|
338
|
+
只做 ``shutil.which`` 枚举,不启动任何工具子命令;具体栈的完整校验
|
|
339
|
+
(版本、模块可用性)仍归各 ``*_report()``。环境不满足时返回 False,
|
|
340
|
+
调用方必须走 ``run_static_degraded``,禁止伪装 profiling 可用。
|
|
341
|
+
"""
|
|
342
|
+
names = _MEMORY_STACK_TOOLS.get(target)
|
|
343
|
+
if names is None:
|
|
344
|
+
return False, f"未知内存审计栈: {target}"
|
|
345
|
+
host = host_name()
|
|
346
|
+
if target == "native" and host == "unsupported":
|
|
347
|
+
return False, f"当前主机平台不受支持: {sys.platform}"
|
|
348
|
+
found = [name for name in names if _which(name)]
|
|
349
|
+
if not found:
|
|
350
|
+
return False, f"{target} 栈关键工具均未安装(候选: {', '.join(names)})"
|
|
351
|
+
return True, f"{target} 栈可用工具: {', '.join(found)}"
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def run_static_degraded(target: str = "native", *, platform: str | None = None) -> dict:
|
|
355
|
+
"""降级契约:内存 profiling 环境不满足时的降级输出,绝不伪装运行期数据。
|
|
356
|
+
|
|
357
|
+
输出与成功路径(``_finish`` 的 READY Report)字段级可区分:
|
|
358
|
+
``status="degraded"`` + ``degraded=True`` + ``degraded_reason``,只汇总
|
|
359
|
+
静态预检结论(which 级事实)并显式声明运行期 profiling 未执行。
|
|
360
|
+
"""
|
|
361
|
+
available, availability_detail = is_available(target)
|
|
362
|
+
report = reports_for(target, platform=platform)[0]
|
|
363
|
+
failed_required = [
|
|
364
|
+
check.name for check in report.checks if check.required and not check.ok
|
|
365
|
+
]
|
|
366
|
+
return {
|
|
367
|
+
"schema_version": 1,
|
|
368
|
+
"success": True,
|
|
369
|
+
"status": "degraded",
|
|
370
|
+
"degraded": True,
|
|
371
|
+
"degraded_reason": (
|
|
372
|
+
"static_mode_forced" if available else "memory_profiling_unavailable"
|
|
373
|
+
),
|
|
374
|
+
"probe_mode": "static_degraded",
|
|
375
|
+
"target": target,
|
|
376
|
+
"findings": [],
|
|
377
|
+
"evidence": {
|
|
378
|
+
"availability_detail": availability_detail,
|
|
379
|
+
"failed_required_checks": failed_required,
|
|
380
|
+
"checks": [asdict(check) for check in report.checks],
|
|
381
|
+
},
|
|
382
|
+
"warnings": list(report.warnings),
|
|
383
|
+
"metadata": {
|
|
384
|
+
"degraded_mode": "static_precheck_only",
|
|
385
|
+
"runtime_profiling_executed": False,
|
|
386
|
+
"fallback": "运行期数据缺失时以静态证据边界声明替代,禁止把预检结论伪装成 profiling 完成",
|
|
387
|
+
},
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
|
|
325
391
|
if __name__ == "__main__":
|
|
326
392
|
sys.exit(main())
|
|
@@ -61,7 +61,11 @@ class MiniProgramProbe(BaseProbe):
|
|
|
61
61
|
return "miniprogram_probe"
|
|
62
62
|
|
|
63
63
|
def is_available(self) -> bool:
|
|
64
|
-
"""AUDIT-04: 极速探活 (<5ms,零阻塞)。
|
|
64
|
+
"""AUDIT-04: 极速探活 (<5ms,零阻塞)。
|
|
65
|
+
|
|
66
|
+
降级契约:布尔返回值受 BaseProbe 布尔契约约束(execute_probe 以真值
|
|
67
|
+
判定是否降级);(bool, detail) 明细结构见模块级 ``check_availability()``。
|
|
68
|
+
"""
|
|
65
69
|
for tool in ("miniprogram-ci", "cli", "wechat-cli"):
|
|
66
70
|
if shutil.which(tool) is not None:
|
|
67
71
|
return True
|
|
@@ -126,11 +130,13 @@ class MiniProgramProbe(BaseProbe):
|
|
|
126
130
|
cf_dir = Path(cloud_functions_dir)
|
|
127
131
|
findings: list[dict[str, Any]] = []
|
|
128
132
|
scanned_functions = 0
|
|
133
|
+
read_errors: list[str] = []
|
|
129
134
|
|
|
130
135
|
if not cf_dir.exists():
|
|
131
136
|
return {
|
|
132
137
|
"scanned_functions": 0,
|
|
133
138
|
"findings": [],
|
|
139
|
+
"read_errors": [f"cloud_functions_dir 不存在: {cf_dir}"],
|
|
134
140
|
}
|
|
135
141
|
|
|
136
142
|
# 遍历所有云函数目录
|
|
@@ -146,7 +152,8 @@ class MiniProgramProbe(BaseProbe):
|
|
|
146
152
|
for src_file in source_files:
|
|
147
153
|
try:
|
|
148
154
|
code = src_file.read_text(encoding="utf-8", errors="replace")
|
|
149
|
-
except
|
|
155
|
+
except OSError as exc:
|
|
156
|
+
read_errors.append(f"{src_file}: {exc}")
|
|
150
157
|
continue
|
|
151
158
|
|
|
152
159
|
has_privileged_op = any(op in code for op in self.PRIVILEGED_CLOUD_OPERATIONS)
|
|
@@ -195,6 +202,7 @@ class MiniProgramProbe(BaseProbe):
|
|
|
195
202
|
"scanned_functions": scanned_functions,
|
|
196
203
|
"findings": findings,
|
|
197
204
|
"unprotected_cloud_functions": len(findings),
|
|
205
|
+
"read_errors": read_errors,
|
|
198
206
|
}
|
|
199
207
|
|
|
200
208
|
def _find_app_json(self, target: str | Path) -> Path | None:
|
|
@@ -267,47 +275,67 @@ class MiniProgramProbe(BaseProbe):
|
|
|
267
275
|
context: dict[str, Any] | None = None,
|
|
268
276
|
**kwargs: Any,
|
|
269
277
|
) -> dict[str, Any]:
|
|
270
|
-
"""AUDIT-04: 无微信 CLI 环境时,优雅降级为静态 WXML/JSON 路由遍历与云函数源码扫描。
|
|
278
|
+
"""AUDIT-04: 无微信 CLI 环境时,优雅降级为静态 WXML/JSON 路由遍历与云函数源码扫描。
|
|
279
|
+
|
|
280
|
+
降级契约:输出与成功路径(run_dynamic,status="ok")**可区分**——
|
|
281
|
+
status="degraded" + degraded=True + degraded_reason,绝不伪装成正常动态结果。
|
|
282
|
+
"""
|
|
271
283
|
all_findings: list[dict[str, Any]] = []
|
|
272
284
|
routes_summary: list[str] = []
|
|
285
|
+
parse_errors: list[str] = []
|
|
273
286
|
|
|
274
|
-
# 1. 尝试解析 app.json
|
|
287
|
+
# 1. 尝试解析 app.json(解析失败显式留痕,禁止静默吞错)
|
|
275
288
|
app_json_path = self._find_app_json(target)
|
|
276
289
|
if app_json_path and app_json_path.exists():
|
|
277
|
-
|
|
290
|
+
try:
|
|
291
|
+
route_res = self.parse_app_json(app_json_path)
|
|
292
|
+
except Exception as exc:
|
|
293
|
+
parse_errors.append(
|
|
294
|
+
f"{app_json_path}: {exc.__class__.__name__}: {exc}"
|
|
295
|
+
)
|
|
296
|
+
route_res = {"findings": [], "all_routes": []}
|
|
278
297
|
all_findings.extend(route_res["findings"])
|
|
279
298
|
routes_summary.extend(route_res["all_routes"])
|
|
280
299
|
elif isinstance(target, str) and "pages" in target and "{" in target:
|
|
281
|
-
# 传入的是 app.json
|
|
300
|
+
# 传入的是 app.json 文本;解析失败必须显式留痕,禁止静默吞错
|
|
282
301
|
try:
|
|
283
302
|
route_res = self.parse_app_json(target)
|
|
284
303
|
all_findings.extend(route_res["findings"])
|
|
285
304
|
routes_summary.extend(route_res["all_routes"])
|
|
286
|
-
except Exception:
|
|
287
|
-
|
|
305
|
+
except Exception as exc:
|
|
306
|
+
parse_errors.append(
|
|
307
|
+
f"inline app.json: {exc.__class__.__name__}: {exc}"
|
|
308
|
+
)
|
|
288
309
|
|
|
289
310
|
# 2. 扫描云函数源码
|
|
290
311
|
cf_dir = self._find_cloud_functions_dir(target)
|
|
291
|
-
cf_res = {"scanned_functions": 0, "findings": []}
|
|
312
|
+
cf_res = {"scanned_functions": 0, "findings": [], "read_errors": []}
|
|
292
313
|
if cf_dir:
|
|
293
314
|
cf_res = self.probe_cloud_functions(cf_dir)
|
|
294
315
|
all_findings.extend(cf_res["findings"])
|
|
295
316
|
|
|
296
317
|
# 3. 静态扫描 WXML 导航标签
|
|
297
318
|
wxml_nav_count = 0
|
|
319
|
+
read_errors: list[str] = []
|
|
298
320
|
p = Path(target)
|
|
299
321
|
if p.is_dir():
|
|
300
322
|
for wxml in list(p.glob("**/*.wxml"))[:50]:
|
|
301
323
|
try:
|
|
302
324
|
txt = wxml.read_text(encoding="utf-8", errors="ignore")
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
except Exception:
|
|
325
|
+
except OSError as exc:
|
|
326
|
+
read_errors.append(f"{wxml}: {exc}")
|
|
306
327
|
continue
|
|
328
|
+
matches = re.findall(r'<navigator\s+[^>]*url=["\']([^"\']+)["\']', txt)
|
|
329
|
+
wxml_nav_count += len(matches)
|
|
307
330
|
|
|
331
|
+
parse_errors.extend(cf_res.get("read_errors", []))
|
|
308
332
|
return {
|
|
309
333
|
"success": True,
|
|
310
|
-
"status": "
|
|
334
|
+
"status": "degraded",
|
|
335
|
+
"degraded": True,
|
|
336
|
+
"degraded_reason": (
|
|
337
|
+
"wechat_cli_unavailable" if not self.is_available() else "static_mode_forced"
|
|
338
|
+
),
|
|
311
339
|
"probe_mode": "static_degraded",
|
|
312
340
|
"findings": all_findings,
|
|
313
341
|
"evidence": {
|
|
@@ -315,9 +343,43 @@ class MiniProgramProbe(BaseProbe):
|
|
|
315
343
|
"wxml_nav_links": wxml_nav_count,
|
|
316
344
|
"cloud_functions_scanned": cf_res.get("scanned_functions", 0),
|
|
317
345
|
"findings_count": len(all_findings),
|
|
346
|
+
"read_errors": parse_errors,
|
|
318
347
|
},
|
|
319
348
|
"metadata": {
|
|
320
349
|
"target": str(target),
|
|
321
350
|
"degraded_mode": "static_miniprogram_structure_analysis",
|
|
322
351
|
},
|
|
323
352
|
}
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def check_availability() -> dict[str, Any]:
|
|
356
|
+
"""降级契约:小程序审计能力结构化探活明细((bool, detail) 的结构化形态)。
|
|
357
|
+
|
|
358
|
+
机械探测微信开发者工具 CLI / miniprogram-ci 是否在 PATH(<5ms,零阻塞、
|
|
359
|
+
零子进程);DEGRADED 时必须走 ``MiniProgramProbe.run_static_degraded``,
|
|
360
|
+
禁止伪装成动态审计结果。
|
|
361
|
+
"""
|
|
362
|
+
tools = ("miniprogram-ci", "cli", "wechat-cli")
|
|
363
|
+
found = {tool: shutil.which(tool) for tool in tools}
|
|
364
|
+
hit = next((path for path in found.values() if path), None)
|
|
365
|
+
ready = hit is not None
|
|
366
|
+
return {
|
|
367
|
+
"name": "miniprogram_probe",
|
|
368
|
+
"status": "READY" if ready else "DEGRADED",
|
|
369
|
+
"available": ready,
|
|
370
|
+
"detail": hit or "微信开发者工具 CLI / miniprogram-ci 均未安装:动态探针不可用,降级为静态结构分析",
|
|
371
|
+
"checks": [
|
|
372
|
+
{
|
|
373
|
+
"name": tool,
|
|
374
|
+
"ok": path is not None,
|
|
375
|
+
"required": True,
|
|
376
|
+
"detail": path or f"未找到 {tool}",
|
|
377
|
+
}
|
|
378
|
+
for tool, path in found.items()
|
|
379
|
+
],
|
|
380
|
+
"capabilities": ["miniprogram_dynamic_probe"] if ready else [],
|
|
381
|
+
"fallbacks": {} if ready else {
|
|
382
|
+
"audit": "MiniProgramProbe.run_static_degraded(app.json 路由 + WXML + 云函数静态扫描)",
|
|
383
|
+
},
|
|
384
|
+
"warnings": [],
|
|
385
|
+
}
|