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,242 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'timeout'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::Vault, 'EUI-SEC-001 software master key safety' do
|
|
7
|
+
include_context 'pwn tmp sandbox'
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
11
|
+
@key_path = File.join(@tmp, '.pwn-vault.key')
|
|
12
|
+
@box_path = File.join(@tmp, '.pwn', 'engagements', 'default', 'loot.json')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def expect_key_rejected
|
|
16
|
+
ciphertext = File.binread(@box_path)
|
|
17
|
+
allow(OpenSSL::Random).to receive(:random_bytes).and_call_original
|
|
18
|
+
expect(OpenSSL::Random).not_to receive(:random_bytes).with(32)
|
|
19
|
+
expect { described_class.store(label: 'original', secret: 'synthetic-replacement') }.to raise_error(IOError, /software vault master key/) do |error|
|
|
20
|
+
expect(error.cause).to be_nil
|
|
21
|
+
end
|
|
22
|
+
expect { described_class.fetch(label: 'original') }.to raise_error(IOError, /software vault master key/)
|
|
23
|
+
expect(File.binread(@box_path) == ciphertext).to be(true)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
[0o644, 0o640, 0o660, 0o700, 0o4600, 0o000].each do |mode|
|
|
27
|
+
it "rejects existing key permissions #{mode.to_s(8)} without repair or ciphertext loss" do
|
|
28
|
+
described_class.store(label: 'original', secret: 'synthetic-original')
|
|
29
|
+
key = File.binread(@key_path)
|
|
30
|
+
File.chmod(mode, @key_path)
|
|
31
|
+
expect_key_rejected
|
|
32
|
+
expect(File.stat(@key_path).mode & 0o7777).to eq(mode)
|
|
33
|
+
File.chmod(0o600, @key_path)
|
|
34
|
+
expect(File.binread(@key_path) == key).to be(true)
|
|
35
|
+
expect(described_class.fetch(label: 'original') == 'synthetic-original').to be(true)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
[0, 31, 33, 1_048_576].each do |size|
|
|
40
|
+
it "rejects an existing #{size}-byte key without silently replacing it" do
|
|
41
|
+
described_class.store(label: 'original', secret: 'synthetic-original')
|
|
42
|
+
File.binwrite(@key_path, 'k' * size)
|
|
43
|
+
expect_key_rejected
|
|
44
|
+
expect(File.size(@key_path)).to eq(size)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
%w[symlink directory fifo hardlink].each do |kind|
|
|
49
|
+
it "rejects an existing #{kind} key before reading or modifying it" do
|
|
50
|
+
described_class.store(label: 'original', secret: 'synthetic-original')
|
|
51
|
+
saved = File.join(@tmp, 'saved-key')
|
|
52
|
+
File.rename(@key_path, saved)
|
|
53
|
+
case kind
|
|
54
|
+
when 'symlink' then File.symlink(saved, @key_path)
|
|
55
|
+
when 'directory' then Dir.mkdir(@key_path)
|
|
56
|
+
when 'fifo' then File.mkfifo(@key_path, 0o600)
|
|
57
|
+
when 'hardlink' then File.link(saved, @key_path)
|
|
58
|
+
end
|
|
59
|
+
before = File.lstat(@key_path)
|
|
60
|
+
Timeout.timeout(2) { expect_key_rejected }
|
|
61
|
+
expect(File.lstat(@key_path).ino).to eq(before.ino)
|
|
62
|
+
expect(File.lstat(@key_path).ftype).to eq(before.ftype)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'rejects foreign ownership metadata before reading the existing key' do
|
|
67
|
+
described_class.store(label: 'original', secret: 'synthetic-original')
|
|
68
|
+
allow(Process).to receive(:uid).and_return(Process.uid + 1)
|
|
69
|
+
expect_key_rejected
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
%w[default another].each do |engagement|
|
|
73
|
+
it "refuses to recreate a missing key used by existing #{engagement} ciphertext" do
|
|
74
|
+
described_class.store(engagement: engagement, label: 'original', secret: 'synthetic-original')
|
|
75
|
+
path = File.join(@tmp, '.pwn', 'engagements', engagement, 'loot.json')
|
|
76
|
+
ciphertext = File.binread(path)
|
|
77
|
+
File.unlink(@key_path)
|
|
78
|
+
expect { described_class.store(label: 'new', secret: 'synthetic-new') }.to raise_error(IOError, /software vault master key/)
|
|
79
|
+
expect { described_class.fetch(engagement: engagement, label: 'original') }.to raise_error(IOError, /software vault master key/)
|
|
80
|
+
expect(File).not_to exist(@key_path)
|
|
81
|
+
expect(File.binread(path) == ciphertext).to be(true)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def stop_vault_child(pid)
|
|
86
|
+
Process.kill('KILL', pid)
|
|
87
|
+
rescue Errno::ESRCH
|
|
88
|
+
nil
|
|
89
|
+
ensure
|
|
90
|
+
begin
|
|
91
|
+
Process.wait(pid)
|
|
92
|
+
rescue Errno::ECHILD
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def vault_child(&operation)
|
|
98
|
+
reader, writer = IO.pipe
|
|
99
|
+
pid = fork do
|
|
100
|
+
reader.close
|
|
101
|
+
begin
|
|
102
|
+
writer.puts(JSON.generate(operation.call))
|
|
103
|
+
exit! 0
|
|
104
|
+
rescue StandardError, Interrupt => e
|
|
105
|
+
writer.puts(JSON.generate(child_error: e.class.name))
|
|
106
|
+
exit! 1
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
writer.close
|
|
110
|
+
result = JSON.parse(Timeout.timeout(10) { reader.read }, symbolize_names: true)
|
|
111
|
+
_, status = Process.wait2(pid)
|
|
112
|
+
pid = nil
|
|
113
|
+
expect(status.success?).to be(true), result.inspect
|
|
114
|
+
result
|
|
115
|
+
ensure
|
|
116
|
+
stop_vault_child(pid) if pid
|
|
117
|
+
[reader, writer].compact.each { |io| io.close unless io.closed? }
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
[Interrupt, IOError].each do |failure|
|
|
121
|
+
it "cleans private staging on #{failure} before publication and allows public store retry" do
|
|
122
|
+
observed = vault_child do
|
|
123
|
+
File.umask(0o022)
|
|
124
|
+
modes = []
|
|
125
|
+
allow(OpenSSL::Random).to receive(:random_bytes).and_call_original
|
|
126
|
+
allow(OpenSSL::Random).to receive(:random_bytes).with(32) do
|
|
127
|
+
modes = Dir.glob(File.join(@tmp, '.pwn-vault-key-*')).map { |path| File.stat(path).mode & 0o777 }
|
|
128
|
+
raise failure, 'synthetic-private-error-marker'
|
|
129
|
+
end
|
|
130
|
+
begin
|
|
131
|
+
described_class.store(label: 'cancelled', secret: 'synthetic-cancelled')
|
|
132
|
+
rescue Interrupt, IOError => e
|
|
133
|
+
safe = e.is_a?(Interrupt) || (!e.message.include?('synthetic-private-error-marker') && e.cause.nil?)
|
|
134
|
+
caught = e.is_a?(failure)
|
|
135
|
+
end
|
|
136
|
+
absent = !File.exist?(@key_path) && !File.exist?(@box_path)
|
|
137
|
+
cleaned = Dir.glob(File.join(@tmp, '.pwn-vault-key-*')).empty?
|
|
138
|
+
allow(OpenSSL::Random).to receive(:random_bytes).with(32).and_call_original
|
|
139
|
+
retry_result = described_class.store(label: 'retry', secret: 'synthetic-retry')
|
|
140
|
+
{ modes: modes, caught: caught, safe: safe, absent: absent, cleaned: cleaned, stored: retry_result[:stored],
|
|
141
|
+
roundtrip: described_class.fetch(label: 'retry') == 'synthetic-retry' }
|
|
142
|
+
end
|
|
143
|
+
expect(observed).to eq(modes: [0o600], caught: true, safe: true, absent: true, cleaned: true, stored: true, roundtrip: true)
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'retains a complete key after a publication error without exposing the cause or rotating it' do
|
|
148
|
+
allow(File).to receive(:link).and_wrap_original do |method, source, destination|
|
|
149
|
+
method.call(source, destination)
|
|
150
|
+
raise IOError, 'synthetic-private-error-marker' if destination == @key_path
|
|
151
|
+
end
|
|
152
|
+
expect { described_class.store(label: 'failed', secret: 'synthetic-failed') }.to raise_error(IOError, /software vault master key/) do |error|
|
|
153
|
+
expect(error.message).not_to include('synthetic-private-error-marker')
|
|
154
|
+
expect(error.cause).to be_nil
|
|
155
|
+
end
|
|
156
|
+
expect(File.stat(@key_path).mode & 0o777).to eq(0o600)
|
|
157
|
+
expect(Dir.glob(File.join(@tmp, '.pwn-vault-key-*'))).to be_empty
|
|
158
|
+
key = File.binread(@key_path)
|
|
159
|
+
described_class.store(label: 'retry', secret: 'synthetic-retry')
|
|
160
|
+
expect(File.binread(@key_path) == key).to be(true)
|
|
161
|
+
expect(described_class.fetch(label: 'retry') == 'synthetic-retry').to be(true)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
it 'serializes two public creators across processes and preserves every ciphertext' do
|
|
165
|
+
children = []
|
|
166
|
+
start_r, start_w = IO.pipe
|
|
167
|
+
result_r, result_w = IO.pipe
|
|
168
|
+
2.times do |index|
|
|
169
|
+
children << fork do
|
|
170
|
+
start_w.close
|
|
171
|
+
result_r.close
|
|
172
|
+
begin
|
|
173
|
+
File.umask(0o022)
|
|
174
|
+
start_r.read(1)
|
|
175
|
+
3.times do |number|
|
|
176
|
+
described_class.store(engagement: "group#{index}", label: "item#{number}", secret: "synthetic-#{index}-#{number}")
|
|
177
|
+
end
|
|
178
|
+
result_w.puts(JSON.generate(index: index, stored: true))
|
|
179
|
+
exit! 0
|
|
180
|
+
rescue StandardError, Interrupt => e
|
|
181
|
+
result_w.puts(JSON.generate(index: index, error: e.class.name))
|
|
182
|
+
exit! 1
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
start_r.close
|
|
187
|
+
result_w.close
|
|
188
|
+
start_w.write('go')
|
|
189
|
+
start_w.close
|
|
190
|
+
records = Timeout.timeout(10) { result_r.read.lines.map { |line| JSON.parse(line, symbolize_names: true) } }
|
|
191
|
+
statuses = children.map { |pid| Process.wait2(pid)[1] }
|
|
192
|
+
children.clear
|
|
193
|
+
expect(records).to contain_exactly({ index: 0, stored: true }, { index: 1, stored: true })
|
|
194
|
+
expect(statuses.all?(&:success?)).to be(true)
|
|
195
|
+
2.times do |index|
|
|
196
|
+
expect(described_class.query(engagement: "group#{index}").size).to eq(3)
|
|
197
|
+
3.times do |number|
|
|
198
|
+
expect(described_class.fetch(engagement: "group#{index}", label: "item#{number}") == "synthetic-#{index}-#{number}").to be(true)
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
expect(File.stat(@key_path).mode & 0o777).to eq(0o600)
|
|
202
|
+
ensure
|
|
203
|
+
children&.each { |pid| stop_vault_child(pid) }
|
|
204
|
+
[start_r, start_w, result_r, result_w].compact.each { |io| io.close unless io.closed? }
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'publishes a private key under child umask 022 even when cancelled at first visibility' do
|
|
208
|
+
observed = vault_child do
|
|
209
|
+
File.umask(0o022)
|
|
210
|
+
File.chmod(0o755, @tmp)
|
|
211
|
+
mode = nil
|
|
212
|
+
interrupted = false
|
|
213
|
+
# Interrupt on the first completed native operation exposing the final
|
|
214
|
+
# key path, before any later chmod can conceal unsafe creation modes.
|
|
215
|
+
trace = TracePoint.new(:c_return) do
|
|
216
|
+
next unless File.exist?(@key_path)
|
|
217
|
+
|
|
218
|
+
trace.disable
|
|
219
|
+
mode = File.stat(@key_path).mode & 0o777
|
|
220
|
+
raise Interrupt
|
|
221
|
+
end
|
|
222
|
+
begin
|
|
223
|
+
trace.enable { described_class.store(label: 'cancelled', secret: 'synthetic-cancelled') }
|
|
224
|
+
rescue Interrupt
|
|
225
|
+
interrupted = true
|
|
226
|
+
ensure
|
|
227
|
+
trace.disable
|
|
228
|
+
end
|
|
229
|
+
key = File.binread(@key_path)
|
|
230
|
+
stored = described_class.store(label: 'retry', secret: 'synthetic-retry')
|
|
231
|
+
{
|
|
232
|
+
interrupted: interrupted, mode_at_publication: mode,
|
|
233
|
+
retry_stored: stored[:stored], same_key: File.binread(@key_path) == key,
|
|
234
|
+
retry_mode: File.stat(@key_path).mode & 0o777,
|
|
235
|
+
roundtrip: described_class.fetch(label: 'retry') == 'synthetic-retry',
|
|
236
|
+
labels: described_class.query.map { |row| row[:label] }
|
|
237
|
+
}
|
|
238
|
+
end
|
|
239
|
+
expect(observed).to eq(interrupted: true, mode_at_publication: 0o600, retry_stored: true,
|
|
240
|
+
same_key: true, retry_mode: 0o600, roundtrip: true, labels: ['retry'])
|
|
241
|
+
end
|
|
242
|
+
end
|
|
@@ -3,6 +3,64 @@
|
|
|
3
3
|
require 'spec_helper'
|
|
4
4
|
require 'tmpdir'
|
|
5
5
|
|
|
6
|
+
describe PWN::Plugins::Vault, 'concurrent loot storage' do
|
|
7
|
+
include_context 'pwn tmp sandbox'
|
|
8
|
+
|
|
9
|
+
it 'keeps one master key when separate engagements are initialized concurrently' do
|
|
10
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
11
|
+
allow(described_class).to receive(:note_mission_loot)
|
|
12
|
+
entered = Queue.new
|
|
13
|
+
release = Queue.new
|
|
14
|
+
allow(OpenSSL::Random).to receive(:random_bytes).and_wrap_original do |method, length|
|
|
15
|
+
if length == 32 && Thread.current[:vault_first_writer]
|
|
16
|
+
entered << true
|
|
17
|
+
release.pop
|
|
18
|
+
end
|
|
19
|
+
method.call(length)
|
|
20
|
+
end
|
|
21
|
+
first = Thread.new do
|
|
22
|
+
Thread.current[:vault_first_writer] = true
|
|
23
|
+
described_class.store(engagement: 'first', label: 'first', secret: 'first-fixture')
|
|
24
|
+
end
|
|
25
|
+
Timeout.timeout(5) { entered.pop }
|
|
26
|
+
second = Thread.new { described_class.store(engagement: 'second', label: 'second', secret: 'second-fixture') }
|
|
27
|
+
second.join(0.5)
|
|
28
|
+
release << true
|
|
29
|
+
Timeout.timeout(5) { [first, second].each(&:value) }
|
|
30
|
+
expect(described_class.fetch(label: 'first', engagement: 'first')).to eq('first-fixture')
|
|
31
|
+
expect(described_class.fetch(label: 'second', engagement: 'second')).to eq('second-fixture')
|
|
32
|
+
ensure
|
|
33
|
+
release << true if release
|
|
34
|
+
[first, second].compact.each { |thread| thread.kill.join if thread.alive? }
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'retains both records when another writer arrives during encryption' do
|
|
38
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
39
|
+
allow(described_class).to receive(:note_mission_loot)
|
|
40
|
+
entered = Queue.new
|
|
41
|
+
release = Queue.new
|
|
42
|
+
allow(described_class).to receive(:encrypt_secret).and_wrap_original do |method, opts|
|
|
43
|
+
if opts[:secret] == 'first-fixture'
|
|
44
|
+
entered << true
|
|
45
|
+
release.pop
|
|
46
|
+
end
|
|
47
|
+
method.call(opts)
|
|
48
|
+
end
|
|
49
|
+
first = Thread.new { described_class.store(label: 'first', secret: 'first-fixture') }
|
|
50
|
+
Timeout.timeout(5) { entered.pop }
|
|
51
|
+
second = Thread.new { described_class.store(label: 'second', secret: 'second-fixture') }
|
|
52
|
+
second.join(0.5)
|
|
53
|
+
release << true
|
|
54
|
+
Timeout.timeout(5) { [first, second].each(&:value) }
|
|
55
|
+
expect(described_class.query.map { |row| row[:label] }).to contain_exactly('first', 'second')
|
|
56
|
+
expect(described_class.fetch(label: 'first')).to eq('first-fixture')
|
|
57
|
+
expect(described_class.fetch(label: 'second')).to eq('second-fixture')
|
|
58
|
+
ensure
|
|
59
|
+
release << true if release
|
|
60
|
+
[first, second].compact.each { |thread| thread.kill.join if thread.alive? }
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
6
64
|
describe PWN::Plugins::Vault do
|
|
7
65
|
it 'should display information for authors' do
|
|
8
66
|
authors_response = PWN::Plugins::Vault
|
|
@@ -229,7 +229,7 @@ RSpec.describe PWN::Plugins::Vault, 'loot corruption safety' do
|
|
|
229
229
|
cipher.auth_data = 'pwn-vault'
|
|
230
230
|
ct = cipher.update('legacy-fixture') + cipher.final
|
|
231
231
|
secret = { iv: Base64.strict_encode64(iv), ct: Base64.strict_encode64(ct), tag: Base64.strict_encode64(cipher.auth_tag) }
|
|
232
|
-
File.
|
|
232
|
+
File.open(File.join(@root, '.pwn-vault.key'), File::WRONLY | File::CREAT | File::EXCL, 0o600) { |file| file.write(key) }
|
|
233
233
|
File.write(@legacy_path, JSON.generate(legacy: secret))
|
|
234
234
|
expect(described_class.fetch(label: 'legacy')).to eq('legacy-fixture')
|
|
235
235
|
described_class.store(label: 'hardware', secret: 'hardware-fixture', yubikey: {})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::XXD, 'partial-row reversal regression' do
|
|
7
|
+
it 'preserves a partial final row when reversing into byte chunks' do
|
|
8
|
+
Dir.mktmpdir('xxd-chunks-audit') do |dir|
|
|
9
|
+
source = File.join(dir, 'input.bin')
|
|
10
|
+
output = File.join(dir, 'output.bin')
|
|
11
|
+
data = ('A B ' * 8).byteslice(0, 29)
|
|
12
|
+
File.binwrite(source, data)
|
|
13
|
+
dump = described_class.dump(file: source)
|
|
14
|
+
described_class.reverse_dump(hexdump: dump, file: output, byte_chunks: 16)
|
|
15
|
+
expect(File.binread("#{output}.00000010-00000010")).to eq(data.byteslice(16..))
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
[13, 14, 15].each do |length|
|
|
20
|
+
[false, true].each do |hashed|
|
|
21
|
+
it "round-trips #{length} bytes with spaced ASCII and hashed=#{hashed}" do
|
|
22
|
+
Dir.mktmpdir('xxd-audit') do |dir|
|
|
23
|
+
source = File.join(dir, 'input.bin')
|
|
24
|
+
output = File.join(dir, 'output.bin')
|
|
25
|
+
data = ('A B ' * 4).byteslice(0, length)
|
|
26
|
+
File.binwrite(source, data)
|
|
27
|
+
dump = described_class.dump(file: source, hashed: hashed)
|
|
28
|
+
described_class.reverse_dump(hexdump: dump, file: output)
|
|
29
|
+
expect(File.binread(output)).to eq(data)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'ffi'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::YubiKey::Transport do
|
|
7
|
+
it 'preserves enumeration cancellation over native release failure' do
|
|
8
|
+
library = double('fake HID API')
|
|
9
|
+
native = double('fake backend', acquire: nil, library: library)
|
|
10
|
+
allow(library).to receive(:hid_enumerate).and_raise(Interrupt, 'primary cancellation')
|
|
11
|
+
allow(native).to receive(:release).and_raise(IOError, 'secondary release failure')
|
|
12
|
+
allow(native).to receive(:devices) { described_class::HIDInventory.new(native).devices }
|
|
13
|
+
allow(described_class).to receive(:native).with(kind: :hid).and_return(native)
|
|
14
|
+
expect { described_class.devices(backend: :hid) }.to raise_error(Interrupt, 'primary cancellation')
|
|
15
|
+
expect(native).to have_received(:release).once
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'preserves the first cleanup failure while still releasing the native library' do
|
|
19
|
+
library = double('fake HID API')
|
|
20
|
+
native = double('fake backend', acquire: nil, library: library)
|
|
21
|
+
inventory = described_class::HIDInventory.new(native)
|
|
22
|
+
entry = inventory.instance_variable_get(:@info).new
|
|
23
|
+
allow(library).to receive(:hid_enumerate).and_return(entry.pointer)
|
|
24
|
+
allow(library).to receive(:hid_free_enumeration).and_raise(IOError, 'first cleanup failure')
|
|
25
|
+
allow(native).to receive(:release).and_raise(IOError, 'second cleanup failure')
|
|
26
|
+
allow(native).to receive(:devices) { inventory.devices }
|
|
27
|
+
allow(described_class).to receive(:native).with(kind: :hid).and_return(native)
|
|
28
|
+
expect { described_class.devices(backend: :hid) }.to raise_error(IOError, 'first cleanup failure')
|
|
29
|
+
expect(native).to have_received(:release).once
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'surfaces cleanup-only errors inside an unrelated caller rescue' do
|
|
33
|
+
library = double('fake HID API', hid_enumerate: FFI::Pointer::NULL)
|
|
34
|
+
native = double('fake backend', acquire: nil, library: library)
|
|
35
|
+
allow(native).to receive(:release).and_raise(IOError, 'release failure')
|
|
36
|
+
inventory = described_class::HIDInventory.new(native)
|
|
37
|
+
begin
|
|
38
|
+
raise 'unrelated caller error'
|
|
39
|
+
rescue RuntimeError
|
|
40
|
+
expect { inventory.devices }.to raise_error(IOError, 'release failure')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'returns an empty fake native inventory and releases it exactly once' do
|
|
45
|
+
library = double('fake HID API', hid_enumerate: FFI::Pointer::NULL)
|
|
46
|
+
native = double('fake backend', acquire: nil, library: library, release: nil)
|
|
47
|
+
allow(native).to receive(:devices) { described_class::HIDInventory.new(native).devices }
|
|
48
|
+
allow(described_class).to receive(:native).with(kind: :hid).and_return(native)
|
|
49
|
+
expect(described_class.devices(backend: :hid)).to eq([])
|
|
50
|
+
expect(native).to have_received(:release).once
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::YubiKey, 'primary failure preservation' do
|
|
6
|
+
it 'preserves an owned facade operation failure when closing the handle also fails' do
|
|
7
|
+
connection = double('owned transport', descriptor: { protocol: :apdu })
|
|
8
|
+
allow(described_class::Transport).to receive(:open).and_return(connection)
|
|
9
|
+
allow(connection).to receive(:exchange).and_raise(described_class::TimeoutError, 'fixture primary timeout')
|
|
10
|
+
allow(connection).to receive(:close).and_raise(IOError, 'fixture secondary close')
|
|
11
|
+
expect { described_class.apdu(ins: 0xa4, confirm: true, reader: 'fixture-reader') }.to raise_error(described_class::TimeoutError, 'fixture primary timeout')
|
|
12
|
+
expect(connection).to have_received(:close).once
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
it 'preserves an in-flight native operation error while retiring its failed connection' do
|
|
16
|
+
io = double('native IO')
|
|
17
|
+
allow(io).to receive(:transmit).and_raise(described_class::CommandError, 'fixture primary transmit')
|
|
18
|
+
allow(io).to receive(:close).and_raise(IOError, 'fixture secondary close')
|
|
19
|
+
connection = described_class::Transport::Connection.new(descriptor: { protocol: :apdu }, io: io)
|
|
20
|
+
expect { connection.exchange(protocol: :apdu, data: "\x00\xa4\x00\x00".b) }.to raise_error(described_class::CommandError, 'fixture primary transmit')
|
|
21
|
+
expect { connection.exchange(protocol: :apdu, data: "\x00\xa4\x00\x00".b) }.to raise_error(described_class::Error, /closed/)
|
|
22
|
+
expect(io).to have_received(:close).once
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'preserves HID acquisition errors when native release also fails' do
|
|
26
|
+
require 'ffi'
|
|
27
|
+
library = double('HID library', hid_open_path: FFI::Pointer::NULL)
|
|
28
|
+
native = double('HID backend', acquire: nil, library: library)
|
|
29
|
+
allow(native).to receive(:release).and_raise(IOError, 'fixture release failure')
|
|
30
|
+
expect { described_class::Transport::HIDIO.new(native, '/fixture/hid') }.to raise_error(described_class::CommandError, /Cannot open/)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it 'preserves PCSC acquisition status when context release also fails' do
|
|
34
|
+
require 'ffi'
|
|
35
|
+
library = double('PCSC library', SCardConnect: 0x123, SCardReleaseContext: 0x456)
|
|
36
|
+
allow(library).to receive(:SCardEstablishContext) do |_, _, _, pointer|
|
|
37
|
+
pointer.write_long(1)
|
|
38
|
+
0
|
|
39
|
+
end
|
|
40
|
+
native = double('PCSC backend', library: library, handle_type: :long, dword: :ulong, platform: :linux)
|
|
41
|
+
expect { described_class::Transport::PCSCIO.new(native, 'fixture-reader') }.to raise_error(described_class::CommandError, /connect.*00000123/)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'preserves PCSC discovery status when context release also fails' do
|
|
45
|
+
require 'ffi'
|
|
46
|
+
library = double('PCSC library', SCardListReaders: 0x123, SCardReleaseContext: 0x456)
|
|
47
|
+
allow(library).to receive(:SCardEstablishContext) do |_, _, _, pointer|
|
|
48
|
+
pointer.write_long(1)
|
|
49
|
+
0
|
|
50
|
+
end
|
|
51
|
+
native = double('PCSC backend', library: library, handle_type: :long, dword: :ulong)
|
|
52
|
+
expect { described_class::Transport::PCSCInventory.new(native).devices }.to raise_error(described_class::CommandError, /00000123/)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'preserves a secure-channel handshake failure during invalidation' do
|
|
56
|
+
connection = double('plain APDU', descriptor: { protocol: :apdu })
|
|
57
|
+
allow(connection).to receive(:exchange).and_raise(described_class::TimeoutError, 'fixture primary handshake')
|
|
58
|
+
allow(connection).to receive(:close).and_raise(IOError, 'fixture secondary close')
|
|
59
|
+
expect do
|
|
60
|
+
described_class::SecurityDomain.secure_connection(connection: connection, scp: :scp03, kvn: 1,
|
|
61
|
+
key_enc: 'a'.b * 16, key_mac: 'b'.b * 16, confirm: true)
|
|
62
|
+
end.to raise_error(described_class::TimeoutError, 'fixture primary handshake')
|
|
63
|
+
expect(connection).to have_received(:close).once
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::YubiKey, 'HSM Auth facade options' do
|
|
6
|
+
it 'documents typed HSM authorization options without device access' do
|
|
7
|
+
expect(described_class::Transport).not_to receive(:open)
|
|
8
|
+
expect { described_class.help }.to output(/management_password:.*auth_method:/m).to_stdout
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'forwards an explicit management password through the real HSM Auth APDU codec' do
|
|
12
|
+
connection = double('APDU transport', descriptor: { protocol: :apdu })
|
|
13
|
+
expect(connection).to receive(:exchange).with(hash_including(data: ['00a4040008a000000527210701'].pack('H*'))).ordered.and_return(['79030508009000'].pack('H*'))
|
|
14
|
+
payload = "\x7b\x10".b + 'old-fixture'.ljust(16, "\0") + "\x7b\x10".b + 'new-fixture'.ljust(16, "\0")
|
|
15
|
+
expected = "\x00\x08\x00\x00".b + [payload.bytesize].pack('C') + payload
|
|
16
|
+
expect(connection).to receive(:exchange).with(hash_including(data: expected)).ordered.and_return("\x90\x00".b)
|
|
17
|
+
result = described_class.hsmauth(args: %w[access change-management-password], connection: connection,
|
|
18
|
+
confirm: true, management_password: 'old-fixture', new_management_password: 'new-fixture')
|
|
19
|
+
expect(result).to eq(status: :acknowledged, verification: :not_readable)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'retains the explicit credential authentication conflict guard at the facade' do
|
|
23
|
+
connection = double('APDU transport', descriptor: { protocol: :apdu }, exchange: nil)
|
|
24
|
+
expect do
|
|
25
|
+
described_class.hsmauth(args: %w[credentials change-password fixture], connection: connection, confirm: true,
|
|
26
|
+
auth_method: :credential, management_key: 'x'.b * 16, new_credential_password: 'new-fixture')
|
|
27
|
+
end.to raise_error(ArgumentError, /conflicts with explicit credential auth_method/)
|
|
28
|
+
expect(connection).not_to have_received(:exchange)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::YubiKey, 'borrowed connection selectors' do
|
|
6
|
+
%i[serial reader device_path].each do |selector|
|
|
7
|
+
[nil, 'other'].each do |observed|
|
|
8
|
+
it "rejects #{selector} #{observed.nil? ? 'missing from' : 'mismatching'} the borrowed descriptor before APDUs" do
|
|
9
|
+
connection = double('borrowed transport', descriptor: { protocol: :apdu, selector => observed })
|
|
10
|
+
allow(connection).to receive(:exchange).and_return("\x90\x00".b)
|
|
11
|
+
expect(connection).not_to receive(:close)
|
|
12
|
+
expect(described_class::Transport).not_to receive(:open)
|
|
13
|
+
options = { connection: connection, selector => '123', confirm: true, ins: 0xa4 }
|
|
14
|
+
expect { described_class.apdu(options) }.to raise_error(ArgumentError, /selector/)
|
|
15
|
+
expect(connection).not_to have_received(:exchange)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'retains an exactly matching borrowed connection and does not close it' do
|
|
21
|
+
connection = double('borrowed transport', descriptor: { protocol: :apdu, serial: '00123' })
|
|
22
|
+
expect(connection).to receive(:exchange).with(hash_including(data: "\x00\xa4\x00\x00\x00".b)).and_return("\x90\x00".b)
|
|
23
|
+
expect(connection).not_to receive(:close)
|
|
24
|
+
expect(described_class.apdu(connection: connection, serial: '00123', confirm: true, ins: 0xa4)).to eq(''.b)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -104,7 +104,7 @@ RSpec.describe PWN::Plugins::YubiKey, 'native family routing' do
|
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
RSpec.describe PWN::Plugins::YubiKey, 'native Vault and MFA helpers' do
|
|
107
|
-
let(:connection) { double('native connection', descriptor: { protocol: :otp }, close: :closed) }
|
|
107
|
+
let(:connection) { double('native connection', descriptor: { protocol: :otp, serial: '001234' }, close: :closed) }
|
|
108
108
|
|
|
109
109
|
it 'returns the raw RFC 2202 HMAC from the native OTP exchange' do
|
|
110
110
|
expect(described_class::Transport).not_to receive(:open)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'rest-client'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::Zaproxy, 'namespace audit regressions' do
|
|
7
|
+
it 'filters returned HAR entries by keyword' do
|
|
8
|
+
allow(described_class).to receive(:stop)
|
|
9
|
+
response = double('HAR response', body: { log: { entries: [{ request: { url: 'https://example.invalid/keep' } }, { request: { url: 'https://example.invalid/drop' } }] } }.to_json)
|
|
10
|
+
empty = double('empty page', body: { log: { entries: [] } }.to_json)
|
|
11
|
+
allow(described_class).to receive(:zap_rest_call).and_return(response, empty)
|
|
12
|
+
result = described_class.get_sitemap(zap_obj: { api_key: 'fixture-token' }, keyword: '/keep', return_as: :har)
|
|
13
|
+
expect(result).to eq([{ request: { url: 'https://example.invalid/keep' } }])
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'does not retry shutdown recursively when the shutdown request fails' do
|
|
17
|
+
allow(PWN::Plugins::TransparentBrowser).to receive(:close)
|
|
18
|
+
allow(RestClient::Request).to receive(:execute).and_raise(Errno::ECONNREFUSED)
|
|
19
|
+
calls = 0
|
|
20
|
+
allow(described_class).to receive(:stop).and_wrap_original do |original, options|
|
|
21
|
+
calls += 1
|
|
22
|
+
raise 'recursive shutdown' if calls > 1
|
|
23
|
+
|
|
24
|
+
original.call(options)
|
|
25
|
+
end
|
|
26
|
+
zap = { api_key: 'fixture-token', rest_browser: RestClient, mitm_rest_api: 'zap.invalid' }
|
|
27
|
+
expect { described_class.stop(zap_obj: zap) }.to raise_error(Errno::ECONNREFUSED)
|
|
28
|
+
expect(calls).to eq(1)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
[PWN::Reports::SAST, PWN::Reports::AIRedTeam].each do |reporter|
|
|
7
|
+
RSpec.describe reporter, 'empty report generation' do
|
|
8
|
+
it 'generates an empty report with the caller supplied name' do
|
|
9
|
+
Dir.mktmpdir('report-empty-audit-') do |dir|
|
|
10
|
+
described_class.generate(dir_path: dir, report_name: 'fixture-empty')
|
|
11
|
+
data = JSON.parse(File.read(File.join(dir, 'fixture-empty.json')))
|
|
12
|
+
expect(data).to eq('report_name' => 'fixture-empty', 'data' => [])
|
|
13
|
+
html = File.read(File.join(dir, 'fixture-empty.html'))
|
|
14
|
+
expect(html).to include('"ajax": "fixture-empty.json"', '</html>')
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'pdf/reader'
|
|
4
6
|
|
|
5
7
|
describe PWN::Reports::PDF do
|
|
8
|
+
it 'paginates long reports so every finding remains inside the page bounds' do
|
|
9
|
+
Dir.mktmpdir('pdf-page-audit-') do |dir|
|
|
10
|
+
findings = Array.new(80) { |i| { title: "Fixture finding #{i}", description: "Evidence marker #{i}" } }
|
|
11
|
+
path = described_class.generate(path: File.join(dir, 'fixture.pdf'), results_hash: { title: 'Fixture report', findings: findings })
|
|
12
|
+
reader = PDF::Reader.new(path)
|
|
13
|
+
expect(reader.page_count).to be > 1
|
|
14
|
+
text = reader.pages.map(&:text).join("\n")
|
|
15
|
+
findings.each { |row| expect(text).to include(row[:title], row[:description]) }
|
|
16
|
+
reader.pages.each do |page|
|
|
17
|
+
line_count = page.raw_content.scan(') Tj').length
|
|
18
|
+
expect(720 - ((line_count - 1) * 14)).to be >= 72
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'preserves literal backslashes and parentheses in extracted report text' do
|
|
24
|
+
Dir.mktmpdir('pdf-escape-audit-') do |dir|
|
|
25
|
+
title = 'Fixture C:\\new\\report(1)'
|
|
26
|
+
path = described_class.generate(path: File.join(dir, 'fixture.pdf'), results_hash: { title: title, findings: [] })
|
|
27
|
+
expect(PDF::Reader.new(path).pages.first.text).to include(title)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
6
31
|
it 'should display information for authors' do
|
|
7
32
|
authors_response = PWN::Reports::PDF
|
|
8
33
|
expect(authors_response).to respond_to :authors
|