pwn 0.5.795 → 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 +1 -1
- 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/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 +111 -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/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 +8 -5
- data/third_party/pwn_rdoc.jsonl +73 -31
- metadata +137 -18
- 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,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::SDR::Decoder::Base, 'review exception ownership regression' do
|
|
6
|
+
it 'PSR-L01 retains clean EOF when the caller is handling an unrelated exception' do
|
|
7
|
+
demod = Object.new
|
|
8
|
+
demod.define_singleton_method(:feed_iq) { |_samples, rate:| rate }
|
|
9
|
+
demod.define_singleton_method(:flush) { |&emit| emit.call(event: 'clean-eof') }
|
|
10
|
+
output = StringIO.new
|
|
11
|
+
input = StringIO.new('')
|
|
12
|
+
result = begin
|
|
13
|
+
raise 'unrelated caller exception'
|
|
14
|
+
rescue RuntimeError
|
|
15
|
+
described_class.run_iq(freq_obj: {}, source: input, demod: demod,
|
|
16
|
+
output: output, log_file: false, interactive: false)
|
|
17
|
+
end
|
|
18
|
+
expect(output.string.lines.map { |line| JSON.parse(line)['event'] }).to eq(['clean-eof'])
|
|
19
|
+
expect(result).to include(reason: :eof, capture_complete: true, frames: 1)
|
|
20
|
+
expect(input).to be_closed
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'preserves local supervisor interruption and prevents cleanup EOF finalization' do
|
|
24
|
+
reader, writer = IO.pipe
|
|
25
|
+
threads = []
|
|
26
|
+
allow(Thread).to receive(:new).and_wrap_original do |original, *args, &block|
|
|
27
|
+
original.call(*args, &block).tap { |thread| threads << thread }
|
|
28
|
+
end
|
|
29
|
+
demod = Object.new
|
|
30
|
+
demod.define_singleton_method(:feed) { |_samples| nil }
|
|
31
|
+
demod.define_singleton_method(:flush) { |&emit| emit.call(event: 'incorrect-finalization') }
|
|
32
|
+
output = StringIO.new
|
|
33
|
+
cancel_read = lambda do
|
|
34
|
+
writer.close unless writer.closed?
|
|
35
|
+
threads.each { |thread| thread.join(1) }
|
|
36
|
+
end
|
|
37
|
+
expect do
|
|
38
|
+
described_class.run_native(freq_obj: {}, source: reader, demod: demod, cancel_read: cancel_read,
|
|
39
|
+
stop: -> { raise Interrupt, 'cancel fixture' },
|
|
40
|
+
interactive: false, output: output, log_file: false)
|
|
41
|
+
end.to raise_error(Interrupt, 'cancel fixture')
|
|
42
|
+
expect(output.string).to be_empty
|
|
43
|
+
expect(reader).to be_closed
|
|
44
|
+
expect(threads).to all(satisfy { |thread| !thread.alive? })
|
|
45
|
+
ensure
|
|
46
|
+
[reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
47
|
+
threads&.each { |thread| thread.kill.join if thread.alive? }
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'timeout'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::SDR::Decoder::Base do
|
|
7
|
+
def silent_demod
|
|
8
|
+
Object.new.tap do |demod|
|
|
9
|
+
demod.define_singleton_method(:feed_iq) { |_samples, rate:| rate }
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
[0, -1].each do |rate|
|
|
14
|
+
it "rejects configured sample rate #{rate} before resolving a source" do
|
|
15
|
+
allow(described_class).to receive(:resolve_iq_source).and_return(kind: :io, io: StringIO.new(''))
|
|
16
|
+
expect do
|
|
17
|
+
described_class.run_iq(freq_obj: {}, sample_rate: rate, demod: silent_demod,
|
|
18
|
+
interactive: false, output: StringIO.new, log_file: false)
|
|
19
|
+
end.to raise_error(ArgumentError, /sample_rate.*positive/)
|
|
20
|
+
expect(described_class).not_to have_received(:resolve_iq_source)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
[0, -1, Float::NAN, Float::INFINITY].each do |rate|
|
|
25
|
+
it "rejects descriptor rate #{rate} even for empty captures before flushing" do
|
|
26
|
+
input = StringIO.new('')
|
|
27
|
+
demod = silent_demod
|
|
28
|
+
expect(demod).not_to receive(:flush)
|
|
29
|
+
expect do
|
|
30
|
+
described_class.run_iq(freq_obj: {}, source: { kind: :io, io: input, rate_hz: rate }, demod: demod,
|
|
31
|
+
interactive: false, output: StringIO.new, log_file: false)
|
|
32
|
+
end.to raise_error(ArgumentError, /rate.*finite.*positive/)
|
|
33
|
+
expect(input).to be_closed
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'does not finalize or emit when supervisor failure unblocks a pipe during cleanup' do
|
|
38
|
+
reader, writer = IO.pipe
|
|
39
|
+
threads = []
|
|
40
|
+
allow(Thread).to receive(:new).and_wrap_original do |original, *args, &block|
|
|
41
|
+
original.call(*args, &block).tap { |thread| threads << thread }
|
|
42
|
+
end
|
|
43
|
+
demod = Object.new
|
|
44
|
+
demod.define_singleton_method(:feed) { |_samples| nil }
|
|
45
|
+
demod.define_singleton_method(:flush) { |&emit| emit.call(event: 'incorrect-finalization') }
|
|
46
|
+
output = StringIO.new
|
|
47
|
+
cancel_read = lambda do
|
|
48
|
+
writer.close unless writer.closed?
|
|
49
|
+
threads.each { |thread| thread.join(1) }
|
|
50
|
+
end
|
|
51
|
+
expect do
|
|
52
|
+
described_class.run_native(freq_obj: {}, source: reader, demod: demod, cancel_read: cancel_read,
|
|
53
|
+
stop: -> { raise IOError, 'supervisor failed' },
|
|
54
|
+
interactive: false, output: output, log_file: false)
|
|
55
|
+
end.to raise_error(IOError, 'supervisor failed')
|
|
56
|
+
expect(output.string).to be_empty
|
|
57
|
+
expect(reader).to be_closed
|
|
58
|
+
expect(threads).to all(satisfy { |thread| !thread.alive? })
|
|
59
|
+
ensure
|
|
60
|
+
[reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
61
|
+
threads&.each { |thread| thread.kill.join if thread.alive? }
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
it 'rejects unsupported formats before waiting on an idle pipe or flushing empty input' do
|
|
65
|
+
reader, writer = IO.pipe
|
|
66
|
+
demod = silent_demod
|
|
67
|
+
expect(demod).not_to receive(:flush)
|
|
68
|
+
expect do
|
|
69
|
+
Timeout.timeout(1) do
|
|
70
|
+
described_class.run_iq(freq_obj: {}, source: reader, iq_format: :cf32, demod: demod,
|
|
71
|
+
interactive: false, output: StringIO.new, log_file: false)
|
|
72
|
+
end
|
|
73
|
+
end.to raise_error(ArgumentError, /Unsupported IQ format/)
|
|
74
|
+
expect(reader).to be_closed
|
|
75
|
+
ensure
|
|
76
|
+
[reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -8,6 +8,15 @@ describe PWN::SDR::Decoder::LoRa do
|
|
|
8
8
|
expect(described_class).to respond_to(:detect)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
it 'raises on source loss rather than silently replacing payload decoding with detection' do
|
|
12
|
+
base = PWN::SDR::Decoder::Base
|
|
13
|
+
allow(base).to receive(:resolve_iq_source).and_return(nil)
|
|
14
|
+
allow(base).to receive(:run_detector).and_return(reason: :eof, frames: 0)
|
|
15
|
+
expect { described_class.decode(freq_obj: {}, source: :file, file: 'offline.cu8', fallback: :detector) }
|
|
16
|
+
.to raise_error(RuntimeError, %r{no I/Q source available})
|
|
17
|
+
expect(base).not_to have_received(:run_detector)
|
|
18
|
+
end
|
|
19
|
+
|
|
11
20
|
it 'decodes an independently encoded CRC-protected packet from chunked IQ' do
|
|
12
21
|
root = File.expand_path('../../../../fixtures/sdr/lora', __dir__)
|
|
13
22
|
vector = JSON.parse(File.read("#{root}/vectors.json"), symbolize_names: true).first
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'pty'
|
|
5
|
+
require 'timeout'
|
|
6
|
+
|
|
7
|
+
RSpec.describe PWN::SDR::FlipperZero do
|
|
8
|
+
it 'uses and flushes only its own real UART buffer with two PTYs' do
|
|
9
|
+
PTY.open do |master1, slave1|
|
|
10
|
+
PTY.open do |master2, slave2|
|
|
11
|
+
first = PWN::Plugins::Serial.connect(block_dev: slave1.path)
|
|
12
|
+
second = PWN::Plugins::Serial.connect(block_dev: slave2.path)
|
|
13
|
+
master1.write('first')
|
|
14
|
+
master2.write('second')
|
|
15
|
+
Timeout.timeout(2) do
|
|
16
|
+
Thread.pass until [first, second].all? { |s| PWN::Plugins::Serial.dump_session_data(serial_obj: s).any? }
|
|
17
|
+
end
|
|
18
|
+
expect(described_class.request(flipper_zero_obj: first, payload: 'help').join).to eq('first')
|
|
19
|
+
expect(master1.read_nonblock(64)).to eq("help\r\n")
|
|
20
|
+
expect(PWN::Plugins::Serial.dump_session_data(serial_obj: first)).to be_empty
|
|
21
|
+
expect(PWN::Plugins::Serial.dump_session_data(serial_obj: second).join).to eq('second')
|
|
22
|
+
ensure
|
|
23
|
+
[first, second].compact.each { |s| PWN::Plugins::Serial.disconnect(serial_obj: s) }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
[nil, false, '', '/fixture/missing'].each do |selector|
|
|
29
|
+
it "rejects invalid explicit screen selection #{selector.inspect}" do
|
|
30
|
+
expect(described_class).not_to receive(:system)
|
|
31
|
+
expect { described_class.connect_via_screen(block_dev: selector) }.to raise_error(ArgumentError)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'socket'
|
|
5
|
+
require 'timeout'
|
|
6
|
+
require 'tempfile'
|
|
7
|
+
require 'open3'
|
|
8
|
+
|
|
9
|
+
RSpec.describe PWN::SDR::GQRX do
|
|
10
|
+
it 'passes device selectors literally to the rate probe without shell expansion' do
|
|
11
|
+
device = 'driver=offline,label=$(fixture),serial="mock"'
|
|
12
|
+
allow(described_class).to receive(:`).and_return('')
|
|
13
|
+
allow(Open3).to receive(:capture2).with('SoapySDRUtil', '--find', err: File::NULL).and_return(['', nil])
|
|
14
|
+
allow(Open3).to receive(:capture2).with('SoapySDRUtil', "--probe=#{device}", err: File::NULL)
|
|
15
|
+
.and_return(["Sample rates: 1, 2 MSps\n", nil])
|
|
16
|
+
expect(described_class.device_input_rates(device: device)).to eq([1_000_000, 2_000_000])
|
|
17
|
+
expect(described_class).not_to have_received(:`)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'updates only the input sample rate in a multi-section configuration' do
|
|
21
|
+
Tempfile.create(['gqrx-config-', '.conf']) do |file|
|
|
22
|
+
file.write("[other]\nsample_rate=111\n[input]\ndevice=offline\nsample_rate=222\n[output]\nsample_rate=333\n")
|
|
23
|
+
file.flush
|
|
24
|
+
result = described_class.set_input_rate(path: file.path, input_rate: 24_000, clamp: false, restart: false)
|
|
25
|
+
expect(result).to include(previous: 222, input_rate: 24_000, restarted: false)
|
|
26
|
+
expect(File.read(file.path)).to eq("[other]\nsample_rate=111\n[input]\ndevice=offline\nsample_rate=24000\n[output]\nsample_rate=333\n")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'keeps a numeric RDS PI value unchanged rather than formatting it as a frequency' do
|
|
31
|
+
client, server = UNIXSocket.pair
|
|
32
|
+
server.write("1234\n")
|
|
33
|
+
expect(described_class.cmd(gqrx_sock: client, cmd: 'p RDS_PI')).to eq('1234')
|
|
34
|
+
ensure
|
|
35
|
+
[client, server].compact.each { |io| io.close unless io.closed? }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it 'returns a complete reply even when the peer immediately closes its output' do
|
|
39
|
+
client, server = UNIXSocket.pair
|
|
40
|
+
server.write("RPRT 0\n")
|
|
41
|
+
server.close_write
|
|
42
|
+
expect(described_class.cmd(gqrx_sock: client, cmd: 'U RDS 0', resp_ok: 'RPRT 0')).to eq('RPRT 0')
|
|
43
|
+
ensure
|
|
44
|
+
[client, server].compact.each { |io| io.close unless io.closed? }
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'rejects a mode response missing its passband line at EOF' do
|
|
48
|
+
client, server = UNIXSocket.pair
|
|
49
|
+
server.write("FM\n")
|
|
50
|
+
server.close_write
|
|
51
|
+
expect { described_class.cmd(gqrx_sock: client, cmd: 'm') }.to raise_error(IOError, /Incomplete.*response/)
|
|
52
|
+
ensure
|
|
53
|
+
[client, server].compact.each { |io| io.close unless io.closed? }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'bounds partial-line waits rather than blocking forever after readability' do
|
|
57
|
+
client, server = UNIXSocket.pair
|
|
58
|
+
server.write('RPRT ')
|
|
59
|
+
expect do
|
|
60
|
+
Timeout.timeout(3) { described_class.cmd(gqrx_sock: client, cmd: 'U RDS 0') }
|
|
61
|
+
end.to raise_error(IOError, /response.*timed out/)
|
|
62
|
+
ensure
|
|
63
|
+
[client, server].compact.each { |io| io.close unless io.closed? }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'collects delayed mode and passband lines without consuming the next command response' do
|
|
67
|
+
client, server = UNIXSocket.pair
|
|
68
|
+
peer = Thread.new do
|
|
69
|
+
expect(server.gets).to eq("m\n")
|
|
70
|
+
server.write("FM\n")
|
|
71
|
+
sleep 0.02
|
|
72
|
+
server.write("12000\n")
|
|
73
|
+
expect(server.gets).to eq("l STRENGTH\n")
|
|
74
|
+
server.write("-50.0\n")
|
|
75
|
+
end
|
|
76
|
+
expect(described_class.cmd(gqrx_sock: client, cmd: 'm')).to eq('FM 12000')
|
|
77
|
+
expect(described_class.cmd(gqrx_sock: client, cmd: 'l STRENGTH')).to eq('-50.0')
|
|
78
|
+
Timeout.timeout(1) { peer.value }
|
|
79
|
+
ensure
|
|
80
|
+
peer&.kill&.join
|
|
81
|
+
[client, server].compact.each { |io| io.close unless io.closed? }
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::SDR::GQRX, 'review configuration insertion regressions' do
|
|
7
|
+
["[input]\n[output]\nsample_rate=333\n", "[input]\n\n[output]\nsample_rate=333\n",
|
|
8
|
+
"[input]\r\n[output]\r\nsample_rate=333\r\n", '[input]'].each do |original|
|
|
9
|
+
it "PSR-L02 inserts a distinct sample-rate line in #{original.inspect}" do
|
|
10
|
+
Dir.mktmpdir('gqrx-empty-input') do |dir|
|
|
11
|
+
file = File.join(dir, 'fixture.conf')
|
|
12
|
+
File.binwrite(file, original)
|
|
13
|
+
result = described_class.set_input_rate(path: file, input_rate: 24_000, clamp: false, restart: false)
|
|
14
|
+
expect(result).to include(input_rate: 24_000, restarted: false)
|
|
15
|
+
lines = File.readlines(file, chomp: true)
|
|
16
|
+
expect(lines.first(2)).to eq(['[input]', 'sample_rate=24000'])
|
|
17
|
+
expect(lines.drop(2)).to eq(original.lines(chomp: true).drop(1))
|
|
18
|
+
expect(described_class.read_input_config(path: file)[:input_rate]).to eq(24_000)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::SDR::SonMicroRFID, 'review write/readback regressions' do
|
|
6
|
+
# These are host parser fixtures, not physical-device protocol captures.
|
|
7
|
+
def serial_fixture(type: '02', data: [1] * 16, read_status: '00', auth_status: '00')
|
|
8
|
+
commands = []
|
|
9
|
+
pending = nil
|
|
10
|
+
allow(PWN::Plugins::Serial).to receive(:request) do |opts|
|
|
11
|
+
payload = opts.fetch(:payload)
|
|
12
|
+
commands << payload
|
|
13
|
+
code = payload[3]
|
|
14
|
+
pending = case code
|
|
15
|
+
when 0x82, 0x83 then "FF 00 06 #{format('%02X', code)} #{type} 11 22 33 44 00"
|
|
16
|
+
when 0x85 then "FF 00 02 85 #{auth_status} 00"
|
|
17
|
+
when 0x87 then 'FF 00 02 87 00 00'
|
|
18
|
+
when 0x86 then "FF 00 #{format('%02X', data.length + 2)} 86 #{read_status} #{data.map { |byte| format('%02X', byte) }.join(' ')} 00"
|
|
19
|
+
else raise "unexpected fixture command #{code}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
allow(PWN::Plugins::Serial).to receive(:response) { [pending] }
|
|
23
|
+
allow(PWN::Plugins::Serial).to receive(:flush_session_data)
|
|
24
|
+
commands
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
allow(described_class).to receive(:logger).and_return(Logger.new(StringIO.new))
|
|
29
|
+
allow(described_class).to receive(:gets).and_return("Y\n")
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
[nil, '', 'GG', '01', ['01'], (['01'] * 17).join(' ')].each do |payload|
|
|
33
|
+
it "PSR-L03 rejects absent or unsupported Classic block data #{payload.inspect} before confirmation or serial traffic" do
|
|
34
|
+
commands = serial_fixture
|
|
35
|
+
data = { resp_code_desc: :mifare_classic_1k, tag_id: '11 22 33 44', block_data: payload }
|
|
36
|
+
expect do
|
|
37
|
+
described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data, authn: true)
|
|
38
|
+
end.to raise_error(ArgumentError, /block_data/)
|
|
39
|
+
expect(described_class).not_to have_received(:gets)
|
|
40
|
+
expect(commands).to be_empty
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'PSR-L03 requires authentication for a Classic write before confirmation or serial traffic' do
|
|
45
|
+
commands = serial_fixture
|
|
46
|
+
data = { resp_code_desc: :mifare_classic_1k, tag_id: '11 22 33 44', block_data: (['01'] * 16).join(' ') }
|
|
47
|
+
expect do
|
|
48
|
+
described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data)
|
|
49
|
+
end.to raise_error(ArgumentError, /authn/)
|
|
50
|
+
expect(described_class).not_to have_received(:gets)
|
|
51
|
+
expect(commands).to be_empty
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
%i[mifare_classic_1k mifare_classic_4k].each do |type|
|
|
55
|
+
it "PSR-L03 authenticates both write and real readback for #{type}" do
|
|
56
|
+
commands = serial_fixture(type: type == :mifare_classic_1k ? '02' : '03', data: [0xab] * 16)
|
|
57
|
+
data = { resp_code_desc: type, tag_id: '11 22 33 44', block_data: (['ab'] * 16).join(' ') }
|
|
58
|
+
key = [1, 2, 3, 4, 5, 6] # synthetic authentication fixture
|
|
59
|
+
result = described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data, authn: true, key: key)
|
|
60
|
+
expect(result).to eq(data)
|
|
61
|
+
expect(commands.map { |payload| payload[3] }).to eq([0x83, 0x85, 0x87, 0x82, 0x85, 0x86])
|
|
62
|
+
expect(commands.select { |payload| payload[3] == 0x85 }.map { |payload| payload.drop(4) }).to eq([[0, 0x60, *key]] * 2)
|
|
63
|
+
expect(commands.find { |payload| payload[3] == 0x87 }.drop(4)).to eq([0, *([0xab] * 16)])
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'preserves successful Ultralight return data after a real readback' do
|
|
68
|
+
commands = serial_fixture(type: '01', data: [1, 2, 3, 4])
|
|
69
|
+
data = { resp_code_desc: :mifare_ultralight, tag_id: '11 22 33 44', block_data: '01 02 03 04' }
|
|
70
|
+
expect(described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data)).to eq(data)
|
|
71
|
+
expect(commands.map { |payload| payload[3] }).to eq([0x83, 0x87, 0x82, 0x86])
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
%w[01 00].each do |read_status|
|
|
75
|
+
it "does not verify missing/failed real readback (#{read_status.inspect})" do
|
|
76
|
+
serial_fixture(type: '01', data: [], read_status: read_status)
|
|
77
|
+
data = { resp_code_desc: :mifare_ultralight, tag_id: '11 22 33 44', block_data: '01 02 03 04' }
|
|
78
|
+
expect do
|
|
79
|
+
described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data)
|
|
80
|
+
end.to raise_error(IOError, /readback.*match/)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'rejects an unsupported tag type before asking for confirmation' do
|
|
85
|
+
commands = serial_fixture
|
|
86
|
+
data = { resp_code_desc: :unknown_tag_type, tag_id: '11 22 33 44', block_data: '01 02 03 04' }
|
|
87
|
+
expect do
|
|
88
|
+
described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data)
|
|
89
|
+
end.to raise_error(ArgumentError, /Unsupported tag type/)
|
|
90
|
+
expect(described_class).not_to have_received(:gets)
|
|
91
|
+
expect(commands).to be_empty
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it 'PSR-L03 refuses the default Classic clone when its read supplies no block payload' do
|
|
95
|
+
commands = serial_fixture
|
|
96
|
+
expect do
|
|
97
|
+
described_class.clone_tag(son_micro_rfid_obj: Object.new)
|
|
98
|
+
end.to raise_error(ArgumentError, /block_data/)
|
|
99
|
+
expect(commands.map { |payload| payload[3] }).to eq([0x82])
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'documents the supported payload and authenticated readback requirements' do
|
|
103
|
+
expect { described_class.help }.to output(/4 Ultralight or 16 Classic.*authn: true/m).to_stdout
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'retains cancellation without any write or readback' do
|
|
107
|
+
commands = serial_fixture(type: '01', data: [1, 2, 3, 4])
|
|
108
|
+
allow(described_class).to receive(:gets).and_return("N\n")
|
|
109
|
+
data = { resp_code_desc: :mifare_ultralight, tag_id: '11 22 33 44', block_data: '01 02 03 04' }
|
|
110
|
+
expect(described_class.write_tag(son_micro_rfid_obj: Object.new, rfid_data: data)).to eq(data)
|
|
111
|
+
expect(commands).to be_empty
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'pwn/plugins/serial'
|
|
5
|
+
require 'socket'
|
|
6
|
+
require 'timeout'
|
|
7
|
+
|
|
8
|
+
RSpec.describe PWN::SDR::SonMicroRFID, 'review Serial session ownership regressions' do
|
|
9
|
+
def with_two_sessions(reply: [0xff, 0x00, 0x06, 0x82, 0x02, 0x11, 0x22, 0x33, 0x44, 0x00])
|
|
10
|
+
sessions = []
|
|
11
|
+
sockets = []
|
|
12
|
+
allow(File).to receive(:exist?).and_call_original
|
|
13
|
+
%w[/fixture/sonmicro /fixture/other].each do |path|
|
|
14
|
+
local, remote = UNIXSocket.pair
|
|
15
|
+
sockets.push(local, remote)
|
|
16
|
+
allow(File).to receive(:exist?).with(path).and_return(true)
|
|
17
|
+
allow(UART).to receive(:open).with(path, 9600, '8N1').and_return(local)
|
|
18
|
+
sessions << PWN::Plugins::Serial.connect(block_dev: path)
|
|
19
|
+
end
|
|
20
|
+
sockets.last.write('untouched')
|
|
21
|
+
Timeout.timeout(2) do
|
|
22
|
+
Thread.pass until PWN::Plugins::Serial.dump_session_data(serial_obj: sessions.last).join == 'untouched'
|
|
23
|
+
end
|
|
24
|
+
peer = Thread.new do
|
|
25
|
+
request = sockets[1].read(5)
|
|
26
|
+
if request && request.bytesize == 5
|
|
27
|
+
if reply == :eof
|
|
28
|
+
sockets[1].close
|
|
29
|
+
else
|
|
30
|
+
sockets[1].write(reply.pack('C*'))
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
Timeout.timeout(2) { yield sessions.first, sessions.last }
|
|
35
|
+
expect(PWN::Plugins::Serial.dump_session_data(serial_obj: sessions.last).join).to eq('untouched')
|
|
36
|
+
ensure
|
|
37
|
+
peer&.kill&.join
|
|
38
|
+
sessions&.each do |session|
|
|
39
|
+
session[:session_data] = session[:session_data].dup if session[:session_data].frozen?
|
|
40
|
+
PWN::Plugins::Serial.disconnect(serial_obj: session)
|
|
41
|
+
end
|
|
42
|
+
sockets&.each { |socket| socket.close unless socket.closed? }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
before do
|
|
46
|
+
allow(described_class).to receive(:logger).and_return(Logger.new(StringIO.new))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'flushes only the selected handle through real Serial and actual response parsing' do
|
|
50
|
+
with_two_sessions do |selected, _other|
|
|
51
|
+
result = described_class.read_tag(son_micro_rfid_obj: selected)
|
|
52
|
+
expect(result).to include(resp_code_desc: :mifare_classic_1k, tag_id: '11 22 33 44')
|
|
53
|
+
expect(PWN::Plugins::Serial.dump_session_data(serial_obj: selected)).to eq([])
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'preserves actual Serial EOF instead of masking it with an ambiguous cleanup error' do
|
|
58
|
+
with_two_sessions(reply: :eof) do |selected, _other|
|
|
59
|
+
expect { described_class.read_tag(son_micro_rfid_obj: selected) }.to raise_error(EOFError)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it 'preserves command errors when real selected-session cleanup also fails' do
|
|
64
|
+
with_two_sessions do |selected, _other|
|
|
65
|
+
selected[:session_data].freeze
|
|
66
|
+
expect { described_class.exec(son_micro_rfid_obj: selected, cmd: :unsupported_fixture) }
|
|
67
|
+
.to raise_error(RuntimeError, /Unsupported Command/)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it 'does not choose a global session during cleanup when no handle was supplied' do
|
|
72
|
+
with_two_sessions do |_selected, _other|
|
|
73
|
+
expect { described_class.exec(cmd: :unsupported_fixture) }.to raise_error(RuntimeError, /Unsupported Command/)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -3,6 +3,45 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe PWN::SDR::SonMicroRFID do
|
|
6
|
+
before do
|
|
7
|
+
allow(described_class).to receive(:logger).and_return(Logger.new(StringIO.new))
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'preserves connection errors instead of referencing an unassigned connection' do
|
|
11
|
+
allow(PWN::Plugins::Serial).to receive(:connect).and_raise(IOError, 'serial unavailable')
|
|
12
|
+
expect { described_class.connect(block_dev: '/offline/serial') }.to raise_error(IOError, 'serial unavailable')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'preserves the serial disconnect return value on successful antenna shutdown' do
|
|
16
|
+
connection = Object.new
|
|
17
|
+
allow(described_class).to receive(:exec).and_return([{ status: :off }])
|
|
18
|
+
allow(PWN::Plugins::Serial).to receive(:disconnect).with(serial_obj: connection).and_return(:closed)
|
|
19
|
+
expect(described_class.disconnect(son_micro_rfid_obj: connection)).to eq(:closed)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'closes the serial connection even when antenna shutdown fails' do
|
|
23
|
+
connection = Object.new
|
|
24
|
+
allow(described_class).to receive(:exec).and_raise(IOError, 'antenna shutdown failed')
|
|
25
|
+
expect(PWN::Plugins::Serial).to receive(:disconnect).with(serial_obj: connection).once
|
|
26
|
+
expect { described_class.disconnect(son_micro_rfid_obj: connection) }.to raise_error(IOError, 'antenna shutdown failed')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'raises on mismatched write readback instead of reporting a successful write' do
|
|
30
|
+
connection = Object.new
|
|
31
|
+
data = { resp_code_desc: :mifare_ultralight, tag_id: 'AA BB CC DD', block_data: '01 02 03 04' }
|
|
32
|
+
allow(described_class).to receive(:gets).and_return("Y\n")
|
|
33
|
+
allow(described_class).to receive(:exec).with(son_micro_rfid_obj: connection, cmd: :select_tag)
|
|
34
|
+
.and_return([{ resp_code_desc: :mifare_ultralight }])
|
|
35
|
+
allow(described_class).to receive(:exec).with(son_micro_rfid_obj: connection, cmd: :write_block,
|
|
36
|
+
params: { block: 4, data: [1, 2, 3, 4] })
|
|
37
|
+
.and_return([{ resp_code_desc: :write_success }])
|
|
38
|
+
allow(described_class).to receive(:read_tag).and_return(data.merge(block_data: '05 06 07 08'))
|
|
39
|
+
expect do
|
|
40
|
+
expect { described_class.write_tag(son_micro_rfid_obj: connection, rfid_data: data) }
|
|
41
|
+
.to raise_error(IOError, /readback.*match/)
|
|
42
|
+
end.to output(/ERROR/).to_stdout
|
|
43
|
+
end
|
|
44
|
+
|
|
6
45
|
it 'should display information for authors' do
|
|
7
46
|
authors_response = PWN::SDR::SonMicroRFID
|
|
8
47
|
expect(authors_response).to respond_to :authors
|
data/spec/lib/pwn/sdr_spec.rb
CHANGED
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
|
|
5
5
|
describe PWN::SDR do
|
|
6
|
+
it 'formats an all-zero padded frequency as zero rather than an empty string' do
|
|
7
|
+
expect(described_class.hz_to_s(freq: '000000')).to eq('0')
|
|
8
|
+
expect(described_class.hz_to_s(freq: '0002450000000')).to eq('2.450.000.000')
|
|
9
|
+
end
|
|
10
|
+
|
|
6
11
|
it 'should return data for help method' do
|
|
7
12
|
help_response = PWN::SDR.help
|
|
8
13
|
expect(help_response).not_to be_nil
|
|
@@ -132,7 +132,7 @@ RSpec.describe 'Bundled session cleanup' do
|
|
|
132
132
|
allow(PWN::SessionCleanup).to receive(:maintain).and_return(state: 'planned')
|
|
133
133
|
expect(PWN::AI::Agent::Learning).not_to receive(:consolidate)
|
|
134
134
|
expect(PWN::AI::Agent::Learning).to receive(:prune_outcomes!).with(dry_run: true).once.and_return({})
|
|
135
|
-
expect(PWN::AI::Agent::Mistakes).
|
|
135
|
+
expect(PWN::AI::Agent::Mistakes).not_to receive(:lean!)
|
|
136
136
|
expect(PWN::AI::Agent::Policy).to receive(:lean!).with(dry_run: true).once.and_return({})
|
|
137
137
|
expect(PWN::SessionCleanup.coordinate(dry_run: true)[:state]).to eq('planned')
|
|
138
138
|
expect(Dir.exist?(File.join(@tmp, '.pwn', 'maintenance', 'runs'))).to be(false)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require File.expand_path('../../../etc/default_cron/session_cleanup', __dir__)
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::SessionCleanup, 'lifecycle audit regressions' do
|
|
7
|
+
include_context 'pwn tmp sandbox'
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
11
|
+
@root = File.join(@tmp, '.pwn')
|
|
12
|
+
FileUtils.mkdir_p(@root, mode: 0o700)
|
|
13
|
+
stub_const('PWN::Sessions::SESSIONS_DIR', File.join(@root, 'sessions'))
|
|
14
|
+
stub_const('PWN::AI::Agent::Learning::LEARNING_FILE', File.join(@root, 'learning.jsonl'))
|
|
15
|
+
@proc_root = File.join(@tmp, 'fixture-processes')
|
|
16
|
+
Dir.mkdir(@proc_root)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'stops coordinator retention after an admitted disposable deletion is interrupted' do
|
|
20
|
+
described_class.install
|
|
21
|
+
path = File.join(@root, 'cache', 'fixture.txt')
|
|
22
|
+
described_class.cache(path: path, bytes: 'fixture disposable bytes')
|
|
23
|
+
described_class.register_disposable(path: path, category: 'cache', expires_at: 0)
|
|
24
|
+
allow(File).to receive(:unlink).and_call_original
|
|
25
|
+
allow(File).to receive(:unlink).with(path).and_raise(Errno::EACCES)
|
|
26
|
+
expect(PWN::AI::Agent::Learning).not_to receive(:consolidate)
|
|
27
|
+
expect(PWN::AI::Agent::Learning).not_to receive(:prune_outcomes!)
|
|
28
|
+
expect(PWN::AI::Agent::Mistakes).not_to receive(:lean!)
|
|
29
|
+
expect(PWN::AI::Agent::Policy).not_to receive(:lean!)
|
|
30
|
+
result = described_class.coordinate(proc_root: @proc_root)
|
|
31
|
+
expect(result[:state]).to eq('interrupted')
|
|
32
|
+
maintenance = result[:phases].fetch(:maintenance)
|
|
33
|
+
expect(maintenance[:storage][:state]).to eq('interrupted')
|
|
34
|
+
expect(maintenance[:storage][:records]).to include(hash_including('state' => 'prepared'))
|
|
35
|
+
expect(File.binread(path)).to eq('fixture disposable bytes')
|
|
36
|
+
ensure
|
|
37
|
+
allow(File).to receive(:unlink).with(path).and_call_original if path
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -572,7 +572,8 @@ RSpec.describe PWN::SessionCleanup do
|
|
|
572
572
|
expect(PWN::AI::Agent::Learning.evidence_complete?(row: row)).to be(true)
|
|
573
573
|
evidence = File.join(Dir.home, '.pwn', 'learning', 'evidence', "#{row[:evidence_ref][:sha256]}.json")
|
|
574
574
|
expect(Digest::SHA256.file(evidence).hexdigest).to eq(row[:evidence_ref][:sha256])
|
|
575
|
-
PWN::AI::Agent::Reward.
|
|
575
|
+
binding = PWN::AI::Agent::Reward.prm_snapshot(session_id: id, request: 'offline evidence fixture café')[:binding]
|
|
576
|
+
PWN::AI::Agent::Reward.send(:annotate_session, session_id: id, rewards: [1], binding: binding)
|
|
576
577
|
expect(PWN::Sessions.load(session_id: id).find { |entry| entry[:role] == 'tool' }[:step_reward]).to eq(1)
|
|
577
578
|
expect(Digest::SHA256.file(evidence).hexdigest).to eq(row[:evidence_ref][:sha256])
|
|
578
579
|
expect(PWN::Sessions.catalog[:sessions]).to eq([])
|
|
@@ -1146,7 +1147,7 @@ RSpec.describe PWN::SessionCleanup do
|
|
|
1146
1147
|
expect(dry[:candidate_ids]).to include(id)
|
|
1147
1148
|
expect(dry[:deleted_ids]).to eq([])
|
|
1148
1149
|
expect(File).to exist(path)
|
|
1149
|
-
expect(PWN::Sessions).to receive(:delete).with(session_id: id, current_session_id: nil, force: true, cleanup_lock: an_instance_of(File)).and_call_original
|
|
1150
|
+
expect(PWN::Sessions).to receive(:delete).with(session_id: id, current_session_id: nil, force: true, cleanup_lock: an_instance_of(File), deletion_progress: an_instance_of(Proc)).and_call_original
|
|
1150
1151
|
expect(described_class.sweep(dry_run: false)[:deleted_ids]).to eq([id])
|
|
1151
1152
|
expect(File).not_to exist(path)
|
|
1152
1153
|
expect(File).not_to exist(meta_path)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'pwn/session_trace'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::SessionTrace, 'lifecycle audit regressions' do
|
|
7
|
+
include_context 'pwn tmp sandbox'
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'does not create a session store when reading a missing trace' do
|
|
14
|
+
directory = File.join(@tmp, 'absent-sessions')
|
|
15
|
+
stub_const('PWN::Sessions::SESSIONS_DIR', directory)
|
|
16
|
+
expect { described_class.read(session_id: 'missing') }.to raise_error(Errno::ENOENT)
|
|
17
|
+
expect(File).not_to exist(directory)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'refuses trace writes through a symlinked session-store ancestor' do
|
|
21
|
+
outside = File.join(@tmp, 'outside')
|
|
22
|
+
Dir.mkdir(outside)
|
|
23
|
+
linked = File.join(@tmp, 'linked-sessions')
|
|
24
|
+
File.symlink(outside, linked)
|
|
25
|
+
stub_const('PWN::Sessions::SESSIONS_DIR', linked)
|
|
26
|
+
expect { described_class.append(session_id: 'fixture', event: 'request', data: 'fixture') }.to raise_error(ArgumentError, /Symlink/)
|
|
27
|
+
expect(Dir.children(outside)).to eq([])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'does not publish a new trace reference while cleanup owns the session lease' do
|
|
31
|
+
session = PWN::Sessions.create
|
|
32
|
+
path = PWN::Sessions.support_path(kind: :lease, session_id: session[:id])
|
|
33
|
+
File.open(path, File::RDWR) do |lock|
|
|
34
|
+
expect(lock.flock(File::LOCK_EX | File::LOCK_NB)).to be_truthy
|
|
35
|
+
expect { described_class.append(session_id: session[:id], event: 'request', data: 'fixture') }.to raise_error(IOError, /removed/)
|
|
36
|
+
end
|
|
37
|
+
expect(File).not_to exist(PWN::Sessions.support_path(kind: :trace, session_id: session[:id], read_only: true))
|
|
38
|
+
end
|
|
39
|
+
end
|