pwn 0.5.795 → 0.5.798
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.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/bin/pwn_autoinc_version +4 -5
- data/bin/pwn_web_cache_deception +40 -29
- data/documentation/AWS.md +15 -5
- data/documentation/Diagrams.md +1 -1
- data/documentation/Home.md +2 -2
- data/documentation/How-PWN-Works.md +1 -1
- data/documentation/Mission-Cancellation.md +6 -4
- data/documentation/Operability.md +1 -1
- data/documentation/What-is-PWN.md +1 -1
- data/documentation/diagrams/aws-cloud-security.svg +1 -1
- data/documentation/diagrams/dot/aws-cloud-security.dot +1 -1
- data/documentation/diagrams/dot/network-infra-testing.dot +1 -1
- data/documentation/diagrams/network-infra-testing.svg +1 -1
- data/etc/default_cron/session_cleanup.rb +84 -51
- data/etc/default_skills/pwn/ai/agent/mission_namespace/SKILL.md +6 -4
- data/lib/pwn/ai/agent/assembly.rb +0 -2
- data/lib/pwn/ai/agent/btc.rb +0 -2
- data/lib/pwn/ai/agent/burp_suite.rb +0 -2
- data/lib/pwn/ai/agent/curriculum.rb +2 -2
- data/lib/pwn/ai/agent/dispatch.rb +3 -0
- data/lib/pwn/ai/agent/engagement.rb +96 -41
- data/lib/pwn/ai/agent/extrospection/osint/bridges.rb +2 -0
- data/lib/pwn/ai/agent/extrospection.rb +50 -13
- data/lib/pwn/ai/agent/gqrx.rb +0 -2
- data/lib/pwn/ai/agent/hacker_one.rb +0 -2
- data/lib/pwn/ai/agent/learning.rb +45 -13
- data/lib/pwn/ai/agent/loop.rb +16 -11
- data/lib/pwn/ai/agent/metrics.rb +1 -1
- data/lib/pwn/ai/agent/mission.rb +6 -3
- data/lib/pwn/ai/agent/mission_namespace.rb +70 -14
- data/lib/pwn/ai/agent/policy.rb +1 -1
- data/lib/pwn/ai/agent/policy_evaluation.rb +2 -2
- data/lib/pwn/ai/agent/reflect.rb +1 -0
- data/lib/pwn/ai/agent/request_runtime.rb +1 -1
- data/lib/pwn/ai/agent/reward.rb +155 -53
- data/lib/pwn/ai/agent/sast.rb +0 -2
- data/lib/pwn/ai/agent/task_dag.rb +5 -3
- data/lib/pwn/ai/agent/task_summarizer.rb +21 -11
- data/lib/pwn/ai/agent/tool_guard.rb +19 -0
- data/lib/pwn/ai/agent/tools/ruby_eval.rb +1 -1
- data/lib/pwn/ai/agent/tools/verify.rb +7 -3
- data/lib/pwn/ai/agent/transparent_browser.rb +0 -2
- data/lib/pwn/ai/agent/turn_finalizer.rb +3 -0
- data/lib/pwn/ai/anthropic.rb +3 -3
- data/lib/pwn/ai/context.rb +2 -1
- data/lib/pwn/ai/gemini.rb +7 -5
- data/lib/pwn/ai/grok.rb +37 -18
- data/lib/pwn/ai/mcp.rb +17 -5
- data/lib/pwn/ai/ollama.rb +76 -35
- data/lib/pwn/ai/open_ai.rb +7 -19
- data/lib/pwn/ai/open_web_ui.rb +76 -40
- data/lib/pwn/aws/cloud_search_domain.rb +6 -0
- data/lib/pwn/aws/iam.rb +2 -2
- data/lib/pwn/aws/workspaces.rb +2 -2
- data/lib/pwn/aws.rb +0 -5
- data/lib/pwn/bounty/lifecycle_authz_replay.rb +1 -1
- data/lib/pwn/config.rb +17 -10
- data/lib/pwn/corpus.rb +33 -5
- data/lib/pwn/cron.rb +60 -17
- data/lib/pwn/driver.rb +2 -3
- data/lib/pwn/engagement.rb +28 -10
- data/lib/pwn/ffi/capstone.rb +3 -2
- data/lib/pwn/ffi/fftw.rb +8 -6
- data/lib/pwn/ffi/keystone.rb +3 -2
- data/lib/pwn/ffi/soapy_sdr.rb +10 -6
- data/lib/pwn/json_text.rb +25 -13
- data/lib/pwn/memory_index.rb +6 -4
- data/lib/pwn/module_skills.rb +3 -1
- data/lib/pwn/plugins/aflplusplus.rb +1 -0
- data/lib/pwn/plugins/ai_sandbox.rb +42 -10
- data/lib/pwn/plugins/android.rb +429 -466
- data/lib/pwn/plugins/artifact_registry.rb +12 -2
- data/lib/pwn/plugins/assembly.rb +9 -42
- data/lib/pwn/plugins/authentication_helper.rb +4 -3
- data/lib/pwn/plugins/baresip.rb +70 -28
- data/lib/pwn/plugins/binary_analysis.rb +14 -5
- data/lib/pwn/plugins/binary_parser.rb +42 -7
- data/lib/pwn/plugins/black_duck_binary_analysis.rb +3 -3
- data/lib/pwn/plugins/burp_suite.rb +15 -12
- data/lib/pwn/plugins/bus_pirate.rb +3 -7
- data/lib/pwn/plugins/char.rb +9 -3
- data/lib/pwn/plugins/credit_card.rb +7 -0
- data/lib/pwn/plugins/dao_ldap.rb +2 -2
- data/lib/pwn/plugins/dao_mongo.rb +1 -1
- data/lib/pwn/plugins/debugger.rb +1 -1
- data/lib/pwn/plugins/defect_dojo.rb +7 -3
- data/lib/pwn/plugins/detect_os.rb +1 -1
- data/lib/pwn/plugins/detonate.rb +9 -19
- data/lib/pwn/plugins/exploit_db.rb +1 -1
- data/lib/pwn/plugins/file_fu.rb +4 -1
- data/lib/pwn/plugins/findings.rb +76 -2
- data/lib/pwn/plugins/fuzz.rb +12 -3
- data/lib/pwn/plugins/gdb.rb +7 -2
- data/lib/pwn/plugins/gdbmi.rb +10 -6
- data/lib/pwn/plugins/git.rb +18 -13
- data/lib/pwn/plugins/github.rb +11 -6
- data/lib/pwn/plugins/google_workspace.rb +11 -3
- data/lib/pwn/plugins/hacker_one.rb +5 -1
- data/lib/pwn/plugins/httpx.rb +24 -8
- data/lib/pwn/plugins/ip_info.rb +11 -8
- data/lib/pwn/plugins/irc.rb +73 -45
- data/lib/pwn/plugins/jenkins.rb +2 -2
- data/lib/pwn/plugins/jira_data_center.rb +13 -6
- data/lib/pwn/plugins/jobs.rb +62 -4
- data/lib/pwn/plugins/log.rb +1 -1
- data/lib/pwn/plugins/monkey_patch.rb +1 -1
- data/lib/pwn/plugins/msr206.rb +157 -182
- data/lib/pwn/plugins/nessus_cloud.rb +2 -2
- data/lib/pwn/plugins/nexpose_vuln_scan.rb +44 -33
- data/lib/pwn/plugins/nuclei.rb +24 -8
- data/lib/pwn/plugins/ocr.rb +3 -1
- data/lib/pwn/plugins/open_api.rb +0 -4
- data/lib/pwn/plugins/openvas.rb +31 -43
- data/lib/pwn/plugins/packet.rb +40 -25
- data/lib/pwn/plugins/pony.rb +2 -2
- data/lib/pwn/plugins/preflight_checker.rb +1 -1
- data/lib/pwn/plugins/process_tube.rb +17 -2
- data/lib/pwn/plugins/ps.rb +6 -1
- data/lib/pwn/plugins/pwn_logger.rb +37 -1
- data/lib/pwn/plugins/repl/ai.rb +1 -0
- data/lib/pwn/plugins/repl/ai_console.rb +18 -6
- data/lib/pwn/plugins/repl/mesh.rb +51 -28
- data/lib/pwn/plugins/sbom.rb +59 -27
- data/lib/pwn/plugins/scannable_codes.rb +3 -1
- data/lib/pwn/plugins/serial.rb +102 -44
- data/lib/pwn/plugins/shodan.rb +4 -10
- data/lib/pwn/plugins/sock.rb +16 -11
- data/lib/pwn/plugins/ssn.rb +3 -1
- data/lib/pwn/plugins/transparent_browser.rb +43 -3
- data/lib/pwn/plugins/vault.rb +92 -30
- data/lib/pwn/plugins/vin.rb +2 -1
- data/lib/pwn/plugins/vsphere.rb +2 -1
- data/lib/pwn/plugins/xxd.rb +3 -5
- data/lib/pwn/plugins/yubikey/security_domain/scp.rb +4 -0
- data/lib/pwn/plugins/yubikey/transport.rb +42 -11
- data/lib/pwn/plugins/yubikey.rb +21 -6
- data/lib/pwn/plugins/zaproxy.rb +3 -4
- data/lib/pwn/reports/ai_red_team.rb +4 -4
- data/lib/pwn/reports/pdf.rb +9 -5
- data/lib/pwn/reports/sast.rb +4 -4
- data/lib/pwn/sast/keystore.rb +2 -2
- data/lib/pwn/sast/logger.rb +1 -1
- data/lib/pwn/sast/php_type_juggling.rb +3 -6
- data/lib/pwn/sast/pom_version.rb +12 -6
- data/lib/pwn/sast/port.rb +1 -1
- data/lib/pwn/sast/sql.rb +3 -7
- data/lib/pwn/sast/test_case_engine.rb +62 -16
- data/lib/pwn/sast/type_script_type_juggling.rb +3 -6
- data/lib/pwn/sdr/decoder/base.rb +8 -0
- data/lib/pwn/sdr/decoder/lora.rb +1 -1
- data/lib/pwn/sdr/flipper_zero.rb +4 -7
- data/lib/pwn/sdr/gqrx.rb +35 -16
- data/lib/pwn/sdr/son_micro_rfid.rb +44 -26
- data/lib/pwn/sdr.rb +1 -1
- data/lib/pwn/session_trace.rb +7 -2
- data/lib/pwn/sessions.rb +310 -41
- data/lib/pwn/setup.rb +4 -3
- data/lib/pwn/version.rb +1 -1
- data/lib/pwn/www/app_cobalt_io.rb +14 -2
- data/lib/pwn/www/bing.rb +13 -1
- data/lib/pwn/www/bug_crowd.rb +14 -2
- data/lib/pwn/www/checkip.rb +13 -1
- data/lib/pwn/www/coinbase_pro.rb +14 -2
- data/lib/pwn/www/duckduckgo.rb +13 -1
- data/lib/pwn/www/facebook.rb +14 -2
- data/lib/pwn/www/github.rb +14 -2
- data/lib/pwn/www/google.rb +13 -1
- data/lib/pwn/www/hacker_one.rb +117 -33
- data/lib/pwn/www/linkedin.rb +14 -2
- data/lib/pwn/www/pandora.rb +14 -2
- data/lib/pwn/www/pastebin.rb +13 -1
- data/lib/pwn/www/paypal.rb +16 -4
- data/lib/pwn/www/synack.rb +14 -2
- data/lib/pwn/www/torch.rb +17 -3
- data/lib/pwn/www/trading_view.rb +14 -2
- data/lib/pwn/www/twitter.rb +14 -2
- data/lib/pwn/www/uber.rb +14 -2
- data/lib/pwn/www/upwork.rb +14 -2
- data/lib/pwn/www/wayback_machine.rb +16 -2
- data/lib/pwn/www/youtube.rb +13 -1
- data/lib/pwn.rb +11 -0
- data/pwn.gemspec +4 -0
- data/spec/conventions_spec.rb +43 -0
- data/spec/integration/authentication_helper_oath_spec.rb +1 -1
- data/spec/integration/autoinc_lifecycle_supplement_spec.rb +47 -0
- data/spec/integration/gemspec_deleted_files_spec.rb +43 -0
- data/spec/integration/harness_evaluation_spec.rb +22 -31
- data/spec/integration/harness_live_spec.rb +8 -18
- data/spec/integration/spec_curriculum_isolation_spec.rb +41 -0
- data/spec/integration/verify_acceptance_eui_regression_spec.rb +162 -0
- data/spec/integration/web_cache_lifecycle_closure_spec.rb +89 -0
- data/spec/integration/web_cache_lifecycle_supplement_spec.rb +70 -0
- data/spec/lib/pwn/ai/agent/analysis_errors_regression_spec.rb +33 -0
- data/spec/lib/pwn/ai/agent/curriculum_cooldown_regression_spec.rb +19 -0
- data/spec/lib/pwn/ai/agent/curriculum_spec.rb +2 -0
- data/spec/lib/pwn/ai/agent/engagement_boundary_regression_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/engagement_dispatch_review_spec.rb +82 -0
- data/spec/lib/pwn/ai/agent/engagement_roe_regression_spec.rb +25 -0
- data/spec/lib/pwn/ai/agent/engagement_scope_regression_spec.rb +37 -0
- data/spec/lib/pwn/ai/agent/extrospection/osint/bridges_spec.rb +4 -0
- data/spec/lib/pwn/ai/agent/extrospection_input_regression_spec.rb +31 -0
- data/spec/lib/pwn/ai/agent/extrospection_review_spec.rb +61 -0
- data/spec/lib/pwn/ai/agent/extrospection_serial_review_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/extrospection_spec.rb +9 -0
- data/spec/lib/pwn/ai/agent/extrospection_verification_regression_spec.rb +39 -0
- data/spec/lib/pwn/ai/agent/learning_last_answer_regression_spec.rb +32 -0
- data/spec/lib/pwn/ai/agent/learning_lifecycle_closure_spec.rb +84 -0
- data/spec/lib/pwn/ai/agent/learning_prune_regression_spec.rb +17 -0
- data/spec/lib/pwn/ai/agent/learning_spec.rb +2 -1
- data/spec/lib/pwn/ai/agent/loop_execution_audit_spec.rb +30 -0
- data/spec/lib/pwn/ai/agent/metrics_usage_regression_spec.rb +20 -0
- data/spec/lib/pwn/ai/agent/mission_execution_audit_spec.rb +27 -0
- data/spec/lib/pwn/ai/agent/mission_namespace_spec.rb +218 -18
- data/spec/lib/pwn/ai/agent/policy_confidence_regression_spec.rb +16 -0
- data/spec/lib/pwn/ai/agent/policy_evaluation_spec.rb +1 -1
- data/spec/lib/pwn/ai/agent/policy_evaluation_tmp_regression_spec.rb +36 -0
- data/spec/lib/pwn/ai/agent/reflect_model_regression_spec.rb +15 -0
- data/spec/lib/pwn/ai/agent/request_runtime_execution_audit_spec.rb +43 -0
- data/spec/lib/pwn/ai/agent/reward_binding_review_spec.rb +129 -0
- data/spec/lib/pwn/ai/agent/reward_dispatch_review_spec.rb +154 -0
- data/spec/lib/pwn/ai/agent/reward_envelope_regression_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/reward_turn_regression_spec.rb +40 -0
- data/spec/lib/pwn/ai/agent/swarm_spec.rb +2 -2
- data/spec/lib/pwn/ai/agent/task_dag_execution_audit_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/task_summarizer_failure_regression_spec.rb +26 -0
- data/spec/lib/pwn/ai/agent/tools/verify_execution_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/context_range_audit_spec.rb +24 -0
- data/spec/lib/pwn/ai/gemini_roundtrip_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/grok_reasoning_effort_spec.rb +43 -0
- data/spec/lib/pwn/ai/mcp_session_audit_spec.rb +36 -0
- data/spec/lib/pwn/ai/ollama_spec.rb +6 -11
- data/spec/lib/pwn/ai/open_web_ui_spec.rb +6 -11
- data/spec/lib/pwn/ai/provider_history_audit_spec.rb +44 -0
- data/spec/lib/pwn/ai/provider_operations_audit_spec.rb +53 -0
- data/spec/lib/pwn/ai/provider_review_history_stream_regression_spec.rb +143 -0
- data/spec/lib/pwn/ai/provider_review_tls_regression_spec.rb +62 -0
- data/spec/lib/pwn/ai/provider_stream_audit_spec.rb +49 -0
- data/spec/lib/pwn/aws/iam_decoding_regression_spec.rb +23 -0
- data/spec/lib/pwn/aws/services_runtime_regression_spec.rb +51 -0
- data/spec/lib/pwn/aws_spec.rb +6 -0
- data/spec/lib/pwn/banner_operational_audit_spec.rb +105 -0
- data/spec/lib/pwn/bounty/lifecycle_authz_replay_spec.rb +17 -0
- data/spec/lib/pwn/config_redaction_regression_spec.rb +24 -0
- data/spec/lib/pwn/config_skills_regression_spec.rb +38 -0
- data/spec/lib/pwn/corpus_core_review_regression_spec.rb +96 -0
- data/spec/lib/pwn/corpus_spec.rb +13 -0
- data/spec/lib/pwn/cron_core_review_regression_spec.rb +95 -0
- data/spec/lib/pwn/cron_execution_spec.rb +75 -0
- data/spec/lib/pwn/driver_core_review_regression_spec.rb +38 -0
- data/spec/lib/pwn/driver_spec.rb +13 -0
- data/spec/lib/pwn/engagement_core_review_regression_spec.rb +88 -0
- data/spec/lib/pwn/engagement_storage_regression_spec.rb +44 -0
- data/spec/lib/pwn/ffi/capstone_spec.rb +19 -0
- data/spec/lib/pwn/ffi/fftw_spec.rb +19 -0
- data/spec/lib/pwn/ffi/keystone_spec.rb +13 -0
- data/spec/lib/pwn/ffi/soapy_sdr_spec.rb +13 -0
- data/spec/lib/pwn/json_schemer_regexp_parser_spec.rb +12 -0
- data/spec/lib/pwn/json_text_spec.rb +25 -0
- data/spec/lib/pwn/memory_index_spec.rb +23 -0
- data/spec/lib/pwn/module_skills_parsing_regression_spec.rb +34 -0
- data/spec/lib/pwn/module_skills_spec.rb +11 -1
- data/spec/lib/pwn/plugins/ai_sandbox_boundary_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +10 -18
- data/spec/lib/pwn/plugins/android_review_fixes_spec.rb +121 -0
- data/spec/lib/pwn/plugins/android_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/api_import_namespace_audit_spec.rb +49 -0
- data/spec/lib/pwn/plugins/artifact_registry_namespace_audit_spec.rb +20 -0
- data/spec/lib/pwn/plugins/artifact_registry_review_fixes_spec.rb +63 -0
- data/spec/lib/pwn/plugins/assembly_namespace_audit_spec.rb +16 -0
- data/spec/lib/pwn/plugins/assembly_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/authentication_helper_spec.rb +14 -0
- data/spec/lib/pwn/plugins/baresip_review_fixes_spec.rb +127 -0
- data/spec/lib/pwn/plugins/baresip_transport_audit_spec.rb +59 -0
- data/spec/lib/pwn/plugins/binary_analysis_process_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/black_duck_namespace_audit_spec.rb +25 -0
- data/spec/lib/pwn/plugins/burp_suite_har_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/plugins/burp_suite_import_review_fixes_spec.rb +62 -0
- data/spec/lib/pwn/plugins/burp_suite_namespace_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/bus_pirate_transport_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/file_fu_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/findings_structured_spec.rb +1 -1
- data/spec/lib/pwn/plugins/gdbmi_namespace_audit_spec.rb +28 -0
- data/spec/lib/pwn/plugins/gdbmi_review_fixes_spec.rb +73 -0
- data/spec/lib/pwn/plugins/github_argv_review_spec.rb +49 -0
- data/spec/lib/pwn/plugins/google_workspace_provider_review_oauth_spec.rb +80 -0
- data/spec/lib/pwn/plugins/irc_review_fixes_spec.rb +92 -0
- data/spec/lib/pwn/plugins/irc_transport_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/jenkins_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/jira_data_center_namespace_audit_spec.rb +44 -0
- data/spec/lib/pwn/plugins/jira_data_center_review_fixes_spec.rb +81 -0
- data/spec/lib/pwn/plugins/jsonl_elf_review_fixes_spec.rb +59 -0
- data/spec/lib/pwn/plugins/log_spec.rb +36 -20
- data/spec/lib/pwn/plugins/monkey_patch_spec.rb +16 -0
- data/spec/lib/pwn/plugins/msr206_readback_review_fixes_spec.rb +119 -0
- data/spec/lib/pwn/plugins/msr206_review_fixes_spec.rb +50 -0
- data/spec/lib/pwn/plugins/msr206_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/nessus_cloud_namespace_audit_spec.rb +14 -0
- data/spec/lib/pwn/plugins/nexpose_review_fixes_spec.rb +55 -0
- data/spec/lib/pwn/plugins/open_api_namespace_audit_spec.rb +22 -0
- data/spec/lib/pwn/plugins/packet_transport_audit_spec.rb +47 -0
- data/spec/lib/pwn/plugins/plugins_b_operational_regression_spec.rb +600 -0
- data/spec/lib/pwn/plugins/pony_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/pony_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/process_tube_namespace_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/ps_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/pwn_logger_spec.rb +30 -0
- data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +127 -0
- data/spec/lib/pwn/plugins/repl/ai_spec.rb +38 -0
- data/spec/lib/pwn/plugins/repl/mesh_spec.rb +52 -0
- data/spec/lib/pwn/plugins/repl_mesh_rx_errors_spec.rb +18 -0
- data/spec/lib/pwn/plugins/sandbox_spec.rb +9 -7
- data/spec/lib/pwn/plugins/sbom_review_fixes_spec.rb +43 -0
- data/spec/lib/pwn/plugins/scannable_codes_namespace_audit_spec.rb +15 -0
- data/spec/lib/pwn/plugins/serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/plugins/serial_transport_audit_spec.rb +102 -0
- data/spec/lib/pwn/plugins/shodan_namespace_audit_spec.rb +10 -0
- data/spec/lib/pwn/plugins/sock_transport_audit_spec.rb +55 -0
- data/spec/lib/pwn/plugins/transparent_browser_navigation_review_spec.rb +21 -0
- data/spec/lib/pwn/plugins/vault_master_key_eui_regression_spec.rb +242 -0
- data/spec/lib/pwn/plugins/vault_spec.rb +58 -0
- data/spec/lib/pwn/plugins/vault_store_safety_spec.rb +1 -1
- data/spec/lib/pwn/plugins/xxd_namespace_audit_spec.rb +34 -0
- data/spec/lib/pwn/plugins/yubikey_hid_cleanup_review_fixes_spec.rb +52 -0
- data/spec/lib/pwn/plugins/yubikey_lifecycle_audit_spec.rb +65 -0
- data/spec/lib/pwn/plugins/yubikey_options_audit_spec.rb +30 -0
- data/spec/lib/pwn/plugins/yubikey_selector_audit_spec.rb +26 -0
- data/spec/lib/pwn/plugins/yubikey_spec.rb +1 -1
- data/spec/lib/pwn/plugins/zaproxy_namespace_audit_spec.rb +30 -0
- data/spec/lib/pwn/reports/empty_report_audit_spec.rb +18 -0
- data/spec/lib/pwn/reports/pdf_spec.rb +25 -0
- data/spec/lib/pwn/reports/provider_review_encoding_regression_spec.rb +35 -0
- data/spec/lib/pwn/sast/engine_runtime_regression_spec.rb +91 -0
- data/spec/lib/pwn/sast/filter_edge_regression_spec.rb +39 -0
- data/spec/lib/pwn/sast/formatter_review_fixes_spec.rb +178 -0
- data/spec/lib/pwn/sast/path_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/sast/pom_runtime_regression_spec.rb +37 -0
- data/spec/lib/pwn/sast/rules_runtime_regression_spec.rb +78 -0
- data/spec/lib/pwn/sast/sql_review_fixes_spec.rb +38 -0
- data/spec/lib/pwn/sdr/decoder/base_iq_spec.rb +21 -18
- data/spec/lib/pwn/sdr/decoder/base_review_fixes_spec.rb +49 -0
- data/spec/lib/pwn/sdr/decoder/base_validation_spec.rb +78 -0
- data/spec/lib/pwn/sdr/decoder/lora_spec.rb +9 -0
- data/spec/lib/pwn/sdr/flipper_zero_review_fixes_spec.rb +34 -0
- data/spec/lib/pwn/sdr/gqrx_operational_spec.rb +83 -0
- data/spec/lib/pwn/sdr/gqrx_review_fixes_spec.rb +22 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_review_fixes_spec.rb +113 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_spec.rb +39 -0
- data/spec/lib/pwn/sdr_spec.rb +5 -0
- data/spec/lib/pwn/session_cleanup_concurrency_spec.rb +21 -0
- data/spec/lib/pwn/session_cleanup_default_spec.rb +1 -1
- data/spec/lib/pwn/session_cleanup_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/session_cleanup_payload_spec.rb +3 -2
- data/spec/lib/pwn/session_trace_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/sessions_archive_closure_spec.rb +126 -0
- data/spec/lib/pwn/sessions_lifecycle_closure_spec.rb +373 -0
- data/spec/lib/pwn/sessions_lifecycle_supplement_spec.rb +204 -0
- data/spec/lib/pwn/setup_operational_regression_spec.rb +36 -0
- data/spec/lib/pwn/www/browser_review_fixes_spec.rb +70 -0
- data/spec/lib/pwn/www/browser_runtime_regression_spec.rb +100 -0
- data/spec/lib/pwn/www/hacker_one_runtime_regression_spec.rb +146 -0
- data/spec/lib/pwn/www/pagination_review_fixes_spec.rb +84 -0
- data/spec/spec_helper.rb +34 -5
- data/spec/support/namespace_controller_observability_fixture.rb +141 -0
- data/spec/support/sandbox.rb +8 -5
- data/third_party/pwn_rdoc.jsonl +83 -32
- metadata +7690 -7386
- data/etc/default_skills/pwn/aws/elastic_transcoder/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/lambda_preview/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works_cm/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/sms/SKILL.md +0 -48
- data/lib/pwn/aws/elastic_transcoder.rb +0 -95
- data/lib/pwn/aws/lambda_preview.rb +0 -95
- data/lib/pwn/aws/ops_works.rb +0 -95
- data/lib/pwn/aws/ops_works_cm.rb +0 -95
- data/lib/pwn/aws/sms.rb +0 -95
- data/spec/lib/pwn/aws/elastic_transcoder_spec.rb +0 -15
- data/spec/lib/pwn/aws/lambda_preview_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_cm_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_spec.rb +0 -15
- data/spec/lib/pwn/aws/sms_spec.rb +0 -15
|
@@ -10,10 +10,12 @@ metadata:
|
|
|
10
10
|
|
|
11
11
|
# PWN::AI::Agent::MissionNamespace
|
|
12
12
|
|
|
13
|
-
Launch typed mission descriptors using util-linux `unshare
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
Launch typed mission descriptors using util-linux `unshare` when the kernel
|
|
14
|
+
allows an unprivileged user namespace. If that call is denied, or the
|
|
15
|
+
namespace child closes the supervision socket, the same handshake runs in a
|
|
16
|
+
process-group supervisor. No apparmor or sysctl change is required. Pidfds
|
|
17
|
+
still cancel the owned child. A setsid descendant can leave a process group;
|
|
18
|
+
a PID namespace, when available, is what reaps those.
|
|
17
19
|
|
|
18
20
|
The controller remains outside namespaces. Each request transfers its private
|
|
19
21
|
configuration snapshot in memory, then owns a PID namespace. Cancellation kills
|
data/lib/pwn/ai/agent/btc.rb
CHANGED
|
@@ -195,7 +195,7 @@ module PWN
|
|
|
195
195
|
{
|
|
196
196
|
practiced: results.length,
|
|
197
197
|
resolved: results.count { |r| r[:resolved] },
|
|
198
|
-
skipped_cooldown: cool.count { |_, v| v[:fail_nights].to_i >= COOLDOWN_FAIL_NIGHTS },
|
|
198
|
+
skipped_cooldown: cool.count { |_, v| (v[:fail_nights] || v['fail_nights']).to_i >= COOLDOWN_FAIL_NIGHTS },
|
|
199
199
|
skipped_parked: (defined?(Mistakes) && Mistakes.respond_to?(:operator_inbox) ? Mistakes.operator_inbox[:count] : 0),
|
|
200
200
|
operator_inbox: (defined?(Mistakes) && Mistakes.respond_to?(:operator_inbox) ? Mistakes.operator_inbox[:items] : []),
|
|
201
201
|
results: results,
|
|
@@ -971,7 +971,7 @@ module PWN
|
|
|
971
971
|
|
|
972
972
|
cool = opts[:cooldown] || {}
|
|
973
973
|
entry = cool[m[:signature].to_s] || cool[m[:signature].to_sym]
|
|
974
|
-
return true if entry && entry[:fail_nights].to_i >= COOLDOWN_FAIL_NIGHTS && (entry[:parked] || entry['parked'])
|
|
974
|
+
return true if entry && (entry[:fail_nights] || entry['fail_nights']).to_i >= COOLDOWN_FAIL_NIGHTS && (entry[:parked] || entry['parked'])
|
|
975
975
|
|
|
976
976
|
false
|
|
977
977
|
end
|
|
@@ -145,6 +145,7 @@ module PWN
|
|
|
145
145
|
raise
|
|
146
146
|
end
|
|
147
147
|
telemetry = finish_budget(budget: budget, result: result, elapsed: Process.clock_gettime(Process::CLOCK_MONOTONIC) - started)
|
|
148
|
+
eval_outcome = result.slice(:execution_success, :application_status) if entry.name == 'pwn_eval' && result.is_a?(Hash)
|
|
148
149
|
result = Result.page(value: result, entry: entry, session_id: opts[:session_id])
|
|
149
150
|
result = ToolGuard.quarantine_output(text: result) if defined?(ToolGuard) && result.is_a?(String) && ToolGuard.respond_to?(:quarantine_output)
|
|
150
151
|
note_taint(text: result)
|
|
@@ -159,12 +160,14 @@ module PWN
|
|
|
159
160
|
error: 'Vault redaction failed; result withheld. The tool already executed; verify its effects before retrying.')
|
|
160
161
|
end
|
|
161
162
|
response = { success: true, result: result, effect: effect(name: entry.name, args: args) }
|
|
163
|
+
response.merge!(eval_outcome) if eval_outcome
|
|
162
164
|
response[:success] = false if result.is_a?(Hash) && (result[:error] || result['error'] || result[:success] == false || result['success'] == false || result[:ok] == false || result['ok'] == false || (result.key?(:exit) && result[:exit] != 0) || (result.key?('exit') && result['exit'] != 0))
|
|
163
165
|
response[:budget] = telemetry if telemetry
|
|
164
166
|
if telemetry && telemetry[:remaining_s].zero?
|
|
165
167
|
response[:success] = false
|
|
166
168
|
response[:error] = 'budget_exhausted'
|
|
167
169
|
end
|
|
170
|
+
response[:informational_exit] = true if entry.name == 'shell' && Reward.semantic_ok(name: entry.name, raw: JSON.generate(Result.utf8_value(value: response)), args: args)[:benign]
|
|
168
171
|
JSON.generate(PWN::AI::Agent::Result.utf8_value(value: response))
|
|
169
172
|
rescue StandardError => e
|
|
170
173
|
JSON.generate(
|
|
@@ -14,8 +14,7 @@ module PWN
|
|
|
14
14
|
ACTIVE_FILE = File.join(ROOT, 'active')
|
|
15
15
|
|
|
16
16
|
public_class_method def self.open(opts = {})
|
|
17
|
-
name = (opts[:name] || opts[:engagement] || 'default')
|
|
18
|
-
raise 'ERROR: name is required' if name.empty?
|
|
17
|
+
name = validate_name(name: opts[:name] || opts[:engagement] || 'default')
|
|
19
18
|
|
|
20
19
|
FileUtils.mkdir_p(ROOT)
|
|
21
20
|
path = File.join(ROOT, "#{name}.json")
|
|
@@ -38,9 +37,10 @@ module PWN
|
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
public_class_method def self.status(opts = {})
|
|
41
|
-
name =
|
|
42
|
-
return { active: nil } if name.
|
|
40
|
+
name = opts[:name] || opts[:engagement] || current_name
|
|
41
|
+
return { active: nil } if name.nil?
|
|
43
42
|
|
|
43
|
+
name = validate_name(name: name)
|
|
44
44
|
path = File.join(ROOT, "#{name}.json")
|
|
45
45
|
return { active: name, missing: true } unless File.file?(path)
|
|
46
46
|
|
|
@@ -51,7 +51,15 @@ module PWN
|
|
|
51
51
|
return nil unless opts.is_a?(Hash)
|
|
52
52
|
return nil unless File.file?(ACTIVE_FILE)
|
|
53
53
|
|
|
54
|
-
File.read(ACTIVE_FILE)
|
|
54
|
+
validate_name(name: File.read(ACTIVE_FILE))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
public_class_method def self.validate_name(opts = {})
|
|
58
|
+
name = opts[:name].to_s
|
|
59
|
+
raise ArgumentError, 'Invalid engagement name: expected a single nonempty filename component' if name.empty? || %w[. ..].include?(name) || name.match?(%r{[/\\\x00-\x1f\x7f]})
|
|
60
|
+
raise ArgumentError, 'Invalid engagement name: active pointer and .json metadata names are reserved' if name == File.basename(ACTIVE_FILE) || name.downcase.end_with?('.json')
|
|
61
|
+
|
|
62
|
+
name
|
|
55
63
|
end
|
|
56
64
|
|
|
57
65
|
public_class_method def self.in_scope?(opts = {})
|
|
@@ -59,45 +67,23 @@ module PWN
|
|
|
59
67
|
return true if token.empty?
|
|
60
68
|
|
|
61
69
|
roe = load_roe
|
|
62
|
-
host = token
|
|
63
|
-
begin
|
|
64
|
-
host = URI.parse(token).host || token if token.include?('://')
|
|
65
|
-
rescue StandardError
|
|
66
|
-
host = token
|
|
67
|
-
end
|
|
68
|
-
host = host.sub(%r{\Ahttps?://}i, '').split('/').first.to_s.split(':').first
|
|
70
|
+
host = scope_host(target: token)
|
|
69
71
|
if roe[:present]
|
|
70
72
|
deny = Array(roe[:targets_deny])
|
|
71
|
-
return false if deny.any? { |ex| host
|
|
73
|
+
return false if deny.any? { |ex| scope_match?(host: host, target: ex, deny: true) }
|
|
72
74
|
|
|
73
75
|
allow = Array(roe[:targets_allow])
|
|
74
|
-
unless allow.empty?
|
|
75
|
-
ok = allow.any? do |a|
|
|
76
|
-
a = a.to_s
|
|
77
|
-
host == a || host.end_with?(".#{a}") || begin
|
|
78
|
-
IPAddr.new(a).include?(IPAddr.new(host))
|
|
79
|
-
rescue StandardError
|
|
80
|
-
false
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
return false unless ok
|
|
84
|
-
end
|
|
76
|
+
return false unless allow.empty? || allow.any? { |target| scope_match?(host: host, target: target) }
|
|
85
77
|
end
|
|
86
78
|
|
|
87
|
-
row = status
|
|
88
|
-
return true if row[:active].nil?
|
|
79
|
+
row = status(name: opts[:name] || opts[:engagement])
|
|
80
|
+
return true if row[:active].nil?
|
|
81
|
+
return false if row[:missing]
|
|
89
82
|
|
|
90
83
|
enforce = engagement_enforce
|
|
91
84
|
return true if enforce == 'off'
|
|
92
85
|
|
|
93
|
-
host
|
|
94
|
-
begin
|
|
95
|
-
host = URI.parse(token).host || token if token.include?('://')
|
|
96
|
-
rescue StandardError
|
|
97
|
-
host = token
|
|
98
|
-
end
|
|
99
|
-
host = host.sub(%r{\Ahttps?://}i, '').split('/').first.to_s.split(':').first
|
|
100
|
-
return false if Array(row[:excluded]).any? { |ex| host.include?(ex.to_s) }
|
|
86
|
+
return false if Array(row[:excluded]).any? { |ex| scope_match?(host: host, target: ex, deny: true) }
|
|
101
87
|
|
|
102
88
|
cidrs = Array(row[:scope_cidrs]).map(&:to_s).reject(&:empty?)
|
|
103
89
|
domains = Array(row[:scope_domains]).map(&:to_s).reject(&:empty?)
|
|
@@ -126,7 +112,7 @@ module PWN
|
|
|
126
112
|
violating: [tech_hit]
|
|
127
113
|
}
|
|
128
114
|
end
|
|
129
|
-
tokens =
|
|
115
|
+
tokens = scope_targets(value: args)
|
|
130
116
|
bad = tokens.reject { |tok| in_scope?(host: tok) }
|
|
131
117
|
return nil if bad.empty?
|
|
132
118
|
|
|
@@ -143,8 +129,10 @@ module PWN
|
|
|
143
129
|
return { present: false, targets_allow: [], targets_deny: [], techniques_deny: [] } unless File.file?(path)
|
|
144
130
|
|
|
145
131
|
require 'yaml'
|
|
146
|
-
raw = YAML.safe_load_file(path, permitted_classes: [], symbolize_names: true)
|
|
147
|
-
raw = {}
|
|
132
|
+
raw = YAML.safe_load_file(path, permitted_classes: [], symbolize_names: true)
|
|
133
|
+
raw = {} if raw.nil?
|
|
134
|
+
raise ArgumentError, 'Invalid RoE policy: expected a YAML mapping' unless raw.is_a?(Hash)
|
|
135
|
+
|
|
148
136
|
{
|
|
149
137
|
present: true,
|
|
150
138
|
targets_allow: Array(raw[:targets_allow] || raw['targets_allow']),
|
|
@@ -152,8 +140,8 @@ module PWN
|
|
|
152
140
|
techniques_deny: Array(raw[:techniques_deny] || raw['techniques_deny']),
|
|
153
141
|
time_windows: raw[:time_windows] || raw['time_windows']
|
|
154
142
|
}
|
|
155
|
-
rescue
|
|
156
|
-
|
|
143
|
+
rescue Psych::Exception, SystemCallError, IOError
|
|
144
|
+
raise ArgumentError, 'Invalid RoE policy: cannot read or parse the policy file'
|
|
157
145
|
end
|
|
158
146
|
|
|
159
147
|
public_class_method def self.authors
|
|
@@ -180,7 +168,8 @@ module PWN
|
|
|
180
168
|
|
|
181
169
|
# Return the active engagement document.
|
|
182
170
|
#{self}.status(
|
|
183
|
-
name: 'optional - engagement name (defaults to active)'
|
|
171
|
+
name: 'optional - engagement name (defaults to active)',
|
|
172
|
+
engagement: 'optional - alias for name'
|
|
184
173
|
)
|
|
185
174
|
|
|
186
175
|
# Return the active engagement name or nil.
|
|
@@ -188,12 +177,19 @@ module PWN
|
|
|
188
177
|
unused: 'optional - reserved'
|
|
189
178
|
)
|
|
190
179
|
|
|
180
|
+
# Validate an engagement filename component without normalizing it.
|
|
181
|
+
#{self}.validate_name(
|
|
182
|
+
name: 'required - nonempty engagement name without separators or control characters; active and .json suffixes are reserved'
|
|
183
|
+
)
|
|
184
|
+
|
|
191
185
|
# True when host/ip/url is inside the active engagement scope.
|
|
192
186
|
#{self}.in_scope?(
|
|
193
187
|
host: 'optional - DNS hostname to test against scope_domains',
|
|
194
188
|
ip: 'optional - IPv4 or IPv6 address to test against scope_cidrs',
|
|
195
189
|
target: 'optional - host or IP alias when the caller has one field',
|
|
196
|
-
url: 'optional - URL whose host is extracted and tested'
|
|
190
|
+
url: 'optional - URL whose host is extracted and tested',
|
|
191
|
+
name: 'optional - explicit engagement name; otherwise use the active engagement',
|
|
192
|
+
engagement: 'optional - alias for name'
|
|
197
193
|
)
|
|
198
194
|
|
|
199
195
|
# Structured denial when args mention an out-of-scope host.
|
|
@@ -214,6 +210,65 @@ module PWN
|
|
|
214
210
|
constants.sort
|
|
215
211
|
end
|
|
216
212
|
|
|
213
|
+
private_class_method def self.scope_match?(opts = {})
|
|
214
|
+
target = opts[:target].to_s
|
|
215
|
+
host = opts[:host].to_s
|
|
216
|
+
begin
|
|
217
|
+
network = IPAddr.new(target)
|
|
218
|
+
rescue IPAddr::InvalidAddressError
|
|
219
|
+
raise ArgumentError, 'Invalid scope network' if target.include?('/')
|
|
220
|
+
|
|
221
|
+
return host == target || host.end_with?(".#{target}") || (opts[:deny] == true && host.include?(target))
|
|
222
|
+
end
|
|
223
|
+
begin
|
|
224
|
+
network.include?(IPAddr.new(host))
|
|
225
|
+
rescue IPAddr::InvalidAddressError
|
|
226
|
+
false
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Read typed target fields first; scan code/commands without treating URL
|
|
231
|
+
# paths as extra destinations. IPAddr validates candidates, never resolves DNS.
|
|
232
|
+
private_class_method def self.scope_targets(opts = {})
|
|
233
|
+
value = opts[:value]
|
|
234
|
+
case value
|
|
235
|
+
when Hash
|
|
236
|
+
value.flat_map { |key, item| scope_targets(value: item, typed: key.to_s.match?(/\A(?:hosts?|ips?|targets?|urls?|hostname|address)\z/)) }.uniq
|
|
237
|
+
when Array
|
|
238
|
+
value.flat_map { |item| scope_targets(value: item, typed: opts[:typed]) }.uniq
|
|
239
|
+
when String
|
|
240
|
+
return [scope_host(target: value)] if opts[:typed] && !value.match?(/\s/)
|
|
241
|
+
|
|
242
|
+
tokens = []
|
|
243
|
+
rest = value.gsub(%r{[a-z][a-z0-9+.-]*://[^\s"'<>]+}i) do |url|
|
|
244
|
+
tokens << scope_host(target: url)
|
|
245
|
+
' '
|
|
246
|
+
end
|
|
247
|
+
rest = rest.gsub(/(?<![\w:])[\da-f]*:[\da-f:.]+(?:%[\w.-]+)?/i) do |candidate|
|
|
248
|
+
address = IPAddr.new(candidate)
|
|
249
|
+
tokens << candidate if address.ipv6?
|
|
250
|
+
' '
|
|
251
|
+
rescue IPAddr::InvalidAddressError
|
|
252
|
+
candidate
|
|
253
|
+
end
|
|
254
|
+
(tokens + rest.scan(/(?:\d{1,3}\.){3}\d{1,3}|[A-Za-z0-9.-]+\.[A-Za-z]{2,}/)).reject(&:empty?).uniq
|
|
255
|
+
else
|
|
256
|
+
[]
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
private_class_method def self.scope_host(opts = {})
|
|
261
|
+
token = opts[:target].to_s
|
|
262
|
+
return URI.parse(token).hostname.to_s if token.include?('://')
|
|
263
|
+
|
|
264
|
+
host = token.split('/').first.to_s
|
|
265
|
+
return host[/\A\[([^\]]+)\]/, 1] if host.start_with?('[')
|
|
266
|
+
|
|
267
|
+
host.count(':') <= 1 ? host.split(':').first.to_s : host
|
|
268
|
+
rescue URI::InvalidURIError
|
|
269
|
+
token
|
|
270
|
+
end
|
|
271
|
+
|
|
217
272
|
private_class_method def self.engagement_enforce
|
|
218
273
|
v = (PWN::Env.dig(:ai, :engagement, :enforce) if defined?(PWN::Env))
|
|
219
274
|
(v || 'block').to_s
|
|
@@ -49,6 +49,8 @@ module PWN
|
|
|
49
49
|
private_class_method def self.bridge_domain(opts = {})
|
|
50
50
|
q = opts[:query].to_s.strip.sub(%r{\Ahttps?://}i, '').sub(%r{/.*\z}, '')
|
|
51
51
|
q = q.split('@').last if q.include?('@')
|
|
52
|
+
return '' unless q.length <= 253 && q.match?(/\A[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)+\.?\z/i)
|
|
53
|
+
|
|
52
54
|
q
|
|
53
55
|
end
|
|
54
56
|
|
|
@@ -319,7 +319,7 @@ module PWN
|
|
|
319
319
|
# On :refuted -> Mistakes.record(tool:'assumption', error:claim) so the
|
|
320
320
|
# KNOWN MISTAKES block warns every future run.
|
|
321
321
|
# On :confirmed-> observe(category::intel, ttl:30d) reinforces w/ freshness.
|
|
322
|
-
# On :unknown -> Learning.note_outcome
|
|
322
|
+
# On :unknown -> Learning.note_outcome with a nil training decision.
|
|
323
323
|
#
|
|
324
324
|
# This is the extrospective mirror of Mistakes: a PROACTIVE trigger that
|
|
325
325
|
# catches the model being wrong about the world before a human does.
|
|
@@ -344,8 +344,11 @@ module PWN
|
|
|
344
344
|
fp = fingerprint_page(browser_obj: bo, url: u)
|
|
345
345
|
evidence << fp if fp
|
|
346
346
|
end
|
|
347
|
-
|
|
348
|
-
if
|
|
347
|
+
pages = evidence.select { |page| canonical_cve_page?(page: page, cve: cve) }
|
|
348
|
+
next if pages.empty?
|
|
349
|
+
|
|
350
|
+
body = pages.map { |page| page[:text].to_s }.join(' ')
|
|
351
|
+
if body =~ /could not be found|does not exist|reserved but/i
|
|
349
352
|
verdict = :refuted
|
|
350
353
|
conf = 0.8
|
|
351
354
|
else
|
|
@@ -363,7 +366,10 @@ module PWN
|
|
|
363
366
|
u = opts[:url] || claim[URI::DEFAULT_PARSER.make_regexp(%w[http https])]
|
|
364
367
|
fp = fingerprint_page(browser_obj: bo, url: u)
|
|
365
368
|
evidence << fp if fp
|
|
366
|
-
|
|
369
|
+
next unless fp && (fp[:status].to_i.between?(200, 299) || [404, 410].include?(fp[:status].to_i))
|
|
370
|
+
next if fp[:reachable] == false && fp[:status].to_i < 400
|
|
371
|
+
|
|
372
|
+
if fp[:status].to_i >= 400
|
|
367
373
|
verdict = :refuted
|
|
368
374
|
conf = 0.7
|
|
369
375
|
else
|
|
@@ -406,7 +412,10 @@ module PWN
|
|
|
406
412
|
action = commit ? commit_verdict(claim: claim, kind: kind, verdict: verdict, confidence: conf, evidence: evidence) : nil
|
|
407
413
|
{ claim: claim, kind: kind, verdict: verdict, confidence: conf.round(2), evidence: evidence, action_taken: action }
|
|
408
414
|
rescue StandardError => e
|
|
409
|
-
|
|
415
|
+
evidence = Array(evidence).map { |page| page.except(:text) }
|
|
416
|
+
evidence << { reachable: false, error: e.class.name }
|
|
417
|
+
action = commit ? commit_verdict(claim: claim, kind: kind, verdict: :unknown, confidence: 0.0, evidence: evidence) : nil
|
|
418
|
+
{ claim: claim, kind: kind, verdict: :unknown, confidence: 0.0, evidence: evidence, error: "#{e.class}: #{e.message}", action_taken: action }
|
|
410
419
|
end
|
|
411
420
|
|
|
412
421
|
# Supported Method Parameters::
|
|
@@ -733,10 +742,10 @@ module PWN
|
|
|
733
742
|
stop_bits: (opts[:stop_bits] || 1).to_i,
|
|
734
743
|
parity: (opts[:parity] || :none).to_sym
|
|
735
744
|
)
|
|
736
|
-
PWN::Plugins::Serial.flush_session_data
|
|
745
|
+
PWN::Plugins::Serial.flush_session_data(serial_obj: serial_obj)
|
|
737
746
|
PWN::Plugins::Serial.request(serial_obj: serial_obj, payload: payload) if payload
|
|
738
747
|
sleep settle
|
|
739
|
-
raw = Array(PWN::Plugins::Serial.dump_session_data)
|
|
748
|
+
raw = Array(PWN::Plugins::Serial.dump_session_data(serial_obj: serial_obj))
|
|
740
749
|
text = raw.join.force_encoding('UTF-8').scrub
|
|
741
750
|
hex = raw.map do |b|
|
|
742
751
|
case b
|
|
@@ -1626,6 +1635,26 @@ module PWN
|
|
|
1626
1635
|
end
|
|
1627
1636
|
end
|
|
1628
1637
|
|
|
1638
|
+
private_class_method def self.canonical_cve_page?(opts = {})
|
|
1639
|
+
page = opts[:page]
|
|
1640
|
+
return false unless page[:reachable] != false && page[:status].to_i.between?(200, 299)
|
|
1641
|
+
|
|
1642
|
+
url = URI.parse((page[:final_url] || page[:url]).to_s)
|
|
1643
|
+
return false unless url.scheme == 'https' && %w[nvd.nist.gov www.cve.org cve.org].include?(url.host)
|
|
1644
|
+
return false if page[:title].to_s.match?(/\bmaintenance|\blogin\b|sign in|access denied|service unavailable|\berror\b|\bchallenge\b/i)
|
|
1645
|
+
|
|
1646
|
+
text = page[:text].to_s
|
|
1647
|
+
return false unless text.match?(/\b#{Regexp.escape(opts[:cve].to_s)}\b/i)
|
|
1648
|
+
return false if text.match?(/temporarily unavailable|checking your browser|sign in to continue|under maintenance|verify you are human/i)
|
|
1649
|
+
|
|
1650
|
+
# Record identity alone is also present on empty JS shells and login
|
|
1651
|
+
# pages. Require rendered canonical description content, not HTTP 200.
|
|
1652
|
+
description = text[/\bDescription\b\s*:?\s*(.+)/im, 1].to_s.strip
|
|
1653
|
+
description.length >= 20 && description.match?(/[a-z]{3}/i)
|
|
1654
|
+
rescue URI::InvalidURIError
|
|
1655
|
+
false
|
|
1656
|
+
end
|
|
1657
|
+
|
|
1629
1658
|
private_class_method def self.fingerprint_page(opts = {})
|
|
1630
1659
|
bo = opts[:browser_obj]
|
|
1631
1660
|
url = opts[:url].to_s
|
|
@@ -1637,8 +1666,9 @@ module PWN
|
|
|
1637
1666
|
resp = b.get(url) { |r, _rq, _res| r }
|
|
1638
1667
|
body = resp.body.to_s
|
|
1639
1668
|
require 'nokogiri'
|
|
1640
|
-
doc
|
|
1641
|
-
|
|
1669
|
+
doc = Nokogiri::HTML.parse(body)
|
|
1670
|
+
doc.css('script, style').remove
|
|
1671
|
+
text = doc.xpath('//text()').map(&:text).join(' ')
|
|
1642
1672
|
cfp, cna = tls_fingerprint(url: url)
|
|
1643
1673
|
return { url: url, final_url: url, status: resp.code.to_i, title: doc.title.to_s,
|
|
1644
1674
|
server: resp.headers[:server].to_s, generator: doc.at('meta[name="generator"]')&.[]('content').to_s,
|
|
@@ -1756,7 +1786,14 @@ module PWN
|
|
|
1756
1786
|
if junk_unknown
|
|
1757
1787
|
:skipped_junk
|
|
1758
1788
|
else
|
|
1759
|
-
|
|
1789
|
+
if defined?(Learning) && Learning.respond_to?(:note_outcome)
|
|
1790
|
+
Learning.note_outcome(
|
|
1791
|
+
task: "extro_verify: #{claim[0, 120]}", success: nil,
|
|
1792
|
+
details: 'verdict :unknown - needs human review', tags: %w[needs_human extro_verify],
|
|
1793
|
+
outcome: { score: nil, confidence: opts[:confidence], source: :extro_verify,
|
|
1794
|
+
grounded: { verdict: :unknown, kind: opts[:kind], evidence: opts[:evidence] } }
|
|
1795
|
+
)
|
|
1796
|
+
end
|
|
1760
1797
|
:learning_note
|
|
1761
1798
|
end
|
|
1762
1799
|
end
|
|
@@ -2570,10 +2607,10 @@ module PWN
|
|
|
2570
2607
|
else 'unknown'
|
|
2571
2608
|
end
|
|
2572
2609
|
nanp = nil
|
|
2573
|
-
if digits.match
|
|
2574
|
-
area =
|
|
2610
|
+
if (match = digits.match(/\A1?(\d{3})(\d{3})(\d{4})\z/))
|
|
2611
|
+
area = match[1]
|
|
2575
2612
|
# Area-code → region via public NPA style (best-effort subset)
|
|
2576
|
-
nanp = { area_code: area, nxx:
|
|
2613
|
+
nanp = { area_code: area, nxx: match[2], station: match[3] }
|
|
2577
2614
|
end
|
|
2578
2615
|
# OpenCNAM-style public CNAM is largely paywalled; expose format + link targets for deeper manual/keyed lookup.
|
|
2579
2616
|
{
|
data/lib/pwn/ai/agent/gqrx.rb
CHANGED
|
@@ -30,6 +30,7 @@ module PWN
|
|
|
30
30
|
DISPUTED_FILE = File.join(Dir.home, '.pwn', 'learning', 'disputed.jsonl')
|
|
31
31
|
LESSONS_FILE = File.join(Dir.home, '.pwn', 'lessons.json')
|
|
32
32
|
FINETUNE_DIR = File.join(Dir.home, '.pwn', 'finetune')
|
|
33
|
+
EVIDENCE_ANNOTATION_VERSION = 2
|
|
33
34
|
# Evidence is immutable; provenance is not permission to remove a session.
|
|
34
35
|
# All readers validate the content hash and full-snapshot contract first.
|
|
35
36
|
public_class_method def self.evidence_transcript(opts = {})
|
|
@@ -230,15 +231,14 @@ module PWN
|
|
|
230
231
|
return { annotated: false } unless row
|
|
231
232
|
|
|
232
233
|
transcript = session_evidence(session_id: sid)
|
|
234
|
+
binding = opts[:binding]
|
|
235
|
+
return { annotated: false, reason: :stale_binding } unless Reward.prm_binding_valid?(binding: binding, transcript: transcript, session_id: sid) && rewards.length == binding[:actions].length
|
|
236
|
+
|
|
233
237
|
prior = row[:evidence_ref][:sha256]
|
|
234
238
|
artifact = File.join(File.dirname(LEARNING_FILE), 'learning', 'evidence', "#{prior}.json")
|
|
235
239
|
data = JSON.parse(evidence_read(path: artifact), symbolize_names: true)
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
next unless entry[:role].to_s == 'tool'
|
|
239
|
-
|
|
240
|
-
index += 1
|
|
241
|
-
entry[:step_reward] = rewards[index] unless rewards[index].nil?
|
|
240
|
+
binding[:actions].each_with_index do |action, index|
|
|
241
|
+
transcript[action[:row_index]][:step_reward] = rewards[index] unless rewards[index].nil?
|
|
242
242
|
end
|
|
243
243
|
return { annotated: false, unchanged: true } if transcript == data[:transcript]
|
|
244
244
|
|
|
@@ -247,7 +247,7 @@ module PWN
|
|
|
247
247
|
updated = rows.map { |entry| entry[:session_id] == sid ? entry.except(:evidence_ref) : entry }
|
|
248
248
|
snapshot = { body: body, source: nil, path: File.join(PWN::Sessions::SESSIONS_DIR, "#{sid}.jsonl"),
|
|
249
249
|
ref: { version: 1, id: hash, sha256: hash } }
|
|
250
|
-
evidence_commit(rows: updated, original: original, snapshots: { sid => snapshot }, report: { migrated_rows: 0 }).merge(annotated: true)
|
|
250
|
+
evidence_commit(rows: updated, original: original, snapshots: { sid => snapshot }, report: { migrated_rows: 0 }).merge(annotated: true, binding_sha256: Digest::SHA256.hexdigest(JSON.generate(binding)))
|
|
251
251
|
ensure
|
|
252
252
|
learning_unlock(lock: lock) if lock
|
|
253
253
|
end
|
|
@@ -455,6 +455,7 @@ module PWN
|
|
|
455
455
|
|
|
456
456
|
public_class_method def self.note_outcome(opts = {})
|
|
457
457
|
lock = learning_lock
|
|
458
|
+
lease, evidence_ref = source_ownership(session_id: opts[:session_id])
|
|
458
459
|
task = opts[:task].to_s
|
|
459
460
|
# 4.1 — allow success: 'soft' (HER) distinct from true/false
|
|
460
461
|
raw_ok = opts[:success]
|
|
@@ -493,6 +494,7 @@ module PWN
|
|
|
493
494
|
timestamp: Time.now.utc.iso8601
|
|
494
495
|
}
|
|
495
496
|
entry[:score] = score if decision || opts.key?(:score)
|
|
497
|
+
entry[:evidence_ref] = evidence_ref if evidence_ref
|
|
496
498
|
if decision
|
|
497
499
|
%i[verdict confidence training_score decision_version verification verifier_verdict grounded critic_pass judge_score quality_score rationale claimed_completion verified_completion false_completion].each do |key|
|
|
498
500
|
entry[key] = decision[key] if decision.key?(key)
|
|
@@ -534,6 +536,7 @@ module PWN
|
|
|
534
536
|
end
|
|
535
537
|
entry
|
|
536
538
|
ensure
|
|
539
|
+
PWN::Sessions.deactivate(lease: lease)
|
|
537
540
|
learning_unlock(lock: lock) if lock
|
|
538
541
|
end
|
|
539
542
|
|
|
@@ -546,10 +549,33 @@ module PWN
|
|
|
546
549
|
end
|
|
547
550
|
|
|
548
551
|
public_class_method def self.disputed_save(opts = {})
|
|
552
|
+
lock = learning_lock
|
|
549
553
|
entry = opts[:entry] || {}
|
|
554
|
+
lease, evidence_ref = source_ownership(session_id: entry[:session_id])
|
|
555
|
+
entry = entry.merge(evidence_ref: evidence_ref) if evidence_ref
|
|
550
556
|
FileUtils.mkdir_p(File.dirname(DISPUTED_FILE))
|
|
551
557
|
File.open(DISPUTED_FILE, 'a') { |f| f.puts(JSON.generate(entry)) }
|
|
552
558
|
entry
|
|
559
|
+
ensure
|
|
560
|
+
PWN::Sessions.deactivate(lease: lease)
|
|
561
|
+
learning_unlock(lock: lock) if lock
|
|
562
|
+
end
|
|
563
|
+
|
|
564
|
+
# Manual noncanonical IDs are legacy provenance, not canonical evidence
|
|
565
|
+
# claims. Existing legacy transcripts still get lifetime ownership.
|
|
566
|
+
# Called only under learning_lock, so deletion cannot race this decision.
|
|
567
|
+
private_class_method def self.source_ownership(opts = {})
|
|
568
|
+
sid = opts[:session_id].to_s
|
|
569
|
+
safe = !sid.empty? && File.basename(sid) == sid && !sid.include?("\0") && !%w[. ..].include?(sid)
|
|
570
|
+
path = File.join(PWN::Sessions::SESSIONS_DIR, "#{sid}.jsonl") if safe
|
|
571
|
+
return [PWN::Sessions.activate(session_id: sid), nil] if path && (File.exist?(path) || File.symlink?(path))
|
|
572
|
+
return [nil, nil] unless sid.match?(PWN::Sessions::SESSION_ID)
|
|
573
|
+
|
|
574
|
+
raise IOError, 'Missing learning source or verified archived evidence' unless session_evidence(session_id: sid)
|
|
575
|
+
|
|
576
|
+
rows = evidence_read(path: LEARNING_FILE).lines.map { |line| JSON.parse(line, symbolize_names: true) }
|
|
577
|
+
row = rows.find { |item| item[:session_id] == sid && item[:evidence_ref] }
|
|
578
|
+
[nil, row.fetch(:evidence_ref)]
|
|
553
579
|
end
|
|
554
580
|
|
|
555
581
|
# Supported Method Parameters::
|
|
@@ -2025,11 +2051,16 @@ module PWN
|
|
|
2025
2051
|
return { kept: 0, removed: 0, skipped: true } unless File.exist?(LEARNING_FILE)
|
|
2026
2052
|
|
|
2027
2053
|
before_bytes = File.size(LEARNING_FILE)
|
|
2028
|
-
rows = File.readlines(LEARNING_FILE).map do |
|
|
2029
|
-
JSON.parse(
|
|
2030
|
-
rescue
|
|
2054
|
+
rows = File.readlines(LEARNING_FILE).map do |line|
|
|
2055
|
+
JSON.parse(line, symbolize_names: true)
|
|
2056
|
+
rescue JSON::ParserError
|
|
2031
2057
|
nil
|
|
2032
|
-
end
|
|
2058
|
+
end
|
|
2059
|
+
malformed = rows.count { |row| !row.is_a?(Hash) }
|
|
2060
|
+
if malformed.positive?
|
|
2061
|
+
return { state: 'blocked', aborted: true, reason: 'malformed_learning_rows', malformed_rows: malformed,
|
|
2062
|
+
kept: rows.length, removed: 0, bytes_before: before_bytes, bytes_after: before_bytes, dry_run: dry }
|
|
2063
|
+
end
|
|
2033
2064
|
|
|
2034
2065
|
now = Time.now.utc
|
|
2035
2066
|
age_days = lambda do |r|
|
|
@@ -2126,7 +2157,7 @@ module PWN
|
|
|
2126
2157
|
|
|
2127
2158
|
{
|
|
2128
2159
|
kept: kept.size,
|
|
2129
|
-
removed:
|
|
2160
|
+
removed: rows.size - kept.size,
|
|
2130
2161
|
deduped: removed_dupes,
|
|
2131
2162
|
truncated_details: truncated,
|
|
2132
2163
|
protected: protected.size,
|
|
@@ -2433,7 +2464,8 @@ module PWN
|
|
|
2433
2464
|
# Persist derived PRM rewards without rewriting immutable supporting content.
|
|
2434
2465
|
#{self}.annotate_evidence(
|
|
2435
2466
|
session_id: 'required - canonical source session ID with retained evidence and no live transcript',
|
|
2436
|
-
rewards: 'required - Array of integer -1, 0, 1 or nil per tool row'
|
|
2467
|
+
rewards: 'required - Array of integer -1, 0, 1 or nil per bound tool row',
|
|
2468
|
+
binding: 'required - versioned Reward.prm_snapshot binding for the exact request turn and original action bytes'
|
|
2437
2469
|
)
|
|
2438
2470
|
|
|
2439
2471
|
# Read and verify the immutable evidence supporting one outcome.
|