bugx-cli 0.1.1__py3-none-any.whl
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.
- bugx_cli/__init__.py +6 -0
- bugx_cli/cli.py +1685 -0
- bugx_cli/commands/__init__.py +1 -0
- bugx_cli/commands/advisory.py +94 -0
- bugx_cli/commands/agent.py +4210 -0
- bugx_cli/commands/audit.py +632 -0
- bugx_cli/commands/autonomous.py +260 -0
- bugx_cli/commands/cloud.py +1371 -0
- bugx_cli/commands/daemon.py +50 -0
- bugx_cli/commands/doctor.py +1590 -0
- bugx_cli/commands/goal.py +107 -0
- bugx_cli/commands/interaction.py +248 -0
- bugx_cli/commands/knowledge.py +619 -0
- bugx_cli/commands/lifecycle.py +2763 -0
- bugx_cli/commands/patch.py +1014 -0
- bugx_cli/commands/plugin.py +2749 -0
- bugx_cli/commands/plugin_claude.py +1446 -0
- bugx_cli/commands/plugin_cline.py +269 -0
- bugx_cli/commands/plugin_codex.py +74 -0
- bugx_cli/commands/plugin_funide.py +729 -0
- bugx_cli/commands/plugin_qoder.py +216 -0
- bugx_cli/commands/plugin_zcode.py +710 -0
- bugx_cli/commands/project.py +670 -0
- bugx_cli/commands/report.py +256 -0
- bugx_cli/commands/skill.py +251 -0
- bugx_cli/commands/stats.py +133 -0
- bugx_cli/commands/system.py +2567 -0
- bugx_cli/common.py +906 -0
- bugx_cli/host_adapters.py +1892 -0
- bugx_cli/hosts/__init__.py +80 -0
- bugx_cli/hosts/base.py +99 -0
- bugx_cli/hosts/registry.py +573 -0
- bugx_cli/hosts/template_engine.py +188 -0
- bugx_cli/infra/__init__.py +209 -0
- bugx_cli/infra/ai_advisor.py +851 -0
- bugx_cli/infra/engine_installer.py +1945 -0
- bugx_cli/infra/host_sync.py +548 -0
- bugx_cli/infra/mcp_advisor.py +826 -0
- bugx_cli/infra/security.py +339 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/bugx-mcp-manifest.json +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/CATALOG.json +141 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/README.md +254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android-interaction.json +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/android.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/desktop-macos.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios-interaction.json +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/ios.json +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/adapters/memory-macos.json +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/__init__.py +146 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_artifacts.py +766 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_eval.py +1155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_execution.py +718 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_orchestrator.py +1351 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_targets.py +877 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/agent_workspace.py +770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/agent/feature_baseline.py +150 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/README.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE-3RD-PARTY.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/LICENSE.txt +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/UPSTREAM.md +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/axe-core/axe.min.js +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-1024.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-512.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar-tight.svg +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-avatar.svg +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-cn.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-en.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/bugx-hero-zh.svg +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/codex.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/dsh.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/project-layout.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/assets/zcode.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/README.md +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/manifest.json +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/manifest.json +123 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/memory-testing.md +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/manifest.json +155 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/android.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/manifest.json +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/platform-testing.md +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/manifest.json +191 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/graphql.md +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/h5.md +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/oauth.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/upload.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/modules/websocket.md +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/INTERFACE.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/README.md +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/__init__.py +109 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph.py +1096 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/attack_graph_store.py +1868 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/audit_campaign.py +1232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/behavior_graph.py +465 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/ghsa_advisories.py +174 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/models.py +93 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/mutator.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/patcher.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/scout.py +278 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/synthesizer.py +207 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/autonomous_cve/verifier.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx.md +1299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/bugx_paths.py +1881 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cli-help.txt +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/INTERFACE.md +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/__init__.py +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/auto_sync.py +398 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_client.py +1218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_onboard.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/cloud_schema.py +648 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/consent.py +81 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/device_identity.py +307 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/endpoint_router.py +415 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/flywheel_client.py +769 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/network_transport.py +296 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/onboard_wizard.py +493 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sensitive_filter.py +285 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_pull.py +695 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/cloud_sync/sync_push.py +723 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/AGENT_GUIDE.md +359 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/README.md +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-blackbox.md +541 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-opencode.md +469 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-quick.md +44 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-runtime-contract.md +353 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/bugx-worker.md +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/contracts/engine_gap_contracts.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/README.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/__init__.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_ai_review.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_backfill.py +54 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_bootstrap.py +713 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_business.py +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_cli.py +715 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_discovery.py +1429 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_evidence.py +1024 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_forensics.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_gate.py +277 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_intelligence.py +734 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_manifest.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_platform.py +77 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/coverage_validate.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/coverage/module_coverage.py +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/__init__.py +5 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/dev_harness/interaction_preset.py +408 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/engine-integrity.json +2797 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/README.md +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/__init__.py +82 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/concurrency_fuzzer.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/differential_oracle.py +1164 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/fuzz_input.py +1291 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/fuzzing/stateful_fuzzer.py +404 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/README.md +61 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/__init__.py +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/capacity_planner.py +124 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/dependency_lock.py +317 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/goal_governor.py +754 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/guide_budget.py +458 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/lockdown.sh +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/readonly_enforcer.py +154 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/runtime_tool_gate.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/secret_redactor.py +784 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/governance/token_budget.py +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/INTERFACE.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/__init__.py +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/base.py +111 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/claude.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/cline.py +298 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/codex.py +300 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/dsh.py +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/opencode.py +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/pi.py +94 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_acp/zcode.py +99 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/INTERFACE.md +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/__init__.py +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/adapters.py +412 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/autonomous_runner.py +1152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/cline.py +448 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/common.py +103 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/free_models.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_bootstrap.py +389 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_evaluators.py +761 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_probe.py +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_provider_arbitrator.py +831 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_registry.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/host_usage.py +127 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_process_tracker.py +509 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/mcp_registry_gate.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/pi.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/host_runtime/provider_facts.py +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/INTERFACE.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/README.md +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/__init__.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_base_usage.py +152 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_codex_usage.py +297 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_dsh_usage.py +184 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_mcp_toml.py +365 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/_zcode_usage.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/base.py +479 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/claude.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/cline.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/codex.py +1006 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/dsh.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/opencode.py +358 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/pi.py +308 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/hosts/zcode.py +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/i18n.py +252 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/README.md +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/__init__.py +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/build_info.py +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/client_metadata.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/json_utils.py +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/python_runtime.py +540 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/infra/safe_xml.py +221 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_bugx.py +118 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/INTERFACE.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/README.md +106 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/__init__.py +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/candidate_revalidation.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/common.py +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_confirm_phase.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/finding_settlement.py +1432 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_adjudication.py +666 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/findings_snapshot.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/judge_phase.py +848 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lesson_context.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/lifecycle_reporter.py +627 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/orchestrator_controls.py +686 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_commit.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_coverage_sync.py +598 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_dry_run.py +817 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_observability.py +367 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_phase.py +1223 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_receipt.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/post_round_lifecycle.py +786 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_phase.py +1029 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_recon_scout.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/pre_state_builder.py +1133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/report_sharing.py +414 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/round_orchestrator.py +1116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/session_runtime.py +1670 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_gates.py +1050 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_interaction.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/startup_version_gate.py +879 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_bridge.py +1253 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_coverage.py +423 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/supervisor_degraded.py +1211 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_barriers.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_orchestrator.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/launch_phases/worker_prior.py +749 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/INTERFACE.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/README.md +160 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/__init__.py +67 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/_facade.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/archive_ops.py +630 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/auto_materialization.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/bug-log.md +22 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/cli.py +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/export_ops.py +554 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_confirmation.py +1316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_io.py +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_lifecycle.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/finding_verification.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/incidents.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson-replay-cases.json +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_ledger.py +241 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/lesson_replay.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/life_ledger.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/mistake-book.md +130 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/patterns.py +684 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/receipt_contract.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/schema.py +1192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/sync_ops.py +940 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/tool_experience.py +683 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/ledger/verify_life.py +1597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/lesson-ledger.json +275 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/README.md +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/en-US.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/locales/zh-CN.json +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/INTERFACE.md +75 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/README.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/__init__.py +128 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/base.py +717 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/channel_lifecycle.py +751 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/graph_handlers.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/knowledge_handlers.py +536 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/mining_handlers.py +586 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/resource_prompt_table.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/retrieval_handlers.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/rpc_server.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/supervisor_handlers.py +1461 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/telemetry_handlers.py +227 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_handlers/tool_table.py +1030 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/README.md +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/__init__.py +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/common.py +363 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/environment.py +567 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/mcp_runtime_support/verifier.py +758 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/metadata.txt +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/README.md +157 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/__init__.py +242 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_plan.py +187 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/capability_planner.py +195 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_archetype.py +542 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/domain_router.py +269 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/dynamic_flow_analyzer.py +533 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/impact_pruner.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/intent_adjudicator.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/judge_pipeline.py +1246 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/logic_analysis.py +419 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/prompt_harness.py +1704 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/source_inspector.py +267 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/spec_harvester.py +449 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/target_sandbox_manager.py +573 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/test_capability_verifier.py +1364 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/tools-kb.md +38 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/planning/unit_kind.py +122 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/INTERFACE.md +83 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/README.md +51 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/SPEC.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/__init__.py +76 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/android_probe.py +552 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/base.py +147 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/codebase_memory_probe.py +647 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/desktop_probe.py +342 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/differential_probe.py +434 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/efficiency_probe.py +232 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ios_binary_probe.py +472 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/memory_probe.py +392 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/miniprogram_probe.py +385 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/mobile_probe.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/native_probe.py +302 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/openwiki_probe.py +263 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/pattern_probe.py +453 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/platform_probe.py +424 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/probe_registry.py +1770 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_fixture_corpus.py +340 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_probe.py +1510 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sast_rules.py +1481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/sca_scanner.py +779 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_accessibility.py +149 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_audit.py +513 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_contract.py +273 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_evidence.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_measurements.py +314 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_repair.py +250 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_review.py +133 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_storybook.py +107 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_tokens.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/ui_visual_diff.py +131 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/probes/web_probe.py +714 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/INTERFACE.md +62 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/__init__.py +201 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/arbitrator.py +316 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/constants.py +247 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/detector.py +399 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/extractors.py +836 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/fingerprint.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/storage.py +258 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/project_profiler/strategy.py +301 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/codex_dialog_dispatch.md +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_en.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/command_routing_zh.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/l0_router.md +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/anti_patterns.md +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/concurrency_rules.md +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/memory_leak_rules.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/rules/prompt_injection_defense.md +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_explore.md +31 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_gate.md +43 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_mutate.md +42 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/prompts/stages/stage_repair.md +85 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/README.md +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/__init__.py +169 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/fix_watchlist.py +391 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_dynamic.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_repair_loop.py +462 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/l7_selfcheck.py +862 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/minimize_repro.py +466 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/patch_synthesizer.py +617 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/regression_pack.py +379 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_fixer.py +910 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_loop.py +311 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_repair.py +348 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_rounds.py +212 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/rsi_scope.py +281 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/self_heal.py +604 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_generator.py +1108 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_quality_auditor.py +410 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/repair/test_strategy.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/INTERFACE.md +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/README.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/SPEC.md +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/__init__.py +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/attestation.py +228 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/authority.py +255 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/finding_report.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/formal_report_builder.py +924 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/html_renderers.py +696 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/models.py +759 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/pdf_exporter.py +231 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/projects_assets.py +730 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_client.py +743 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_data_builder.py +388 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/report_share.py +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/sast_bridge.py +116 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/server.py +832 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/visual_report_builder.py +796 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web-conformance.md +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/web_conformance.py +428 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/report_engine/workbench_assets.py +484 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/INTERFACE.md +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/README.md +161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/code_analyzer.py +1720 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/codebase_memory_bridge.py +337 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/context_assembler.py +240 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/corpus_fetch.py +369 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/graph_ego.py +597 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_auto.py +662 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sources.py +168 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/knowledge_sync.py +1003 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/memory_store.py +480 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/query_planner.py +1020 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/rrf_engine.py +137 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_extractor.py +1209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_normalizer.py +373 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/slice_spec.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/symbol_index.py +1151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/universal_code_matcher.py +622 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_bridge.py +476 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/retrieval/xerj_supervisor.py +362 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/README.md +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/PROVENANCE.json +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/crypto.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/network.yaml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/resilience.yaml +47 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/ios/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/LICENSE +173 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/PROVENANCE.json +270 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/PROVENANCE.json +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/network.yaml +37 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/platform.yaml +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/miniprogram/storage.yaml +48 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/LICENSE +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/auth.yaml +59 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/logging.yaml +23 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/network.yaml +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/storage.yaml +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/rules/mobsfscan-swift/webview.yaml +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/README.md +198 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/__init__.py +3 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/bugx_logging.py +1464 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/daemon_runner.py +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/fixture_solidify.py +444 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/global_telemetry.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/incident_eval.py +148 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interaction_store.py +435 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/interactive_menu.py +95 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/log_analytics.py +922 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/mining_quality_framework.py +1387 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/model_runner.py +732 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/platform_adapter.py +579 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/prep_validate.py +478 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_graph.py +827 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_init.py +481 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_profile.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/project_settings.py +964 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/provider_window.py +97 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/resume_ticket.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/scenario_eval.py +856 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/seed_drill.py +549 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/self_audit.py +550 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/session_profile.py +205 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/setup_ui_env.py +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/startup_environment.py +859 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/sync_store.py +1421 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/runtime/tool_install_targets.py +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/README.md +35 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/agent-graph.schema.json +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/attack-graph.schema.json +88 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/evidence-bundle.schema.json +33 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/skill-pack.schema.json +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/schemas/worker-checkpoint.schema.json +119 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/secure_atomic.py +289 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/README.md +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/c.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/cpp.txt +32 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/css.txt +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/go.txt +46 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/java.txt +30 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/javascript.txt +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/kotlin.txt +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/python.txt +71 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/rust.txt +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/swift.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/seed_corpus/typescript.txt +29 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/README.md +53 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/__init__.py +189 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_docs_mcp_server.py +418 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/bugx_mcp_server.py +1161 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_runtime.py +968 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mcp_session_proof.py +605 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/mobile_ui_inspector.py +405 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_pack.py +1214 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/skill_synthesizer.py +1153 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/skills/tools_kb.py +313 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/INTERFACE.md +121 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/README.md +209 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/SPEC.md +25 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/__init__.py +175 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/audit_supervisor.py +1015 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/budget_governor.py +1254 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_handler.py +368 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_pipeline.py +1564 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/checkpoint_sync.py +653 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_events.py +74 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/claim_sync.py +590 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/cli.py +812 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/context_sync.py +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/coverage_sync.py +115 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_commit.py +470 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_sync.py +688 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finding_workflow.py +676 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_policy.py +224 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/finish_sync.py +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/graph_sync.py +669 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lease_manager.py +788 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/lifecycle_blocks.py +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/next_round_sync.py +126 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/observability.py +140 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/recovery_sync.py +165 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/rejection_remedies.py +355 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/round_governor.py +306 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/serial_authorization.py +544 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/start_sync.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/state_store.py +249 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_host.py +511 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/supervisor_models.py +1143 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/systemic_failure.py +104 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/task_scheduler.py +1640 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_checkpoint.py +230 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_execution.py +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_handoff.py +192 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_lifecycle.py +396 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_runtime.py +1005 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor/worker_sync.py +89 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/README.md +36 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/__init__.py +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/exceptions.py +52 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/graph_models.py +357 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/path_containment.py +151 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/target_fingerprint.py +310 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/supervisor_types/worker_claim.py +411 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/INTERFACE.md +50 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/README.md +57 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/SPEC.md +26 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/__init__.py +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/__init__.py +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/base.py +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/bugx.py +102 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/claude.py +222 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/cline.py +407 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/codex.py +260 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/dsh.py +177 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/opencode.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/pi.py +272 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/registry.py +100 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/adapters/zcode.py +312 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/api_routes_post.py +668 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/dispatcher.py +1376 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/docs_session_service.py +473 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/handler.py +674 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/ide_cloud_service.py +526 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/mcp_inspector.py +1747 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/00-base.css +1060 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/01-monitoring.css +802 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/02-header-actions.css +321 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/03-trigger-popover.css +697 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/04-composer.css +628 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/05-skills-center.css +878 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/06-mcp-center.css +623 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/07-skill-detail.css +265 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/08-files-management.css +167 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/09-files-center.css +386 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/10-icons.css +105 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/11-project-options.css +185 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/12-profile-tab.css +383 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/design-tokens.css +113 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/favicon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/icon-192.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/index.html +55 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/manifest.webmanifest +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/project-settings.js +9602 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/static/sw.js +8 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/core/webui/workspace_service.py +218 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/agents/bugx.md +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/dsh-patch.yml +18 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/index.js +219 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/mcp/package.json +28 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/skills/bugx-dsh/SKILL.md +229 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/client.js +87 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/cordis.patch.yml +4 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/index.js +7 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/dsh/ui/package.json +27 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/mcp-lock.json +3075 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/opencode.json +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/README.md +12 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/index.ts +299 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/extensions/bugx/manifest.json +11 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/pi/skills/bugx/SKILL.md +69 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/connector-meta.json +19 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/icon.png +0 -0
- bugx_cli-0.1.1.data/data/share/bugx-agent/workbuddy/skills/bugx/SKILL.md +70 -0
- bugx_cli-0.1.1.dist-info/METADATA +335 -0
- bugx_cli-0.1.1.dist-info/RECORD +762 -0
- bugx_cli-0.1.1.dist-info/WHEEL +5 -0
- bugx_cli-0.1.1.dist-info/entry_points.txt +2 -0
- bugx_cli-0.1.1.dist-info/licenses/LICENSE +55 -0
- bugx_cli-0.1.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1291 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""fuzz_input.py — 变异模糊矩阵工具(并发批量轰输入,筛出异常样本)。
|
|
3
|
+
|
|
4
|
+
用途:取一份合法输入,逐字段/逐字节变异成批量变体,**并发**喂给目标,
|
|
5
|
+
收集每次 exit code + 输出,筛出异常样本(崩溃/挂起/非零退出)供进一步
|
|
6
|
+
最小化与根因分析。与 minimize_repro.py 配套:fuzz 负责"广撒网找异常",
|
|
7
|
+
minimize 负责"把异常缩到最小复现"。
|
|
8
|
+
|
|
9
|
+
用法:
|
|
10
|
+
python3 fuzz_input.py --input <合法输入文件> \
|
|
11
|
+
--cmd '<目标命令,{input} 占位>' \
|
|
12
|
+
--out <输出目录> [--count N] [--jobs P] [--timeout S] [--seed S]
|
|
13
|
+
|
|
14
|
+
# 从多语言种子语料选起点变异(--lang python/java/rust/swift/kotlin/
|
|
15
|
+
# c/cpp/typescript/javascript/css),比随机起点命中率更高:
|
|
16
|
+
python3 fuzz_input.py --lang python \
|
|
17
|
+
--cmd '<目标命令,{input} 占位>' --out /tmp/fuzz-out --count 500 --jobs 8
|
|
18
|
+
|
|
19
|
+
示例:
|
|
20
|
+
# 对 json 解析器变异 500 个样本,8 并发,异常存到 /tmp/fuzz-out
|
|
21
|
+
python3 fuzz_input.py \
|
|
22
|
+
--input valid.json --cmd 'python3 -m json.tool {input}' \
|
|
23
|
+
--out /tmp/fuzz-out --count 500 --jobs 8
|
|
24
|
+
|
|
25
|
+
变异策略(each sample applies one random strategy):
|
|
26
|
+
- truncate 截断文件尾部(模拟不完整数据)
|
|
27
|
+
- flip_byte 随机翻转一个字节
|
|
28
|
+
- insert_garbage 在随机位置插入一段垃圾字节
|
|
29
|
+
- mutate_numeric 把数字字段放大/改负/改零(正则)
|
|
30
|
+
- mutate_string 把字符串字段换成超长/CJK/emoji/控制字符
|
|
31
|
+
- duplicate 重复文件中间一段(制造超大/重复结构)
|
|
32
|
+
|
|
33
|
+
种子语料:seed_corpus/ 目录存放 10 种常用语言的典型语法片段与易错输入,
|
|
34
|
+
`--lang` 从对应文件随机选一行作为变异起点(--input 与 --lang 二选一)。
|
|
35
|
+
|
|
36
|
+
筛选标准:目标进程 exit code 非 0(崩溃/报错)或超时(挂起)→ 记为异常样本,
|
|
37
|
+
原始输入与 stderr 一并保存到输出目录。
|
|
38
|
+
|
|
39
|
+
安全:命令默认按 argv 执行;使用 shell 运算符时必须显式加
|
|
40
|
+
`--allow-shell`,且仅应对完全可信的命令模板使用。
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
from __future__ import annotations
|
|
44
|
+
# --- 引擎导入根(直接执行脚本时自举 core.* 命名空间)---
|
|
45
|
+
import sys as _sys
|
|
46
|
+
from pathlib import Path as _Path
|
|
47
|
+
|
|
48
|
+
for _p in _Path(__file__).resolve().parents:
|
|
49
|
+
if (_p / "core" / "bugx.md").is_file():
|
|
50
|
+
if str(_p) not in _sys.path:
|
|
51
|
+
_sys.path.insert(0, str(_p))
|
|
52
|
+
break
|
|
53
|
+
del _p
|
|
54
|
+
|
|
55
|
+
import argparse
|
|
56
|
+
import hashlib
|
|
57
|
+
import json
|
|
58
|
+
import os
|
|
59
|
+
import random
|
|
60
|
+
import re
|
|
61
|
+
import shlex
|
|
62
|
+
import subprocess
|
|
63
|
+
import sys
|
|
64
|
+
import tempfile
|
|
65
|
+
import threading
|
|
66
|
+
import time
|
|
67
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
68
|
+
from pathlib import Path
|
|
69
|
+
from typing import Any, Mapping
|
|
70
|
+
|
|
71
|
+
_CORE_DIR = Path(__file__).resolve().parents[1]
|
|
72
|
+
_REPO_ROOT = _CORE_DIR.parent
|
|
73
|
+
for _p in (str(_REPO_ROOT), str(_CORE_DIR)):
|
|
74
|
+
if _p not in sys.path:
|
|
75
|
+
sys.path.insert(0, _p)
|
|
76
|
+
|
|
77
|
+
import core.bugx_paths as bugx_paths
|
|
78
|
+
|
|
79
|
+
from core.supervisor.worker_execution import run_bounded
|
|
80
|
+
|
|
81
|
+
SEED_CORPUS = Path(__file__).resolve().parents[1] / "seed_corpus"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _read_confined_input(root: str | Path, raw_path: str | Path) -> bytes:
|
|
85
|
+
"""读取项目内受控文件作为 fuzz 起点。
|
|
86
|
+
|
|
87
|
+
``input_path`` 来自 Worker,而被审计项目的一切内容都不可信;必须做
|
|
88
|
+
``resolve() + relative_to(root)`` 与逐级符号链接检查,否则它就是一个
|
|
89
|
+
任意文件读取入口(读到的内容会被写进临时输入文件并喂给目标命令)。
|
|
90
|
+
"""
|
|
91
|
+
return bugx_paths.read_confined_bytes(
|
|
92
|
+
Path(root), raw_path, max_bytes=MAX_INPUT_BYTES, error_cls=ValueError,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
LANGS = [
|
|
96
|
+
"python", "go", "java", "rust", "swift", "kotlin",
|
|
97
|
+
"c", "cpp", "typescript", "javascript", "css",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
|
102
|
+
p = argparse.ArgumentParser(description=__doc__)
|
|
103
|
+
source = p.add_mutually_exclusive_group()
|
|
104
|
+
source.add_argument("--input", help="合法输入文件路径(与 --lang 二选一)")
|
|
105
|
+
source.add_argument("--lang", choices=LANGS,
|
|
106
|
+
help="从种子语料选起点变异(%s)" % ", ".join(LANGS))
|
|
107
|
+
p.add_argument("--cmd", required=True,
|
|
108
|
+
help="目标命令,用 {input} 占位表示输入文件路径")
|
|
109
|
+
p.add_argument("--out", required=True, help="异常样本输出目录")
|
|
110
|
+
p.add_argument("--root", type=Path, default=Path.cwd(),
|
|
111
|
+
help="项目根目录;--target-gaps 中引用的文件必须落在其内(默认当前目录)")
|
|
112
|
+
p.add_argument("--target-gaps", type=Path, default=None,
|
|
113
|
+
help="coverage_intelligence gaps JSON:把未覆盖/欠覆盖文件"
|
|
114
|
+
"自身作为种子优先变异(定向模糊,无插桩环境可用)")
|
|
115
|
+
p.add_argument("--count", type=int, default=100, help="变异样本数(默认 100)")
|
|
116
|
+
p.add_argument("--jobs", type=int, default=4, help="并发数(默认 4)")
|
|
117
|
+
p.add_argument("--timeout", type=float, default=10, help="单次执行超时秒(默认 10)")
|
|
118
|
+
p.add_argument("--seed", type=int, default=None, help="随机种子(可复现)")
|
|
119
|
+
p.add_argument("--allow-shell", action="store_true",
|
|
120
|
+
help="允许通过 shell 执行命令(仅限完全可信的命令模板)")
|
|
121
|
+
p.add_argument("--evolve", type=Path, default=None,
|
|
122
|
+
help="行为引导进化目录:跨轮维护行为哈希库,把触发新行为的"
|
|
123
|
+
"样本回填为下轮种子(dir/behaviors.json + dir/seeds/)")
|
|
124
|
+
p.add_argument("--accepted-exits", default="0",
|
|
125
|
+
help="预期退出码逗号列表(默认 0;如 CLI 参数拒绝可用 0,2)")
|
|
126
|
+
p.add_argument("--feedback-json", action="store_true",
|
|
127
|
+
help="解析 stdout 最后一条 JSON feedback envelope")
|
|
128
|
+
p.add_argument("--latency-baseline", type=float, default=None,
|
|
129
|
+
help="延迟基线秒;只有显式设置后才启用慢响应标记")
|
|
130
|
+
p.add_argument("--latency-factor", type=float, default=3.0,
|
|
131
|
+
help="慢响应阈值倍数(默认 3)")
|
|
132
|
+
p.add_argument("--watch-status", default="500,502,503",
|
|
133
|
+
help="feedback envelope 中需关注的 HTTP 状态码,逗号列表")
|
|
134
|
+
return p.parse_args(argv)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
MAX_GAP_SEED_FILES = 50
|
|
138
|
+
MAX_GAP_SEED_BYTES = 256 * 1024
|
|
139
|
+
MAX_INPUT_BYTES = 16 * 1024 * 1024
|
|
140
|
+
MAX_OUTPUT_BYTES = 64 * 1024
|
|
141
|
+
MAX_EVOLUTION_SEED_BYTES = MAX_INPUT_BYTES
|
|
142
|
+
_SHELL_PUNCTUATION = ";&|<>`$()"
|
|
143
|
+
_SHELL_OPERATORS = frozenset({
|
|
144
|
+
";", "&", "&&", "|", "||", "<", ">", ">>", "<<", "<&", ">&",
|
|
145
|
+
"`", "$(", "(", ")",
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class _PayloadLimitError(ValueError):
|
|
150
|
+
"""单个 fuzz 样本超过执行边界。"""
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def split_argv(
|
|
154
|
+
template: str,
|
|
155
|
+
*,
|
|
156
|
+
error_type: type[Exception] = ValueError,
|
|
157
|
+
parse_error_prefix: str = "命令无法解析",
|
|
158
|
+
empty_message: str = "命令不能为空",
|
|
159
|
+
operator_message: str = "命令包含 shell 运算符;如确需使用,请显式传入 --allow-shell",
|
|
160
|
+
) -> list[str]:
|
|
161
|
+
"""解析 argv 模板,并拒绝未授权的 shell 语法。
|
|
162
|
+
|
|
163
|
+
这是全仓命令拆分的唯一实现(QUA-03)。调用方如需领域异常,只能通过
|
|
164
|
+
``error_type`` 和消息参数适配,不得复制 lexer 与运算符校验。
|
|
165
|
+
"""
|
|
166
|
+
lexer = shlex.shlex(template, posix=True, punctuation_chars=_SHELL_PUNCTUATION)
|
|
167
|
+
lexer.whitespace_split = True
|
|
168
|
+
lexer.commenters = ""
|
|
169
|
+
try:
|
|
170
|
+
argv = list(lexer)
|
|
171
|
+
except ValueError as exc:
|
|
172
|
+
raise error_type(f"{parse_error_prefix}: {exc}") from exc
|
|
173
|
+
if not argv:
|
|
174
|
+
raise error_type(empty_message)
|
|
175
|
+
if any(token in _SHELL_OPERATORS for token in argv):
|
|
176
|
+
raise error_type(operator_message)
|
|
177
|
+
return argv
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def shell_argv(rendered: str) -> list[str]:
|
|
181
|
+
"""把已渲染的命令串交给 shell;Windows 用 COMSPEC,POSIX 用 /bin/sh。"""
|
|
182
|
+
if os.name == "nt": # pragma: no cover - 项目宿主目前为 POSIX
|
|
183
|
+
return [os.environ.get("COMSPEC", "cmd.exe"), "/c", rendered]
|
|
184
|
+
return ["/bin/sh", "-c", rendered]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
# 兼容本模块既有的私有调用点;实现只此一份。
|
|
188
|
+
_split_argv = split_argv
|
|
189
|
+
_shell_argv = shell_argv
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def _as_bytes(value: object) -> bytes:
|
|
193
|
+
if isinstance(value, bytes):
|
|
194
|
+
return value
|
|
195
|
+
return str(value or "").encode("utf-8", errors="replace")
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def load_gap_seeds(gaps_path: Path | None, *, root: Path) -> list[bytes]:
|
|
199
|
+
"""从 coverage gaps JSON 提取「欠覆盖文件本身」作为定向种子。
|
|
200
|
+
|
|
201
|
+
变异对象 = 覆盖缺口文件内容:无插桩环境里最直接的定向模糊形态——
|
|
202
|
+
变异产物落在同材质输入域,比通用语料更可能踩进未覆盖分支。
|
|
203
|
+
|
|
204
|
+
``unit["path"]`` 来自被测项目的 coverage 产物(不可信)。提供 ``root``
|
|
205
|
+
时该路径必须落在项目内且不含符号链接,否则跳过——否则 gaps JSON 可以
|
|
206
|
+
把任意系统文件变成 fuzz 种子。
|
|
207
|
+
"""
|
|
208
|
+
if gaps_path is None:
|
|
209
|
+
return []
|
|
210
|
+
try:
|
|
211
|
+
data = json.loads(gaps_path.read_text(encoding="utf-8"))
|
|
212
|
+
except (OSError, json.JSONDecodeError) as exc:
|
|
213
|
+
print(f"[fuzz_input] ⚠ gaps 文件无法读取(忽略定向): {exc}")
|
|
214
|
+
return []
|
|
215
|
+
units = data.get("units") if isinstance(data, dict) else data
|
|
216
|
+
if not isinstance(units, list):
|
|
217
|
+
print("[fuzz_input] ⚠ gaps JSON 无 units 数组(忽略定向)")
|
|
218
|
+
return []
|
|
219
|
+
seeds: list[bytes] = []
|
|
220
|
+
for unit in units:
|
|
221
|
+
if len(seeds) >= MAX_GAP_SEED_FILES:
|
|
222
|
+
break
|
|
223
|
+
if not isinstance(unit, dict):
|
|
224
|
+
continue
|
|
225
|
+
if unit.get("covered") is True:
|
|
226
|
+
continue
|
|
227
|
+
path = unit.get("path")
|
|
228
|
+
if not isinstance(path, str) or not path:
|
|
229
|
+
continue
|
|
230
|
+
try:
|
|
231
|
+
content = bugx_paths.read_confined_bytes(
|
|
232
|
+
Path(root), path, max_bytes=MAX_GAP_SEED_BYTES, error_cls=ValueError,
|
|
233
|
+
)
|
|
234
|
+
except (ValueError, OSError):
|
|
235
|
+
continue
|
|
236
|
+
if content:
|
|
237
|
+
seeds.append(content)
|
|
238
|
+
return seeds
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
_RESERVED_WORDS = {
|
|
242
|
+
b"def", b"class", b"return", b"import", b"from", b"with", b"as",
|
|
243
|
+
b"if", b"elif", b"else", b"while", b"for", b"in", b"try", b"except",
|
|
244
|
+
b"finally", b"raise", b"yield", b"async", b"await", b"pass", b"true",
|
|
245
|
+
b"false", b"none", b"self", b"cls",
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def extract_gap_tokens(gaps_path: Path | None, *, root: Path) -> list[bytes]:
|
|
250
|
+
"""从 coverage gaps JSON 提取未覆盖符号、函数名及目标标识符作为定向变异词库。
|
|
251
|
+
|
|
252
|
+
``unit["path"]`` 属于被测项目产物(不可信);提供 ``root`` 时只读取项目内
|
|
253
|
+
的普通文件,且不跟随符号链接。
|
|
254
|
+
"""
|
|
255
|
+
if gaps_path is None:
|
|
256
|
+
return []
|
|
257
|
+
try:
|
|
258
|
+
data = json.loads(gaps_path.read_text(encoding="utf-8"))
|
|
259
|
+
except (OSError, json.JSONDecodeError):
|
|
260
|
+
return []
|
|
261
|
+
units = data.get("units") if isinstance(data, dict) else data
|
|
262
|
+
if not isinstance(units, list):
|
|
263
|
+
return []
|
|
264
|
+
tokens: set[bytes] = set()
|
|
265
|
+
ident_pattern = re.compile(rb"[a-zA-Z_][a-zA-Z0-9_]{2,32}")
|
|
266
|
+
for unit in units:
|
|
267
|
+
if not isinstance(unit, dict) or unit.get("covered") is True:
|
|
268
|
+
continue
|
|
269
|
+
# 1. 显式提取 symbols / functions / missing / uncovered_symbols 字段
|
|
270
|
+
for field in ("symbols", "functions", "uncovered_symbols", "missing", "uncovered_branches"):
|
|
271
|
+
vals = unit.get(field)
|
|
272
|
+
if isinstance(vals, list):
|
|
273
|
+
for v in vals:
|
|
274
|
+
if isinstance(v, str) and v.strip():
|
|
275
|
+
tokens.add(v.strip().encode("utf-8"))
|
|
276
|
+
# 2. 提取文件名标识符与文件内未覆盖符号
|
|
277
|
+
path = unit.get("path")
|
|
278
|
+
if isinstance(path, str) and path:
|
|
279
|
+
stem = Path(path).stem
|
|
280
|
+
if len(stem) >= 3:
|
|
281
|
+
tokens.add(stem.encode("utf-8"))
|
|
282
|
+
try:
|
|
283
|
+
content = bugx_paths.read_confined_bytes(
|
|
284
|
+
Path(root), path, max_bytes=MAX_GAP_SEED_BYTES,
|
|
285
|
+
error_cls=ValueError,
|
|
286
|
+
)
|
|
287
|
+
except (ValueError, OSError):
|
|
288
|
+
content = b""
|
|
289
|
+
if content:
|
|
290
|
+
for m in ident_pattern.findall(content):
|
|
291
|
+
lower_m = m.lower()
|
|
292
|
+
if lower_m not in _RESERVED_WORDS:
|
|
293
|
+
tokens.add(m)
|
|
294
|
+
if len(tokens) >= 120:
|
|
295
|
+
break
|
|
296
|
+
if len(tokens) >= 120:
|
|
297
|
+
break
|
|
298
|
+
return sorted(tokens)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def load_seed(lang: str) -> list[bytes]:
|
|
302
|
+
"""从语言种子语料加载全部种子(每行一个,空行跳过)。"""
|
|
303
|
+
f = SEED_CORPUS / f"{lang}.txt"
|
|
304
|
+
if not f.is_file():
|
|
305
|
+
print(f"[fuzz_input] 种子语料缺失: {f}")
|
|
306
|
+
return []
|
|
307
|
+
return [
|
|
308
|
+
ln.encode("utf-8")
|
|
309
|
+
for ln in f.read_text(encoding="utf-8").splitlines()
|
|
310
|
+
if ln.strip() and not ln.strip().startswith("#")
|
|
311
|
+
]
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
# ---------- 变异策略 ----------
|
|
315
|
+
|
|
316
|
+
def _mutate_truncate(data: bytes, rng: random.Random) -> bytes:
|
|
317
|
+
if len(data) <= 1:
|
|
318
|
+
return b""
|
|
319
|
+
cut = rng.randint(1, len(data) - 1)
|
|
320
|
+
return data[:cut]
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
def _mutate_flip_byte(data: bytes, rng: random.Random) -> bytes:
|
|
324
|
+
if not data:
|
|
325
|
+
return data
|
|
326
|
+
pos = rng.randrange(len(data))
|
|
327
|
+
val = data[pos] ^ (1 << rng.randrange(8))
|
|
328
|
+
return data[:pos] + bytes([val]) + data[pos + 1:]
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def _mutate_insert_garbage(data: bytes, rng: random.Random) -> bytes:
|
|
332
|
+
garbage = bytes(
|
|
333
|
+
rng.choice(b"\x00\xff\x7f\n\r\x01\x1b") for _ in range(rng.randint(1, 16))
|
|
334
|
+
)
|
|
335
|
+
pos = rng.randrange(len(data) + 1)
|
|
336
|
+
return data[:pos] + garbage + data[pos:]
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
_NUM_RE = re.compile(rb"-?\d+\.?\d*")
|
|
340
|
+
|
|
341
|
+
def _mutate_numeric(data: bytes, rng: random.Random) -> bytes:
|
|
342
|
+
choices = [b"0", b"-1", b"999999999999999999999", b"1e999", b"-0.0"]
|
|
343
|
+
def repl(m: re.Match) -> bytes:
|
|
344
|
+
return rng.choice(choices)
|
|
345
|
+
mutated, matches = _NUM_RE.subn(repl, data, count=rng.randint(1, 3))
|
|
346
|
+
if matches:
|
|
347
|
+
return mutated
|
|
348
|
+
insertion = rng.choice(choices)
|
|
349
|
+
position = rng.randrange(len(data) + 1)
|
|
350
|
+
return data[:position] + insertion + data[position:]
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
_STR_FILL = [b"a" * 1000, "你好世界".encode(), "🎉🎉🎉".encode(),
|
|
354
|
+
b"\x00\x01\x02", b"%s%s%s%s"]
|
|
355
|
+
|
|
356
|
+
_STRING_RE = re.compile(
|
|
357
|
+
rb'(?P<prefix>[bBrRuUfF]{0,3})(?P<quote>"""|\'\'\'|"|\')'
|
|
358
|
+
rb'(?P<body>(?:\\.|[^\\])*?)(?P=quote)'
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
def _mutate_string(data: bytes, rng: random.Random) -> bytes:
|
|
362
|
+
def repl(match: re.Match) -> bytes:
|
|
363
|
+
body = match.group("body")
|
|
364
|
+
candidates = [fill for fill in _STR_FILL if fill != body]
|
|
365
|
+
replacement = rng.choice(candidates) if candidates else body + b"x"
|
|
366
|
+
return b"".join((
|
|
367
|
+
match.group("prefix"), match.group("quote"), replacement,
|
|
368
|
+
match.group("quote"),
|
|
369
|
+
))
|
|
370
|
+
|
|
371
|
+
mutated, matches = _STRING_RE.subn(repl, data, count=rng.randint(1, 2))
|
|
372
|
+
if matches:
|
|
373
|
+
return mutated
|
|
374
|
+
marker = rng.choice(_STR_FILL)
|
|
375
|
+
position = rng.randrange(len(data) + 1)
|
|
376
|
+
return data[:position] + b'"' + marker + b'"' + data[position:]
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _mutate_duplicate(data: bytes, rng: random.Random) -> bytes:
|
|
380
|
+
if not data:
|
|
381
|
+
return data
|
|
382
|
+
mid = len(data) // 2
|
|
383
|
+
chunk = data[mid:mid + rng.randint(1, max(1, len(data) // 4))]
|
|
384
|
+
return data + chunk
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
# ---------- 语法感知与语义深层变异(Grammar-Aware Structural Mutators) ----------
|
|
389
|
+
|
|
390
|
+
_SECURITY_PAYLOADS = [
|
|
391
|
+
b"../../../etc/passwd",
|
|
392
|
+
b"'; SELECT pg_sleep(1); --",
|
|
393
|
+
b"${IFS}cat${IFS}/etc/passwd",
|
|
394
|
+
b"\x00\xff\xfe\xfd",
|
|
395
|
+
b"A" * 4096,
|
|
396
|
+
b"NaN",
|
|
397
|
+
b"Infinity",
|
|
398
|
+
b"-Infinity",
|
|
399
|
+
]
|
|
400
|
+
|
|
401
|
+
|
|
402
|
+
def _mutate_boundary_injection(data: bytes, rng: random.Random) -> bytes:
|
|
403
|
+
"""在输入任意位置注入经典安全与数值边界载荷。"""
|
|
404
|
+
payload = rng.choice(_SECURITY_PAYLOADS)
|
|
405
|
+
pos = rng.randrange(len(data) + 1)
|
|
406
|
+
return data[:pos] + payload + data[pos:]
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
def _mutate_json_structural(data: bytes, rng: random.Random) -> bytes:
|
|
410
|
+
"""语法树保持型 JSON 结构化突变:穿透语法解析层,直击深层业务逻辑崩溃。"""
|
|
411
|
+
try:
|
|
412
|
+
raw_str = data.decode("utf-8")
|
|
413
|
+
parsed = json.loads(raw_str)
|
|
414
|
+
except Exception:
|
|
415
|
+
return _mutate_flip_byte(data, rng)
|
|
416
|
+
|
|
417
|
+
def _walk_and_mutate(obj: Any, depth: int = 0) -> Any:
|
|
418
|
+
if depth > 4:
|
|
419
|
+
return obj
|
|
420
|
+
if isinstance(obj, dict):
|
|
421
|
+
if not obj:
|
|
422
|
+
return {"_fuzz_injected": "payload"}
|
|
423
|
+
keys = list(obj.keys())
|
|
424
|
+
action = rng.choice(["swap_val", "delete_key", "pollute_key", "nest_bomb", "walk"])
|
|
425
|
+
target_key = rng.choice(keys)
|
|
426
|
+
if action == "swap_val":
|
|
427
|
+
obj[target_key] = rng.choice([None, {}, [], 1e308, -1, "\x00\xff", True, 9223372036854775807])
|
|
428
|
+
elif action == "delete_key" and len(obj) > 1:
|
|
429
|
+
del obj[target_key]
|
|
430
|
+
elif action == "pollute_key":
|
|
431
|
+
obj[rng.choice(["__proto__", "constructor", "prototype", "\x00key"])] = {"polluted": True}
|
|
432
|
+
elif action == "nest_bomb":
|
|
433
|
+
bomb: Any = "deep_recursion_overflow"
|
|
434
|
+
for _ in range(25):
|
|
435
|
+
bomb = {"nested": bomb}
|
|
436
|
+
obj[target_key] = bomb
|
|
437
|
+
else:
|
|
438
|
+
obj[target_key] = _walk_and_mutate(obj[target_key], depth + 1)
|
|
439
|
+
return obj
|
|
440
|
+
elif isinstance(obj, list):
|
|
441
|
+
if not obj:
|
|
442
|
+
return ["injected_item"]
|
|
443
|
+
action = rng.choice(["insert_large", "type_swap", "mutate_item"])
|
|
444
|
+
if action == "insert_large":
|
|
445
|
+
obj.extend([rng.randint(-999999, 999999) for _ in range(20)])
|
|
446
|
+
elif action == "type_swap":
|
|
447
|
+
idx = rng.randrange(len(obj))
|
|
448
|
+
obj[idx] = rng.choice([{}, None, "overflow_string", 0, 1e308])
|
|
449
|
+
elif action == "mutate_item":
|
|
450
|
+
idx = rng.randrange(len(obj))
|
|
451
|
+
obj[idx] = _walk_and_mutate(obj[idx], depth + 1)
|
|
452
|
+
return obj
|
|
453
|
+
elif isinstance(obj, str):
|
|
454
|
+
payloads = [
|
|
455
|
+
"../../../../../../etc/passwd",
|
|
456
|
+
"' OR '1'='1",
|
|
457
|
+
"%s%s%s%s%n",
|
|
458
|
+
"\x00\x01\x02",
|
|
459
|
+
"A" * 1500,
|
|
460
|
+
"\u202e\u202d\ufeff",
|
|
461
|
+
]
|
|
462
|
+
return rng.choice(payloads)
|
|
463
|
+
elif isinstance(obj, (int, float)):
|
|
464
|
+
return rng.choice([0, -1, 1e308, -1e308, 9223372036854775807, -9223372036854775808])
|
|
465
|
+
elif isinstance(obj, bool):
|
|
466
|
+
return not obj
|
|
467
|
+
return obj
|
|
468
|
+
|
|
469
|
+
import copy
|
|
470
|
+
mutated_obj = _walk_and_mutate(copy.deepcopy(parsed))
|
|
471
|
+
try:
|
|
472
|
+
return json.dumps(mutated_obj, ensure_ascii=False).encode("utf-8")
|
|
473
|
+
except Exception:
|
|
474
|
+
return data
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def _mutate_gap_guided(data: bytes, rng: random.Random, tokens: list[bytes]) -> bytes:
|
|
478
|
+
"""覆盖导向自适应变异:将未覆盖目标符号定向合成到当前载荷中。"""
|
|
479
|
+
if not tokens:
|
|
480
|
+
return data
|
|
481
|
+
target_token = rng.choice(tokens)
|
|
482
|
+
stripped = data.strip()
|
|
483
|
+
if (stripped.startswith(b"{") and stripped.endswith(b"}")) or (stripped.startswith(b"[") and stripped.endswith(b"]")):
|
|
484
|
+
try:
|
|
485
|
+
parsed = json.loads(data.decode("utf-8"))
|
|
486
|
+
token_str = target_token.decode("utf-8", errors="replace")
|
|
487
|
+
if isinstance(parsed, dict):
|
|
488
|
+
key_choice = rng.choice(["inject_key", "inject_val", "inject_action"])
|
|
489
|
+
if key_choice == "inject_key":
|
|
490
|
+
parsed[token_str] = "gap_targeted_probe"
|
|
491
|
+
elif key_choice == "inject_val" and parsed:
|
|
492
|
+
k = rng.choice(list(parsed.keys()))
|
|
493
|
+
parsed[k] = token_str
|
|
494
|
+
else:
|
|
495
|
+
parsed["action"] = token_str
|
|
496
|
+
return json.dumps(parsed, ensure_ascii=False).encode("utf-8")
|
|
497
|
+
except Exception:
|
|
498
|
+
pass
|
|
499
|
+
|
|
500
|
+
pos = rng.randrange(len(data) + 1)
|
|
501
|
+
sep = b" " if (data and not data.endswith(b" ")) else b""
|
|
502
|
+
return data[:pos] + sep + target_token + sep + data[pos:]
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
STRATEGIES = [
|
|
506
|
+
("truncate", _mutate_truncate),
|
|
507
|
+
("flip_byte", _mutate_flip_byte),
|
|
508
|
+
("insert_garbage", _mutate_insert_garbage),
|
|
509
|
+
("mutate_numeric", _mutate_numeric),
|
|
510
|
+
("mutate_string", _mutate_string),
|
|
511
|
+
("duplicate", _mutate_duplicate),
|
|
512
|
+
("boundary_injection", _mutate_boundary_injection),
|
|
513
|
+
("json_structural", _mutate_json_structural),
|
|
514
|
+
]
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def mutate(
|
|
518
|
+
data: bytes,
|
|
519
|
+
rng: random.Random,
|
|
520
|
+
gap_tokens: list[bytes] | None = None,
|
|
521
|
+
) -> tuple[str, bytes]:
|
|
522
|
+
"""对输入施加自适应变异策略,支持语法树保持与覆盖导向符号注入。"""
|
|
523
|
+
# 覆盖导向增强:若提供未覆盖缺失符号,以 40% 倾向性权重定向注入缺失符号
|
|
524
|
+
if gap_tokens and rng.random() < 0.40:
|
|
525
|
+
mutated = _mutate_gap_guided(data, rng, gap_tokens)
|
|
526
|
+
if mutated != data:
|
|
527
|
+
return "gap_guided", mutated
|
|
528
|
+
|
|
529
|
+
# 自省检测:如果是合法的 JSON 结构化数据,优先以 65% 概率调用语法感知结构变异
|
|
530
|
+
stripped = data.strip()
|
|
531
|
+
if (stripped.startswith(b"{") and stripped.endswith(b"}")) or (stripped.startswith(b"[") and stripped.endswith(b"]")):
|
|
532
|
+
if rng.random() < 0.65:
|
|
533
|
+
mutated = _mutate_json_structural(data, rng)
|
|
534
|
+
if mutated != data:
|
|
535
|
+
return "json_structural", mutated
|
|
536
|
+
|
|
537
|
+
name, fn = rng.choice(STRATEGIES)
|
|
538
|
+
mutated = fn(data, rng)
|
|
539
|
+
if mutated != data:
|
|
540
|
+
return name, mutated
|
|
541
|
+
return name, _mutate_flip_byte(data, rng) if data else b"\x00"
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def _seed_for_index(seeds: list[bytes], index: int) -> bytes:
|
|
545
|
+
if not seeds:
|
|
546
|
+
raise ValueError("seeds 不能为空")
|
|
547
|
+
return seeds[index % len(seeds)]
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def _crash_signature(kind: str, exit_code: object, stderr: bytes = b"") -> str:
|
|
551
|
+
text = stderr.decode("utf-8", errors="replace") if isinstance(stderr, bytes) else str(stderr)
|
|
552
|
+
text = re.sub(r"0x[0-9a-fA-F]+", "0xADDR", text)
|
|
553
|
+
text = re.sub(r"\b\d+\b", "N", text)
|
|
554
|
+
text = "\n".join(line.strip() for line in text.splitlines() if line.strip())[:500]
|
|
555
|
+
value = "\0".join((kind, str(exit_code), text))
|
|
556
|
+
return hashlib.sha256(value.encode("utf-8", errors="replace")).hexdigest()[:16]
|
|
557
|
+
|
|
558
|
+
|
|
559
|
+
def _group_crashes(crashes: list[dict]) -> list[dict]:
|
|
560
|
+
grouped: dict[str, dict] = {}
|
|
561
|
+
for crash in sorted(crashes, key=lambda item: item["idx"]):
|
|
562
|
+
signature = crash["crash_signature"]
|
|
563
|
+
current = grouped.get(signature)
|
|
564
|
+
if current is None:
|
|
565
|
+
current = dict(crash)
|
|
566
|
+
current["occurrences"] = 0
|
|
567
|
+
current["sample_indices"] = []
|
|
568
|
+
current["payload_hashes"] = []
|
|
569
|
+
grouped[signature] = current
|
|
570
|
+
current["occurrences"] += 1
|
|
571
|
+
current["sample_indices"].append(crash["idx"])
|
|
572
|
+
payload_hash = crash.get("payload_sha256")
|
|
573
|
+
if payload_hash and payload_hash not in current["payload_hashes"]:
|
|
574
|
+
current["payload_hashes"].append(payload_hash)
|
|
575
|
+
return list(grouped.values())
|
|
576
|
+
|
|
577
|
+
|
|
578
|
+
# ---------- 执行与筛选 ----------
|
|
579
|
+
|
|
580
|
+
def _parse_code_set(value: str, name: str) -> frozenset[int]:
|
|
581
|
+
try:
|
|
582
|
+
values = frozenset(int(item.strip()) for item in value.split(",") if item.strip())
|
|
583
|
+
except (TypeError, ValueError) as exc:
|
|
584
|
+
raise ValueError(f"{name} 必须是逗号分隔的整数") from exc
|
|
585
|
+
if not values:
|
|
586
|
+
raise ValueError(f"{name} 不能为空")
|
|
587
|
+
return values
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
_FEEDBACK_KEYS = frozenset({"status_code", "state", "error_signature", "feedback"})
|
|
591
|
+
_FEEDBACK_SECRET = re.compile(
|
|
592
|
+
r"(?:bearer\s+\S+|(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*\S+)",
|
|
593
|
+
re.I,
|
|
594
|
+
)
|
|
595
|
+
|
|
596
|
+
|
|
597
|
+
def _feedback_value(value: object) -> str | int | float | bool | None:
|
|
598
|
+
if isinstance(value, bool):
|
|
599
|
+
return value
|
|
600
|
+
if isinstance(value, int) and not isinstance(value, bool):
|
|
601
|
+
return value
|
|
602
|
+
if isinstance(value, float) and value == value and abs(value) != float("inf"):
|
|
603
|
+
return value
|
|
604
|
+
if isinstance(value, str):
|
|
605
|
+
value = _FEEDBACK_SECRET.sub("[REDACTED]", value.strip())[:128]
|
|
606
|
+
return value or None
|
|
607
|
+
return None
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
def _extract_feedback(stdout: bytes, stderr: bytes, enabled: bool) -> dict:
|
|
611
|
+
"""读取显式 envelope;非 JSON 或未知字段都按无反馈处理。"""
|
|
612
|
+
if not enabled:
|
|
613
|
+
return {}
|
|
614
|
+
for stream in (stdout, stderr):
|
|
615
|
+
lines = stream.decode("utf-8", errors="replace").splitlines()
|
|
616
|
+
for line in reversed(lines):
|
|
617
|
+
try:
|
|
618
|
+
decoded = json.loads(line)
|
|
619
|
+
except json.JSONDecodeError:
|
|
620
|
+
continue
|
|
621
|
+
if not isinstance(decoded, dict):
|
|
622
|
+
continue
|
|
623
|
+
candidate = decoded.get("feedback") if isinstance(decoded.get("feedback"), dict) else decoded
|
|
624
|
+
vector: dict[str, object] = {}
|
|
625
|
+
for key in _FEEDBACK_KEYS - {"feedback"}:
|
|
626
|
+
if key not in candidate:
|
|
627
|
+
continue
|
|
628
|
+
safe = _feedback_value(candidate[key])
|
|
629
|
+
if safe is not None:
|
|
630
|
+
vector[key] = safe
|
|
631
|
+
nested = candidate.get("feedback") if isinstance(candidate, dict) else None
|
|
632
|
+
if isinstance(nested, dict):
|
|
633
|
+
safe_nested = {
|
|
634
|
+
str(key)[:64]: safe
|
|
635
|
+
for key, value in list(nested.items())[:8]
|
|
636
|
+
if (safe := _feedback_value(value)) is not None
|
|
637
|
+
}
|
|
638
|
+
if safe_nested:
|
|
639
|
+
vector["feedback"] = safe_nested
|
|
640
|
+
return vector
|
|
641
|
+
return {}
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
def _feedback_vector(feedback: dict, duration_ms: float,
|
|
645
|
+
latency_baseline: float | None, latency_factor: float,
|
|
646
|
+
watch_status: frozenset[int]) -> dict:
|
|
647
|
+
vector = dict(feedback)
|
|
648
|
+
status = vector.get("status_code")
|
|
649
|
+
if isinstance(status, str) and status.isdigit():
|
|
650
|
+
status = int(status)
|
|
651
|
+
vector["status_code"] = status
|
|
652
|
+
slow = (
|
|
653
|
+
latency_baseline is not None
|
|
654
|
+
and latency_baseline > 0
|
|
655
|
+
and latency_factor > 0
|
|
656
|
+
and duration_ms / 1000.0 >= latency_baseline * latency_factor
|
|
657
|
+
)
|
|
658
|
+
vector["latency_class"] = "slow" if slow else "normal"
|
|
659
|
+
vector["watched_status"] = isinstance(status, int) and status in watch_status
|
|
660
|
+
return vector
|
|
661
|
+
|
|
662
|
+
|
|
663
|
+
def _behavior_hash(exit_code: object, stdout: bytes = b"", stderr: bytes = b"",
|
|
664
|
+
feedback: Mapping[str, object] | None = None) -> str:
|
|
665
|
+
"""行为指纹:退出码、双流与显式反馈向量的 SHA-256。"""
|
|
666
|
+
digest = hashlib.sha256()
|
|
667
|
+
digest.update(str(exit_code).encode())
|
|
668
|
+
digest.update(b"\0")
|
|
669
|
+
digest.update(stdout[:4096])
|
|
670
|
+
digest.update(b"\0")
|
|
671
|
+
digest.update(stderr[:4096])
|
|
672
|
+
digest.update(b"\0")
|
|
673
|
+
digest.update(json.dumps(feedback or {}, ensure_ascii=False, sort_keys=True,
|
|
674
|
+
separators=(",", ":")).encode("utf-8"))
|
|
675
|
+
return digest.hexdigest()
|
|
676
|
+
|
|
677
|
+
|
|
678
|
+
def _load_evolution(evolve: Path | None) -> tuple[set[str], list[bytes]]:
|
|
679
|
+
"""读取既有行为哈希库与进化种子;目录不存在则初始化空库。"""
|
|
680
|
+
behaviors: set[str] = set()
|
|
681
|
+
seeds: list[bytes] = []
|
|
682
|
+
if evolve is None:
|
|
683
|
+
return behaviors, seeds
|
|
684
|
+
index = evolve / "behaviors.json"
|
|
685
|
+
if index.is_file():
|
|
686
|
+
try:
|
|
687
|
+
data = json.loads(index.read_text(encoding="utf-8"))
|
|
688
|
+
behaviors = {
|
|
689
|
+
str(item) for item in (data or {}).get("behaviors", [])
|
|
690
|
+
if isinstance(item, str)
|
|
691
|
+
}
|
|
692
|
+
except (OSError, json.JSONDecodeError):
|
|
693
|
+
print(f"[fuzz_input] ⚠ 行为库损坏,按空库重启: {index}")
|
|
694
|
+
seeds_dir = evolve / "seeds"
|
|
695
|
+
if seeds_dir.is_dir():
|
|
696
|
+
for path in sorted(seeds_dir.glob("*.bin")):
|
|
697
|
+
if path.is_symlink():
|
|
698
|
+
continue
|
|
699
|
+
try:
|
|
700
|
+
if path.stat().st_size > MAX_EVOLUTION_SEED_BYTES:
|
|
701
|
+
continue
|
|
702
|
+
seeds.append(path.read_bytes())
|
|
703
|
+
except OSError:
|
|
704
|
+
continue
|
|
705
|
+
return behaviors, seeds
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
def _save_evolution(evolve: Path, behaviors: set[str],
|
|
709
|
+
new_records: list[dict], max_seeds: int = 200) -> int:
|
|
710
|
+
"""把新行为样本写回进化目录(种子 + 行为库),返回新增种子数。"""
|
|
711
|
+
bugx_paths.ensure_dir(evolve)
|
|
712
|
+
seeds_dir = bugx_paths.ensure_dir(evolve / "seeds")
|
|
713
|
+
written = 0
|
|
714
|
+
for record in new_records:
|
|
715
|
+
payload = record.get("payload")
|
|
716
|
+
if not isinstance(payload, bytes) or len(payload) > MAX_EVOLUTION_SEED_BYTES:
|
|
717
|
+
continue
|
|
718
|
+
name = f"seed-{record['idx']:08d}-{record['behavior_sha256'][:12]}.bin"
|
|
719
|
+
target = seeds_dir / name
|
|
720
|
+
if target.is_symlink():
|
|
721
|
+
continue
|
|
722
|
+
target.write_bytes(payload)
|
|
723
|
+
written += 1
|
|
724
|
+
existing_seeds = sorted(seeds_dir.glob("*.bin"))
|
|
725
|
+
if len(existing_seeds) > max_seeds:
|
|
726
|
+
for stale in existing_seeds[:len(existing_seeds) - max_seeds]:
|
|
727
|
+
try:
|
|
728
|
+
stale.unlink()
|
|
729
|
+
except OSError:
|
|
730
|
+
pass
|
|
731
|
+
index_path = evolve / "behaviors.json"
|
|
732
|
+
if index_path.is_symlink():
|
|
733
|
+
raise ValueError(f"拒绝写入符号链接行为库: {index_path}")
|
|
734
|
+
content = json.dumps({
|
|
735
|
+
"schema_version": 1,
|
|
736
|
+
"behaviors": sorted(behaviors),
|
|
737
|
+
"seeds": min(len(existing_seeds), max_seeds),
|
|
738
|
+
}, ensure_ascii=False, indent=2) + "\n"
|
|
739
|
+
temporary = index_path.with_name(f".{index_path.name}.tmp")
|
|
740
|
+
temporary.write_text(content, encoding="utf-8")
|
|
741
|
+
temporary.replace(index_path)
|
|
742
|
+
return written
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
def _run_target(cmd: str, payload: bytes, tmp: Path,
|
|
746
|
+
timeout: float, allow_shell: bool = False) -> subprocess.CompletedProcess:
|
|
747
|
+
if len(payload) > MAX_INPUT_BYTES:
|
|
748
|
+
raise _PayloadLimitError(
|
|
749
|
+
f"输入样本超过 {MAX_INPUT_BYTES} 字节上限: {len(payload)}"
|
|
750
|
+
)
|
|
751
|
+
if not isinstance(timeout, (int, float)) or isinstance(timeout, bool) or timeout <= 0:
|
|
752
|
+
raise ValueError("timeout 必须是正数")
|
|
753
|
+
if not tmp.is_dir():
|
|
754
|
+
raise ValueError(f"执行工作目录不是目录: {tmp}")
|
|
755
|
+
inp = tmp / "input"
|
|
756
|
+
if inp.is_symlink():
|
|
757
|
+
inp.unlink()
|
|
758
|
+
inp.write_bytes(payload)
|
|
759
|
+
if allow_shell:
|
|
760
|
+
rendered = cmd.replace("{input}", shlex.quote(str(inp)))
|
|
761
|
+
argv = _shell_argv(rendered)
|
|
762
|
+
else:
|
|
763
|
+
argv = [token.replace("{input}", str(inp)) for token in _split_argv(cmd)]
|
|
764
|
+
return run_bounded(
|
|
765
|
+
argv,
|
|
766
|
+
cwd=tmp,
|
|
767
|
+
timeout=timeout,
|
|
768
|
+
max_output_bytes=MAX_OUTPUT_BYTES,
|
|
769
|
+
)
|
|
770
|
+
|
|
771
|
+
|
|
772
|
+
def fuzz_once(cmd: str, data: bytes, rng: random.Random, tmp: Path,
|
|
773
|
+
timeout: float, idx: int, allow_shell: bool = False,
|
|
774
|
+
seen_payloads: set[str] | None = None,
|
|
775
|
+
seen_lock: threading.Lock | None = None,
|
|
776
|
+
track_behavior: bool = False,
|
|
777
|
+
seen_behaviors: set[str] | None = None,
|
|
778
|
+
accepted_exits: frozenset[int] | None = None,
|
|
779
|
+
feedback_json: bool = False,
|
|
780
|
+
latency_baseline: float | None = None,
|
|
781
|
+
latency_factor: float = 3.0,
|
|
782
|
+
watch_status: frozenset[int] | None = None,
|
|
783
|
+
gap_tokens: list[bytes] | None = None) -> dict | None:
|
|
784
|
+
"""跑一个变异样本;异常或新的反馈行为返回记录,正常返回 None。
|
|
785
|
+
|
|
786
|
+
``track_behavior`` 开启后,正常退出但行为指纹未见过的样本也返回
|
|
787
|
+
``kind="new-behavior"`` 记录——它们会被回填为下一轮种子,实现
|
|
788
|
+
行为多样性引导(无插桩环境下的最小覆盖引导形态)。
|
|
789
|
+
"""
|
|
790
|
+
name, payload = mutate(data, rng, gap_tokens=gap_tokens)
|
|
791
|
+
accepted_exits = accepted_exits or frozenset({0})
|
|
792
|
+
watch_status = watch_status or frozenset()
|
|
793
|
+
payload_hash = hashlib.sha256(payload).hexdigest()
|
|
794
|
+
if seen_payloads is not None:
|
|
795
|
+
if seen_lock is None:
|
|
796
|
+
duplicate = payload_hash in seen_payloads
|
|
797
|
+
seen_payloads.add(payload_hash)
|
|
798
|
+
else:
|
|
799
|
+
with seen_lock:
|
|
800
|
+
duplicate = payload_hash in seen_payloads
|
|
801
|
+
seen_payloads.add(payload_hash)
|
|
802
|
+
if duplicate:
|
|
803
|
+
return {
|
|
804
|
+
"idx": idx, "strategy": name, "kind": "duplicate",
|
|
805
|
+
"len": len(payload), "payload_sha256": payload_hash,
|
|
806
|
+
}
|
|
807
|
+
case_tmp = tmp / f"case-{idx:08d}"
|
|
808
|
+
case_tmp.mkdir(parents=True, exist_ok=True)
|
|
809
|
+
try:
|
|
810
|
+
r = _run_target(cmd, payload, case_tmp, timeout, allow_shell)
|
|
811
|
+
except _PayloadLimitError as exc:
|
|
812
|
+
behavior = _behavior_hash("INPUT_LIMIT")
|
|
813
|
+
return {
|
|
814
|
+
"idx": idx, "strategy": name, "kind": "input-limit",
|
|
815
|
+
"exit": "INPUT_LIMIT", "len": len(payload), "payload": payload,
|
|
816
|
+
"payload_sha256": payload_hash,
|
|
817
|
+
"crash_signature": _crash_signature("input-limit", "INPUT_LIMIT"),
|
|
818
|
+
"behavior_sha256": behavior, "error": str(exc),
|
|
819
|
+
}
|
|
820
|
+
except OSError as exc:
|
|
821
|
+
behavior = _behavior_hash("EXECUTION_ERROR")
|
|
822
|
+
return {
|
|
823
|
+
"idx": idx, "strategy": name, "kind": "execution-error",
|
|
824
|
+
"exit": "EXECUTION_ERROR", "len": len(payload), "payload": payload,
|
|
825
|
+
"payload_sha256": payload_hash,
|
|
826
|
+
"crash_signature": _crash_signature("execution-error", "EXECUTION_ERROR"),
|
|
827
|
+
"behavior_sha256": behavior, "error": str(exc),
|
|
828
|
+
}
|
|
829
|
+
if getattr(r, "timed_out", False):
|
|
830
|
+
behavior = _behavior_hash("TIMEOUT")
|
|
831
|
+
return {
|
|
832
|
+
"idx": idx, "strategy": name, "kind": "timeout",
|
|
833
|
+
"exit": "TIMEOUT", "len": len(payload), "payload": payload,
|
|
834
|
+
"payload_sha256": payload_hash,
|
|
835
|
+
"crash_signature": _crash_signature("timeout", "TIMEOUT"),
|
|
836
|
+
"behavior_sha256": behavior,
|
|
837
|
+
}
|
|
838
|
+
stdout = _as_bytes(r.stdout)
|
|
839
|
+
stderr = _as_bytes(r.stderr)
|
|
840
|
+
duration_ms = round(float(getattr(r, "duration_seconds", 0.0) or 0.0) * 1000, 2)
|
|
841
|
+
feedback = _extract_feedback(stdout, stderr, feedback_json)
|
|
842
|
+
vector = _feedback_vector(
|
|
843
|
+
feedback, duration_ms, latency_baseline, latency_factor, watch_status,
|
|
844
|
+
)
|
|
845
|
+
if getattr(r, "output_exceeded", False):
|
|
846
|
+
behavior = _behavior_hash("OUTPUT_LIMIT", stdout, stderr, vector)
|
|
847
|
+
return {
|
|
848
|
+
"idx": idx, "strategy": name, "kind": "output-limit",
|
|
849
|
+
"exit": "OUTPUT_LIMIT", "len": len(payload), "payload": payload,
|
|
850
|
+
"stderr": stderr[:2000], "payload_sha256": payload_hash,
|
|
851
|
+
"crash_signature": _crash_signature("output-limit", "OUTPUT_LIMIT", stderr),
|
|
852
|
+
"behavior_sha256": behavior, "output_limit": MAX_OUTPUT_BYTES,
|
|
853
|
+
"duration_ms": duration_ms, "feedback": vector,
|
|
854
|
+
}
|
|
855
|
+
behavior = _behavior_hash(r.returncode, stdout, stderr, vector)
|
|
856
|
+
if r.returncode not in accepted_exits:
|
|
857
|
+
return {
|
|
858
|
+
"idx": idx, "strategy": name, "kind": "crash",
|
|
859
|
+
"exit": r.returncode, "len": len(payload), "payload": payload,
|
|
860
|
+
"stderr": stderr[:2000],
|
|
861
|
+
"payload_sha256": payload_hash,
|
|
862
|
+
"crash_signature": _crash_signature("crash", r.returncode, stderr),
|
|
863
|
+
"behavior_sha256": behavior, "duration_ms": duration_ms,
|
|
864
|
+
"feedback": vector,
|
|
865
|
+
}
|
|
866
|
+
if vector.get("watched_status") or vector.get("latency_class") == "slow":
|
|
867
|
+
kind = "feedback-anomaly" if vector.get("watched_status") else "latency-anomaly"
|
|
868
|
+
return {
|
|
869
|
+
"idx": idx, "strategy": name, "kind": kind,
|
|
870
|
+
"exit": r.returncode, "len": len(payload), "payload": payload,
|
|
871
|
+
"stderr": stderr[:2000], "payload_sha256": payload_hash,
|
|
872
|
+
"crash_signature": _crash_signature(kind, vector, stderr),
|
|
873
|
+
"behavior_sha256": behavior, "duration_ms": duration_ms,
|
|
874
|
+
"feedback": vector,
|
|
875
|
+
}
|
|
876
|
+
if track_behavior and seen_behaviors is not None:
|
|
877
|
+
if seen_lock is None:
|
|
878
|
+
known = behavior in seen_behaviors
|
|
879
|
+
seen_behaviors.add(behavior)
|
|
880
|
+
else:
|
|
881
|
+
with seen_lock:
|
|
882
|
+
known = behavior in seen_behaviors
|
|
883
|
+
seen_behaviors.add(behavior)
|
|
884
|
+
if not known:
|
|
885
|
+
return {
|
|
886
|
+
"idx": idx, "strategy": name, "kind": "new-behavior",
|
|
887
|
+
"exit": 0, "len": len(payload), "payload": payload,
|
|
888
|
+
"payload_sha256": payload_hash,
|
|
889
|
+
"behavior_sha256": behavior,
|
|
890
|
+
"duration_ms": duration_ms, "feedback": vector,
|
|
891
|
+
}
|
|
892
|
+
return None
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
def fuzz_target(
|
|
896
|
+
cmd: str,
|
|
897
|
+
*,
|
|
898
|
+
input_content: str | bytes | None = None,
|
|
899
|
+
input_path: str | Path | None = None,
|
|
900
|
+
root: str | Path | None = None,
|
|
901
|
+
lang: str | None = None,
|
|
902
|
+
count: int = 50,
|
|
903
|
+
jobs: int = 4,
|
|
904
|
+
timeout: float = 5.0,
|
|
905
|
+
allow_shell: bool = False,
|
|
906
|
+
out_dir: str | Path | None = None,
|
|
907
|
+
target_gaps: str | Path | None = None,
|
|
908
|
+
accepted_exits: set[int] | None = None,
|
|
909
|
+
seed: int | None = None,
|
|
910
|
+
) -> dict[str, Any]:
|
|
911
|
+
"""供 Python 模块或 MCP 工具调用的输入变异模糊测试执行引擎。
|
|
912
|
+
|
|
913
|
+
``input_content`` 是**纯内容**:即使它的字面量恰好等于某个已存在文件的
|
|
914
|
+
路径,也不会被当作文件读取。需要「从项目内文件取种子」时显式使用
|
|
915
|
+
``input_path``(必须落在 ``root`` 内且不含符号链接)。把两者合并成
|
|
916
|
+
「恰好是文件就当路径」的嗅探,曾让 ``input_content`` 变成任意文件读取入口。
|
|
917
|
+
"""
|
|
918
|
+
if count < 1 or jobs < 1 or timeout <= 0:
|
|
919
|
+
raise ValueError("count、jobs 必须 >= 1,timeout 必须 > 0")
|
|
920
|
+
if not allow_shell:
|
|
921
|
+
_split_argv(cmd)
|
|
922
|
+
|
|
923
|
+
actual_seed = seed if seed is not None else random.SystemRandom().randrange(2**63)
|
|
924
|
+
seed_inputs: list[bytes] | None = None
|
|
925
|
+
gap_path = Path(target_gaps) if target_gaps else None
|
|
926
|
+
gap_root = Path(root) if root is not None else None
|
|
927
|
+
gap_seeds = load_gap_seeds(gap_path, root=gap_root)
|
|
928
|
+
gap_tokens = extract_gap_tokens(gap_path, root=gap_root)
|
|
929
|
+
|
|
930
|
+
if input_content is not None and input_path is not None:
|
|
931
|
+
raise ValueError("input_content 与 input_path 不能同时提供")
|
|
932
|
+
if input_path is not None:
|
|
933
|
+
if root is None:
|
|
934
|
+
raise ValueError("使用 input_path 时必须提供 root 以校验项目边界")
|
|
935
|
+
data = _read_confined_input(root, input_path)
|
|
936
|
+
elif input_content is not None:
|
|
937
|
+
if isinstance(input_content, bytes):
|
|
938
|
+
data = input_content
|
|
939
|
+
else:
|
|
940
|
+
data = str(input_content).encode("utf-8")
|
|
941
|
+
elif gap_seeds:
|
|
942
|
+
seed_inputs = gap_seeds
|
|
943
|
+
data = seed_inputs[0]
|
|
944
|
+
elif lang:
|
|
945
|
+
seed_inputs = load_seed(lang)
|
|
946
|
+
if not seed_inputs:
|
|
947
|
+
raise ValueError(f"指定语言种子缺失: {lang}")
|
|
948
|
+
data = seed_inputs[0]
|
|
949
|
+
else:
|
|
950
|
+
data = b'{"test": 1, "value": "demo"}'
|
|
951
|
+
|
|
952
|
+
temp_out_dir = None
|
|
953
|
+
if out_dir:
|
|
954
|
+
out = Path(out_dir).expanduser().resolve()
|
|
955
|
+
bugx_paths.ensure_dir(out)
|
|
956
|
+
else:
|
|
957
|
+
temp_out_dir = tempfile.TemporaryDirectory(prefix="bugx-fuzz-")
|
|
958
|
+
out = Path(temp_out_dir.name)
|
|
959
|
+
|
|
960
|
+
crashes_dir = bugx_paths.ensure_dir(out / "crashes")
|
|
961
|
+
|
|
962
|
+
crashes: list[dict] = []
|
|
963
|
+
duplicates_skipped = 0
|
|
964
|
+
seen_payloads: set[str] = set()
|
|
965
|
+
seen_lock = threading.Lock()
|
|
966
|
+
accepted = accepted_exits or {0}
|
|
967
|
+
|
|
968
|
+
with tempfile.TemporaryDirectory(prefix="fuzz-tmp-") as td:
|
|
969
|
+
tmp = Path(td)
|
|
970
|
+
|
|
971
|
+
def _seed_pool(index: int) -> bytes:
|
|
972
|
+
base = [data] if seed_inputs is None else seed_inputs
|
|
973
|
+
pool = gap_seeds + base
|
|
974
|
+
return pool[index % len(pool)]
|
|
975
|
+
|
|
976
|
+
with ThreadPoolExecutor(max_workers=jobs) as pool:
|
|
977
|
+
futs = {
|
|
978
|
+
pool.submit(
|
|
979
|
+
fuzz_once, cmd,
|
|
980
|
+
_seed_pool(i),
|
|
981
|
+
random.Random(actual_seed + i), tmp,
|
|
982
|
+
timeout, i, allow_shell,
|
|
983
|
+
seen_payloads, seen_lock,
|
|
984
|
+
False, None, accepted, None,
|
|
985
|
+
None, 3.0, None, gap_tokens,
|
|
986
|
+
): i
|
|
987
|
+
for i in range(count)
|
|
988
|
+
}
|
|
989
|
+
for fut in as_completed(futs):
|
|
990
|
+
try:
|
|
991
|
+
res = fut.result()
|
|
992
|
+
except Exception:
|
|
993
|
+
continue
|
|
994
|
+
if res is not None and res.get("kind") == "duplicate":
|
|
995
|
+
duplicates_skipped += 1
|
|
996
|
+
elif res is not None and res.get("kind") != "new-behavior":
|
|
997
|
+
crashes.append(res)
|
|
998
|
+
|
|
999
|
+
unique_crashes = _group_crashes(crashes)
|
|
1000
|
+
records = []
|
|
1001
|
+
for c in unique_crashes:
|
|
1002
|
+
rec = {k: v for k, v in c.items() if k != "payload"}
|
|
1003
|
+
if isinstance(rec.get("stderr"), bytes):
|
|
1004
|
+
rec["stderr"] = rec["stderr"].decode("utf-8", errors="replace")
|
|
1005
|
+
records.append(rec)
|
|
1006
|
+
|
|
1007
|
+
return {
|
|
1008
|
+
"status": "ok",
|
|
1009
|
+
"total": count,
|
|
1010
|
+
"executed": count - duplicates_skipped,
|
|
1011
|
+
"duplicates_skipped": duplicates_skipped,
|
|
1012
|
+
"anomalies": len(crashes),
|
|
1013
|
+
"unique_anomalies": len(unique_crashes),
|
|
1014
|
+
"crashes": records[:10],
|
|
1015
|
+
"crash_signatures": sorted(list({c.get("crash_signature", "") for c in unique_crashes if c.get("crash_signature")})),
|
|
1016
|
+
"out_dir": str(out),
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
|
|
1020
|
+
def main(argv: list[str] | None = None) -> int:
|
|
1021
|
+
args = parse_args(argv)
|
|
1022
|
+
if args.count < 1 or args.jobs < 1 or args.timeout <= 0:
|
|
1023
|
+
print("[fuzz_input] --count、--jobs 必须 >= 1,--timeout 必须 > 0")
|
|
1024
|
+
return 2
|
|
1025
|
+
if args.latency_baseline is not None and args.latency_baseline <= 0:
|
|
1026
|
+
print("[fuzz_input] --latency-baseline 必须 > 0")
|
|
1027
|
+
return 2
|
|
1028
|
+
if args.latency_factor <= 0:
|
|
1029
|
+
print("[fuzz_input] --latency-factor 必须 > 0")
|
|
1030
|
+
return 2
|
|
1031
|
+
try:
|
|
1032
|
+
accepted_exits = _parse_code_set(args.accepted_exits, "--accepted-exits")
|
|
1033
|
+
watch_status = _parse_code_set(args.watch_status, "--watch-status")
|
|
1034
|
+
except ValueError as exc:
|
|
1035
|
+
print(f"[fuzz_input] {exc}")
|
|
1036
|
+
return 2
|
|
1037
|
+
if not args.allow_shell:
|
|
1038
|
+
try:
|
|
1039
|
+
_split_argv(args.cmd)
|
|
1040
|
+
except ValueError as exc:
|
|
1041
|
+
print(f"[fuzz_input] 命令无效: {exc}")
|
|
1042
|
+
return 2
|
|
1043
|
+
seed = args.seed if args.seed is not None else random.SystemRandom().randrange(2**63)
|
|
1044
|
+
seed_inputs: list[bytes] | None = None
|
|
1045
|
+
gap_seeds = load_gap_seeds(args.target_gaps, root=args.root)
|
|
1046
|
+
gap_tokens = extract_gap_tokens(args.target_gaps, root=args.root)
|
|
1047
|
+
if gap_seeds:
|
|
1048
|
+
print(f"[fuzz_input] 定向模式:{len(gap_seeds)} 个欠覆盖文件作为优先种子")
|
|
1049
|
+
if gap_tokens:
|
|
1050
|
+
print(f"[fuzz_input] 覆盖导向:提取到 {len(gap_tokens)} 个缺失符号引导变异")
|
|
1051
|
+
if args.input:
|
|
1052
|
+
src = Path(args.input)
|
|
1053
|
+
if not src.is_file():
|
|
1054
|
+
print(f"[fuzz_input] 输入文件不存在: {src}")
|
|
1055
|
+
return 2
|
|
1056
|
+
data = src.read_bytes()
|
|
1057
|
+
source_name = src.name
|
|
1058
|
+
elif gap_seeds:
|
|
1059
|
+
seed_inputs = gap_seeds
|
|
1060
|
+
data = seed_inputs[0]
|
|
1061
|
+
source_name = f"gap-seeds({len(gap_seeds)} 个欠覆盖文件)"
|
|
1062
|
+
elif args.lang:
|
|
1063
|
+
seed_inputs = load_seed(args.lang)
|
|
1064
|
+
if not seed_inputs:
|
|
1065
|
+
return 2
|
|
1066
|
+
data = seed_inputs[0]
|
|
1067
|
+
source_name = f"seed:{args.lang}({len(seed_inputs)} 条,按样本轮询)"
|
|
1068
|
+
else:
|
|
1069
|
+
print("[fuzz_input] 必须提供 --input / --lang / --target-gaps 之一作为种子来源")
|
|
1070
|
+
return 2
|
|
1071
|
+
out = Path(args.out).expanduser()
|
|
1072
|
+
if out.is_symlink():
|
|
1073
|
+
print(f"[fuzz_input] 拒绝写入符号链接输出目录: {out}")
|
|
1074
|
+
return 2
|
|
1075
|
+
out = out.resolve()
|
|
1076
|
+
bugx_paths.ensure_dir(out)
|
|
1077
|
+
crashes_dir = bugx_paths.ensure_dir(out / "crashes")
|
|
1078
|
+
|
|
1079
|
+
evolve_arg = args.evolve.expanduser() if args.evolve else None
|
|
1080
|
+
if evolve_arg and evolve_arg.is_symlink():
|
|
1081
|
+
print(f"[fuzz_input] 拒绝使用符号链接进化目录: {evolve_arg}")
|
|
1082
|
+
return 2
|
|
1083
|
+
evolve = evolve_arg.resolve() if evolve_arg else None
|
|
1084
|
+
seen_behaviors, evolve_seeds = _load_evolution(evolve)
|
|
1085
|
+
if evolve and evolve_seeds:
|
|
1086
|
+
print(f"[fuzz_input] 进化种子库: {len(evolve_seeds)} 条 "
|
|
1087
|
+
f"(已知行为 {len(seen_behaviors)} 个)")
|
|
1088
|
+
|
|
1089
|
+
print(f"[fuzz_input] 目标: {source_name} ({len(data)} 字节) "
|
|
1090
|
+
f"样本={args.count} 并发={args.jobs} 种子={seed}")
|
|
1091
|
+
crashes: list[dict] = []
|
|
1092
|
+
new_behaviors: list[dict] = []
|
|
1093
|
+
duplicates_skipped = 0
|
|
1094
|
+
seen_payloads: set[str] = set()
|
|
1095
|
+
seen_lock = threading.Lock()
|
|
1096
|
+
with tempfile.TemporaryDirectory(prefix="fuzz-") as td:
|
|
1097
|
+
tmp = Path(td)
|
|
1098
|
+
|
|
1099
|
+
def _seed_pool(index: int) -> bytes:
|
|
1100
|
+
base = [data] if seed_inputs is None else seed_inputs
|
|
1101
|
+
pool = gap_seeds + base + evolve_seeds
|
|
1102
|
+
return pool[index % len(pool)]
|
|
1103
|
+
|
|
1104
|
+
with ThreadPoolExecutor(max_workers=args.jobs) as pool:
|
|
1105
|
+
futs = {
|
|
1106
|
+
pool.submit(fuzz_once, args.cmd,
|
|
1107
|
+
_seed_pool(i),
|
|
1108
|
+
random.Random(seed + i), tmp,
|
|
1109
|
+
args.timeout, i, args.allow_shell,
|
|
1110
|
+
seen_payloads, seen_lock,
|
|
1111
|
+
bool(evolve),
|
|
1112
|
+
seen_behaviors if evolve else None,
|
|
1113
|
+
accepted_exits, args.feedback_json,
|
|
1114
|
+
args.latency_baseline, args.latency_factor,
|
|
1115
|
+
watch_status, gap_tokens): i
|
|
1116
|
+
for i in range(args.count)
|
|
1117
|
+
}
|
|
1118
|
+
for fut in as_completed(futs):
|
|
1119
|
+
try:
|
|
1120
|
+
res = fut.result()
|
|
1121
|
+
except Exception as e: # noqa: BLE001
|
|
1122
|
+
print(f" ! 任务异常: {e}")
|
|
1123
|
+
continue
|
|
1124
|
+
if res is not None and res.get("kind") == "duplicate":
|
|
1125
|
+
duplicates_skipped += 1
|
|
1126
|
+
elif res is not None and res.get("kind") == "new-behavior":
|
|
1127
|
+
new_behaviors.append(res)
|
|
1128
|
+
elif res is not None:
|
|
1129
|
+
crashes.append(res)
|
|
1130
|
+
|
|
1131
|
+
# 写异常样本
|
|
1132
|
+
meta = out / "summary.json"
|
|
1133
|
+
unique_crashes = _group_crashes(crashes)
|
|
1134
|
+
records = []
|
|
1135
|
+
for c in unique_crashes:
|
|
1136
|
+
fn = crashes_dir / (
|
|
1137
|
+
f"crash-{c['idx']:04d}-{c['strategy']}-exit{c['exit']}"
|
|
1138
|
+
f"-{c['crash_signature']}"
|
|
1139
|
+
)
|
|
1140
|
+
fn.write_bytes(c["payload"])
|
|
1141
|
+
rec = {k: v for k, v in c.items() if k != "payload"}
|
|
1142
|
+
if isinstance(rec.get("stderr"), bytes):
|
|
1143
|
+
rec["stderr"] = rec["stderr"].decode("utf-8", errors="replace")
|
|
1144
|
+
rec["file"] = fn.name
|
|
1145
|
+
records.append(rec)
|
|
1146
|
+
meta.write_text(
|
|
1147
|
+
json.dumps({
|
|
1148
|
+
"total": args.count,
|
|
1149
|
+
"executed": args.count - duplicates_skipped,
|
|
1150
|
+
"duplicates_skipped": duplicates_skipped,
|
|
1151
|
+
"anomalies": len(crashes),
|
|
1152
|
+
"unique_anomalies": len(unique_crashes),
|
|
1153
|
+
"new_behaviors": len(new_behaviors) if evolve else None,
|
|
1154
|
+
"feedback_anomalies": sum(
|
|
1155
|
+
1 for item in crashes if item.get("kind") == "feedback-anomaly"
|
|
1156
|
+
),
|
|
1157
|
+
"latency_anomalies": sum(
|
|
1158
|
+
1 for item in crashes if item.get("kind") == "latency-anomaly"
|
|
1159
|
+
),
|
|
1160
|
+
"accepted_exits": sorted(accepted_exits),
|
|
1161
|
+
"feedback_json": args.feedback_json,
|
|
1162
|
+
"evolve_dir": str(evolve) if evolve else None,
|
|
1163
|
+
"crashes": records,
|
|
1164
|
+
}, ensure_ascii=False, indent=2),
|
|
1165
|
+
encoding="utf-8",
|
|
1166
|
+
)
|
|
1167
|
+
|
|
1168
|
+
if evolve:
|
|
1169
|
+
# 异常行为同样入行为库:同一崩溃签名跨轮不必重复留种。
|
|
1170
|
+
for c in crashes:
|
|
1171
|
+
if c.get("behavior_sha256"):
|
|
1172
|
+
seen_behaviors.add(c["behavior_sha256"])
|
|
1173
|
+
seed_records = new_behaviors + [
|
|
1174
|
+
c for c in crashes if c.get("behavior_sha256")
|
|
1175
|
+
]
|
|
1176
|
+
written = _save_evolution(evolve, seen_behaviors, seed_records)
|
|
1177
|
+
print(f"[fuzz_input] 进化回写: 新行为 {len(new_behaviors)} 个,"
|
|
1178
|
+
f"新增种子 {written} 条(库内行为共 {len(seen_behaviors)} 个)-> {evolve}")
|
|
1179
|
+
|
|
1180
|
+
by_kind: dict[str, int] = {}
|
|
1181
|
+
for c in crashes:
|
|
1182
|
+
by_kind[c["kind"]] = by_kind.get(c["kind"], 0) + 1
|
|
1183
|
+
print(f"[fuzz_input] 完成: {args.count} 样本, 去重跳过 {duplicates_skipped} 个,"
|
|
1184
|
+
f"异常 {len(crashes)} 个(唯一签名 {len(unique_crashes)},{by_kind})")
|
|
1185
|
+
print(f"[fuzz_input] 异常样本已写入: {crashes_dir}")
|
|
1186
|
+
print(f"[fuzz_input] 汇总: {meta}")
|
|
1187
|
+
if crashes:
|
|
1188
|
+
print(" 下一步: 用 minimize_repro.py 把异常样本缩到最小复现,再定位根因。")
|
|
1189
|
+
if evolve:
|
|
1190
|
+
print(" 进化模式: 新行为样本已回填种子,下一轮 --evolve 同目录继续。")
|
|
1191
|
+
return 0
|
|
1192
|
+
|
|
1193
|
+
|
|
1194
|
+
def is_available() -> tuple[bool, str]:
|
|
1195
|
+
"""降级契约:机械探活模糊执行前提(解释器 + CPU + 可写临时目录,零子进程)。"""
|
|
1196
|
+
if not sys.executable:
|
|
1197
|
+
return False, "缺少 Python 解释器;模糊目标执行不可用"
|
|
1198
|
+
cpu = os.cpu_count()
|
|
1199
|
+
if not cpu:
|
|
1200
|
+
return False, "无法确定 CPU 数量;并发变异调度不可用"
|
|
1201
|
+
tmp = tempfile.gettempdir()
|
|
1202
|
+
if not os.path.isdir(tmp) or not os.access(tmp, os.W_OK):
|
|
1203
|
+
return False, f"模糊样本临时目录不可写: {tmp}"
|
|
1204
|
+
return True, f"执行前提就绪(cpu={cpu}, tmp={tmp})"
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
def run_static_degraded(
|
|
1208
|
+
input_path: str | Path | None = None,
|
|
1209
|
+
*,
|
|
1210
|
+
count: int = 8,
|
|
1211
|
+
seed: int | None = None,
|
|
1212
|
+
gap_tokens: list[bytes] | None = None,
|
|
1213
|
+
) -> dict[str, Any]:
|
|
1214
|
+
"""降级契约:只生成变异样本(不执行目标),显式声明为变异发生器自检。
|
|
1215
|
+
|
|
1216
|
+
输出与成功路径(``main`` 的并发轰靶 summary.json 工件)字段级可区分:
|
|
1217
|
+
``status="degraded"`` + ``degraded=True`` + ``degraded_reason`` +
|
|
1218
|
+
``target_executed=False``;只产出变异策略直方图,绝不产出任何
|
|
1219
|
+
「异常样本/crash」结论,禁止把变异发生器自检伪装成模糊测试完成。
|
|
1220
|
+
"""
|
|
1221
|
+
available, availability_detail = is_available()
|
|
1222
|
+
if input_path is None:
|
|
1223
|
+
return {
|
|
1224
|
+
"schema_version": 1,
|
|
1225
|
+
"success": False,
|
|
1226
|
+
"status": "degraded",
|
|
1227
|
+
"degraded": True,
|
|
1228
|
+
"degraded_reason": "seed_input_missing",
|
|
1229
|
+
"probe_mode": "static_degraded",
|
|
1230
|
+
"target_executed": False,
|
|
1231
|
+
"mutations_generated": 0,
|
|
1232
|
+
"strategy_histogram": {},
|
|
1233
|
+
"findings": [],
|
|
1234
|
+
"evidence": {"availability_detail": availability_detail},
|
|
1235
|
+
"metadata": {"degraded_mode": "mutation_generator_selfcheck"},
|
|
1236
|
+
}
|
|
1237
|
+
src = Path(input_path)
|
|
1238
|
+
if not src.is_file():
|
|
1239
|
+
return {
|
|
1240
|
+
"schema_version": 1,
|
|
1241
|
+
"success": False,
|
|
1242
|
+
"status": "degraded",
|
|
1243
|
+
"degraded": True,
|
|
1244
|
+
"degraded_reason": "seed_input_not_found",
|
|
1245
|
+
"probe_mode": "static_degraded",
|
|
1246
|
+
"target_executed": False,
|
|
1247
|
+
"mutations_generated": 0,
|
|
1248
|
+
"strategy_histogram": {},
|
|
1249
|
+
"findings": [],
|
|
1250
|
+
"evidence": {
|
|
1251
|
+
"availability_detail": availability_detail,
|
|
1252
|
+
"seed_input": str(src),
|
|
1253
|
+
},
|
|
1254
|
+
"metadata": {"degraded_mode": "mutation_generator_selfcheck"},
|
|
1255
|
+
}
|
|
1256
|
+
data = src.read_bytes()
|
|
1257
|
+
rng = random.Random(seed if seed is not None else 0)
|
|
1258
|
+
sample_count = max(1, min(int(count), 64))
|
|
1259
|
+
strategy_histogram: dict[str, int] = {}
|
|
1260
|
+
distinct_variants: set[str] = set()
|
|
1261
|
+
for _ in range(sample_count):
|
|
1262
|
+
strategy, variant = mutate(data, rng, gap_tokens)
|
|
1263
|
+
strategy_histogram[strategy] = strategy_histogram.get(strategy, 0) + 1
|
|
1264
|
+
distinct_variants.add(hashlib.sha256(variant).hexdigest())
|
|
1265
|
+
return {
|
|
1266
|
+
"schema_version": 1,
|
|
1267
|
+
"success": True,
|
|
1268
|
+
"status": "degraded",
|
|
1269
|
+
"degraded": True,
|
|
1270
|
+
"degraded_reason": (
|
|
1271
|
+
"static_mode_forced" if available else "target_execution_unavailable"
|
|
1272
|
+
),
|
|
1273
|
+
"probe_mode": "static_degraded",
|
|
1274
|
+
"target_executed": False,
|
|
1275
|
+
"seed_input": str(src),
|
|
1276
|
+
"seed_sha256": hashlib.sha256(data).hexdigest(),
|
|
1277
|
+
"mutations_generated": sample_count,
|
|
1278
|
+
"distinct_variants": len(distinct_variants),
|
|
1279
|
+
"strategy_histogram": strategy_histogram,
|
|
1280
|
+
"findings": [],
|
|
1281
|
+
"evidence": {"availability_detail": availability_detail},
|
|
1282
|
+
"metadata": {
|
|
1283
|
+
"degraded_mode": "mutation_generator_selfcheck",
|
|
1284
|
+
"anomalies_reported": 0,
|
|
1285
|
+
"fallback": "目标执行不可用时只验证变异发生器;禁止产出任何 crash/异常样本结论",
|
|
1286
|
+
},
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
if __name__ == "__main__":
|
|
1291
|
+
sys.exit(main())
|