bugx-cli 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +55 -0
- package/README.md +280 -2
- package/core/CATALOG.json +141 -0
- package/core/README.md +254 -0
- package/core/adapters/README.md +35 -0
- package/core/adapters/android-interaction.json +81 -0
- package/core/adapters/android.json +24 -0
- package/core/adapters/desktop-macos.json +20 -0
- package/core/adapters/ios-interaction.json +34 -0
- package/core/adapters/ios.json +23 -0
- package/core/adapters/memory-macos.json +24 -0
- package/core/agent/README.md +50 -0
- package/core/agent/__init__.py +146 -0
- package/core/agent/agent_artifacts.py +764 -0
- package/core/agent/agent_eval.py +1073 -0
- package/core/agent/agent_execution.py +552 -0
- package/core/agent/agent_orchestrator.py +1345 -0
- package/core/agent/agent_targets.py +871 -0
- package/core/agent/agent_workspace.py +770 -0
- package/core/assets/README.md +24 -0
- package/core/assets/bugx-avatar-1024.png +0 -0
- package/core/assets/bugx-avatar-512.png +0 -0
- package/core/assets/bugx-avatar-tight.svg +23 -0
- package/core/assets/bugx-avatar.svg +28 -0
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
- package/core/assets/project-layout.md +42 -0
- package/core/audit_packs/README.md +37 -0
- package/core/audit_packs/data-audit/manifest.json +94 -0
- package/core/audit_packs/data-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/data-audit/stages/10-schema-inventory.md +14 -0
- package/core/audit_packs/data-audit/stages/20-query-and-integrity.md +14 -0
- package/core/audit_packs/data-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/desktop-audit/manifest.json +123 -0
- package/core/audit_packs/desktop-audit/stages/00-scope.md +15 -0
- package/core/audit_packs/desktop-audit/stages/10-process-model.md +14 -0
- package/core/audit_packs/desktop-audit/stages/20-package-integrity.md +15 -0
- package/core/audit_packs/desktop-audit/stages/30-ui-behavior.md +14 -0
- package/core/audit_packs/desktop-audit/stages/80-evidence-regression.md +15 -0
- package/core/audit_packs/memory-testing.md +227 -0
- package/core/audit_packs/mobile-audit/manifest.json +155 -0
- package/core/audit_packs/mobile-audit/modules/android.md +19 -0
- package/core/audit_packs/mobile-audit/modules/h5.md +18 -0
- package/core/audit_packs/mobile-audit/modules/ios.md +25 -0
- package/core/audit_packs/mobile-audit/modules/miniprogram.md +26 -0
- package/core/audit_packs/mobile-audit/modules/webview.md +18 -0
- package/core/audit_packs/mobile-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/mobile-audit/stages/10-platform-inventory.md +14 -0
- package/core/audit_packs/mobile-audit/stages/20-masvs-static.md +20 -0
- package/core/audit_packs/mobile-audit/stages/30-component-exposure.md +14 -0
- package/core/audit_packs/mobile-audit/stages/40-device-behavior.md +14 -0
- package/core/audit_packs/mobile-audit/stages/80-evidence-regression.md +13 -0
- package/core/audit_packs/native-audit/manifest.json +127 -0
- package/core/audit_packs/native-audit/stages/00-scope.md +14 -0
- package/core/audit_packs/native-audit/stages/10-static-white-box.md +14 -0
- package/core/audit_packs/native-audit/stages/20-memory-concurrency.md +15 -0
- package/core/audit_packs/native-audit/stages/30-behavior-black-box.md +39 -0
- package/core/audit_packs/native-audit/stages/80-evidence-regression.md +14 -0
- package/core/audit_packs/platform-testing.md +174 -0
- package/core/audit_packs/web-audit/manifest.json +191 -0
- package/core/audit_packs/web-audit/modules/graphql.md +5 -0
- package/core/audit_packs/web-audit/modules/h5.md +18 -0
- package/core/audit_packs/web-audit/modules/multi-tenant.md +4 -0
- package/core/audit_packs/web-audit/modules/oauth.md +4 -0
- package/core/audit_packs/web-audit/modules/upload.md +4 -0
- package/core/audit_packs/web-audit/modules/websocket.md +4 -0
- package/core/audit_packs/web-audit/stages/00-scope.md +13 -0
- package/core/audit_packs/web-audit/stages/10-discovery.md +13 -0
- package/core/audit_packs/web-audit/stages/20-auth-session.md +13 -0
- package/core/audit_packs/web-audit/stages/30-authz-business.md +13 -0
- package/core/audit_packs/web-audit/stages/40-input-output.md +13 -0
- package/core/audit_packs/web-audit/stages/50-state-async.md +13 -0
- package/core/audit_packs/web-audit/stages/60-file-ssrf-deser.md +12 -0
- package/core/audit_packs/web-audit/stages/70-config-dependency.md +12 -0
- package/core/audit_packs/web-audit/stages/80-evidence-regression.md +12 -0
- package/core/autonomous_cve/INTERFACE.md +61 -0
- package/core/autonomous_cve/README.md +58 -0
- package/core/autonomous_cve/SPEC.md +25 -0
- package/core/autonomous_cve/__init__.py +109 -0
- package/core/autonomous_cve/attack_graph.py +1096 -0
- package/core/autonomous_cve/attack_graph_store.py +1822 -0
- package/core/autonomous_cve/audit_campaign.py +1232 -0
- package/core/autonomous_cve/behavior_graph.py +459 -0
- package/core/autonomous_cve/ghsa_advisories.py +174 -0
- package/core/autonomous_cve/models.py +93 -0
- package/core/autonomous_cve/mutator.py +87 -0
- package/core/autonomous_cve/patcher.py +126 -0
- package/core/autonomous_cve/scout.py +278 -0
- package/core/autonomous_cve/synthesizer.py +207 -0
- package/core/autonomous_cve/verifier.py +100 -0
- package/core/bugx.md +1299 -0
- package/core/bugx_paths.py +1846 -0
- package/core/cloud_sync/INTERFACE.md +32 -0
- package/core/cloud_sync/README.md +62 -0
- package/core/cloud_sync/SPEC.md +25 -0
- package/core/cloud_sync/__init__.py +23 -0
- package/core/cloud_sync/auto_sync.py +398 -0
- package/core/cloud_sync/cloud_client.py +1199 -0
- package/core/cloud_sync/cloud_onboard.py +702 -0
- package/core/cloud_sync/cloud_schema.py +648 -0
- package/core/cloud_sync/consent.py +81 -0
- package/core/cloud_sync/device_identity.py +307 -0
- package/core/cloud_sync/endpoint_router.py +415 -0
- package/core/cloud_sync/flywheel_client.py +760 -0
- package/core/cloud_sync/network_transport.py +275 -0
- package/core/cloud_sync/onboard_wizard.py +493 -0
- package/core/cloud_sync/sensitive_filter.py +285 -0
- package/core/cloud_sync/sync_pull.py +695 -0
- package/core/cloud_sync/sync_push.py +721 -0
- package/core/contracts/AGENT_GUIDE.md +362 -0
- package/core/contracts/README.md +34 -0
- package/core/contracts/bugx-blackbox.md +541 -0
- package/core/contracts/bugx-opencode.md +469 -0
- package/core/contracts/bugx-quick.md +44 -0
- package/core/contracts/bugx-runtime-contract.md +353 -0
- package/core/contracts/bugx-worker.md +470 -0
- package/core/contracts/engine_gap_contracts.py +390 -0
- package/core/coverage/README.md +70 -0
- package/core/coverage/__init__.py +106 -0
- package/core/coverage/coverage_ai_review.py +185 -0
- package/core/coverage/coverage_backfill.py +54 -0
- package/core/coverage/coverage_bootstrap.py +713 -0
- package/core/coverage/coverage_business.py +36 -0
- package/core/coverage/coverage_cli.py +715 -0
- package/core/coverage/coverage_discovery.py +859 -0
- package/core/coverage/coverage_evidence.py +977 -0
- package/core/coverage/coverage_forensics.py +115 -0
- package/core/coverage/coverage_gate.py +277 -0
- package/core/coverage/coverage_intelligence.py +734 -0
- package/core/coverage/coverage_manifest.py +396 -0
- package/core/coverage/coverage_platform.py +77 -0
- package/core/coverage/coverage_validate.py +236 -0
- package/core/coverage/module_coverage.py +157 -0
- package/core/dev_harness/INTERFACE.md +20 -0
- package/core/dev_harness/README.md +21 -0
- package/core/dev_harness/SPEC.md +25 -0
- package/core/dev_harness/__init__.py +5 -0
- package/core/dev_harness/interaction_preset.py +408 -0
- package/core/engine-integrity.json +2625 -0
- package/core/fuzzing/README.md +49 -0
- package/core/fuzzing/__init__.py +82 -0
- package/core/fuzzing/concurrency_fuzzer.py +382 -0
- package/core/fuzzing/differential_oracle.py +629 -0
- package/core/fuzzing/fuzz_input.py +1188 -0
- package/core/fuzzing/stateful_fuzzer.py +332 -0
- package/core/governance/README.md +61 -0
- package/core/governance/__init__.py +130 -0
- package/core/governance/capacity_planner.py +124 -0
- package/core/governance/dependency_lock.py +317 -0
- package/core/governance/goal_governor.py +754 -0
- package/core/governance/guide_budget.py +458 -0
- package/core/governance/lockdown.sh +50 -0
- package/core/governance/readonly_enforcer.py +154 -0
- package/core/governance/runtime_tool_gate.py +373 -0
- package/core/governance/secret_redactor.py +772 -0
- package/core/governance/token_budget.py +38 -0
- package/core/host_acp/INTERFACE.md +36 -0
- package/core/host_acp/README.md +51 -0
- package/core/host_acp/SPEC.md +25 -0
- package/core/host_acp/__init__.py +121 -0
- package/core/host_acp/base.py +111 -0
- package/core/host_acp/claude.py +41 -0
- package/core/host_acp/cline.py +235 -0
- package/core/host_acp/codex.py +245 -0
- package/core/host_acp/dsh.py +48 -0
- package/core/host_acp/opencode.py +154 -0
- package/core/host_acp/pi.py +36 -0
- package/core/host_acp/zcode.py +41 -0
- package/core/host_runtime/INTERFACE.md +24 -0
- package/core/host_runtime/README.md +62 -0
- package/core/host_runtime/SPEC.md +25 -0
- package/core/host_runtime/__init__.py +21 -0
- package/core/host_runtime/adapters.py +412 -0
- package/core/host_runtime/autonomous_runner.py +1152 -0
- package/core/host_runtime/cline.py +435 -0
- package/core/host_runtime/common.py +103 -0
- package/core/host_runtime/free_models.py +786 -0
- package/core/host_runtime/host_bootstrap.py +389 -0
- package/core/host_runtime/host_evaluators.py +721 -0
- package/core/host_runtime/host_probe.py +41 -0
- package/core/host_runtime/host_provider_arbitrator.py +777 -0
- package/core/host_runtime/host_registry.py +655 -0
- package/core/host_runtime/host_usage.py +127 -0
- package/core/host_runtime/mcp_process_tracker.py +509 -0
- package/core/host_runtime/mcp_registry_gate.py +368 -0
- package/core/hosts/INTERFACE.md +51 -0
- package/core/hosts/README.md +67 -0
- package/core/hosts/SPEC.md +25 -0
- package/core/hosts/__init__.py +136 -0
- package/core/hosts/_base_usage.py +152 -0
- package/core/hosts/_codex_usage.py +297 -0
- package/core/hosts/_dsh_usage.py +184 -0
- package/core/hosts/_mcp_toml.py +365 -0
- package/core/hosts/_zcode_usage.py +269 -0
- package/core/hosts/base.py +451 -0
- package/core/hosts/claude.py +157 -0
- package/core/hosts/cline.py +225 -0
- package/core/hosts/codex.py +948 -0
- package/core/hosts/dsh.py +518 -0
- package/core/hosts/opencode.py +358 -0
- package/core/hosts/pi.py +151 -0
- package/core/hosts/zcode.py +219 -0
- package/core/i18n.py +252 -0
- package/core/infra/README.md +39 -0
- package/core/infra/__init__.py +15 -0
- package/core/infra/build_info.py +86 -0
- package/core/infra/client_metadata.py +185 -0
- package/core/infra/python_runtime.py +540 -0
- package/core/infra/safe_xml.py +221 -0
- package/core/launch_bugx.py +118 -0
- package/core/launch_phases/INTERFACE.md +31 -0
- package/core/launch_phases/README.md +106 -0
- package/core/launch_phases/SPEC.md +25 -0
- package/core/launch_phases/__init__.py +29 -0
- package/core/launch_phases/candidate_revalidation.py +484 -0
- package/core/launch_phases/common.py +1041 -0
- package/core/launch_phases/finding_confirm_phase.py +387 -0
- package/core/launch_phases/finding_settlement.py +1245 -0
- package/core/launch_phases/findings_adjudication.py +666 -0
- package/core/launch_phases/findings_snapshot.py +357 -0
- package/core/launch_phases/judge_phase.py +791 -0
- package/core/launch_phases/lesson_context.py +536 -0
- package/core/launch_phases/lifecycle_reporter.py +627 -0
- package/core/launch_phases/orchestrator_controls.py +682 -0
- package/core/launch_phases/post_commit.py +567 -0
- package/core/launch_phases/post_coverage_sync.py +591 -0
- package/core/launch_phases/post_dry_run.py +817 -0
- package/core/launch_phases/post_observability.py +367 -0
- package/core/launch_phases/post_phase.py +1087 -0
- package/core/launch_phases/post_receipt.py +362 -0
- package/core/launch_phases/post_round_lifecycle.py +786 -0
- package/core/launch_phases/pre_phase.py +1029 -0
- package/core/launch_phases/pre_recon_scout.py +862 -0
- package/core/launch_phases/pre_state_builder.py +1286 -0
- package/core/launch_phases/report_sharing.py +414 -0
- package/core/launch_phases/round_orchestrator.py +1133 -0
- package/core/launch_phases/session_runtime.py +1623 -0
- package/core/launch_phases/startup_gates.py +1022 -0
- package/core/launch_phases/startup_interaction.py +947 -0
- package/core/launch_phases/startup_version_gate.py +873 -0
- package/core/launch_phases/supervisor_bridge.py +1224 -0
- package/core/launch_phases/supervisor_coverage.py +417 -0
- package/core/launch_phases/supervisor_degraded.py +1219 -0
- package/core/launch_phases/worker_barriers.py +414 -0
- package/core/launch_phases/worker_orchestrator.py +1166 -0
- package/core/launch_phases/worker_prior.py +749 -0
- package/core/ledger/INTERFACE.md +35 -0
- package/core/ledger/README.md +160 -0
- package/core/ledger/SPEC.md +25 -0
- package/core/ledger/__init__.py +67 -0
- package/core/ledger/_facade.py +226 -0
- package/core/ledger/archive_ops.py +572 -0
- package/core/ledger/auto_materialization.py +459 -0
- package/core/ledger/bug-log.md +22 -0
- package/core/ledger/cli.py +270 -0
- package/core/ledger/export_ops.py +549 -0
- package/core/ledger/finding_confirmation.py +1274 -0
- package/core/ledger/finding_io.py +299 -0
- package/core/ledger/finding_lifecycle.py +307 -0
- package/core/ledger/finding_verification.py +369 -0
- package/core/ledger/incidents.py +999 -0
- package/core/ledger/lesson-replay-cases.json +20 -0
- package/core/ledger/lesson_ledger.py +241 -0
- package/core/ledger/lesson_replay.py +272 -0
- package/core/ledger/life_ledger.py +668 -0
- package/core/ledger/mistake-book.md +130 -0
- package/core/ledger/patterns.py +681 -0
- package/core/ledger/receipt_contract.py +253 -0
- package/core/ledger/schema.py +1192 -0
- package/core/ledger/sync_ops.py +935 -0
- package/core/ledger/tool_experience.py +682 -0
- package/core/ledger/verify_life.py +1526 -0
- package/core/lesson-ledger.json +275 -0
- package/core/locales/README.md +19 -0
- package/core/locales/en-US.json +462 -0
- package/core/locales/zh-CN.json +462 -0
- package/core/mcp_handlers/INTERFACE.md +75 -0
- package/core/mcp_handlers/README.md +62 -0
- package/core/mcp_handlers/SPEC.md +25 -0
- package/core/mcp_handlers/__init__.py +128 -0
- package/core/mcp_handlers/base.py +697 -0
- package/core/mcp_handlers/channel_lifecycle.py +696 -0
- package/core/mcp_handlers/graph_handlers.py +222 -0
- package/core/mcp_handlers/knowledge_handlers.py +536 -0
- package/core/mcp_handlers/mining_handlers.py +586 -0
- package/core/mcp_handlers/resource_prompt_table.py +116 -0
- package/core/mcp_handlers/retrieval_handlers.py +239 -0
- package/core/mcp_handlers/rpc_server.py +465 -0
- package/core/mcp_handlers/supervisor_handlers.py +1435 -0
- package/core/mcp_handlers/telemetry_handlers.py +227 -0
- package/core/mcp_handlers/tool_table.py +1015 -0
- package/core/mcp_runtime_support/README.md +21 -0
- package/core/mcp_runtime_support/__init__.py +1 -0
- package/core/mcp_runtime_support/common.py +363 -0
- package/core/mcp_runtime_support/environment.py +605 -0
- package/core/mcp_runtime_support/verifier.py +810 -0
- package/core/metadata.txt +5 -0
- package/core/planning/README.md +157 -0
- package/core/planning/__init__.py +242 -0
- package/core/planning/capability_plan.py +187 -0
- package/core/planning/capability_planner.py +195 -0
- package/core/planning/domain_archetype.py +542 -0
- package/core/planning/domain_router.py +267 -0
- package/core/planning/dynamic_flow_analyzer.py +328 -0
- package/core/planning/impact_pruner.py +435 -0
- package/core/planning/intent_adjudicator.py +175 -0
- package/core/planning/judge_pipeline.py +1163 -0
- package/core/planning/logic_analysis.py +419 -0
- package/core/planning/prompt_harness.py +1702 -0
- package/core/planning/source_inspector.py +267 -0
- package/core/planning/spec_harvester.py +449 -0
- package/core/planning/target_sandbox_manager.py +573 -0
- package/core/planning/test_capability_verifier.py +1364 -0
- package/core/planning/tools-kb.md +38 -0
- package/core/planning/unit_kind.py +122 -0
- package/core/probes/INTERFACE.md +73 -0
- package/core/probes/README.md +51 -0
- package/core/probes/SPEC.md +26 -0
- package/core/probes/__init__.py +70 -0
- package/core/probes/android_probe.py +384 -0
- package/core/probes/base.py +147 -0
- package/core/probes/codebase_memory_probe.py +590 -0
- package/core/probes/desktop_probe.py +238 -0
- package/core/probes/differential_probe.py +356 -0
- package/core/probes/efficiency_probe.py +168 -0
- package/core/probes/ios_binary_probe.py +368 -0
- package/core/probes/memory_probe.py +326 -0
- package/core/probes/miniprogram_probe.py +323 -0
- package/core/probes/mobile_probe.py +281 -0
- package/core/probes/native_probe.py +214 -0
- package/core/probes/openwiki_probe.py +193 -0
- package/core/probes/pattern_probe.py +347 -0
- package/core/probes/platform_probe.py +343 -0
- package/core/probes/probe_registry.py +1669 -0
- package/core/probes/sast_probe.py +1009 -0
- package/core/probes/sast_rules.py +841 -0
- package/core/probes/sca_scanner.py +731 -0
- package/core/probes/web_probe.py +359 -0
- package/core/project_profiler/INTERFACE.md +62 -0
- package/core/project_profiler/README.md +53 -0
- package/core/project_profiler/SPEC.md +28 -0
- package/core/project_profiler/__init__.py +201 -0
- package/core/project_profiler/arbitrator.py +311 -0
- package/core/project_profiler/constants.py +247 -0
- package/core/project_profiler/detector.py +392 -0
- package/core/project_profiler/extractors.py +836 -0
- package/core/project_profiler/fingerprint.py +116 -0
- package/core/project_profiler/storage.py +258 -0
- package/core/project_profiler/strategy.py +265 -0
- package/core/prompts/README.md +35 -0
- package/core/prompts/codex_dialog_dispatch.md +9 -0
- package/core/prompts/command_routing_en.md +42 -0
- package/core/prompts/command_routing_zh.md +42 -0
- package/core/prompts/l0_router.md +47 -0
- package/core/prompts/rules/anti_patterns.md +16 -0
- package/core/prompts/rules/concurrency_rules.md +14 -0
- package/core/prompts/rules/memory_leak_rules.md +13 -0
- package/core/prompts/rules/prompt_injection_defense.md +13 -0
- package/core/prompts/stages/stage_explore.md +31 -0
- package/core/prompts/stages/stage_gate.md +43 -0
- package/core/prompts/stages/stage_mutate.md +42 -0
- package/core/prompts/stages/stage_repair.md +85 -0
- package/core/repair/README.md +74 -0
- package/core/repair/__init__.py +169 -0
- package/core/repair/fix_watchlist.py +391 -0
- package/core/repair/l7_dynamic.py +418 -0
- package/core/repair/l7_repair_loop.py +465 -0
- package/core/repair/l7_selfcheck.py +862 -0
- package/core/repair/minimize_repro.py +466 -0
- package/core/repair/patch_synthesizer.py +617 -0
- package/core/repair/regression_pack.py +379 -0
- package/core/repair/rsi_fixer.py +910 -0
- package/core/repair/rsi_loop.py +313 -0
- package/core/repair/rsi_repair.py +348 -0
- package/core/repair/rsi_rounds.py +212 -0
- package/core/repair/rsi_scope.py +262 -0
- package/core/repair/self_heal.py +604 -0
- package/core/repair/test_generator.py +1108 -0
- package/core/repair/test_quality_auditor.py +410 -0
- package/core/repair/test_strategy.py +511 -0
- package/core/report_engine/INTERFACE.md +59 -0
- package/core/report_engine/README.md +69 -0
- package/core/report_engine/SPEC.md +28 -0
- package/core/report_engine/__init__.py +47 -0
- package/core/report_engine/attestation.py +224 -0
- package/core/report_engine/authority.py +255 -0
- package/core/report_engine/finding_report.py +417 -0
- package/core/report_engine/formal_report_builder.py +924 -0
- package/core/report_engine/html_renderers.py +696 -0
- package/core/report_engine/models.py +761 -0
- package/core/report_engine/pdf_exporter.py +231 -0
- package/core/report_engine/projects_assets.py +730 -0
- package/core/report_engine/report_client.py +743 -0
- package/core/report_engine/report_data_builder.py +388 -0
- package/core/report_engine/report_share.py +459 -0
- package/core/report_engine/sast_bridge.py +116 -0
- package/core/report_engine/server.py +822 -0
- package/core/report_engine/visual_report_builder.py +796 -0
- package/core/report_engine/web-conformance.md +63 -0
- package/core/report_engine/web_conformance.py +459 -0
- package/core/report_engine/workbench_assets.py +484 -0
- package/core/retrieval/INTERFACE.md +20 -0
- package/core/retrieval/README.md +161 -0
- package/core/retrieval/SPEC.md +25 -0
- package/core/retrieval/__init__.py +3 -0
- package/core/retrieval/code_analyzer.py +1684 -0
- package/core/retrieval/codebase_memory_bridge.py +337 -0
- package/core/retrieval/context_assembler.py +234 -0
- package/core/retrieval/corpus_fetch.py +369 -0
- package/core/retrieval/graph_ego.py +597 -0
- package/core/retrieval/knowledge_auto.py +662 -0
- package/core/retrieval/knowledge_sources.py +168 -0
- package/core/retrieval/knowledge_sync.py +909 -0
- package/core/retrieval/memory_store.py +480 -0
- package/core/retrieval/query_planner.py +1020 -0
- package/core/retrieval/rrf_engine.py +137 -0
- package/core/retrieval/slice_extractor.py +1209 -0
- package/core/retrieval/slice_normalizer.py +373 -0
- package/core/retrieval/slice_spec.py +357 -0
- package/core/retrieval/symbol_index.py +1132 -0
- package/core/retrieval/universal_code_matcher.py +437 -0
- package/core/retrieval/xerj_bridge.py +476 -0
- package/core/retrieval/xerj_supervisor.py +362 -0
- package/core/rules/README.md +33 -0
- package/core/rules/ios/PROVENANCE.json +30 -0
- package/core/rules/ios/crypto.yaml +36 -0
- package/core/rules/ios/network.yaml +20 -0
- package/core/rules/ios/resilience.yaml +47 -0
- package/core/rules/ios/storage.yaml +48 -0
- package/core/rules/mastg/LICENSE +173 -0
- package/core/rules/mastg/PROVENANCE.json +270 -0
- package/core/rules/mastg/mastg-android-asymmetric-key-pair-used-for-multiple-purposes.yml +13 -0
- package/core/rules/mastg/mastg-android-backup-manifest.yml +24 -0
- package/core/rules/mastg/mastg-android-biometric-event-bound.yml +49 -0
- package/core/rules/mastg/mastg-android-biometric-invalidated-enrollment.yml +11 -0
- package/core/rules/mastg/mastg-android-biometric-no-confirmation-required.yml +10 -0
- package/core/rules/mastg/mastg-android-biometric-validity-duration.yml +24 -0
- package/core/rules/mastg/mastg-android-broken-encryption-algorithms.yaml +9 -0
- package/core/rules/mastg/mastg-android-broken-encryption-modes.yaml +13 -0
- package/core/rules/mastg/mastg-android-content-provider-exported.yml +35 -0
- package/core/rules/mastg/mastg-android-custom-deeplink-scheme.yml +29 -0
- package/core/rules/mastg/mastg-android-dangerous-app-permissions.yaml +65 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-apis.yml +36 -0
- package/core/rules/mastg/mastg-android-data-unencrypted-shared-storage-no-user-interaction-manifest.yml +15 -0
- package/core/rules/mastg/mastg-android-debuggable-flag.yml +10 -0
- package/core/rules/mastg/mastg-android-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-deeplink-autoverify-missing.yml +33 -0
- package/core/rules/mastg/mastg-android-deeplink-unvalidated-parameter.yml +11 -0
- package/core/rules/mastg/mastg-android-device-passcode-present.yml +17 -0
- package/core/rules/mastg/mastg-android-fileprovider-broad-scope.yml +46 -0
- package/core/rules/mastg/mastg-android-hardcoded-crypto-keys-usage.yml +14 -0
- package/core/rules/mastg/mastg-android-hardcoded-security-provider.yaml +18 -0
- package/core/rules/mastg/mastg-android-implicit-intent-internal-communication.yml +30 -0
- package/core/rules/mastg/mastg-android-implicit-intent-leaking-extras.yml +29 -0
- package/core/rules/mastg/mastg-android-input-field-usage.yml +11 -0
- package/core/rules/mastg/mastg-android-key-generation-with-insufficient-key-length.yml +21 -0
- package/core/rules/mastg/mastg-android-keyboard-cache-input-types.yml +10 -0
- package/core/rules/mastg/mastg-android-local-storage-input-validation.yml +48 -0
- package/core/rules/mastg/mastg-android-native-debugger-checks.yml +12 -0
- package/core/rules/mastg/mastg-android-network-checkservertrusted.yml +12 -0
- package/core/rules/mastg/mastg-android-network-hostname-verification.yml +11 -0
- package/core/rules/mastg/mastg-android-network-insecure-trust-anchors.yml +11 -0
- package/core/rules/mastg/mastg-android-network-onreceivedsslerror.yml +12 -0
- package/core/rules/mastg/mastg-android-non-random-use.yml +16 -0
- package/core/rules/mastg/mastg-android-object-deserialization.yml +14 -0
- package/core/rules/mastg/mastg-android-overlay-protection.yml +68 -0
- package/core/rules/mastg/mastg-android-pendingintent-mutable.yml +39 -0
- package/core/rules/mastg/mastg-android-random-apis-insufficient-entropy.yml +17 -0
- package/core/rules/mastg/mastg-android-root-detection.yaml +59 -0
- package/core/rules/mastg/mastg-android-sdk-version.yml +10 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications-manifest.yml +17 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-notifications.yml +11 -0
- package/core/rules/mastg/mastg-android-sensitive-data-in-screenshot.yml +18 -0
- package/core/rules/mastg/mastg-android-sql-injection-contentprovider.yml +17 -0
- package/core/rules/mastg/mastg-android-ssl-socket-hostnameverifier.yml +15 -0
- package/core/rules/mastg/mastg-android-strictmode.yml +10 -0
- package/core/rules/mastg/mastg-android-system-alert-window.yml +9 -0
- package/core/rules/mastg/mastg-android-webview-allow-local-access.yml +15 -0
- package/core/rules/mastg/mastg-android-webview-bridges.yml +28 -0
- package/core/rules/mastg/mastg-android-webview-safebrowsing.yml +20 -0
- package/core/rules/mastg/mastg-android-webview-url-handlers.yml +41 -0
- package/core/rules/miniprogram/PROVENANCE.json +26 -0
- package/core/rules/miniprogram/network.yaml +37 -0
- package/core/rules/miniprogram/platform.yaml +36 -0
- package/core/rules/miniprogram/storage.yaml +48 -0
- package/core/rules/mobsfscan-swift/LICENSE +165 -0
- package/core/rules/mobsfscan-swift/PROVENANCE.json +58 -0
- package/core/rules/mobsfscan-swift/auth.yaml +59 -0
- package/core/rules/mobsfscan-swift/crypto.yaml +66 -0
- package/core/rules/mobsfscan-swift/jailbreak.yaml +14 -0
- package/core/rules/mobsfscan-swift/keyboard.yaml +34 -0
- package/core/rules/mobsfscan-swift/logging.yaml +23 -0
- package/core/rules/mobsfscan-swift/network.yaml +55 -0
- package/core/rules/mobsfscan-swift/resilience.yaml +29 -0
- package/core/rules/mobsfscan-swift/secrets.yaml +33 -0
- package/core/rules/mobsfscan-swift/storage.yaml +29 -0
- package/core/rules/mobsfscan-swift/webview.yaml +32 -0
- package/core/runtime/README.md +198 -0
- package/core/runtime/__init__.py +3 -0
- package/core/runtime/bugx_logging.py +1393 -0
- package/core/runtime/daemon_runner.py +623 -0
- package/core/runtime/fixture_solidify.py +449 -0
- package/core/runtime/global_telemetry.py +549 -0
- package/core/runtime/incident_eval.py +148 -0
- package/core/runtime/interaction.py +605 -0
- package/core/runtime/interaction_store.py +435 -0
- package/core/runtime/interactive_menu.py +95 -0
- package/core/runtime/log_analytics.py +922 -0
- package/core/runtime/mining_quality_framework.py +1387 -0
- package/core/runtime/model_runner.py +769 -0
- package/core/runtime/platform_adapter.py +579 -0
- package/core/runtime/prep_validate.py +476 -0
- package/core/runtime/project_graph.py +827 -0
- package/core/runtime/project_init.py +481 -0
- package/core/runtime/project_profile.py +224 -0
- package/core/runtime/project_settings.py +963 -0
- package/core/runtime/provider_window.py +97 -0
- package/core/runtime/resume_ticket.py +115 -0
- package/core/runtime/scenario_eval.py +814 -0
- package/core/runtime/seed_drill.py +549 -0
- package/core/runtime/self_audit.py +550 -0
- package/core/runtime/session_profile.py +205 -0
- package/core/runtime/setup_ui_env.py +229 -0
- package/core/runtime/startup_environment.py +859 -0
- package/core/runtime/sync_store.py +1421 -0
- package/core/runtime/tool_install_targets.py +18 -0
- package/core/schemas/README.md +35 -0
- package/core/schemas/agent-graph.schema.json +368 -0
- package/core/schemas/attack-graph.schema.json +88 -0
- package/core/schemas/evidence-bundle.schema.json +33 -0
- package/core/schemas/skill-pack.schema.json +230 -0
- package/core/schemas/worker-checkpoint.schema.json +119 -0
- package/core/secure_atomic.py +289 -0
- package/core/seed_corpus/README.md +55 -0
- package/core/seed_corpus/c.txt +29 -0
- package/core/seed_corpus/cpp.txt +32 -0
- package/core/seed_corpus/css.txt +70 -0
- package/core/seed_corpus/go.txt +46 -0
- package/core/seed_corpus/java.txt +30 -0
- package/core/seed_corpus/javascript.txt +55 -0
- package/core/seed_corpus/kotlin.txt +28 -0
- package/core/seed_corpus/python.txt +71 -0
- package/core/seed_corpus/rust.txt +53 -0
- package/core/seed_corpus/swift.txt +29 -0
- package/core/seed_corpus/typescript.txt +29 -0
- package/core/skills/README.md +53 -0
- package/core/skills/__init__.py +189 -0
- package/core/skills/bugx_docs_mcp_server.py +416 -0
- package/core/skills/bugx_mcp_server.py +1134 -0
- package/core/skills/mcp_runtime.py +968 -0
- package/core/skills/mcp_session_proof.py +605 -0
- package/core/skills/mobile_ui_inspector.py +405 -0
- package/core/skills/skill_pack.py +1214 -0
- package/core/skills/skill_synthesizer.py +1153 -0
- package/core/skills/tools_kb.py +313 -0
- package/core/supervisor/INTERFACE.md +121 -0
- package/core/supervisor/README.md +209 -0
- package/core/supervisor/SPEC.md +25 -0
- package/core/supervisor/__init__.py +175 -0
- package/core/supervisor/audit_supervisor.py +1015 -0
- package/core/supervisor/budget_governor.py +760 -0
- package/core/supervisor/checkpoint_handler.py +368 -0
- package/core/supervisor/checkpoint_pipeline.py +1322 -0
- package/core/supervisor/checkpoint_sync.py +640 -0
- package/core/supervisor/claim_events.py +74 -0
- package/core/supervisor/claim_sync.py +590 -0
- package/core/supervisor/cli.py +812 -0
- package/core/supervisor/context_sync.py +55 -0
- package/core/supervisor/coverage_sync.py +115 -0
- package/core/supervisor/finding_commit.py +470 -0
- package/core/supervisor/finding_sync.py +688 -0
- package/core/supervisor/finding_workflow.py +659 -0
- package/core/supervisor/finish_policy.py +224 -0
- package/core/supervisor/finish_sync.py +185 -0
- package/core/supervisor/graph_sync.py +669 -0
- package/core/supervisor/lease_manager.py +788 -0
- package/core/supervisor/lifecycle_blocks.py +124 -0
- package/core/supervisor/next_round_sync.py +126 -0
- package/core/supervisor/observability.py +140 -0
- package/core/supervisor/recovery_sync.py +165 -0
- package/core/supervisor/rejection_remedies.py +308 -0
- package/core/supervisor/round_governor.py +306 -0
- package/core/supervisor/serial_authorization.py +500 -0
- package/core/supervisor/start_sync.py +87 -0
- package/core/supervisor/state_store.py +249 -0
- package/core/supervisor/supervisor_host.py +511 -0
- package/core/supervisor/supervisor_models.py +1143 -0
- package/core/supervisor/systemic_failure.py +104 -0
- package/core/supervisor/task_scheduler.py +1640 -0
- package/core/supervisor/worker_checkpoint.py +223 -0
- package/core/supervisor/worker_execution.py +265 -0
- package/core/supervisor/worker_handoff.py +192 -0
- package/core/supervisor/worker_lifecycle.py +396 -0
- package/core/supervisor/worker_runtime.py +999 -0
- package/core/supervisor/worker_sync.py +89 -0
- package/core/supervisor_types/README.md +36 -0
- package/core/supervisor_types/__init__.py +0 -0
- package/core/supervisor_types/exceptions.py +52 -0
- package/core/supervisor_types/graph_models.py +357 -0
- package/core/supervisor_types/path_containment.py +151 -0
- package/core/supervisor_types/target_fingerprint.py +310 -0
- package/core/supervisor_types/worker_claim.py +402 -0
- package/core/webui/INTERFACE.md +50 -0
- package/core/webui/README.md +57 -0
- package/core/webui/SPEC.md +25 -0
- package/core/webui/__init__.py +11 -0
- package/core/webui/adapters/__init__.py +27 -0
- package/core/webui/adapters/base.py +87 -0
- package/core/webui/adapters/bugx.py +102 -0
- package/core/webui/adapters/claude.py +218 -0
- package/core/webui/adapters/cline.py +399 -0
- package/core/webui/adapters/codex.py +256 -0
- package/core/webui/adapters/dsh.py +173 -0
- package/core/webui/adapters/opencode.py +218 -0
- package/core/webui/adapters/pi.py +272 -0
- package/core/webui/adapters/registry.py +100 -0
- package/core/webui/adapters/zcode.py +312 -0
- package/core/webui/api_routes_post.py +668 -0
- package/core/webui/dispatcher.py +1376 -0
- package/core/webui/docs_session_service.py +473 -0
- package/core/webui/handler.py +674 -0
- package/core/webui/ide_cloud_service.py +526 -0
- package/core/webui/mcp_inspector.py +1743 -0
- package/core/webui/static/assets/index-CXAsl8mr.js +333 -0
- package/core/webui/static/assets/index-DHQUtWtx.css +1 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-B8Z6Jvzv.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-400-normal-C44pakCn.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-Bb4u56_6.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-500-normal-BdVUvljg.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-CWV284fw.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-400-normal-DLkyKLvH.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-8-8HP2PF.woff +0 -0
- package/core/webui/static/assets/source-serif-4-cyrillic-ext-500-normal-DaDZE_Na.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-BccYJ-vZ.woff +0 -0
- package/core/webui/static/assets/source-serif-4-greek-400-normal-Cw5-AHNN.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-By8GFJzz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-greek-500-normal-z-Q6FFuG.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-DJ5YJwmz.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-400-normal-Dn3IlU-Z.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-CUHe9xxf.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-500-normal-DVVamBqs.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-CEpydyUl.woff +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-400-normal-Cp7z-ARB.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-BYjRCDVy.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-latin-ext-500-normal-D-qasQTj.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-BbG3LG1A.woff2 +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-400-normal-DR1UuFon.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-8N8MYVKB.woff +0 -0
- package/core/webui/static/assets/source-serif-4-vietnamese-500-normal-Bi3OSTTW.woff2 +0 -0
- package/core/webui/static/favicon.png +0 -0
- package/core/webui/static/icon-192.png +0 -0
- package/core/webui/static/index.html +42 -0
- package/core/webui/static/manifest.webmanifest +19 -0
- package/core/webui/static/project-settings.css +6458 -0
- package/core/webui/static/project-settings.js +9602 -0
- package/core/webui/static/sw.js +8 -0
- package/core/webui/workspace_service.py +218 -0
- package/docs/07_distribution/01_README_NPM.md +281 -0
- package/docs/07_distribution/README.md +16 -0
- package/docs/README.md +121 -0
- package/ecosystem/README.md +129 -0
- package/ecosystem/integrations/README.md +38 -0
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/dsh/agents/bugx.md +27 -0
- package/ecosystem/integrations/dsh/dsh-patch.yml +18 -0
- package/ecosystem/integrations/dsh/mcp/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/mcp/index.js +219 -0
- package/ecosystem/integrations/dsh/mcp/package.json +28 -0
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +70 -0
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/integrations/dsh/ui/client.js +87 -0
- package/ecosystem/integrations/dsh/ui/cordis.patch.yml +4 -0
- package/ecosystem/integrations/dsh/ui/index.js +7 -0
- package/ecosystem/integrations/dsh/ui/package.json +27 -0
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +53 -0
- package/ecosystem/integrations/opencode/mcp-lock.json +3067 -0
- package/ecosystem/integrations/opencode/opencode.json +118 -0
- package/ecosystem/integrations/pi/extensions/bugx/README.md +12 -0
- package/ecosystem/integrations/pi/extensions/bugx/index.ts +299 -0
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +11 -0
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +69 -0
- package/ecosystem/integrations/qoder/CONNECTORS.md +54 -0
- package/ecosystem/integrations/qoder/connector-meta.json +21 -0
- package/ecosystem/integrations/workbuddy/connector-meta.json +19 -0
- package/ecosystem/integrations/workbuddy/icon.png +0 -0
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +70 -0
- package/ecosystem/plugins/README.md +37 -0
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +17 -0
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +16 -0
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +41 -0
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +19 -0
- package/ecosystem/plugins/bugx/agents/bugx-judge.md +71 -0
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +31 -0
- package/ecosystem/plugins/bugx/agents/bugx.md +74 -0
- package/ecosystem/plugins/bugx/assets/bugx-avatar-512.png +0 -0
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +118 -0
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +326 -0
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +229 -0
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +129 -0
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +459 -0
- package/interfaces/README.md +143 -0
- package/interfaces/bin/README.md +35 -0
- package/interfaces/bin/bugx.js +80 -0
- package/interfaces/cli/README.md +90 -0
- package/interfaces/cli/bugx_cli/__init__.py +4 -0
- package/interfaces/cli/bugx_cli/cli.py +1678 -0
- package/interfaces/cli/bugx_cli/commands/__init__.py +1 -0
- package/interfaces/cli/bugx_cli/commands/advisory.py +94 -0
- package/interfaces/cli/bugx_cli/commands/agent.py +3944 -0
- package/interfaces/cli/bugx_cli/commands/audit.py +632 -0
- package/interfaces/cli/bugx_cli/commands/autonomous.py +260 -0
- package/interfaces/cli/bugx_cli/commands/cloud.py +1370 -0
- package/interfaces/cli/bugx_cli/commands/daemon.py +50 -0
- package/interfaces/cli/bugx_cli/commands/doctor.py +1345 -0
- package/interfaces/cli/bugx_cli/commands/goal.py +107 -0
- package/interfaces/cli/bugx_cli/commands/interaction.py +244 -0
- package/interfaces/cli/bugx_cli/commands/knowledge.py +617 -0
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +2763 -0
- package/interfaces/cli/bugx_cli/commands/patch.py +1014 -0
- package/interfaces/cli/bugx_cli/commands/plugin.py +2714 -0
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +1446 -0
- package/interfaces/cli/bugx_cli/commands/plugin_cline.py +269 -0
- package/interfaces/cli/bugx_cli/commands/plugin_codex.py +74 -0
- package/interfaces/cli/bugx_cli/commands/plugin_funide.py +728 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +216 -0
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +710 -0
- package/interfaces/cli/bugx_cli/commands/project.py +670 -0
- package/interfaces/cli/bugx_cli/commands/report.py +260 -0
- package/interfaces/cli/bugx_cli/commands/skill.py +251 -0
- package/interfaces/cli/bugx_cli/commands/stats.py +133 -0
- package/interfaces/cli/bugx_cli/commands/system.py +2567 -0
- package/interfaces/cli/bugx_cli/common.py +898 -0
- package/interfaces/cli/bugx_cli/host_adapters.py +1917 -0
- package/interfaces/cli/bugx_cli/hosts/__init__.py +80 -0
- package/interfaces/cli/bugx_cli/hosts/base.py +99 -0
- package/interfaces/cli/bugx_cli/hosts/registry.py +571 -0
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +188 -0
- package/interfaces/cli/bugx_cli/infra/__init__.py +209 -0
- package/interfaces/cli/bugx_cli/infra/ai_advisor.py +721 -0
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +1937 -0
- package/interfaces/cli/bugx_cli/infra/host_sync.py +545 -0
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +755 -0
- package/interfaces/cli/bugx_cli/infra/security.py +332 -0
- package/package.json +98 -4
- package/pyproject.toml +246 -0
- package/scripts/README.md +118 -0
- package/scripts/ensure-python.mjs +97 -0
- package/scripts/isolate-npm-readme.mjs +40 -0
- package/scripts/runtime.lock.json +31 -0
- package/scripts/sync-version.mjs +37 -0
- package/scripts/test-npm-wrapper.mjs +265 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""core/probes/web_probe.py - Web 形态专属动态黑盒探针 (DOC-248)。
|
|
3
|
+
|
|
4
|
+
落实:
|
|
5
|
+
- AUDIT-02: Playwright 并发上限约束 (MAX_BROWSER_INSTANCES = 2) 与资源池互斥锁;
|
|
6
|
+
- AUDIT-04: 环境缺失时极速探活 (<5ms) 与自动降级为静态代码/DOM结构分析;
|
|
7
|
+
- AUDIT-05: 严禁仅凭 HTTP 500/403 定性漏洞,返回结构化四元响应:
|
|
8
|
+
(status_code, body_diff, response_time, error_stack)。
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import contextlib
|
|
14
|
+
import json
|
|
15
|
+
import os
|
|
16
|
+
import re
|
|
17
|
+
import shutil
|
|
18
|
+
import threading
|
|
19
|
+
import time
|
|
20
|
+
import urllib.error
|
|
21
|
+
import urllib.request
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Any, Mapping, Sequence
|
|
24
|
+
|
|
25
|
+
try:
|
|
26
|
+
from .base import BaseProbe
|
|
27
|
+
except ImportError:
|
|
28
|
+
from core.probes.base import BaseProbe
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class WebDynamicProbe(BaseProbe):
|
|
32
|
+
"""Web 专属黑盒动态探针,支持 HTTP 原始发包与 Playwright 无头浏览器探针。"""
|
|
33
|
+
|
|
34
|
+
MAX_BROWSER_INSTANCES: int = 2
|
|
35
|
+
_BROWSER_SEMAPHORE = threading.BoundedSemaphore(MAX_BROWSER_INSTANCES)
|
|
36
|
+
_ACTIVE_INSTANCES = 0
|
|
37
|
+
_LOCK = threading.Lock()
|
|
38
|
+
|
|
39
|
+
# 常见数据库报错特征,用于判断是否为 SQL 注入导致的 500 报错,而非普通 500
|
|
40
|
+
DATABASE_ERROR_SIGNATURES: tuple[str, ...] = (
|
|
41
|
+
"syntax error at or near",
|
|
42
|
+
"ora-00933",
|
|
43
|
+
"ora-00936",
|
|
44
|
+
"mysql_fetch_array()",
|
|
45
|
+
"you have an error in your sql syntax",
|
|
46
|
+
"sqlite3.operationalerror",
|
|
47
|
+
"unclosed quotation mark after the character string",
|
|
48
|
+
"pg_query(): query failed",
|
|
49
|
+
"microsoft ole db provider for sql server",
|
|
50
|
+
"org.hibernate.exception.sqlgrammarexception",
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# 敏感堆栈暴露签名
|
|
54
|
+
STACK_TRACE_SIGNATURES: tuple[str, ...] = (
|
|
55
|
+
"traceback (most recent call last):",
|
|
56
|
+
"at org.springframework.",
|
|
57
|
+
"exception in thread \"main\"",
|
|
58
|
+
"fatal error: uncaught exception",
|
|
59
|
+
"microsoft.aspnetcore.diagnostics.developerexceptionpage",
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# 静态 DOM XSS 危险汇聚点 (Sinks)
|
|
63
|
+
DOM_XSS_PATTERNS: tuple[tuple[str, str], ...] = (
|
|
64
|
+
(r"\.innerHTML\s*=", "DOM_XSS_INNER_HTML"),
|
|
65
|
+
(r"document\.write\s*\(", "DOM_XSS_DOCUMENT_WRITE"),
|
|
66
|
+
(r"\beval\s*\(", "DOM_XSS_EVAL"),
|
|
67
|
+
(r"v-html\s*=", "DOM_XSS_V_HTML"),
|
|
68
|
+
(r"dangerouslySetInnerHTML\s*=", "DOM_XSS_REACT_DANGEROUSLY_SET"),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def probe_name(self) -> str:
|
|
73
|
+
return "web_dynamic_probe"
|
|
74
|
+
|
|
75
|
+
def is_available(self) -> bool:
|
|
76
|
+
"""AUDIT-04: 极速探活 (<5ms,零阻塞)。"""
|
|
77
|
+
if shutil.which("playwright") is not None:
|
|
78
|
+
return True
|
|
79
|
+
try:
|
|
80
|
+
import importlib.util
|
|
81
|
+
return importlib.util.find_spec("playwright") is not None
|
|
82
|
+
except Exception:
|
|
83
|
+
return False
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
@contextlib.contextmanager
|
|
87
|
+
def browser_slot(cls, timeout: float = 2.0):
|
|
88
|
+
"""AUDIT-02: Playwright 浏览器实例资源池锁,上限 MAX_BROWSER_INSTANCES (2)。"""
|
|
89
|
+
acquired = cls._BROWSER_SEMAPHORE.acquire(timeout=timeout)
|
|
90
|
+
if not acquired:
|
|
91
|
+
raise TimeoutError(
|
|
92
|
+
f"Playwright browser instance pool exhausted (limit: {cls.MAX_BROWSER_INSTANCES})"
|
|
93
|
+
)
|
|
94
|
+
with cls._LOCK:
|
|
95
|
+
cls._ACTIVE_INSTANCES += 1
|
|
96
|
+
try:
|
|
97
|
+
yield
|
|
98
|
+
finally:
|
|
99
|
+
with cls._LOCK:
|
|
100
|
+
cls._ACTIVE_INSTANCES = max(0, cls._ACTIVE_INSTANCES - 1)
|
|
101
|
+
cls._BROWSER_SEMAPHORE.release()
|
|
102
|
+
|
|
103
|
+
@classmethod
|
|
104
|
+
def get_active_instances(cls) -> int:
|
|
105
|
+
"""获取当前活跃的无头浏览器实例数。"""
|
|
106
|
+
with cls._LOCK:
|
|
107
|
+
return cls._ACTIVE_INSTANCES
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def classify_http_response(
|
|
111
|
+
cls,
|
|
112
|
+
response_data: Mapping[str, Any],
|
|
113
|
+
baseline_data: Mapping[str, Any] | None = None,
|
|
114
|
+
) -> dict[str, Any]:
|
|
115
|
+
"""AUDIT-05: 严禁仅凭 HTTP 500/403 定性。
|
|
116
|
+
|
|
117
|
+
返回结构化响应四元组 (status_code, body_diff, response_time, error_stack)。
|
|
118
|
+
只有在明确检测到敏感堆栈泄露、数据库报错注入特征或差分越权时才裁定漏洞。
|
|
119
|
+
"""
|
|
120
|
+
status_code = int(response_data.get("status_code") or 0)
|
|
121
|
+
body = str(response_data.get("body") or "")
|
|
122
|
+
error_stack = str(response_data.get("error_stack") or "")
|
|
123
|
+
response_time = float(response_data.get("response_time") or 0.0)
|
|
124
|
+
|
|
125
|
+
# 计算响应体差分
|
|
126
|
+
baseline_body = str((baseline_data or {}).get("body") or "")
|
|
127
|
+
body_diff = ""
|
|
128
|
+
if baseline_body and body != baseline_body:
|
|
129
|
+
body_diff = f"bytes_diff: {len(body) - len(baseline_body)}"
|
|
130
|
+
|
|
131
|
+
lowered_body = body.lower()
|
|
132
|
+
lowered_stack = error_stack.lower()
|
|
133
|
+
|
|
134
|
+
is_vulnerable = False
|
|
135
|
+
vuln_type = None
|
|
136
|
+
reason = "Normal HTTP interaction"
|
|
137
|
+
|
|
138
|
+
# 1. 检查数据库报错签名泄露
|
|
139
|
+
for sig in cls.DATABASE_ERROR_SIGNATURES:
|
|
140
|
+
if sig in lowered_body or sig in lowered_stack:
|
|
141
|
+
is_vulnerable = True
|
|
142
|
+
vuln_type = "SQL_ERROR_LEAK"
|
|
143
|
+
reason = f"Database error signature leaked: '{sig}'"
|
|
144
|
+
break
|
|
145
|
+
|
|
146
|
+
# 2. 检查敏感异常堆栈泄露
|
|
147
|
+
if not is_vulnerable:
|
|
148
|
+
for sig in cls.STACK_TRACE_SIGNATURES:
|
|
149
|
+
if sig in lowered_body or sig in lowered_stack:
|
|
150
|
+
is_vulnerable = True
|
|
151
|
+
vuln_type = "STACK_TRACE_DISCLOSURE"
|
|
152
|
+
reason = f"Internal framework stack trace leaked: '{sig}'"
|
|
153
|
+
break
|
|
154
|
+
|
|
155
|
+
# 3. AUDIT-05 硬约束:若仅返回 500 或 403 且无敏感数据泄露,严禁判定为漏洞!
|
|
156
|
+
if not is_vulnerable and status_code in (500, 403):
|
|
157
|
+
reason = (
|
|
158
|
+
f"HTTP {status_code} received without sensitive data leakage "
|
|
159
|
+
"(Status Code Sole Reliance Disallowed per AUDIT-05)"
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
"status_code": status_code,
|
|
164
|
+
"body_diff": body_diff,
|
|
165
|
+
"response_time": response_time,
|
|
166
|
+
"error_stack": error_stack,
|
|
167
|
+
"is_vulnerable": is_vulnerable,
|
|
168
|
+
"vulnerability_type": vuln_type,
|
|
169
|
+
"reason": reason,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
def http_raw_request(
|
|
173
|
+
self,
|
|
174
|
+
url: str,
|
|
175
|
+
method: str = "GET",
|
|
176
|
+
headers: Mapping[str, str] | None = None,
|
|
177
|
+
data: bytes | str | None = None,
|
|
178
|
+
timeout: float = 10.0,
|
|
179
|
+
) -> dict[str, Any]:
|
|
180
|
+
"""执行原始 HTTP 网络发包,收集结构化响应指标。"""
|
|
181
|
+
req_headers = dict(headers or {})
|
|
182
|
+
req_data = data.encode("utf-8") if isinstance(data, str) else data
|
|
183
|
+
|
|
184
|
+
req = urllib.request.Request(
|
|
185
|
+
url=url,
|
|
186
|
+
data=req_data,
|
|
187
|
+
headers=req_headers,
|
|
188
|
+
method=method.upper(),
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
start_time = time.monotonic()
|
|
192
|
+
status_code = 0
|
|
193
|
+
resp_headers: dict[str, str] = {}
|
|
194
|
+
body = ""
|
|
195
|
+
error_stack = ""
|
|
196
|
+
|
|
197
|
+
try:
|
|
198
|
+
with urllib.request.urlopen(req, timeout=timeout) as response:
|
|
199
|
+
status_code = response.status
|
|
200
|
+
resp_headers = dict(response.headers.items())
|
|
201
|
+
body = response.read().decode("utf-8", errors="replace")
|
|
202
|
+
except urllib.error.HTTPError as http_err:
|
|
203
|
+
status_code = http_err.code
|
|
204
|
+
resp_headers = dict(http_err.headers.items())
|
|
205
|
+
try:
|
|
206
|
+
body = http_err.read().decode("utf-8", errors="replace")
|
|
207
|
+
except Exception:
|
|
208
|
+
body = str(http_err)
|
|
209
|
+
error_stack = str(http_err)
|
|
210
|
+
except Exception as exc:
|
|
211
|
+
status_code = 0
|
|
212
|
+
error_stack = str(exc)
|
|
213
|
+
|
|
214
|
+
elapsed = time.monotonic() - start_time
|
|
215
|
+
return {
|
|
216
|
+
"status_code": status_code,
|
|
217
|
+
"headers": resp_headers,
|
|
218
|
+
"body": body,
|
|
219
|
+
"response_time": round(elapsed, 4),
|
|
220
|
+
"error_stack": error_stack,
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
def headless_browser_action(
|
|
224
|
+
self,
|
|
225
|
+
url: str,
|
|
226
|
+
actions: Sequence[dict[str, Any]] | None = None,
|
|
227
|
+
timeout: float = 10.0,
|
|
228
|
+
) -> dict[str, Any]:
|
|
229
|
+
"""执行 Playwright 无头浏览器动作。受 AUDIT-02 资源池并发限制保护。"""
|
|
230
|
+
with self.browser_slot(timeout=timeout):
|
|
231
|
+
if not self.is_available():
|
|
232
|
+
raise RuntimeError("Playwright is not installed in current environment")
|
|
233
|
+
|
|
234
|
+
# 在具备真实 Playwright 环境时运行
|
|
235
|
+
import playwright.sync_api # type: ignore
|
|
236
|
+
|
|
237
|
+
with playwright.sync_api.sync_playwright() as p:
|
|
238
|
+
browser = p.chromium.launch(headless=True)
|
|
239
|
+
page = browser.new_page()
|
|
240
|
+
page.goto(url, timeout=int(timeout * 1000))
|
|
241
|
+
title = page.title()
|
|
242
|
+
content = page.content()
|
|
243
|
+
browser.close()
|
|
244
|
+
return {
|
|
245
|
+
"success": True,
|
|
246
|
+
"title": title,
|
|
247
|
+
"content_length": len(content),
|
|
248
|
+
"url": url,
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
def run_dynamic(
|
|
252
|
+
self,
|
|
253
|
+
target: str | Path,
|
|
254
|
+
*,
|
|
255
|
+
payload: dict[str, Any] | None = None,
|
|
256
|
+
context: dict[str, Any] | None = None,
|
|
257
|
+
**kwargs: Any,
|
|
258
|
+
) -> dict[str, Any]:
|
|
259
|
+
"""执行 Web 动态发包或无头探测。"""
|
|
260
|
+
url_target = str(target)
|
|
261
|
+
if not (url_target.startswith("http://") or url_target.startswith("https://")):
|
|
262
|
+
# 非网络 URL,直接交由静态代码分析
|
|
263
|
+
return self.run_static_degraded(target, payload=payload, context=context, **kwargs)
|
|
264
|
+
|
|
265
|
+
method = str((payload or {}).get("method") or "GET")
|
|
266
|
+
headers = (payload or {}).get("headers")
|
|
267
|
+
data = (payload or {}).get("data")
|
|
268
|
+
baseline = (context or {}).get("baseline_response")
|
|
269
|
+
|
|
270
|
+
raw_resp = self.http_raw_request(
|
|
271
|
+
url=url_target,
|
|
272
|
+
method=method,
|
|
273
|
+
headers=headers,
|
|
274
|
+
data=data,
|
|
275
|
+
)
|
|
276
|
+
audit_res = self.classify_http_response(raw_resp, baseline_data=baseline)
|
|
277
|
+
|
|
278
|
+
findings: list[dict[str, Any]] = []
|
|
279
|
+
if audit_res["is_vulnerable"]:
|
|
280
|
+
findings.append({
|
|
281
|
+
"rule_id": audit_res["vulnerability_type"],
|
|
282
|
+
"severity": "HIGH",
|
|
283
|
+
"message": audit_res["reason"],
|
|
284
|
+
"target": url_target,
|
|
285
|
+
"evidence": {
|
|
286
|
+
"status_code": audit_res["status_code"],
|
|
287
|
+
"body_diff": audit_res["body_diff"],
|
|
288
|
+
"response_time": audit_res["response_time"],
|
|
289
|
+
},
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
return {
|
|
293
|
+
"success": True,
|
|
294
|
+
"status": "ok",
|
|
295
|
+
"probe_mode": "dynamic",
|
|
296
|
+
"findings": findings,
|
|
297
|
+
"evidence": {
|
|
298
|
+
"http_response": audit_res,
|
|
299
|
+
},
|
|
300
|
+
"metadata": {
|
|
301
|
+
"url": url_target,
|
|
302
|
+
"method": method,
|
|
303
|
+
},
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
def run_static_degraded(
|
|
307
|
+
self,
|
|
308
|
+
target: str | Path,
|
|
309
|
+
*,
|
|
310
|
+
payload: dict[str, Any] | None = None,
|
|
311
|
+
context: dict[str, Any] | None = None,
|
|
312
|
+
**kwargs: Any,
|
|
313
|
+
) -> dict[str, Any]:
|
|
314
|
+
"""AUDIT-04: 优雅降级为静态 Web 资产结构与 DOM XSS 汇聚点审计。"""
|
|
315
|
+
path = Path(target)
|
|
316
|
+
findings: list[dict[str, Any]] = []
|
|
317
|
+
scanned_files = 0
|
|
318
|
+
|
|
319
|
+
files_to_scan: list[Path] = []
|
|
320
|
+
if path.is_file():
|
|
321
|
+
files_to_scan.append(path)
|
|
322
|
+
elif path.is_dir():
|
|
323
|
+
for ext in ("*.html", "*.htm", "*.js", "*.jsx", "*.ts", "*.tsx", "*.vue"):
|
|
324
|
+
files_to_scan.extend(path.glob(f"**/{ext}"))
|
|
325
|
+
|
|
326
|
+
for file_path in files_to_scan[:100]: # 限制扫描文件数防卡死
|
|
327
|
+
scanned_files += 1
|
|
328
|
+
try:
|
|
329
|
+
content = file_path.read_text(encoding="utf-8", errors="ignore")
|
|
330
|
+
except Exception:
|
|
331
|
+
continue
|
|
332
|
+
|
|
333
|
+
for pattern, rule_id in self.DOM_XSS_PATTERNS:
|
|
334
|
+
matches = re.finditer(pattern, content)
|
|
335
|
+
for m in matches:
|
|
336
|
+
line_no = content[:m.start()].count("\n") + 1
|
|
337
|
+
findings.append({
|
|
338
|
+
"rule_id": rule_id,
|
|
339
|
+
"severity": "HIGH",
|
|
340
|
+
"file": str(file_path),
|
|
341
|
+
"line": line_no,
|
|
342
|
+
"matched": m.group(0),
|
|
343
|
+
"message": f"Detected potential unescaped DOM XSS sink: {m.group(0)}",
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
"success": True,
|
|
348
|
+
"status": "ok",
|
|
349
|
+
"probe_mode": "static_degraded",
|
|
350
|
+
"findings": findings,
|
|
351
|
+
"evidence": {
|
|
352
|
+
"scanned_files": scanned_files,
|
|
353
|
+
"findings_count": len(findings),
|
|
354
|
+
},
|
|
355
|
+
"metadata": {
|
|
356
|
+
"target": str(target),
|
|
357
|
+
"degraded_mode": "static_dom_xss_analysis",
|
|
358
|
+
},
|
|
359
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# project_profiler - Interface & API Contract
|
|
2
|
+
|
|
3
|
+
## 1. Domain Overview & Invariants
|
|
4
|
+
- **Package Path**: `core/project_profiler`
|
|
5
|
+
- **Scope**: Public API and contracts for the `project_profiler` domain.
|
|
6
|
+
- **Contract Boundary**: All external consumers must depend ONLY on symbols declared in this specification.
|
|
7
|
+
|
|
8
|
+
## 2. API Contract Specification
|
|
9
|
+
|
|
10
|
+
<!-- generated:begin -->
|
|
11
|
+
### Exported Public Interface (Auto-generated by `scripts/gen_interface_spec.py`)
|
|
12
|
+
|
|
13
|
+
> **Notice**: Do NOT edit this section manually. Any drift will be rejected by `test_spec_consistency`.
|
|
14
|
+
|
|
15
|
+
- **`DEFAULT_BYTE_LIMIT`** (symbol)
|
|
16
|
+
- **`DEFAULT_FILE_LIMIT`** (symbol)
|
|
17
|
+
- **`DETECTOR_VERSION`** (symbol)
|
|
18
|
+
- **`DETECTOR_VERSION_BASE`** (symbol)
|
|
19
|
+
- **`FORMS`** (symbol)
|
|
20
|
+
#### `class HeuristicProfileClassifier` - DOC-200: 基于文件系统拓扑的主根系锚定与从属固件孤立特征自判器。
|
|
21
|
+
- **Public Methods**:
|
|
22
|
+
- `__init__(self, root: str | os.PathLike[str], files: list[tuple[str, Path, int, str]] | None = None, *, persist: bool = True) -> None`
|
|
23
|
+
- `classify_isolated_fixtures(self) -> tuple[set[str], bool]`
|
|
24
|
+
|
|
25
|
+
- **`LANGUAGES_BY_EXT`** (symbol)
|
|
26
|
+
#### `class LLMProfileArbitrator` - DOC-200: LLM 动态语义复核与冲突裁决器。
|
|
27
|
+
- **Public Methods**:
|
|
28
|
+
- `__init__(self, root: Path, fingerprint: str, *, persist: bool = True) -> None`
|
|
29
|
+
- `arbitrate(self, candidate_fixtures: set[str], heuristic_forms: list[str]) -> tuple[set[str], list[str]]`
|
|
30
|
+
- `get_cached_arbitration(self) -> dict[str, Any] | None`
|
|
31
|
+
- `save_arbitration(self, data: dict[str, Any]) -> None`
|
|
32
|
+
|
|
33
|
+
- **`MAX_COMMANDS`** (symbol)
|
|
34
|
+
- **`MAX_COMPONENTS`** (symbol)
|
|
35
|
+
- **`MAX_EVIDENCE`** (symbol)
|
|
36
|
+
- **`MAX_FACTS`** (symbol)
|
|
37
|
+
- **`MAX_MANIFEST_BYTES`** (symbol)
|
|
38
|
+
- **`PROFILE_ROW_KEY`** (symbol)
|
|
39
|
+
- **`PROFILE_SCHEMA_VERSION`** (symbol)
|
|
40
|
+
- **`RUNTIMES`** (symbol)
|
|
41
|
+
- **`SURFACES`** (symbol)
|
|
42
|
+
- **`TARGETS`** (symbol)
|
|
43
|
+
- **`WIRE_COMPONENTS_LIMIT`** (symbol)
|
|
44
|
+
- **`WIRE_EVIDENCE_LIMIT`** (symbol)
|
|
45
|
+
- **`WIRE_FACTS_LIMIT`** (symbol)
|
|
46
|
+
- **`WIRE_PAYLOAD_BUDGET_BYTES`** (symbol)
|
|
47
|
+
- **`WIRE_RISK_SIGNALS_LIMIT`** (symbol)
|
|
48
|
+
- **`def classify_profile(profile: Mapping[str, Any]) -> dict[str, Any]`** - Compile facts into the bounded action-facing classification object.
|
|
49
|
+
- **`def compile_audit_strategy(profile: Mapping[str, Any]) -> dict[str, Any]`** - Compile classification facts into the small plan consumed by workers.
|
|
50
|
+
- **`def compute_build_fingerprint(root: str | os.PathLike[str]) -> str`** - Hash a bounded set of build manifests using metadata-only stat records.
|
|
51
|
+
- **`def detect_project_profile(root: str | os.PathLike[str], *, file_limit: int = DEFAULT_FILE_LIMIT, byte_limit: int = DEFAULT_BYTE_LIMIT, persist: bool = True, allow_llm: bool = True) -> dict[str, Any]`** - Detect a normalized ProjectProfile without executing project code.
|
|
52
|
+
- **`def ensure_project_profile(ledger_path: str | os.PathLike[str], root: str | os.PathLike[str], *, producer_version: str = 'unknown', force: bool = False) -> tuple[dict[str, Any], bool]`** - Reuse a stable profile when inputs did not change; otherwise update it.
|
|
53
|
+
- **`def export_project_profile(profile: Mapping[str, Any], output: str | os.PathLike[str]) -> None`** - Write a human/debug snapshot; SQLite remains the source of truth.
|
|
54
|
+
- **`def load_project_profile(ledger_path: str | os.PathLike[str]) -> dict[str, Any] | None`** - Read the single project-profile row from an already migrated ledger.
|
|
55
|
+
- **`def routing_tags(profile: Mapping[str, Any]) -> dict[str, list[str]]`** - Return only the stable tags consumed by knowledge retrieval.
|
|
56
|
+
- **`def save_project_profile(ledger_path: str | os.PathLike[str], profile: Mapping[str, Any], *, producer_version: str = 'unknown', revision: int | None = None) -> dict[str, Any]`** - Atomically upsert the project profile; knowledge hashes exclude this row.
|
|
57
|
+
- **`def wire_project_profile(profile: Mapping[str, Any]) -> dict[str, Any]`** - 按 DOC-057 设计项 4 生成云端看板用的紧凑投影。
|
|
58
|
+
|
|
59
|
+
<!-- generated:end -->
|
|
60
|
+
|
|
61
|
+
## 3. Usage Examples & Defensive Patterns
|
|
62
|
+
Refer to `SPEC.md` for architectural context, event topologies, and failure domain mappings.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# BugX Project Profiler (目标代码画像与技术栈自动探测)
|
|
2
|
+
|
|
3
|
+
`core/project_profiler/` 负责对被测目标仓库执行全方位、非侵入式的多语言与技术栈特征画像。它能毫秒级识别编程语言、测试框架、包管理器、敏感路径以及攻击面特征,为后续攻防策略制定提供精准输入。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 架构拓扑与探测时序 (Profiler Pipeline)
|
|
8
|
+
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart TD
|
|
11
|
+
subgraph Scanning["1. 文件指纹与依赖提取"]
|
|
12
|
+
FP["fingerprint.py<br/>项目物理文件树/特征文件哈希计算"]
|
|
13
|
+
EX["extractors.py<br/>配置与依赖提取 (package.json, go.mod, Cargo.toml 等)"]
|
|
14
|
+
CT["constants.py<br/>探测常量、语言模式字典与特征正则库"]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
subgraph Detection["2. 探测与仲裁"]
|
|
18
|
+
DT["detector.py<br/>多语言/多框架特征探测器"]
|
|
19
|
+
AB["arbitrator.py<br/>混杂技术栈权重打分与主语言仲裁"]
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
subgraph Output["3. 策略生成与持久化"]
|
|
23
|
+
ST["strategy.py<br/>自适应攻防策略推荐 (确定测试命令与审计重点)"]
|
|
24
|
+
SO["storage.py<br/>画像结果本地缓存与快速读取"]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
Scanning --> Detection
|
|
28
|
+
Detection --> Output
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 2. 模块文件物理索引与职责清单 (File Inventory)
|
|
34
|
+
|
|
35
|
+
| 文件名 | 职责与功能定位 | 关键类 / 函数 |
|
|
36
|
+
| :--- | :--- | :--- |
|
|
37
|
+
| `__init__.py` | Python 包初始化与核心模块符号导出 | `__all__` |
|
|
38
|
+
| `arbitrator.py` | 主次语言与架构模式权重仲裁器,处理微服务或全栈混合仓库的主流技术栈判定 | `ProjectArbitrator` |
|
|
39
|
+
| `constants.py` | 项目探测全量规则字典与模式特征常量定义 | `LANGUAGE_SIGNATURES`, `FRAMEWORK_MAP` |
|
|
40
|
+
| `detector.py` | 核心探测器,基于特征文件和 AST 深度扫描目标工程的技术栈属性 | `ProjectDetector` |
|
|
41
|
+
| `extractors.py` | 各语言包管理器和构建工具解析器,提取依赖库与版本信息 | `DependencyExtractor` |
|
|
42
|
+
| `fingerprint.py` | 项目指纹生成器,结合 Git 提交哈希与依赖指纹判断项目是否发生结构变化 | `calculate_project_fingerprint` |
|
|
43
|
+
| `INTERFACE.md` | 画像系统对外提供的类型接口与探测产物契约说明 | `ProjectProfile` 数据结构 |
|
|
44
|
+
| `SPEC.md` | 技术画像设计规格书,定义探测算法优先级与启发式打分规则 | 规则与判定矩阵 |
|
|
45
|
+
| `storage.py` | 画像数据本地快照与缓存持久化,加速后续多轮审计启动速度 | `ProfileStorage` |
|
|
46
|
+
| `strategy.py` | 攻防调度策略建议生成器,根据画像自动选择最适配的 Worker 技能包 | `recommend_audit_strategy` |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 3. 核心设计契约与公理 (Design Axioms)
|
|
51
|
+
|
|
52
|
+
1. **零暴力全盘扫描公理**:探测范围严格限制在目标项目根目录内,严禁发散到操作系统根目录或 `$HOME`。
|
|
53
|
+
2. **毫秒级极速画像**:探测器采用由粗到细的短路判定算法,95% 以上的项目探测必须在 300ms 内完成。
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# project_profiler - Domain Specification (SPEC.md)
|
|
2
|
+
|
|
3
|
+
## 1. Responsibility & Domain Boundary
|
|
4
|
+
- **Title**: Deterministic Project Profiling & Classification Engine
|
|
5
|
+
- **Package Path**: `core/project_profiler`
|
|
6
|
+
- **Core Mission**: Non-intrusive, bounded fact discovery, heuristic root anchoring, AI arbitration, and audit strategy compilation for target codebases.
|
|
7
|
+
- **Boundary**: All public capabilities must be formally declared in `INTERFACE.md`. Internal utilities must remain encapsulated.
|
|
8
|
+
|
|
9
|
+
## 2. Dependency & Interaction Topology
|
|
10
|
+
- **Inbound Invocations**: Called by `core.project_profile` (thin facade), `launch_phases`, `capability_plan`, `bugx_cli`, and webui inspectors.
|
|
11
|
+
- **Outbound Dependencies**: `symbol_index` for scope filtering, `secure_atomic` for cache safety, `code_analyzer` for code volume metrics, `sca_scanner` for dependency signals.
|
|
12
|
+
|
|
13
|
+
## 3. System Invariants & Failure Modes
|
|
14
|
+
- **Safety Invariant**: Zero target execution: profiling must never execute target project code. Read budgets and file limits must be bounded.
|
|
15
|
+
- **Engine Isolation**: Never write `.bugx` state into the engine directory itself (`_is_engine_dir`).
|
|
16
|
+
- **Cache Integrity**: Detection version hash embeds both rule table digests and source digests so rule changes automatically invalidate old caches.
|
|
17
|
+
|
|
18
|
+
## 4. Usage Patterns & Quickstart
|
|
19
|
+
```python
|
|
20
|
+
from core.project_profiler import detect_project_profile, compile_audit_strategy
|
|
21
|
+
|
|
22
|
+
profile = detect_project_profile(project_root)
|
|
23
|
+
strategy = compile_audit_strategy(profile)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 5. Maintenance & Verification
|
|
27
|
+
- Unit & regression tests for this package are registered in `tests/test_registry.json`.
|
|
28
|
+
- Changes to exported interfaces must be synchronized via `python3 scripts/gen_interface_spec.py --package core/project_profiler --write`.
|