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,600 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::DAOLDAP do
|
|
7
|
+
it '[B001] uses the documented default LDAP port' do
|
|
8
|
+
client = instance_double(Net::LDAP, bind: true)
|
|
9
|
+
expect(Net::LDAP).to receive(:new).with(hash_including(port: 636)).and_return(client)
|
|
10
|
+
expect(described_class.connect(host: 'ldap.example.test', username: 'fixture', password: 'fixture')).to eq(client)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
RSpec.describe PWN::Plugins::Vsphere do
|
|
15
|
+
it '[B002] closes the authenticated connection on logout' do
|
|
16
|
+
client = double('vsphere connection')
|
|
17
|
+
expect(client).to receive(:close)
|
|
18
|
+
described_class.logout(vsphere_obj: client)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.describe PWN::Plugins::IPInfo do
|
|
23
|
+
it '[B003] returns no addresses on a resolver failure' do
|
|
24
|
+
resolver = instance_double(Resolv::DNS)
|
|
25
|
+
allow(Resolv::DNS).to receive(:new).and_return(resolver)
|
|
26
|
+
allow(resolver).to receive(:getaddresses).and_raise(Resolv::ResolvError)
|
|
27
|
+
allow(resolver).to receive(:close)
|
|
28
|
+
expect(PWN::Plugins::Sock).not_to receive(:check_port_in_use)
|
|
29
|
+
expect(described_class.get(target: 'missing.example.test', skip_api: true)).to eq([])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
RSpec.describe PWN::Plugins::IPInfo do
|
|
34
|
+
it '[B004] keeps each resolved address and its TLS result independent' do
|
|
35
|
+
resolver = instance_double(Resolv::DNS, getaddresses: %w[10.0.0.1 203.0.113.2])
|
|
36
|
+
allow(Resolv::DNS).to receive(:new).and_return(resolver)
|
|
37
|
+
allow(resolver).to receive(:close)
|
|
38
|
+
allow(PWN::Plugins::Sock).to receive(:check_port_in_use).with(server_ip: '10.0.0.1', port: 443).and_return(false)
|
|
39
|
+
allow(PWN::Plugins::Sock).to receive(:check_port_in_use).with(server_ip: '203.0.113.2', port: 443).and_return(true)
|
|
40
|
+
allow(PWN::Plugins::Sock).to receive(:get_tls_cert).and_return(nil)
|
|
41
|
+
rows = described_class.get(target: 'fixture.example.test', skip_api: true)
|
|
42
|
+
expect(rows.map { |row| row.slice(:ip, :is_rfc1918, :tls_avail) }).to eq([
|
|
43
|
+
{ ip: '10.0.0.1', is_rfc1918: true, tls_avail: false },
|
|
44
|
+
{ ip: '203.0.113.2', is_rfc1918: false, tls_avail: true }
|
|
45
|
+
])
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
RSpec.describe PWN::Plugins::IPInfo do
|
|
50
|
+
it '[B005] preserves a validation failure before a results file is opened' do
|
|
51
|
+
expect { described_class.bruteforce_subdomains(parent_domain: '') }.to raise_error(RuntimeError, /parent_domain parameter is required/)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
RSpec.describe PWN::Plugins::Debugger do
|
|
56
|
+
it '[B006] consumes complete MI records through ProcessTube' do
|
|
57
|
+
reader, writer = IO.pipe
|
|
58
|
+
commands = StringIO.new
|
|
59
|
+
tube = PWN::Plugins::ProcessTube.register(io: reader, w: commands)
|
|
60
|
+
allow(PWN::Plugins::ProcessTube).to receive(:dump_scrollback)
|
|
61
|
+
described_class.send(:store_session, handle: tube[:id], tube: tube)
|
|
62
|
+
writer.write("^done,register-values=[{number=\"16\",value=\"0x4141\"}]\n^done,memory=[{begin=\"0x1000\",contents=\"4142\"}]\n")
|
|
63
|
+
expect(described_class.regs(handle: tube[:id])[:registers]).to eq('16' => '0x4141')
|
|
64
|
+
expect(described_class.read_mem(handle: tube[:id], addr: '0x1000', len: 2)[:memory]).to eq(addr: '0x1000', hex: '4142')
|
|
65
|
+
ensure
|
|
66
|
+
described_class.close(handle: tube[:id]) if tube
|
|
67
|
+
writer&.close
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
RSpec.describe PWN::Plugins::GDB do
|
|
72
|
+
it '[B007] forwards debug_session script commands before running the inferior' do
|
|
73
|
+
allow(PWN::Plugins::PreflightChecker).to receive(:require_bin!)
|
|
74
|
+
status = instance_double(Process::Status, exitstatus: 0)
|
|
75
|
+
expect(Open3).to receive(:capture3).with('gdb', '--batch', '--quiet', '-ex', 'set pagination off', '-ex', 'break main', '-ex', 'run', '-ex', 'bt', '-ex', 'info registers', '--args', '/fixture').and_return(['', '', status])
|
|
76
|
+
described_class.debug_session(binary: '/fixture', script: ['break main'])
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
RSpec.describe PWN::Plugins::AFLplusplus do
|
|
81
|
+
it '[B008] passes the campaign runtime budget to AFL++' do
|
|
82
|
+
Dir.mktmpdir('pwn-afl-budget-') do |dir|
|
|
83
|
+
received = nil
|
|
84
|
+
allow(described_class).to receive(:system) { |*argv, **_kw|
|
|
85
|
+
received = argv
|
|
86
|
+
true
|
|
87
|
+
}
|
|
88
|
+
described_class.campaign(in_dir: File.join(dir, 'in'), out_dir: File.join(dir, 'out'), target: 'fixture-target @@', max_runtime: 7, handoff: false)
|
|
89
|
+
expect(received.drop(1)).to include('-V', '7')
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
RSpec.describe PWN::Plugins::Char do
|
|
95
|
+
it '[B009] preserves UTF-8 bytes and never retags caller strings in place' do
|
|
96
|
+
text = 'café'
|
|
97
|
+
expect(described_class.force_utf8(obj: text)).to eq(text)
|
|
98
|
+
bytes = text.b.freeze
|
|
99
|
+
expect(described_class.force_utf8(obj: [bytes])).to eq([text])
|
|
100
|
+
expect(bytes.encoding).to eq(Encoding::BINARY)
|
|
101
|
+
expect(described_class.force_utf8(obj: "caf\xE9".b)).to eq(text)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
RSpec.describe PWN::Plugins::PreflightChecker do
|
|
106
|
+
it '[B010] rejects executable directories as missing binaries' do
|
|
107
|
+
Dir.mktmpdir('pwn-path-') do |dir|
|
|
108
|
+
FileUtils.mkdir_p(File.join(dir, 'fake-bin'))
|
|
109
|
+
allow(ENV).to receive(:[]).and_call_original
|
|
110
|
+
allow(ENV).to receive(:[]).with('PATH').and_return(dir)
|
|
111
|
+
expect(described_class.bin?(name: 'fake-bin')).to be(false)
|
|
112
|
+
expect { described_class.require_bin!(name: 'fake-bin') }.to raise_error(described_class::MissingBinary)
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
RSpec.describe 'bodyless REST success responses' do
|
|
118
|
+
before do
|
|
119
|
+
allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
|
|
120
|
+
allow(RestClient::Request).to receive(:execute).and_return(instance_double(RestClient::Response, body: '', code: 204))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
it '[B011] returns an empty result for GitHub 204 responses' do
|
|
124
|
+
expect(PWN::Plugins::Github.api(method: :delete, path: 'fixture', token: 'fixture')).to eq({})
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it '[B011] returns an empty result after deleting a HackerOne intent' do
|
|
128
|
+
expect(PWN::Plugins::HackerOne.delete_report_intent(id: 'fixture', username: 'fixture', api_key: 'fixture')).to eq({})
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
RSpec.describe PWN::Plugins::NexposeVulnScan do
|
|
133
|
+
it '[B012] reaches the stale-asset query after matching the requested site' do
|
|
134
|
+
site = double('site', id: 7, name: 'lab')
|
|
135
|
+
client = double('nexpose', list_sites: [site], filter: [])
|
|
136
|
+
expect(described_class.delete_site_assets_older_than(nsc_obj: client, site_name: 'lab', days: 30)).to eq(client)
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
RSpec.describe PWN::Plugins::NexposeVulnScan do
|
|
141
|
+
it '[B013] refuses to report a scan as completed when the site is absent' do
|
|
142
|
+
client = double('nexpose', list_sites: [], scan_activity: [])
|
|
143
|
+
expect(client).not_to receive(:scan_site)
|
|
144
|
+
expect { described_class.scan_site_by_name(nsc_obj: client, site_name: 'absent') }.to raise_error(/does not exist/)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
RSpec.describe PWN::Plugins::Fuzz do
|
|
149
|
+
it '[B014] sends a plain request template as actual wire bytes' do
|
|
150
|
+
socket = double('socket', wait_readable: false)
|
|
151
|
+
allow(PWN::Plugins::Sock).to receive(:connect).and_return(socket)
|
|
152
|
+
allow(PWN::Plugins::Sock).to receive(:disconnect).with(sock_obj: socket).and_return(nil)
|
|
153
|
+
expect(socket).to receive(:write).with("GET /café HTTP/1.0\r\n\r\n".b)
|
|
154
|
+
rows = described_class.socket(target: 'fixture', port: 1, request: "GET /♥seed♥ HTTP/1.0\r\n\r\n", payload: 'café', request_rate_limit: 0)
|
|
155
|
+
expect(rows.first[:response]).to eq('')
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
RSpec.describe PWN::Plugins::Fuzz do
|
|
160
|
+
it '[B015] bounds response reads when a peer keeps its connection open' do
|
|
161
|
+
socket, peer = UNIXSocket.pair
|
|
162
|
+
allow(PWN::Plugins::Sock).to receive(:connect).and_return(socket)
|
|
163
|
+
allow(PWN::Plugins::Sock).to receive(:disconnect) { |opts|
|
|
164
|
+
opts[:sock_obj].close unless opts[:sock_obj].closed?
|
|
165
|
+
nil
|
|
166
|
+
}
|
|
167
|
+
peer.write('ok')
|
|
168
|
+
rows = Timeout.timeout(0.5) do
|
|
169
|
+
described_class.socket(target: 'fixture', port: 1, request: '♥x♥', payload: 'A', response_timeout: 0.05, request_rate_limit: 0)
|
|
170
|
+
end
|
|
171
|
+
expect(rows.first).to include(response: '"ok"', response_len: 2)
|
|
172
|
+
ensure
|
|
173
|
+
socket&.close unless socket&.closed?
|
|
174
|
+
peer&.close unless peer&.closed?
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
RSpec.describe PWN::Plugins::GoogleWorkspace do
|
|
179
|
+
it '[B016] escapes apostrophes and backslashes in literal Drive searches' do
|
|
180
|
+
query = "O'Reilly\\guide"
|
|
181
|
+
expect(described_class).to receive(:api).with(hash_including(params: hash_including(q: "fullText contains 'O\\'Reilly\\\\guide'"))).and_return(files: [])
|
|
182
|
+
expect(described_class.drive_search(query: query)).to eq([])
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
RSpec.describe PWN::Plugins::Findings do
|
|
187
|
+
it '[B017] never closes a finding when the reproduction command failed' do
|
|
188
|
+
Dir.mktmpdir('pwn-retest-') do |dir|
|
|
189
|
+
stub_const('PWN::Plugins::Findings::FILE', File.join(dir, 'findings.jsonl'))
|
|
190
|
+
allow(Dir).to receive(:home).and_return(dir)
|
|
191
|
+
row = { id: 'fixture', title: 'fixture', status: 'open', severity: 'high', claimed_severity: 'high', verification_status: 'reproduced', reproduction_steps: ['exit 7'] }
|
|
192
|
+
File.write(described_class::FILE, "#{JSON.generate(row)}\n")
|
|
193
|
+
expect { described_class.retest(id: 'fixture', kind: 'script', impact: 'FIXTURE_IMPACT') }.to raise_error(IOError, /reproduction failed/)
|
|
194
|
+
expect(described_class.report.first).to eq(row)
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
RSpec.describe PWN::Plugins::GoogleWorkspace do
|
|
200
|
+
it '[B018] removes the persisted refresh token on revocation' do
|
|
201
|
+
Dir.mktmpdir('pwn-revoke-') do |dir|
|
|
202
|
+
path = File.join(dir, 'fixture.yaml')
|
|
203
|
+
File.write(path, 'fixture')
|
|
204
|
+
stub_const('PWN::Plugins::GoogleWorkspace::PENDING_FILE', File.join(dir, 'pending'))
|
|
205
|
+
oauth = { bearer_token: 'fixture-bearer', refresh_token: 'fixture-refresh', expires_at: 123 }
|
|
206
|
+
vault = { plugins: { google_workspace: { oauth: oauth.dup } } }
|
|
207
|
+
stub_const('PWN::Env', { plugins: { google_workspace: { oauth: oauth.dup } }, driver_opts: { pwn_env_path: path } })
|
|
208
|
+
allow(RestClient).to receive(:post).and_return('')
|
|
209
|
+
allow(PWN::Plugins::Vault).to receive(:update).and_yield(vault)
|
|
210
|
+
described_class.revoke
|
|
211
|
+
expect(vault.dig(:plugins, :google_workspace, :oauth)).to include(bearer_token: '', refresh_token: nil, expires_at: nil)
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
RSpec.describe PWN::Plugins::DefectDojo do
|
|
217
|
+
it '[B019] supports engagement lookup by id without pagination fields' do
|
|
218
|
+
allow(described_class).to receive(:rest_call).with(dd_obj: {}, rest_call: 'engagements/7', params: { o: 'name', limit: 25 }).and_return('{"id":7,"name":"fixture"}')
|
|
219
|
+
expect(described_class.engagement_list(dd_obj: {}, id: 7)).to eq(id: 7, name: 'fixture')
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
RSpec.describe PWN::Plugins::DefectDojo do
|
|
224
|
+
it '[B020] creates the requested engagement type with optional tools omitted' do
|
|
225
|
+
allow(described_class).to receive(:user_list).and_return(results: [{ username: 'lead', id: 1 }])
|
|
226
|
+
allow(described_class).to receive(:product_list).and_return(results: [{ name: 'product', id: 2 }])
|
|
227
|
+
allow(described_class).to receive(:tool_configuration_list).and_return(results: [])
|
|
228
|
+
expect(described_class).to receive(:rest_call).with(hash_including(http_body: hash_including(engagement_type: 'Interactive', orchestration_engine: nil))).and_return('created')
|
|
229
|
+
expect(described_class.engagement_create(dd_obj: { api_version: 'v2' }, name: 'fixture', lead_username: 'lead', product_name: 'product', engagement_type: 'Interactive')).to eq('created')
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
RSpec.describe 'REST error propagation' do
|
|
234
|
+
before do
|
|
235
|
+
allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
|
|
236
|
+
allow(RestClient::Request).to receive(:execute).and_raise(RestClient::Unauthorized)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it '[B021] preserves the DefectDojo HTTP exception' do
|
|
240
|
+
expect { PWN::Plugins::DefectDojo.product_list(dd_obj: { url: 'https://fixture.test', api_version: 'v2' }) }.to raise_error(RestClient::Unauthorized)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it '[B021] preserves the VIN HTTP exception' do
|
|
244
|
+
expect { PWN::Plugins::VIN.get_all_makes }.to raise_error(RestClient::Unauthorized)
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
RSpec.describe PWN::Plugins::TransparentBrowser do
|
|
249
|
+
it '[B022] stops retrying when both JavaScript forms fail' do
|
|
250
|
+
calls = 0
|
|
251
|
+
browser = double('browser')
|
|
252
|
+
allow(browser).to receive(:execute_script) do
|
|
253
|
+
calls += 1
|
|
254
|
+
raise 'unbounded retry' if calls > 2
|
|
255
|
+
|
|
256
|
+
raise Selenium::WebDriver::Error::JavascriptError, 'invalid JavaScript'
|
|
257
|
+
end
|
|
258
|
+
expect { described_class.console(browser_obj: { type: :chrome, browser: browser }, js: 'broken()') }.to raise_error(Selenium::WebDriver::Error::JavascriptError)
|
|
259
|
+
expect(calls).to eq(2)
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
RSpec.describe PWN::Plugins::TransparentBrowser do
|
|
264
|
+
it '[B023] does not close the last tab for a nonmatching selector' do
|
|
265
|
+
tabs = [{ index: 'actual', title: 'Keep', url: 'https://fixture.test', state: :active }]
|
|
266
|
+
allow(described_class).to receive(:list_tabs).and_return(tabs)
|
|
267
|
+
allow(described_class).to receive(:close)
|
|
268
|
+
browser = { type: :chrome, browser: Object.new }
|
|
269
|
+
expect(described_class.close_tab(browser_obj: browser, index: 'missing')).to eq(tabs)
|
|
270
|
+
expect(described_class.close_tab(browser_obj: browser, keyword: 'not-present')).to eq(tabs)
|
|
271
|
+
expect(described_class).not_to have_received(:close)
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
RSpec.describe PWN::Plugins::BinaryParser do
|
|
276
|
+
it '[B024] resolves a static ELF with load segments but no dynamic table' do
|
|
277
|
+
Dir.mktmpdir('pwn-static-elf-') do |dir|
|
|
278
|
+
path = File.join(dir, 'fixture')
|
|
279
|
+
ident = "\x7fELF\x02\x01\x01".b.ljust(16, "\0")
|
|
280
|
+
header = [2, 62, 1, 0x401000, 64, 0, 0, 64, 56, 1, 64, 0, 0].pack('vvVQ<Q<Q<Vvvvvvv')
|
|
281
|
+
load = [1, 5, 0, 0x400000, 0x400000, 120, 120, 4096].pack('VVQ<Q<Q<Q<Q<Q<')
|
|
282
|
+
File.binwrite(path, ident + header + load)
|
|
283
|
+
expect(described_class.elf_resolve(path: path)).to include(arch: 'x86_64', got: {}, plt: {}, symbols: {})
|
|
284
|
+
end
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
RSpec.describe PWN::Plugins::Jobs do
|
|
289
|
+
it '[B025] terminates a timed-out graph command before its later write' do
|
|
290
|
+
Dir.mktmpdir('pwn-graph-deadline-') do |dir|
|
|
291
|
+
graph = described_class.graph(artifact_dir: dir, jobs: [{ id: 'slow', command: 'sleep 0.4; printf late > marker; sleep 0.5', timeout: 0.05 }])
|
|
292
|
+
expect(graph[:jobs]['slow']).to include(timeout: true, exit: 124)
|
|
293
|
+
expect(File.exist?(File.join(dir, 'marker'))).to be(false)
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
RSpec.describe PWN::Plugins::DAOLDAP do
|
|
299
|
+
it '[B026] rejects an unsuccessful LDAP bind rather than returning an authenticated handle' do
|
|
300
|
+
client = instance_double(Net::LDAP, bind: false)
|
|
301
|
+
allow(Net::LDAP).to receive(:new).and_return(client)
|
|
302
|
+
expect { described_class.connect(host: 'ldap.example.test', username: 'fixture', password: 'fixture') }.to raise_error(IOError, /LDAP bind failed/)
|
|
303
|
+
end
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
RSpec.describe PWN::Plugins::DAOMongo do
|
|
307
|
+
it '[B027] loads its driver when the plugin is loaded in a fresh Ruby process' do
|
|
308
|
+
code = "require 'pwn/plugins/dao_mongo'; abort 'Mongo::Client not loaded' unless defined?(Mongo::Client)"
|
|
309
|
+
out, status = Open3.capture2e(RbConfig.ruby, '-I', File.expand_path('../../../../lib', __dir__), '-e', code)
|
|
310
|
+
expect(status.success?).to be(true), out
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
RSpec.describe PWN::Plugins::NexposeVulnScan do
|
|
315
|
+
it '[B028] accepts the documented Array of recurring report names' do
|
|
316
|
+
report = double('report', name: 'weekly', status: 'Generated', uri: '/reports/weekly.pdf')
|
|
317
|
+
client = double('nexpose')
|
|
318
|
+
polls = 0
|
|
319
|
+
allow(client).to receive(:reports) do
|
|
320
|
+
polls += 1
|
|
321
|
+
raise 'report loop did not finish' if polls > 1
|
|
322
|
+
|
|
323
|
+
[report]
|
|
324
|
+
end
|
|
325
|
+
expect(client).to receive(:download).with('/reports/weekly.pdf', 'weekly.pdf')
|
|
326
|
+
expect(described_class.download_recurring_report(nsc_obj: client, report_names: ['weekly'], poll_interval: 0)).to eq(client)
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
RSpec.describe PWN::Plugins::GoogleWorkspace do
|
|
331
|
+
it '[B029] replies using RFC Message-ID and Reply-To rather than the API id' do
|
|
332
|
+
message = { id: 'api-id', threadId: 'thread-id', payload: { headers: [
|
|
333
|
+
{ name: 'From', value: 'sender@example.test' }, { name: 'Reply-To', value: 'reply@example.test' },
|
|
334
|
+
{ name: 'Subject', value: 'Fixture' }, { name: 'Message-ID', value: '<message@example.test>' }
|
|
335
|
+
] } }
|
|
336
|
+
allow(described_class).to receive(:api).with(hash_including(url: "#{described_class::GMAIL_API}/users/me/messages/api-id")).and_return(message)
|
|
337
|
+
expect(described_class).to receive(:api).with(hash_including(http_method: :post)) do |options|
|
|
338
|
+
raw = Base64.urlsafe_decode64(options[:http_body][:raw])
|
|
339
|
+
expect(raw).to include('To: reply@example.test', 'In-Reply-To: <message@example.test>', 'References: <message@example.test>')
|
|
340
|
+
expect(options[:http_body][:threadId]).to eq('thread-id')
|
|
341
|
+
{ id: 'sent', threadId: 'thread-id' }
|
|
342
|
+
end
|
|
343
|
+
described_class.gmail_reply(id: 'api-id', body: 'Fixture reply')
|
|
344
|
+
end
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
RSpec.describe PWN::Plugins::Git do
|
|
348
|
+
it '[B030] treats git URLs as a single literal argument rather than shell commands' do
|
|
349
|
+
Dir.mktmpdir('pwn-git-argv-') do |dir|
|
|
350
|
+
fake = File.join(dir, 'git')
|
|
351
|
+
File.write(fake, "#!/bin/sh\nprintf '%s\\n' \"$@\"\n")
|
|
352
|
+
File.chmod(0o700, fake)
|
|
353
|
+
old_path = ENV.fetch('PATH', '')
|
|
354
|
+
ENV['PATH'] = "#{dir}:#{old_path}"
|
|
355
|
+
marker = File.join(dir, 'marker')
|
|
356
|
+
url = "repo name; printf bad > #{marker}"
|
|
357
|
+
response = described_class.dump_all_repo_branches(git_url: url)
|
|
358
|
+
expect(File.exist?(marker)).to be(false)
|
|
359
|
+
expect(response.lines.map(&:chomp)).to eq(['ls-remote', '--', url])
|
|
360
|
+
ensure
|
|
361
|
+
ENV['PATH'] = old_path
|
|
362
|
+
end
|
|
363
|
+
end
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
RSpec.describe PWN::Plugins::OpenVAS do
|
|
367
|
+
it '[B031] passes credentials literally and matches quoted task names' do
|
|
368
|
+
expect(described_class).not_to receive(:`)
|
|
369
|
+
expect(Open3).to receive(:capture3).with('sudo', 'runuser', '-u', '_gvm', '--', '/usr/bin/gvm-cli', '--gmp-username', 'fixture', '--gmp-password', "fixture'pass", 'socket', '--xml', anything).and_return(["<get_tasks_response><task id='7'><name>Bob's task</name></task></get_tasks_response>", '', instance_double(Process::Status, success?: true)])
|
|
370
|
+
tasks = described_class.get_task_id(task_name: "Bob's task", username: 'fixture', password: "fixture'pass")
|
|
371
|
+
expect(tasks.xpath('@id').text).to eq('7')
|
|
372
|
+
end
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
RSpec.describe PWN::Plugins::OpenVAS do
|
|
376
|
+
it '[B031] uses argv transport for starting tasks and exporting reports' do
|
|
377
|
+
tasks = Nokogiri::XML("<root><task id='7'/></root>").xpath('/root/task')
|
|
378
|
+
allow(described_class).to receive(:get_task_id).and_return(tasks)
|
|
379
|
+
expect(described_class).not_to receive(:`)
|
|
380
|
+
allow(Open3).to receive(:capture3) do |*argv|
|
|
381
|
+
xml = Nokogiri::XML(argv.last)
|
|
382
|
+
response = case xml.root.name
|
|
383
|
+
when 'start_task' then '<start_task_response/>'
|
|
384
|
+
when 'get_report_formats' then "<get_report_formats_response><report_format id='csv'><name>CSV Results</name></report_format></get_report_formats_response>"
|
|
385
|
+
else
|
|
386
|
+
"<get_reports_response><report id='8'><task id='7'/>#{Base64.strict_encode64("fixture\n")}</report></get_reports_response>"
|
|
387
|
+
end
|
|
388
|
+
[response, '', instance_double(Process::Status, success?: true)]
|
|
389
|
+
end
|
|
390
|
+
described_class.start_task(task_name: 'fixture', username: 'fixture', password: 'fixture')
|
|
391
|
+
expect(described_class.last_report_id(task_name: 'fixture', username: 'fixture', password: 'fixture')).to eq('8')
|
|
392
|
+
Dir.mktmpdir('pwn-gvm-report-') do |dir|
|
|
393
|
+
described_class.save_report(report_dir: dir, report_type: 'csv', report_id: '8', username: 'fixture', password: 'fixture')
|
|
394
|
+
expect(File.binread(File.join(dir, 'openvas_results.csv'))).to eq("fixture\n")
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
RSpec.describe PWN::Plugins::BinaryAnalysis do
|
|
400
|
+
it '[B032] never interprets a one-element argv as a shell command' do
|
|
401
|
+
expect { described_class.run(argv: ['printf not-an-executable'], timeout: 1) }.to raise_error(Errno::ENOENT)
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
RSpec.describe PWN::Plugins::DetectOS do
|
|
406
|
+
it '[B033] excludes already wrapped tools from native living-off-the-land inventory' do
|
|
407
|
+
row = described_class.living_off_the_land(distro: 'fixture', version: '1', type: :linux, arch: 'fixture', endian: :little, cap_net_raw: false, docker: false, pwn_bins: ['wrapped'], which: { 'wrapped' => true, 'extra' => true })
|
|
408
|
+
expect(row[:native]).to eq(['extra'])
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
RSpec.describe PWN::Plugins::ExploitDB do
|
|
413
|
+
it '[B034] leaves the destination absent during a sync dry run' do
|
|
414
|
+
Dir.mktmpdir('pwn-sync-dry-') do |dir|
|
|
415
|
+
destination = File.join(dir, 'not-created')
|
|
416
|
+
expect(described_class.sync(dir: destination, dry_run: true)[:dry_run]).to be(true)
|
|
417
|
+
expect(File.exist?(destination)).to be(false)
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
RSpec.describe 'scanner JSONL validation' do
|
|
423
|
+
it '[B035] skips non-object httpx JSON values' do
|
|
424
|
+
row = PWN::Plugins::Httpx.probe(jsonl: "1\ntrue\n[]\n{\"tech\":[\"fixture\"]}\n")
|
|
425
|
+
expect(row[:hosts]).to eq([{ 'tech' => ['fixture'] }])
|
|
426
|
+
expect(row[:techs]).to eq(['fixture'])
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
it '[B035] skips non-object nuclei JSON values' do
|
|
430
|
+
row = PWN::Plugins::Nuclei.scan(jsonl: "1\ntrue\n[]\n{\"template-id\":\"fixture\"}\n", record: false)
|
|
431
|
+
expect(row[:findings].map { |finding| finding[:template_id] }).to eq(['fixture'])
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
RSpec.describe PWN::Plugins::OCR do
|
|
436
|
+
it '[B036] rejects a missing image before invoking Tesseract' do
|
|
437
|
+
Dir.mktmpdir('pwn-ocr-missing-') do |dir|
|
|
438
|
+
expect(RTesseract).not_to receive(:new)
|
|
439
|
+
expect { described_class.process(file: File.join(dir, 'absent.png')) }.to raise_error(ArgumentError, /image file/)
|
|
440
|
+
end
|
|
441
|
+
end
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
RSpec.describe PWN::Plugins::SBOM do
|
|
445
|
+
it '[B037] preserves explicit untagged image selection for Trivy' do
|
|
446
|
+
status = instance_double(Process::Status, success?: true)
|
|
447
|
+
expect(Open3).to receive(:capture2).with('trivy', 'image', '--format', 'json', 'fixture-image').and_return(['{"Results":[]}', status])
|
|
448
|
+
expect(described_class.scan(image: 'fixture-image', engine: 'trivy')[:vulns]).to eq([])
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
RSpec.describe 'authenticated REST TLS defaults' do
|
|
453
|
+
before do
|
|
454
|
+
allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
|
|
455
|
+
allow(PWN::Plugins::DefectDojo).to receive(:sleep)
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
it '[B038] verifies HTTPS peers on credential-bearing APIs', :aggregate_failures do
|
|
459
|
+
expect(RestClient::Request).to receive(:execute).exactly(4).times do |options|
|
|
460
|
+
expect(options[:verify_ssl]).not_to be(false)
|
|
461
|
+
RestClient::Response.create('{}', Net::HTTPOK.new('1.1', '200', 'OK'), instance_double(RestClient::Request, redirection_history: []))
|
|
462
|
+
end
|
|
463
|
+
PWN::Plugins::Github.api(path: 'fixture', token: 'fixture')
|
|
464
|
+
PWN::Plugins::HackerOne.get_balance(username: 'fixture', api_key: 'fixture')
|
|
465
|
+
PWN::Plugins::DefectDojo.product_list(dd_obj: { url: 'https://fixture.test', api_version: 'v2' })
|
|
466
|
+
PWN::Plugins::VIN.get_all_makes
|
|
467
|
+
end
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
RSpec.describe PWN::Plugins::HackerOne do
|
|
471
|
+
it '[B039] stops after three retries when rate limiting persists' do
|
|
472
|
+
calls = 0
|
|
473
|
+
allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
|
|
474
|
+
allow(described_class).to receive(:sleep)
|
|
475
|
+
allow(RestClient::Request).to receive(:execute) do
|
|
476
|
+
calls += 1
|
|
477
|
+
raise 'unbounded retry' if calls > 4
|
|
478
|
+
|
|
479
|
+
raise RestClient::TooManyRequests
|
|
480
|
+
end
|
|
481
|
+
expect { described_class.get_balance(username: 'fixture', api_key: 'fixture') }.to raise_error(RestClient::TooManyRequests)
|
|
482
|
+
expect(calls).to eq(4)
|
|
483
|
+
end
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
RSpec.describe PWN::Plugins::AISandbox do
|
|
487
|
+
it '[B040] refuses strict execution when the isolation profile is not implemented' do
|
|
488
|
+
Dir.mktmpdir('pwn-strict-profile-') do |dir|
|
|
489
|
+
allow(Dir).to receive(:home).and_return(dir)
|
|
490
|
+
target = File.join(dir, 'outside-artifacts')
|
|
491
|
+
result = described_class.exec(kind: :ruby, mode: :strict, payload: "File.write(#{target.inspect}, 'escaped')")
|
|
492
|
+
expect(result).to include(ok: false)
|
|
493
|
+
expect(result[:error]).to include('strict sandbox profile')
|
|
494
|
+
expect(File.exist?(target)).to be(false)
|
|
495
|
+
end
|
|
496
|
+
end
|
|
497
|
+
end
|
|
498
|
+
|
|
499
|
+
RSpec.describe PWN::Plugins::Detonate do
|
|
500
|
+
it '[B041] refuses synthetic detonation instead of reporting an unexecuted sample as isolated' do
|
|
501
|
+
Dir.mktmpdir('pwn-detonate-unsupported-') do |dir|
|
|
502
|
+
sample = File.join(dir, 'sample')
|
|
503
|
+
File.write(sample, 'fixture')
|
|
504
|
+
allow(PWN::Plugins::PreflightChecker).to receive(:bin?).with(name: 'podman').and_return(true)
|
|
505
|
+
expect(Open3).not_to receive(:capture3)
|
|
506
|
+
row = described_class.detonate(path: sample)
|
|
507
|
+
expect(row).to include(isolated: false, executed: false)
|
|
508
|
+
expect(row[:error]).to include('not implemented')
|
|
509
|
+
end
|
|
510
|
+
end
|
|
511
|
+
end
|
|
512
|
+
|
|
513
|
+
RSpec.describe PWN::Plugins::Char do
|
|
514
|
+
it '[B042] keeps each non-character representation in its own output file' do
|
|
515
|
+
Dir.mktmpdir('pwn-char-files-') do |dir|
|
|
516
|
+
allow(described_class).to receive(:generate_by_range).and_return([{ bin: { char: '01000001', encoder: nil }, hex: { char: '41', encoder: nil } }])
|
|
517
|
+
described_class.generate_encoded_files(from: 65, to: 65, output_dir: dir)
|
|
518
|
+
expect(Dir.children(dir).sort).to eq(%w[65_65_bin.txt 65_65_hex.txt])
|
|
519
|
+
expect(File.read(File.join(dir, '65_65_bin.txt'))).to eq("01000001\n")
|
|
520
|
+
expect(File.read(File.join(dir, '65_65_hex.txt'))).to eq("41\n")
|
|
521
|
+
end
|
|
522
|
+
end
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
RSpec.describe PWN::Plugins::MethodCatalog do
|
|
526
|
+
it '[B043] accepts options forwarded to an internal helper without accepting unknown keys' do
|
|
527
|
+
%i[info sections symbols imports exports relocations].each do |method|
|
|
528
|
+
expect(described_class.guard_eval(code: "PWN::Plugins::BinaryParser.#{method}(path: '/fixture')")).to be_nil
|
|
529
|
+
rejected = described_class.guard_eval(code: "PWN::Plugins::BinaryParser.#{method}(not_a_key: '/fixture')")
|
|
530
|
+
expect(rejected[:error]).to include('not_a_key')
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
RSpec.describe PWN::Plugins::Git do
|
|
536
|
+
it '[B044] keeps dates in one argument and escapes the HTML summary' do
|
|
537
|
+
allow(described_class).to receive(:`).and_return('raw <message>')
|
|
538
|
+
expect(Open3).to receive(:capture2).with('git', 'log', '--since', 'last week', '--stat-width=65535', '--graph', err: File::NULL).and_return(['raw <message>', instance_double(Process::Status, success?: true)])
|
|
539
|
+
html = described_class.gen_html_diff(repo: '<repo>', branch: 'main', since: 'last week')
|
|
540
|
+
expect(html).to include('<repo>', 'raw <message>')
|
|
541
|
+
expect(html).not_to include('<repo>', '<message>')
|
|
542
|
+
end
|
|
543
|
+
|
|
544
|
+
it '[B045] supports frozen filenames and repository paths containing spaces' do
|
|
545
|
+
Dir.mktmpdir('pwn-author space-') do |dir|
|
|
546
|
+
File.write(File.join(dir, 'file name.rb'), "first\nlast")
|
|
547
|
+
filename = 'file name.rb.JS-BEAUTIFIED'
|
|
548
|
+
allow(described_class).to receive(:`).and_return('')
|
|
549
|
+
expect(Open3).to receive(:capture2).with('git', "--git-dir=#{dir}/.git", 'log', '-L', '1,2:file name.rb', err: File::NULL).and_return(["commit fixture\nAuthor: Fixture\n", instance_double(Process::Status, success?: true)])
|
|
550
|
+
expect(described_class.get_author(repo_root: dir, target_file: filename, entry_beautified: true)).to eq("Author: Fixture\n")
|
|
551
|
+
expect(filename).to eq('file name.rb.JS-BEAUTIFIED')
|
|
552
|
+
end
|
|
553
|
+
end
|
|
554
|
+
end
|
|
555
|
+
|
|
556
|
+
RSpec.describe PWN::Plugins::Char do
|
|
557
|
+
it '[B046] rejects a missing output directory before attempting generation or writing' do
|
|
558
|
+
Dir.mktmpdir('pwn-char-output-') do |dir|
|
|
559
|
+
expect(described_class).not_to receive(:generate_by_range)
|
|
560
|
+
expect { described_class.generate_encoded_files(from: 65, to: 65, output_dir: File.join(dir, 'missing')) }.to raise_error(ArgumentError, /output_dir/)
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
RSpec.describe PWN::Plugins::TransparentBrowser do
|
|
566
|
+
it '[B047] preserves parse failure diagnostics instead of referencing an undefined variable' do
|
|
567
|
+
browser = double('browser', driver: double('driver', on_log_event: nil))
|
|
568
|
+
devtools = double('devtools')
|
|
569
|
+
allow(devtools).to receive(:send_cmd).and_return('result' => { 'result' => { 'value' => 'not-json' } })
|
|
570
|
+
allow(described_class).to receive(:verify_devtools_browser).and_return(true)
|
|
571
|
+
expect { described_class.get_page_state(browser_obj: { browser: browser, devtools: devtools }) }.to raise_error(RuntimeError, /Failed to parse state JSON/)
|
|
572
|
+
end
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
RSpec.describe PWN::Plugins::SSN do
|
|
576
|
+
it '[B048] excludes reserved area numbers from randomized fixture identifiers' do
|
|
577
|
+
[666, :max].each do |boundary|
|
|
578
|
+
allow(Random).to receive(:rand) { |range|
|
|
579
|
+
if range.end > 100
|
|
580
|
+
boundary == :max ? range.end : boundary
|
|
581
|
+
else
|
|
582
|
+
1
|
|
583
|
+
end
|
|
584
|
+
}
|
|
585
|
+
area = described_class.generate(count: 1).first.split('-').first.to_i
|
|
586
|
+
expect(area).to be_between(1, 899)
|
|
587
|
+
expect(area).not_to eq(666)
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
end
|
|
591
|
+
|
|
592
|
+
RSpec.describe PWN::Plugins::CreditCard do
|
|
593
|
+
it '[B049] generates every advertised brand using the installed dependency' do
|
|
594
|
+
described_class.list_types.each do |type|
|
|
595
|
+
row = described_class.generate(type: type, count: 1).first
|
|
596
|
+
expect(CreditCardValidations::Detector.new(row[:number]).valid?(type)).to be(true)
|
|
597
|
+
expect(row[:type]).not_to be_nil
|
|
598
|
+
end
|
|
599
|
+
end
|
|
600
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::Pony, 'mail builder regression' do
|
|
6
|
+
it 'builds a plain text mail without attempting delivery' do
|
|
7
|
+
mail = described_class.build_mail(to: 'fixture@example.invalid', body: 'offline body', via: :test)
|
|
8
|
+
expect(mail.body.decoded).to eq('offline body')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'builds both body alternatives alongside an attachment' do
|
|
12
|
+
mail = described_class.build_mail(to: 'fixture@example.invalid', body: 'offline body', html_body: '<p>offline body</p>', attachments: { 'fixture.txt' => 'data' }, via: :test)
|
|
13
|
+
expect(mail.parts.first.mime_type).to eq('multipart/alternative')
|
|
14
|
+
expect(mail.parts.first.parts.map(&:mime_type)).to contain_exactly('text/plain', 'text/html')
|
|
15
|
+
expect(mail.attachments.first.decoded).to eq('data')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::Plugins::Pony, 'review Unicode MIME roundtrip' do
|
|
6
|
+
[false, true].each do |with_attachment|
|
|
7
|
+
it "preserves explicit UTF-8 charset and MIME types (attachment: #{with_attachment})" do
|
|
8
|
+
opts = { to: 'fixture@example.invalid', body: 'café 日本語 ☃', html_body: '<p>café 日本語 ☃</p>',
|
|
9
|
+
charset: 'UTF-8', text_part_charset: 'UTF-8', via: :test }
|
|
10
|
+
opts[:attachments] = { 'fixture.bin' => "\x00\xff\n".b } if with_attachment
|
|
11
|
+
parsed = Mail.read_from_string(described_class.build_mail(opts).encoded)
|
|
12
|
+
alternatives = with_attachment ? parsed.parts.first : parsed
|
|
13
|
+
expect(alternatives.text_part.mime_type).to eq('text/plain')
|
|
14
|
+
expect(alternatives.text_part.decoded).to eq(opts[:body])
|
|
15
|
+
expect(alternatives.html_part.decoded).to eq(opts[:html_body])
|
|
16
|
+
expect(alternatives.text_part.charset).to eq('UTF-8')
|
|
17
|
+
expect(parsed.attachments.first.decoded.b).to eq("\x00\xff\n".b) if with_attachment
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "preserves Unicode text and HTML through Mail serialization (attachment: #{with_attachment})" do
|
|
21
|
+
opts = { to: 'fixture@example.invalid', body: 'café 日本語 ☃', html_body: '<p>café 日本語 ☃</p>', via: :test }
|
|
22
|
+
opts[:attachments] = { 'fixture.bin' => "\x00\xff\n".b } if with_attachment
|
|
23
|
+
parsed = Mail.read_from_string(described_class.build_mail(opts).encoded)
|
|
24
|
+
alternatives = with_attachment ? parsed.parts.first : parsed
|
|
25
|
+
expect(alternatives.mime_type).to eq('multipart/alternative')
|
|
26
|
+
expect(alternatives.text_part.decoded).to eq(opts[:body])
|
|
27
|
+
expect(alternatives.html_part.decoded).to eq(opts[:html_body])
|
|
28
|
+
expect(alternatives.text_part.charset).to eq('UTF-8')
|
|
29
|
+
expect(alternatives.html_part.charset).to eq('UTF-8')
|
|
30
|
+
expect(parsed.attachments.first.decoded.b).to eq("\x00\xff\n".b) if with_attachment
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'socket'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::ProcessTube, 'ANSI expectation regression' do
|
|
7
|
+
it 'consumes the matching raw prefix when matching through ANSI escapes' do
|
|
8
|
+
reader, writer = UNIXSocket.pair
|
|
9
|
+
tube = described_class.register(io: reader)
|
|
10
|
+
writer.write("\e[31mREADY\e[0m\nNEXT\n")
|
|
11
|
+
result = described_class.expect(id: tube[:id], pattern: /READY/, strip_ansi: true, timeout: 1)
|
|
12
|
+
expect(result[:matched]).to eq('READY')
|
|
13
|
+
expect(described_class.recvline(id: tube[:id], timeout: 1)).to eq("\e[0m\n")
|
|
14
|
+
expect(described_class.recvline(id: tube[:id], timeout: 1)).to eq("NEXT\n")
|
|
15
|
+
ensure
|
|
16
|
+
described_class.close(id: tube[:id]) if tube
|
|
17
|
+
writer&.close
|
|
18
|
+
end
|
|
19
|
+
end
|