pwn 0.5.794 → 0.5.796
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 +2 -2
- 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/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/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 +12 -11
- data/lib/pwn/ai/agent/metrics.rb +1 -1
- data/lib/pwn/ai/agent/mission.rb +6 -3
- 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/repl/ai.rb +1 -0
- data/lib/pwn/plugins/repl/ai_console.rb +12 -5
- data/lib/pwn/plugins/repl/mesh.rb +10 -2
- 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 +307 -39
- 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/pwn.gemspec +4 -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/spec_curriculum_isolation_spec.rb +41 -0
- data/spec/integration/spec_sandbox_isolation_spec.rb +43 -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 +210 -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_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/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/repl/ai_console_spec.rb +136 -6
- data/spec/lib/pwn/plugins/repl/ai_legacy_containment_spec.rb +33 -4
- 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/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 +45 -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_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/support/namespace_controller_observability_fixture.rb +141 -0
- data/spec/support/sandbox.rb +11 -6
- data/third_party/pwn_rdoc.jsonl +73 -31
- metadata +140 -20
- 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
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::PS, 'cleanup header regression' do
|
|
6
|
+
it 'does not turn a ps header or malformed PID into process group zero' do
|
|
7
|
+
rows = [%w[USER %CPU PID PPID], ['fixture', '0.0', '42', '1'], ['fixture', '0.0', 'invalid', '1']]
|
|
8
|
+
expect(Process).to receive(:kill).with('TERM', 42).once
|
|
9
|
+
expect(Process).not_to receive(:kill).with('TERM', 0)
|
|
10
|
+
described_class.cleanup_pids(pids_arr: rows)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -4,6 +4,117 @@ require 'spec_helper'
|
|
|
4
4
|
require 'stringio'
|
|
5
5
|
require 'pry'
|
|
6
6
|
|
|
7
|
+
describe 'buffered mission event delivery' do
|
|
8
|
+
include_context 'pwn tmp sandbox'
|
|
9
|
+
|
|
10
|
+
it 'publishes the assistant event before a blocked title refresh on a reopened descriptor' do
|
|
11
|
+
input, input_writer = IO.pipe
|
|
12
|
+
reader, original_writer = IO.pipe
|
|
13
|
+
commands, command_writer = IO.pipe
|
|
14
|
+
command_writer.close
|
|
15
|
+
original_writer.autoclose = false
|
|
16
|
+
writer = PWN::AI::Agent::MissionNamespace.io(original_writer.fileno)
|
|
17
|
+
expect(writer.sync).to be(false)
|
|
18
|
+
entered = Queue.new
|
|
19
|
+
release = Queue.new
|
|
20
|
+
pry = Pry.new
|
|
21
|
+
controller = PWN::Plugins::REPL::AIConsole::Console.new(pry: pry, input: input, curses: nil, getch: nil)
|
|
22
|
+
allow(PWN::Sessions).to receive(:provisional_title).and_return(nil)
|
|
23
|
+
allow(PWN::AI::Agent::Loop).to receive(:run).and_return('answer before title')
|
|
24
|
+
allow(PWN::Sessions).to receive(:refresh_title) do
|
|
25
|
+
entered << true
|
|
26
|
+
release.pop
|
|
27
|
+
{ id: 'buffered-session', title: 'Finished title' }
|
|
28
|
+
end
|
|
29
|
+
previous = [$stdin, $stdout, $stderr]
|
|
30
|
+
Dir.chdir(@tmp) do
|
|
31
|
+
worker = Thread.new do
|
|
32
|
+
controller.send(:mission_request_child, { request: 'fixture', generation: 'generation', session_id: 'buffered-session', title_config: {} }, writer, commands)
|
|
33
|
+
end
|
|
34
|
+
Timeout.timeout(5) { entered.pop }
|
|
35
|
+
expect(worker).to be_alive
|
|
36
|
+
ready = reader.wait_readable(0.5)
|
|
37
|
+
expect(ready).not_to be_nil, 'assistant event remained buffered while title refresh was blocked'
|
|
38
|
+
rows = reader.read_nonblock(16_384).lines.map { |line| JSON.parse(line) }
|
|
39
|
+
expect(rows).to include(['generation', 'assistant', 'answer before title'])
|
|
40
|
+
expect(rows).not_to include(['generation', 'session_title', { 'id' => 'buffered-session', 'title' => 'Finished title' }])
|
|
41
|
+
ensure
|
|
42
|
+
release << true
|
|
43
|
+
worker&.join(5)
|
|
44
|
+
worker&.kill if worker&.alive?
|
|
45
|
+
worker&.join
|
|
46
|
+
end
|
|
47
|
+
ensure
|
|
48
|
+
$stdin, $stdout, $stderr = previous if previous
|
|
49
|
+
[input, input_writer, reader, writer, commands, command_writer].compact.each { |io| io.close unless io.closed? }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
describe 'tool input admission' do
|
|
54
|
+
it 'rejects an oversized line without delivering any prefix to the tool' do
|
|
55
|
+
reader, writer = IO.pipe
|
|
56
|
+
console = PWN::Plugins::REPL::AIConsole::Console.new(pry: Pry.new, input: reader, curses: nil, getch: nil)
|
|
57
|
+
console.instance_variable_set(:@tool_input, writer)
|
|
58
|
+
console.send(:send_tool_input, "/input #{'x' * 4096}")
|
|
59
|
+
expect(reader.read_nonblock(8192, exception: false)).to eq(:wait_readable)
|
|
60
|
+
expect(console.instance_variable_get(:@timeline).last[1]).to include('not sent', '4096')
|
|
61
|
+
console.send(:send_tool_input, '/input accepted')
|
|
62
|
+
expect(reader.read_nonblock(8192)).to eq("accepted\n")
|
|
63
|
+
ensure
|
|
64
|
+
[reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe 'terminal decoder EOF' do
|
|
69
|
+
["\e", "\e[", "\e[13;"].each do |prefix|
|
|
70
|
+
it "drains truncated escape prefix #{prefix.inspect} before reporting EOF" do
|
|
71
|
+
source, writer = IO.pipe
|
|
72
|
+
keyboard = PWN::Plugins::REPL::AIConsole::Keyboard.new(source)
|
|
73
|
+
writer.write(prefix)
|
|
74
|
+
writer.close
|
|
75
|
+
keys = Array.new(prefix.bytesize + 3) { keyboard.call }.compact
|
|
76
|
+
expect(keys.last).to eq(:eof)
|
|
77
|
+
expect(keys.grep(String).join).to eq(prefix)
|
|
78
|
+
ensure
|
|
79
|
+
[source, writer].compact.each { |io| io.close unless io.closed? }
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'consumes a truncated UTF-8 character at EOF instead of polling forever' do
|
|
84
|
+
source, writer = IO.pipe
|
|
85
|
+
keyboard = PWN::Plugins::REPL::AIConsole::Keyboard.new(source)
|
|
86
|
+
writer.write("\xe7\x95".b)
|
|
87
|
+
writer.close
|
|
88
|
+
keys = Array.new(4) { keyboard.call }
|
|
89
|
+
expect(keys).to include('�', :eof)
|
|
90
|
+
expect(keyboard.call).to eq(:eof)
|
|
91
|
+
ensure
|
|
92
|
+
[source, writer].compact.each { |io| io.close unless io.closed? }
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
describe 'frozen configuration command handoff' do
|
|
97
|
+
it 'applies a model command through mission IPC with Config-style frozen outer Env' do
|
|
98
|
+
Dir.mktmpdir('console-frozen-env-') do |root|
|
|
99
|
+
ai = { active: :grok, grok: { model: 'before-fixture' } }
|
|
100
|
+
stub_const('PWN::Env', { ai: ai, driver_opts: { pwn_env_path: File.join(root, 'absent.yaml') } }.freeze)
|
|
101
|
+
allow(Dir).to receive(:home).and_return(root)
|
|
102
|
+
input, sender = IO.pipe
|
|
103
|
+
console = PWN::Plugins::REPL::AIConsole::Console.new(pry: Pry.new, input: input, curses: nil, getch: nil)
|
|
104
|
+
console.start_request('/model grok after-fixture', command: true)
|
|
105
|
+
expect(console.instance_variable_get(:@worker).join(10)).not_to be_nil
|
|
106
|
+
expect { console.drain }.not_to raise_error
|
|
107
|
+
expect(PWN::Env).to be_frozen
|
|
108
|
+
expect(PWN::Env[:ai]).to equal(ai)
|
|
109
|
+
expect(PWN::Env.dig(:ai, :grok, :model)).to eq('after-fixture')
|
|
110
|
+
expect(console).not_to be_busy
|
|
111
|
+
ensure
|
|
112
|
+
console&.stop_worker
|
|
113
|
+
[input, sender, console&.instance_variable_get(:@tool_input)].compact.each { |io| io.close unless io.closed? }
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
7
118
|
describe 'mission configuration handoff' do
|
|
8
119
|
include_context 'pwn tmp sandbox'
|
|
9
120
|
|
|
@@ -530,7 +641,9 @@ describe 'pwn-ai curses launch' do # rubocop:disable Metrics/BlockLength -- publ
|
|
|
530
641
|
PWN::Plugins::REPL::AIConsole.run(pry: @pry, input: input, output: output, curses: screen, getch: reader)
|
|
531
642
|
end
|
|
532
643
|
rescue expired
|
|
533
|
-
|
|
644
|
+
timeline = @console&.instance_variable_get(:@timeline).to_a.last(8).map { |type, text| [type, text.to_s[0, 400]] }
|
|
645
|
+
paint = @paint.last(120).join
|
|
646
|
+
raise expired, "execution expired phase=#{@launch_phase.inspect} session=#{@pry.config.pwn_ai_session_id} timeline=#{timeline.inspect} paint=#{paint[-240, 240] || paint}"
|
|
534
647
|
end
|
|
535
648
|
expect([$stdin, $stdout]).to eq(previous.take(2))
|
|
536
649
|
expect(PWN::Plugins::Log.raw_stderr).to equal(previous[2])
|
|
@@ -2678,34 +2791,51 @@ describe 'pwn-ai curses launch' do # rubocop:disable Metrics/BlockLength -- publ
|
|
|
2678
2791
|
PWN::Sessions.append(session_id: sid, role: 'user', content: 'Previous fixture question')
|
|
2679
2792
|
PWN::Sessions.append(session_id: sid, role: 'assistant', content: 'Previous fixture answer')
|
|
2680
2793
|
allow(PWN::Plugins::REPL).to receive(:persist_ai_selection).and_return(false)
|
|
2794
|
+
seen = File.join(@tmp, 'curses-provider-call.json')
|
|
2795
|
+
recorded = false
|
|
2681
2796
|
allow(PWN::AI::OpenAI).to receive(:chat_with_tools) do |opts|
|
|
2682
|
-
|
|
2683
|
-
|
|
2797
|
+
unless recorded
|
|
2798
|
+
recorded = true
|
|
2799
|
+
messages = Array(opts[:messages]).map { |row| { role: row[:role] || row['role'], content: (row[:content] || row['content']).to_s } }
|
|
2800
|
+
File.write(seen, JSON.generate(model: PWN::Env.dig(:ai, :openai, :model), call_model: opts[:model], messages: messages))
|
|
2801
|
+
end
|
|
2684
2802
|
{ choices: [{ message: { role: 'assistant', content: 'Selected route.', tool_calls: [] } }] }
|
|
2685
2803
|
end
|
|
2804
|
+
allow(PWN::AI::Router).to receive(:summarize).and_return('{"title":"Resumed console","summary":"Fixture summary."}')
|
|
2686
2805
|
keys = "/model openai console-fixture\n".chars
|
|
2687
2806
|
phase = :model
|
|
2688
2807
|
launch(keys) do
|
|
2689
2808
|
@launch_phase = phase
|
|
2690
2809
|
idle = @console && !@console.send(:busy?)
|
|
2810
|
+
prompt = @console&.instance_variable_get(:@model_prompt)
|
|
2691
2811
|
case phase
|
|
2692
2812
|
when :model
|
|
2693
|
-
if idle && @paint.join.include?('model=console-fixture')
|
|
2813
|
+
if idle && !prompt && @paint.join.include?('model=console-fixture') && PWN::Env.dig(:ai, :openai, :model) == 'console-fixture'
|
|
2694
2814
|
phase = :resume
|
|
2695
2815
|
keys.concat("/sessions resume resumed console\n".chars)
|
|
2696
2816
|
end
|
|
2697
2817
|
nil
|
|
2698
2818
|
when :resume
|
|
2699
|
-
if idle && @pry.config.pwn_ai_session_id == sid
|
|
2819
|
+
if idle && !prompt && @pry.config.pwn_ai_session_id == sid && PWN::Env.dig(:ai, :openai, :model) == 'console-fixture'
|
|
2700
2820
|
phase = :ask
|
|
2701
2821
|
keys.concat("what color is a lemon?\n".chars)
|
|
2702
2822
|
end
|
|
2703
2823
|
nil
|
|
2704
2824
|
else
|
|
2705
|
-
"\u0004" if
|
|
2825
|
+
"\u0004" if idle
|
|
2706
2826
|
end
|
|
2707
2827
|
end
|
|
2708
2828
|
expect(@pry.config.pwn_ai_session_id).to eq(sid)
|
|
2829
|
+
expect(File).to exist(seen), "Mission finished without calling the provider: #{@console.instance_variable_get(:@timeline).inspect}"
|
|
2830
|
+
observed = JSON.parse(File.read(seen), symbolize_names: true)
|
|
2831
|
+
expect(observed[:model]).to eq('console-fixture')
|
|
2832
|
+
expect(observed[:call_model]).to eq('console-fixture')
|
|
2833
|
+
expect(observed[:messages]).to include(
|
|
2834
|
+
hash_including(role: 'user', content: 'Previous fixture question'),
|
|
2835
|
+
hash_including(role: 'assistant', content: 'Previous fixture answer'),
|
|
2836
|
+
hash_including(role: 'user', content: 'what color is a lemon?')
|
|
2837
|
+
)
|
|
2838
|
+
expect(@paint.join).to include('Selected route.')
|
|
2709
2839
|
expect(PWN::Sessions.load(session_id: sid).map { |row| row[:content] }.join).to include('Selected route.')
|
|
2710
2840
|
end
|
|
2711
2841
|
|
|
@@ -27,6 +27,37 @@ describe 'regex-ReAct mission containment' do
|
|
|
27
27
|
Pry.config.hooks.get_hook(:after_read, :pwn_ai_hook).call(request, pry)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def wait_for_descendant_pid(marker)
|
|
31
|
+
Timeout.timeout(10) do
|
|
32
|
+
loop do
|
|
33
|
+
text = File.read(marker) if File.file?(marker)
|
|
34
|
+
pid = text.to_s[/^NSpid:[ \t]+([1-9]\d*)(?:[ \t]+\d+)+\n/, 1]
|
|
35
|
+
return pid.to_i if pid
|
|
36
|
+
|
|
37
|
+
sleep 0.01
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'waits for the descendant PID contents rather than an empty readiness file' do
|
|
43
|
+
marker = File.join(@tmp, 'partial-ready')
|
|
44
|
+
File.write(marker, '')
|
|
45
|
+
read_empty = Queue.new
|
|
46
|
+
writer = Thread.new do
|
|
47
|
+
read_empty.pop
|
|
48
|
+
File.write(marker, "NSpid:\t12345\t1\n")
|
|
49
|
+
end
|
|
50
|
+
allow(File).to receive(:read).and_call_original
|
|
51
|
+
allow(File).to receive(:read).with(marker).and_wrap_original do |original, path|
|
|
52
|
+
text = original.call(path)
|
|
53
|
+
read_empty << true if text.empty?
|
|
54
|
+
text
|
|
55
|
+
end
|
|
56
|
+
expect(wait_for_descendant_pid(marker)).to eq(12_345)
|
|
57
|
+
ensure
|
|
58
|
+
writer&.kill&.join
|
|
59
|
+
end
|
|
60
|
+
|
|
30
61
|
it 'fails closed before calling a provider when mission containment is unavailable' do
|
|
31
62
|
allow(PWN::Plugins::AISandbox::MissionProcess).to receive(:new).and_raise(PWN::Plugins::AISandbox::NotStarted, 'enable user/PID namespaces')
|
|
32
63
|
expect(PWN::AI::Ollama).not_to receive(:chat)
|
|
@@ -137,8 +168,7 @@ describe 'regex-ReAct mission containment' do
|
|
|
137
168
|
nil
|
|
138
169
|
end
|
|
139
170
|
marker = File.join(@tmp, '.pwn', 'workspaces', 'runtime', 'pty-ready')
|
|
140
|
-
|
|
141
|
-
host_pid = File.read(marker)[/^NSpid:\s+(\d+)/, 1].to_i
|
|
171
|
+
host_pid = wait_for_descendant_pid(marker)
|
|
142
172
|
writer.write("\x03")
|
|
143
173
|
Timeout.timeout(10) { sleep 0.01 until output.include?('CANCELLED READY') }
|
|
144
174
|
expect { Process.kill(0, host_pid) }.to raise_error(Errno::ESRCH)
|
|
@@ -179,8 +209,7 @@ describe 'regex-ReAct mission containment' do
|
|
|
179
209
|
rescue Interrupt
|
|
180
210
|
:cancelled
|
|
181
211
|
end
|
|
182
|
-
|
|
183
|
-
host_pid = File.read(marker)[/^NSpid:\s+(\d+)/, 1].to_i
|
|
212
|
+
host_pid = wait_for_descendant_pid(marker)
|
|
184
213
|
worker.raise(Interrupt)
|
|
185
214
|
expect(Timeout.timeout(10) { worker.value }).to eq(:cancelled)
|
|
186
215
|
expect(repl).to have_received(:ready_tty!)
|
|
@@ -64,6 +64,44 @@ describe PWN::Plugins::REPL::AI do
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
describe 'buffered line-mode mission delivery' do
|
|
68
|
+
include_context 'pwn tmp sandbox'
|
|
69
|
+
|
|
70
|
+
it 'delivers tool events while the provider is still blocked' do
|
|
71
|
+
input, input_writer = IO.pipe
|
|
72
|
+
reader, original_writer = IO.pipe
|
|
73
|
+
original_writer.autoclose = false
|
|
74
|
+
writer = PWN::AI::Agent::MissionNamespace.io(original_writer.fileno)
|
|
75
|
+
expect(writer.sync).to be(false)
|
|
76
|
+
allow(PWN::AI::Agent::MissionNamespace).to receive(:io).with(4).and_return(writer)
|
|
77
|
+
allow(PWN::AI::Agent::MissionNamespace).to receive(:io).with(0).and_return(input)
|
|
78
|
+
entered = Queue.new
|
|
79
|
+
release = Queue.new
|
|
80
|
+
allow(PWN::AI::Agent::Loop).to receive(:run) do |opts|
|
|
81
|
+
opts[:on_tool].call('fixture-tool', 'fixture-argument', 'fixture-result')
|
|
82
|
+
entered << true
|
|
83
|
+
release.pop
|
|
84
|
+
'final answer'
|
|
85
|
+
end
|
|
86
|
+
Dir.chdir(@tmp) do
|
|
87
|
+
worker = Thread.new do
|
|
88
|
+
PWN::Plugins::REPL.pwn_ai_mission_entry(operation: :steerable, config: {}, options: { request: 'fixture' })
|
|
89
|
+
end
|
|
90
|
+
Timeout.timeout(5) { entered.pop }
|
|
91
|
+
expect(reader.wait_readable(0.5)).not_to be_nil, 'tool event remained buffered until mission completion'
|
|
92
|
+
event = JSON.parse(reader.read_nonblock(16_384))
|
|
93
|
+
expect(event).to eq('event' => 'tool', 'args' => %w[fixture-tool fixture-argument fixture-result])
|
|
94
|
+
ensure
|
|
95
|
+
release << true
|
|
96
|
+
worker&.join(5)
|
|
97
|
+
worker&.kill if worker&.alive?
|
|
98
|
+
worker&.join
|
|
99
|
+
end
|
|
100
|
+
ensure
|
|
101
|
+
[input, input_writer, reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
67
105
|
describe 'menu command result routes' do
|
|
68
106
|
include_context 'pwn tmp sandbox'
|
|
69
107
|
|
|
@@ -2,6 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
|
+
describe 'radio configuration handshake cleanup' do
|
|
6
|
+
%i[serial bluetooth tcp].each do |kind|
|
|
7
|
+
it "closes an opened #{kind} connection when configuration handshake fails" do
|
|
8
|
+
transport = Module.new
|
|
9
|
+
stub_const("Meshtastic::#{kind == :tcp ? 'TCP' : kind.to_s.capitalize}", transport)
|
|
10
|
+
connection = { fixture: kind }
|
|
11
|
+
allow(transport).to receive(:connect).and_return(connection)
|
|
12
|
+
allow(transport).to receive(:wait_for_config).and_raise(IOError, 'fixture handshake failure')
|
|
13
|
+
expect(transport).to receive(:disconnect).with({ "#{kind}_obj": connection })
|
|
14
|
+
expect { PWN::Plugins::REPL.send(:mesh_connect_one, env: {}, transport: kind) }.to raise_error(IOError, 'fixture handshake failure')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe 'auto-selected mesh device editing' do
|
|
20
|
+
it 'updates the connected serial device without overwriting MQTT settings' do
|
|
21
|
+
repl = PWN::Plugins::REPL
|
|
22
|
+
stub_const('PWN::MeshTransport', :serial)
|
|
23
|
+
env = { transport: :auto, serial: { port: '/dev/fixture-old' }, mqtt: { host: 'broker.example.test', port: 1883 } }
|
|
24
|
+
allow(repl).to receive(:persist_mesh_env).and_return(true)
|
|
25
|
+
allow(repl).to receive(:mesh_reconnect!).and_return(:reconnected)
|
|
26
|
+
allow(repl).to receive(:mesh_ui_puts)
|
|
27
|
+
repl.send(:pwn_mesh_run_device, env: env, args: ['/dev/fixture-new'])
|
|
28
|
+
expect(env[:serial][:port]).to eq('/dev/fixture-new')
|
|
29
|
+
expect(env[:mqtt]).to eq(host: 'broker.example.test', port: 1883)
|
|
30
|
+
expect(env[:transport]).to eq(:auto)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
describe 'mesh conversation identity after eviction' do
|
|
35
|
+
it 'retains distinct selectable message identities past the display limit' do
|
|
36
|
+
repl = PWN::Plugins::REPL
|
|
37
|
+
window = double('offline conversation', maxx: 100, attron: nil, attroff: nil, addstr: nil, refresh: nil)
|
|
38
|
+
stub_const('PWN::MeshRxBodyWin', window)
|
|
39
|
+
stub_const('PWN::MeshMutex', Mutex.new)
|
|
40
|
+
stub_const('PWN::MeshRxState', {})
|
|
41
|
+
allow(Curses).to receive(:color_pair).and_return(0)
|
|
42
|
+
allow(repl).to receive(:mesh_paint_details)
|
|
43
|
+
allow(repl).to receive(:mesh_ui_puts) { |opts| raise opts[:text] }
|
|
44
|
+
obj = { my_node_num: 0xaabbccdd, proto_data: [] }
|
|
45
|
+
205.times do |index|
|
|
46
|
+
packet = { id: index + 1, from: 0xaabbccdd, to: 0xffffffff, decoded: { portnum: 1, payload: "fixture #{index}" } }
|
|
47
|
+
repl.send(:mesh_handle_rx, local: true, obj: obj, env: {}, transport: :serial, channel_name: 'LongFast', msg: { packet: packet })
|
|
48
|
+
end
|
|
49
|
+
rows = PWN::MeshRxState[:detail_rows]
|
|
50
|
+
expect(rows.size).to eq(200)
|
|
51
|
+
expect(rows.map { |row| row[:index] }.uniq.size).to eq(rows.size)
|
|
52
|
+
repl.send(:mesh_select_conversation?, key: :up)
|
|
53
|
+
expect(repl.send(:mesh_highlighted_message)).to eq(rows[-2])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
5
57
|
describe PWN::Plugins::REPL::Mesh do
|
|
6
58
|
it 'should display information for authors' do
|
|
7
59
|
authors_response = PWN::Plugins::REPL::Mesh
|
|
@@ -13,13 +13,15 @@ describe 'Sandbox isolation' do
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'triages a real isolated crash with GDB without shell argument injection' do
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
Dir.mktmpdir('pwn-gdb-marker-') do |dir|
|
|
17
|
+
marker = File.join(dir, 'marker')
|
|
18
|
+
result = PWN::Plugins::Sandbox.run(binary: '/bin/sh', backend: 'bwrap', argv: ['-c', 'kill -SEGV $$', "$(touch #{marker})"], timeout: 2, memory_mb: 1024)
|
|
19
|
+
expect(result).to include(ok: true, signal: 'SIGSEGV')
|
|
20
|
+
expect(result[:gdb]).to include('SIGSEGV')
|
|
21
|
+
expect(result[:backtrace]).not_to be_empty
|
|
22
|
+
expect(result[:faulting_address]).to match(/\A0x/)
|
|
23
|
+
expect(File.exist?(marker)).to be(false)
|
|
24
|
+
end
|
|
23
25
|
end
|
|
24
26
|
|
|
25
27
|
it 'snapshots input, rolls it back in isolation and rejects tampering' do
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::SBOM do
|
|
6
|
+
before do
|
|
7
|
+
load File.expand_path('../../../../lib/pwn/ai/agent/tools/sbom_scan.rb', __dir__)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
%w[grype trivy osv-scanner syft].each do |engine|
|
|
11
|
+
it "[PBR-06] propagates fatal #{engine} errors through the real registered handler" do
|
|
12
|
+
allow(Open3).to receive(:capture2).and_return(['{"error":"SYNTHETIC-PRIVATE-ENGINE"}', instance_double(Process::Status, success?: false, exitstatus: 2)])
|
|
13
|
+
handler = PWN::AI::Agent::Registry.lookup(name: 'sbom_scan')[:handler]
|
|
14
|
+
row = handler.call('engine' => engine, 'path' => 'fixture')
|
|
15
|
+
expect(row[:error] || row[:status] == 'failed' || row[:success] == false).to be_truthy
|
|
16
|
+
expect(row[:error].to_s).not_to include('SYNTHETIC-PRIVATE-ENGINE')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
{ 'grype' => 'matches', 'trivy' => 'Results', 'osv-scanner' => 'results', 'syft' => 'artifacts' }.each do |engine, key|
|
|
21
|
+
it "[PBR-06] retains valid empty #{engine} results" do
|
|
22
|
+
allow(Open3).to receive(:capture2).and_return([JSON.generate(key => []), instance_double(Process::Status, success?: true, exitstatus: 0)])
|
|
23
|
+
allow(PWN::Plugins::PreflightChecker).to receive(:bin?).and_return(false)
|
|
24
|
+
expect(described_class.scan(path: 'fixture', engine: engine)[:vulns]).to eq([])
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
['{"error":"SYNTHETIC-PRIVATE-ENGINE"}', '{"SYNTHETIC-PRIVATE-ENGINE":', '[]', '{"matches":42}'].each do |body|
|
|
28
|
+
it "[PBR-06] rejects #{engine} malformed/error envelopes without raw parser causes: #{body.length}" do
|
|
29
|
+
allow(Open3).to receive(:capture2).and_return([body, instance_double(Process::Status, success?: true, exitstatus: 0)])
|
|
30
|
+
allow(PWN::Plugins::PreflightChecker).to receive(:bin?).and_return(false)
|
|
31
|
+
row = described_class.scan(path: 'fixture', engine: engine)
|
|
32
|
+
expect(row[:success]).to be(false)
|
|
33
|
+
expect(row[:error].to_s).not_to include('SYNTHETIC-PRIVATE-ENGINE')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it '[PBR-06] accepts the OSV vulnerability-found exit with a valid response' do
|
|
39
|
+
body = { results: [{ packages: [{ package: { name: 'fixture', version: '1' }, vulnerabilities: [{ id: 'CVE-fixture' }] }] }] }
|
|
40
|
+
allow(Open3).to receive(:capture2).and_return([JSON.generate(body), instance_double(Process::Status, success?: false, exitstatus: 1)])
|
|
41
|
+
expect(described_class.scan(path: 'fixture', engine: 'osv-scanner')[:vulns].first[:cve]).to eq('CVE-fixture')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tempfile'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::ScannableCodes, 'barcode regression' do
|
|
7
|
+
it 'renders a Code128 barcode as a PNG file' do
|
|
8
|
+
Tempfile.create(['barcode-audit', '.png']) do |file|
|
|
9
|
+
described_class.generate(data: 'offline fixture', type: :barcode, path: file.path)
|
|
10
|
+
png = ChunkyPNG::Image.from_file(file.path)
|
|
11
|
+
expect(png.width).to be_positive
|
|
12
|
+
expect(png.height).to be_positive
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'pty'
|
|
5
|
+
require 'timeout'
|
|
6
|
+
|
|
7
|
+
RSpec.describe PWN::Plugins::Serial do
|
|
8
|
+
[Interrupt, IOError].each do |error|
|
|
9
|
+
it "cleans acquired handles and registrations when reader startup raises #{error}" do
|
|
10
|
+
connection = StringIO.new
|
|
11
|
+
allow(File).to receive(:exist?).with('/fixture/serial').and_return(true)
|
|
12
|
+
allow(UART).to receive(:open).and_return(connection)
|
|
13
|
+
allow(Thread).to receive(:new).and_raise(error, 'primary startup failure')
|
|
14
|
+
allow(connection).to receive(:close).and_wrap_original do |original|
|
|
15
|
+
original.call
|
|
16
|
+
raise IOError, 'secondary close failure'
|
|
17
|
+
end
|
|
18
|
+
expect { described_class.connect(block_dev: '/fixture/serial') }.to raise_error(error, 'primary startup failure')
|
|
19
|
+
expect(connection).to be_closed
|
|
20
|
+
expect(described_class.instance_variable_get(:@sessions)).to be_empty
|
|
21
|
+
ensure
|
|
22
|
+
described_class.instance_variable_get(:@sessions).delete_if { |s| s[:serial_conn].equal?(connection) }
|
|
23
|
+
connection.close unless connection.closed?
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
%i[request get_line_state get_modem_params].each do |operation|
|
|
28
|
+
it "preserves the primary #{operation} failure when close fails" do
|
|
29
|
+
connection = double('fake UART', closed?: false)
|
|
30
|
+
allow(connection).to receive(:close).and_raise(IOError, 'secondary close failure')
|
|
31
|
+
allow(connection).to receive(:putc).and_raise(IOError, 'primary operation failure')
|
|
32
|
+
allow(connection).to receive(:ioctl).and_raise(IOError, 'primary operation failure')
|
|
33
|
+
allow(Termios).to receive(:tcgetattr).and_raise(IOError, 'primary operation failure')
|
|
34
|
+
expect { described_class.public_send(operation, serial_obj: { serial_conn: connection }, payload: 'x') }.to raise_error(IOError, 'primary operation failure')
|
|
35
|
+
expect(connection).to have_received(:close).once
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'does not treat an unrelated caller rescue as a primary operation failure' do
|
|
40
|
+
connection = double('fake UART', closed?: false)
|
|
41
|
+
allow(connection).to receive(:close).and_raise(IOError, 'close failure')
|
|
42
|
+
begin
|
|
43
|
+
raise 'unrelated caller error'
|
|
44
|
+
rescue RuntimeError
|
|
45
|
+
expect { described_class.disconnect(serial_obj: { serial_conn: connection }) }.to raise_error(IOError, 'close failure')
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'surfaces a standalone close failure' do
|
|
50
|
+
connection = double('fake UART', closed?: false)
|
|
51
|
+
allow(connection).to receive(:close).and_raise(IOError, 'close failure')
|
|
52
|
+
expect { described_class.disconnect(serial_obj: { serial_conn: connection }) }.to raise_error(IOError, 'close failure')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
[nil, false, '', '/fixture/missing', "bad\0path"].each do |selector|
|
|
56
|
+
it "rejects an explicit invalid selector #{selector.inspect} through BusPirate before acquisition" do
|
|
57
|
+
allow(File).to receive(:exist?).and_call_original
|
|
58
|
+
allow(File).to receive(:exist?).with('/dev/ttyUSB0').and_return(true)
|
|
59
|
+
expect(UART).not_to receive(:open)
|
|
60
|
+
expect { PWN::Plugins::BusPirate.connect(block_dev: selector) }.to raise_error(ArgumentError)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'uses the default only for an absent selector, without mutating the options' do
|
|
65
|
+
reader, writer = IO.pipe
|
|
66
|
+
allow(File).to receive(:exist?).with('/dev/ttyUSB0').and_return(true)
|
|
67
|
+
expect(UART).to receive(:open).with('/dev/ttyUSB0', 9600, '8N1').and_return(reader)
|
|
68
|
+
options = {}.freeze
|
|
69
|
+
session = described_class.connect(options)
|
|
70
|
+
expect(session[:serial_conn]).to equal(reader)
|
|
71
|
+
ensure
|
|
72
|
+
described_class.disconnect(serial_obj: session) if session
|
|
73
|
+
reader&.close unless reader&.closed?
|
|
74
|
+
writer&.close unless writer&.closed?
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'timeout'
|
|
5
|
+
require 'pty'
|
|
6
|
+
|
|
7
|
+
RSpec.describe PWN::Plugins::Serial do
|
|
8
|
+
it 'does not mix bytes from two open connections or flush the other connection' do
|
|
9
|
+
readers = []
|
|
10
|
+
writers = []
|
|
11
|
+
sessions = []
|
|
12
|
+
allow(File).to receive(:exist?).and_call_original
|
|
13
|
+
%w[/fixture/first /fixture/second].each do |path|
|
|
14
|
+
reader, writer = IO.pipe
|
|
15
|
+
readers << reader
|
|
16
|
+
writers << writer
|
|
17
|
+
allow(File).to receive(:exist?).with(path).and_return(true)
|
|
18
|
+
allow(UART).to receive(:open).with(path, 9600, '8N1').and_return(reader)
|
|
19
|
+
sessions << described_class.connect(block_dev: path)
|
|
20
|
+
end
|
|
21
|
+
writers[0].write("\x01".b)
|
|
22
|
+
writers[1].write("\x02".b)
|
|
23
|
+
Timeout.timeout(2) do
|
|
24
|
+
loop do
|
|
25
|
+
combined = sessions.flat_map { |session| described_class.response(serial_obj: session) }.join
|
|
26
|
+
break if combined.include?('01') && combined.include?('02')
|
|
27
|
+
|
|
28
|
+
Thread.pass
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
expect(described_class.response(serial_obj: sessions[0])).to eq(['01'])
|
|
32
|
+
expect(described_class.response(serial_obj: sessions[1])).to eq(['02'])
|
|
33
|
+
expect { described_class.dump_session_data }.to raise_error(ArgumentError, /serial_obj/)
|
|
34
|
+
expect { described_class.flush_session_data }.to raise_error(ArgumentError, /serial_obj/)
|
|
35
|
+
described_class.disconnect(serial_obj: sessions[0])
|
|
36
|
+
expect(described_class.response(serial_obj: sessions[1])).to eq(['02'])
|
|
37
|
+
ensure
|
|
38
|
+
sessions&.each { |session| described_class.disconnect(serial_obj: session) }
|
|
39
|
+
(readers.to_a + writers.to_a).each { |io| io.close unless io.closed? }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'closes a partially acquired connection without requiring a reader thread' do
|
|
43
|
+
connection = StringIO.new
|
|
44
|
+
expect { described_class.disconnect(serial_obj: { serial_conn: connection }) }.not_to raise_error
|
|
45
|
+
expect(connection).to be_closed
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'reports reader EOF to the caller after draining pending bytes rather than losing a worker exception' do
|
|
49
|
+
reader, writer = IO.pipe
|
|
50
|
+
allow(File).to receive(:exist?).with('/fixture/eof').and_return(true)
|
|
51
|
+
allow(UART).to receive(:open).and_return(reader)
|
|
52
|
+
session = described_class.connect(block_dev: '/fixture/eof')
|
|
53
|
+
session[:session_thread].report_on_exception = false
|
|
54
|
+
writer.write('x')
|
|
55
|
+
writer.close
|
|
56
|
+
expect { session[:session_thread].value }.not_to raise_error
|
|
57
|
+
expect(described_class.response(serial_obj: session)).to eq(['78'])
|
|
58
|
+
described_class.flush_session_data(serial_obj: session)
|
|
59
|
+
expect { described_class.response(serial_obj: session) }.to raise_error(EOFError)
|
|
60
|
+
ensure
|
|
61
|
+
described_class.disconnect(serial_obj: session) if session
|
|
62
|
+
reader&.close unless reader&.closed?
|
|
63
|
+
writer&.close unless writer&.closed?
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'queries UART modem settings through termios rather than the removed SerialPort API' do
|
|
67
|
+
connection = StringIO.new
|
|
68
|
+
attributes = double('termios attributes', ospeed: Termios::B9600, cflag: Termios::CS8)
|
|
69
|
+
allow(Termios).to receive(:tcgetattr).with(connection).and_return(attributes)
|
|
70
|
+
expect(described_class.get_modem_params(serial_obj: { serial_conn: connection })).to eq('baud' => 9600, 'data_bits' => 8, 'stop_bits' => 1, 'parity' => 0)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'reads modem line flags with ioctl rather than returning filesystem stat' do
|
|
74
|
+
connection = double('UART file', lstat: :filesystem_stat)
|
|
75
|
+
allow(connection).to receive(:ioctl).with(Termios::TIOCMGET, anything) do |_, buffer|
|
|
76
|
+
buffer.replace([Termios::TIOCM_RTS | Termios::TIOCM_CTS].pack('i'))
|
|
77
|
+
0
|
|
78
|
+
end
|
|
79
|
+
expect(described_class.get_line_state(serial_obj: { serial_conn: connection })).to eq('rts' => 1, 'dtr' => 0, 'cts' => 1, 'dsr' => 0, 'dcd' => 0, 'ri' => 0)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
it 'preserves UTF-8 bytes through the real UART opener on a virtual PTY' do
|
|
83
|
+
PTY.open do |master, slave|
|
|
84
|
+
session = described_class.connect(block_dev: slave.path)
|
|
85
|
+
begin
|
|
86
|
+
expect(described_class.get_modem_params(serial_obj: session)).to include('baud' => 9600, 'data_bits' => 8)
|
|
87
|
+
described_class.request(serial_obj: session, payload: "\u00e9")
|
|
88
|
+
expect(master.wait_readable(1)).to equal(master)
|
|
89
|
+
expect(master.read_nonblock(64).bytes).to eq([0xc3, 0xa9])
|
|
90
|
+
ensure
|
|
91
|
+
described_class.disconnect(serial_obj: session)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'writes every UTF-8 byte rather than the first byte of each character' do
|
|
97
|
+
connection = StringIO.new(''.b)
|
|
98
|
+
allow(described_class).to receive(:sleep)
|
|
99
|
+
described_class.request(serial_obj: { serial_conn: connection }, payload: "\u00e9")
|
|
100
|
+
expect(connection.string.bytes).to eq([0xc3, 0xa9])
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::Shodan, 'optional search parameters regression' do
|
|
6
|
+
it 'allows saved queries without optional sorting parameters' do
|
|
7
|
+
expect(described_class).to receive(:shodan_rest_call).with(hash_including(rest_call: 'shodan/query', params: { key: 'fixture-token' })).and_return(matches: [])
|
|
8
|
+
expect(described_class.saved_search_queries(api_key: 'fixture-token')).to eq(matches: [])
|
|
9
|
+
end
|
|
10
|
+
end
|