pwn 0.5.795 → 0.5.798
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/bin/pwn_autoinc_version +4 -5
- data/bin/pwn_web_cache_deception +40 -29
- data/documentation/AWS.md +15 -5
- data/documentation/Diagrams.md +1 -1
- data/documentation/Home.md +2 -2
- data/documentation/How-PWN-Works.md +1 -1
- data/documentation/Mission-Cancellation.md +6 -4
- data/documentation/Operability.md +1 -1
- data/documentation/What-is-PWN.md +1 -1
- data/documentation/diagrams/aws-cloud-security.svg +1 -1
- data/documentation/diagrams/dot/aws-cloud-security.dot +1 -1
- data/documentation/diagrams/dot/network-infra-testing.dot +1 -1
- data/documentation/diagrams/network-infra-testing.svg +1 -1
- data/etc/default_cron/session_cleanup.rb +84 -51
- data/etc/default_skills/pwn/ai/agent/mission_namespace/SKILL.md +6 -4
- data/lib/pwn/ai/agent/assembly.rb +0 -2
- data/lib/pwn/ai/agent/btc.rb +0 -2
- data/lib/pwn/ai/agent/burp_suite.rb +0 -2
- data/lib/pwn/ai/agent/curriculum.rb +2 -2
- data/lib/pwn/ai/agent/dispatch.rb +3 -0
- data/lib/pwn/ai/agent/engagement.rb +96 -41
- data/lib/pwn/ai/agent/extrospection/osint/bridges.rb +2 -0
- data/lib/pwn/ai/agent/extrospection.rb +50 -13
- data/lib/pwn/ai/agent/gqrx.rb +0 -2
- data/lib/pwn/ai/agent/hacker_one.rb +0 -2
- data/lib/pwn/ai/agent/learning.rb +45 -13
- data/lib/pwn/ai/agent/loop.rb +16 -11
- data/lib/pwn/ai/agent/metrics.rb +1 -1
- data/lib/pwn/ai/agent/mission.rb +6 -3
- data/lib/pwn/ai/agent/mission_namespace.rb +70 -14
- data/lib/pwn/ai/agent/policy.rb +1 -1
- data/lib/pwn/ai/agent/policy_evaluation.rb +2 -2
- data/lib/pwn/ai/agent/reflect.rb +1 -0
- data/lib/pwn/ai/agent/request_runtime.rb +1 -1
- data/lib/pwn/ai/agent/reward.rb +155 -53
- data/lib/pwn/ai/agent/sast.rb +0 -2
- data/lib/pwn/ai/agent/task_dag.rb +5 -3
- data/lib/pwn/ai/agent/task_summarizer.rb +21 -11
- data/lib/pwn/ai/agent/tool_guard.rb +19 -0
- data/lib/pwn/ai/agent/tools/ruby_eval.rb +1 -1
- data/lib/pwn/ai/agent/tools/verify.rb +7 -3
- data/lib/pwn/ai/agent/transparent_browser.rb +0 -2
- data/lib/pwn/ai/agent/turn_finalizer.rb +3 -0
- data/lib/pwn/ai/anthropic.rb +3 -3
- data/lib/pwn/ai/context.rb +2 -1
- data/lib/pwn/ai/gemini.rb +7 -5
- data/lib/pwn/ai/grok.rb +37 -18
- data/lib/pwn/ai/mcp.rb +17 -5
- data/lib/pwn/ai/ollama.rb +76 -35
- data/lib/pwn/ai/open_ai.rb +7 -19
- data/lib/pwn/ai/open_web_ui.rb +76 -40
- data/lib/pwn/aws/cloud_search_domain.rb +6 -0
- data/lib/pwn/aws/iam.rb +2 -2
- data/lib/pwn/aws/workspaces.rb +2 -2
- data/lib/pwn/aws.rb +0 -5
- data/lib/pwn/bounty/lifecycle_authz_replay.rb +1 -1
- data/lib/pwn/config.rb +17 -10
- data/lib/pwn/corpus.rb +33 -5
- data/lib/pwn/cron.rb +60 -17
- data/lib/pwn/driver.rb +2 -3
- data/lib/pwn/engagement.rb +28 -10
- data/lib/pwn/ffi/capstone.rb +3 -2
- data/lib/pwn/ffi/fftw.rb +8 -6
- data/lib/pwn/ffi/keystone.rb +3 -2
- data/lib/pwn/ffi/soapy_sdr.rb +10 -6
- data/lib/pwn/json_text.rb +25 -13
- data/lib/pwn/memory_index.rb +6 -4
- data/lib/pwn/module_skills.rb +3 -1
- data/lib/pwn/plugins/aflplusplus.rb +1 -0
- data/lib/pwn/plugins/ai_sandbox.rb +42 -10
- data/lib/pwn/plugins/android.rb +429 -466
- data/lib/pwn/plugins/artifact_registry.rb +12 -2
- data/lib/pwn/plugins/assembly.rb +9 -42
- data/lib/pwn/plugins/authentication_helper.rb +4 -3
- data/lib/pwn/plugins/baresip.rb +70 -28
- data/lib/pwn/plugins/binary_analysis.rb +14 -5
- data/lib/pwn/plugins/binary_parser.rb +42 -7
- data/lib/pwn/plugins/black_duck_binary_analysis.rb +3 -3
- data/lib/pwn/plugins/burp_suite.rb +15 -12
- data/lib/pwn/plugins/bus_pirate.rb +3 -7
- data/lib/pwn/plugins/char.rb +9 -3
- data/lib/pwn/plugins/credit_card.rb +7 -0
- data/lib/pwn/plugins/dao_ldap.rb +2 -2
- data/lib/pwn/plugins/dao_mongo.rb +1 -1
- data/lib/pwn/plugins/debugger.rb +1 -1
- data/lib/pwn/plugins/defect_dojo.rb +7 -3
- data/lib/pwn/plugins/detect_os.rb +1 -1
- data/lib/pwn/plugins/detonate.rb +9 -19
- data/lib/pwn/plugins/exploit_db.rb +1 -1
- data/lib/pwn/plugins/file_fu.rb +4 -1
- data/lib/pwn/plugins/findings.rb +76 -2
- data/lib/pwn/plugins/fuzz.rb +12 -3
- data/lib/pwn/plugins/gdb.rb +7 -2
- data/lib/pwn/plugins/gdbmi.rb +10 -6
- data/lib/pwn/plugins/git.rb +18 -13
- data/lib/pwn/plugins/github.rb +11 -6
- data/lib/pwn/plugins/google_workspace.rb +11 -3
- data/lib/pwn/plugins/hacker_one.rb +5 -1
- data/lib/pwn/plugins/httpx.rb +24 -8
- data/lib/pwn/plugins/ip_info.rb +11 -8
- data/lib/pwn/plugins/irc.rb +73 -45
- data/lib/pwn/plugins/jenkins.rb +2 -2
- data/lib/pwn/plugins/jira_data_center.rb +13 -6
- data/lib/pwn/plugins/jobs.rb +62 -4
- data/lib/pwn/plugins/log.rb +1 -1
- data/lib/pwn/plugins/monkey_patch.rb +1 -1
- data/lib/pwn/plugins/msr206.rb +157 -182
- data/lib/pwn/plugins/nessus_cloud.rb +2 -2
- data/lib/pwn/plugins/nexpose_vuln_scan.rb +44 -33
- data/lib/pwn/plugins/nuclei.rb +24 -8
- data/lib/pwn/plugins/ocr.rb +3 -1
- data/lib/pwn/plugins/open_api.rb +0 -4
- data/lib/pwn/plugins/openvas.rb +31 -43
- data/lib/pwn/plugins/packet.rb +40 -25
- data/lib/pwn/plugins/pony.rb +2 -2
- data/lib/pwn/plugins/preflight_checker.rb +1 -1
- data/lib/pwn/plugins/process_tube.rb +17 -2
- data/lib/pwn/plugins/ps.rb +6 -1
- data/lib/pwn/plugins/pwn_logger.rb +37 -1
- data/lib/pwn/plugins/repl/ai.rb +1 -0
- data/lib/pwn/plugins/repl/ai_console.rb +18 -6
- data/lib/pwn/plugins/repl/mesh.rb +51 -28
- data/lib/pwn/plugins/sbom.rb +59 -27
- data/lib/pwn/plugins/scannable_codes.rb +3 -1
- data/lib/pwn/plugins/serial.rb +102 -44
- data/lib/pwn/plugins/shodan.rb +4 -10
- data/lib/pwn/plugins/sock.rb +16 -11
- data/lib/pwn/plugins/ssn.rb +3 -1
- data/lib/pwn/plugins/transparent_browser.rb +43 -3
- data/lib/pwn/plugins/vault.rb +92 -30
- data/lib/pwn/plugins/vin.rb +2 -1
- data/lib/pwn/plugins/vsphere.rb +2 -1
- data/lib/pwn/plugins/xxd.rb +3 -5
- data/lib/pwn/plugins/yubikey/security_domain/scp.rb +4 -0
- data/lib/pwn/plugins/yubikey/transport.rb +42 -11
- data/lib/pwn/plugins/yubikey.rb +21 -6
- data/lib/pwn/plugins/zaproxy.rb +3 -4
- data/lib/pwn/reports/ai_red_team.rb +4 -4
- data/lib/pwn/reports/pdf.rb +9 -5
- data/lib/pwn/reports/sast.rb +4 -4
- data/lib/pwn/sast/keystore.rb +2 -2
- data/lib/pwn/sast/logger.rb +1 -1
- data/lib/pwn/sast/php_type_juggling.rb +3 -6
- data/lib/pwn/sast/pom_version.rb +12 -6
- data/lib/pwn/sast/port.rb +1 -1
- data/lib/pwn/sast/sql.rb +3 -7
- data/lib/pwn/sast/test_case_engine.rb +62 -16
- data/lib/pwn/sast/type_script_type_juggling.rb +3 -6
- data/lib/pwn/sdr/decoder/base.rb +8 -0
- data/lib/pwn/sdr/decoder/lora.rb +1 -1
- data/lib/pwn/sdr/flipper_zero.rb +4 -7
- data/lib/pwn/sdr/gqrx.rb +35 -16
- data/lib/pwn/sdr/son_micro_rfid.rb +44 -26
- data/lib/pwn/sdr.rb +1 -1
- data/lib/pwn/session_trace.rb +7 -2
- data/lib/pwn/sessions.rb +310 -41
- data/lib/pwn/setup.rb +4 -3
- data/lib/pwn/version.rb +1 -1
- data/lib/pwn/www/app_cobalt_io.rb +14 -2
- data/lib/pwn/www/bing.rb +13 -1
- data/lib/pwn/www/bug_crowd.rb +14 -2
- data/lib/pwn/www/checkip.rb +13 -1
- data/lib/pwn/www/coinbase_pro.rb +14 -2
- data/lib/pwn/www/duckduckgo.rb +13 -1
- data/lib/pwn/www/facebook.rb +14 -2
- data/lib/pwn/www/github.rb +14 -2
- data/lib/pwn/www/google.rb +13 -1
- data/lib/pwn/www/hacker_one.rb +117 -33
- data/lib/pwn/www/linkedin.rb +14 -2
- data/lib/pwn/www/pandora.rb +14 -2
- data/lib/pwn/www/pastebin.rb +13 -1
- data/lib/pwn/www/paypal.rb +16 -4
- data/lib/pwn/www/synack.rb +14 -2
- data/lib/pwn/www/torch.rb +17 -3
- data/lib/pwn/www/trading_view.rb +14 -2
- data/lib/pwn/www/twitter.rb +14 -2
- data/lib/pwn/www/uber.rb +14 -2
- data/lib/pwn/www/upwork.rb +14 -2
- data/lib/pwn/www/wayback_machine.rb +16 -2
- data/lib/pwn/www/youtube.rb +13 -1
- data/lib/pwn.rb +11 -0
- data/pwn.gemspec +4 -0
- data/spec/conventions_spec.rb +43 -0
- data/spec/integration/authentication_helper_oath_spec.rb +1 -1
- data/spec/integration/autoinc_lifecycle_supplement_spec.rb +47 -0
- data/spec/integration/gemspec_deleted_files_spec.rb +43 -0
- data/spec/integration/harness_evaluation_spec.rb +22 -31
- data/spec/integration/harness_live_spec.rb +8 -18
- data/spec/integration/spec_curriculum_isolation_spec.rb +41 -0
- data/spec/integration/verify_acceptance_eui_regression_spec.rb +162 -0
- data/spec/integration/web_cache_lifecycle_closure_spec.rb +89 -0
- data/spec/integration/web_cache_lifecycle_supplement_spec.rb +70 -0
- data/spec/lib/pwn/ai/agent/analysis_errors_regression_spec.rb +33 -0
- data/spec/lib/pwn/ai/agent/curriculum_cooldown_regression_spec.rb +19 -0
- data/spec/lib/pwn/ai/agent/curriculum_spec.rb +2 -0
- data/spec/lib/pwn/ai/agent/engagement_boundary_regression_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/engagement_dispatch_review_spec.rb +82 -0
- data/spec/lib/pwn/ai/agent/engagement_roe_regression_spec.rb +25 -0
- data/spec/lib/pwn/ai/agent/engagement_scope_regression_spec.rb +37 -0
- data/spec/lib/pwn/ai/agent/extrospection/osint/bridges_spec.rb +4 -0
- data/spec/lib/pwn/ai/agent/extrospection_input_regression_spec.rb +31 -0
- data/spec/lib/pwn/ai/agent/extrospection_review_spec.rb +61 -0
- data/spec/lib/pwn/ai/agent/extrospection_serial_review_spec.rb +42 -0
- data/spec/lib/pwn/ai/agent/extrospection_spec.rb +9 -0
- data/spec/lib/pwn/ai/agent/extrospection_verification_regression_spec.rb +39 -0
- data/spec/lib/pwn/ai/agent/learning_last_answer_regression_spec.rb +32 -0
- data/spec/lib/pwn/ai/agent/learning_lifecycle_closure_spec.rb +84 -0
- data/spec/lib/pwn/ai/agent/learning_prune_regression_spec.rb +17 -0
- data/spec/lib/pwn/ai/agent/learning_spec.rb +2 -1
- data/spec/lib/pwn/ai/agent/loop_execution_audit_spec.rb +30 -0
- data/spec/lib/pwn/ai/agent/metrics_usage_regression_spec.rb +20 -0
- data/spec/lib/pwn/ai/agent/mission_execution_audit_spec.rb +27 -0
- data/spec/lib/pwn/ai/agent/mission_namespace_spec.rb +218 -18
- data/spec/lib/pwn/ai/agent/policy_confidence_regression_spec.rb +16 -0
- data/spec/lib/pwn/ai/agent/policy_evaluation_spec.rb +1 -1
- data/spec/lib/pwn/ai/agent/policy_evaluation_tmp_regression_spec.rb +36 -0
- data/spec/lib/pwn/ai/agent/reflect_model_regression_spec.rb +15 -0
- data/spec/lib/pwn/ai/agent/request_runtime_execution_audit_spec.rb +43 -0
- data/spec/lib/pwn/ai/agent/reward_binding_review_spec.rb +129 -0
- data/spec/lib/pwn/ai/agent/reward_dispatch_review_spec.rb +154 -0
- data/spec/lib/pwn/ai/agent/reward_envelope_regression_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/reward_turn_regression_spec.rb +40 -0
- data/spec/lib/pwn/ai/agent/swarm_spec.rb +2 -2
- data/spec/lib/pwn/ai/agent/task_dag_execution_audit_spec.rb +45 -0
- data/spec/lib/pwn/ai/agent/task_summarizer_failure_regression_spec.rb +26 -0
- data/spec/lib/pwn/ai/agent/tools/verify_execution_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/context_range_audit_spec.rb +24 -0
- data/spec/lib/pwn/ai/gemini_roundtrip_audit_spec.rb +33 -0
- data/spec/lib/pwn/ai/grok_reasoning_effort_spec.rb +43 -0
- data/spec/lib/pwn/ai/mcp_session_audit_spec.rb +36 -0
- data/spec/lib/pwn/ai/ollama_spec.rb +6 -11
- data/spec/lib/pwn/ai/open_web_ui_spec.rb +6 -11
- data/spec/lib/pwn/ai/provider_history_audit_spec.rb +44 -0
- data/spec/lib/pwn/ai/provider_operations_audit_spec.rb +53 -0
- data/spec/lib/pwn/ai/provider_review_history_stream_regression_spec.rb +143 -0
- data/spec/lib/pwn/ai/provider_review_tls_regression_spec.rb +62 -0
- data/spec/lib/pwn/ai/provider_stream_audit_spec.rb +49 -0
- data/spec/lib/pwn/aws/iam_decoding_regression_spec.rb +23 -0
- data/spec/lib/pwn/aws/services_runtime_regression_spec.rb +51 -0
- data/spec/lib/pwn/aws_spec.rb +6 -0
- data/spec/lib/pwn/banner_operational_audit_spec.rb +105 -0
- data/spec/lib/pwn/bounty/lifecycle_authz_replay_spec.rb +17 -0
- data/spec/lib/pwn/config_redaction_regression_spec.rb +24 -0
- data/spec/lib/pwn/config_skills_regression_spec.rb +38 -0
- data/spec/lib/pwn/corpus_core_review_regression_spec.rb +96 -0
- data/spec/lib/pwn/corpus_spec.rb +13 -0
- data/spec/lib/pwn/cron_core_review_regression_spec.rb +95 -0
- data/spec/lib/pwn/cron_execution_spec.rb +75 -0
- data/spec/lib/pwn/driver_core_review_regression_spec.rb +38 -0
- data/spec/lib/pwn/driver_spec.rb +13 -0
- data/spec/lib/pwn/engagement_core_review_regression_spec.rb +88 -0
- data/spec/lib/pwn/engagement_storage_regression_spec.rb +44 -0
- data/spec/lib/pwn/ffi/capstone_spec.rb +19 -0
- data/spec/lib/pwn/ffi/fftw_spec.rb +19 -0
- data/spec/lib/pwn/ffi/keystone_spec.rb +13 -0
- data/spec/lib/pwn/ffi/soapy_sdr_spec.rb +13 -0
- data/spec/lib/pwn/json_schemer_regexp_parser_spec.rb +12 -0
- data/spec/lib/pwn/json_text_spec.rb +25 -0
- data/spec/lib/pwn/memory_index_spec.rb +23 -0
- data/spec/lib/pwn/module_skills_parsing_regression_spec.rb +34 -0
- data/spec/lib/pwn/module_skills_spec.rb +11 -1
- data/spec/lib/pwn/plugins/ai_sandbox_boundary_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +10 -18
- data/spec/lib/pwn/plugins/android_review_fixes_spec.rb +121 -0
- data/spec/lib/pwn/plugins/android_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/api_import_namespace_audit_spec.rb +49 -0
- data/spec/lib/pwn/plugins/artifact_registry_namespace_audit_spec.rb +20 -0
- data/spec/lib/pwn/plugins/artifact_registry_review_fixes_spec.rb +63 -0
- data/spec/lib/pwn/plugins/assembly_namespace_audit_spec.rb +16 -0
- data/spec/lib/pwn/plugins/assembly_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/authentication_helper_spec.rb +14 -0
- data/spec/lib/pwn/plugins/baresip_review_fixes_spec.rb +127 -0
- data/spec/lib/pwn/plugins/baresip_transport_audit_spec.rb +59 -0
- data/spec/lib/pwn/plugins/binary_analysis_process_review_spec.rb +57 -0
- data/spec/lib/pwn/plugins/black_duck_namespace_audit_spec.rb +25 -0
- data/spec/lib/pwn/plugins/burp_suite_har_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/plugins/burp_suite_import_review_fixes_spec.rb +62 -0
- data/spec/lib/pwn/plugins/burp_suite_namespace_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/bus_pirate_transport_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/file_fu_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/findings_structured_spec.rb +1 -1
- data/spec/lib/pwn/plugins/gdbmi_namespace_audit_spec.rb +28 -0
- data/spec/lib/pwn/plugins/gdbmi_review_fixes_spec.rb +73 -0
- data/spec/lib/pwn/plugins/github_argv_review_spec.rb +49 -0
- data/spec/lib/pwn/plugins/google_workspace_provider_review_oauth_spec.rb +80 -0
- data/spec/lib/pwn/plugins/irc_review_fixes_spec.rb +92 -0
- data/spec/lib/pwn/plugins/irc_transport_audit_spec.rb +37 -0
- data/spec/lib/pwn/plugins/jenkins_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/jira_data_center_namespace_audit_spec.rb +44 -0
- data/spec/lib/pwn/plugins/jira_data_center_review_fixes_spec.rb +81 -0
- data/spec/lib/pwn/plugins/jsonl_elf_review_fixes_spec.rb +59 -0
- data/spec/lib/pwn/plugins/log_spec.rb +36 -20
- data/spec/lib/pwn/plugins/monkey_patch_spec.rb +16 -0
- data/spec/lib/pwn/plugins/msr206_readback_review_fixes_spec.rb +119 -0
- data/spec/lib/pwn/plugins/msr206_review_fixes_spec.rb +50 -0
- data/spec/lib/pwn/plugins/msr206_transport_audit_spec.rb +64 -0
- data/spec/lib/pwn/plugins/nessus_cloud_namespace_audit_spec.rb +14 -0
- data/spec/lib/pwn/plugins/nexpose_review_fixes_spec.rb +55 -0
- data/spec/lib/pwn/plugins/open_api_namespace_audit_spec.rb +22 -0
- data/spec/lib/pwn/plugins/packet_transport_audit_spec.rb +47 -0
- data/spec/lib/pwn/plugins/plugins_b_operational_regression_spec.rb +600 -0
- data/spec/lib/pwn/plugins/pony_namespace_audit_spec.rb +17 -0
- data/spec/lib/pwn/plugins/pony_review_fixes_spec.rb +33 -0
- data/spec/lib/pwn/plugins/process_tube_namespace_audit_spec.rb +19 -0
- data/spec/lib/pwn/plugins/ps_namespace_audit_spec.rb +12 -0
- data/spec/lib/pwn/plugins/pwn_logger_spec.rb +30 -0
- data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +127 -0
- data/spec/lib/pwn/plugins/repl/ai_spec.rb +38 -0
- data/spec/lib/pwn/plugins/repl/mesh_spec.rb +52 -0
- data/spec/lib/pwn/plugins/repl_mesh_rx_errors_spec.rb +18 -0
- data/spec/lib/pwn/plugins/sandbox_spec.rb +9 -7
- data/spec/lib/pwn/plugins/sbom_review_fixes_spec.rb +43 -0
- data/spec/lib/pwn/plugins/scannable_codes_namespace_audit_spec.rb +15 -0
- data/spec/lib/pwn/plugins/serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/plugins/serial_transport_audit_spec.rb +102 -0
- data/spec/lib/pwn/plugins/shodan_namespace_audit_spec.rb +10 -0
- data/spec/lib/pwn/plugins/sock_transport_audit_spec.rb +55 -0
- data/spec/lib/pwn/plugins/transparent_browser_navigation_review_spec.rb +21 -0
- data/spec/lib/pwn/plugins/vault_master_key_eui_regression_spec.rb +242 -0
- data/spec/lib/pwn/plugins/vault_spec.rb +58 -0
- data/spec/lib/pwn/plugins/vault_store_safety_spec.rb +1 -1
- data/spec/lib/pwn/plugins/xxd_namespace_audit_spec.rb +34 -0
- data/spec/lib/pwn/plugins/yubikey_hid_cleanup_review_fixes_spec.rb +52 -0
- data/spec/lib/pwn/plugins/yubikey_lifecycle_audit_spec.rb +65 -0
- data/spec/lib/pwn/plugins/yubikey_options_audit_spec.rb +30 -0
- data/spec/lib/pwn/plugins/yubikey_selector_audit_spec.rb +26 -0
- data/spec/lib/pwn/plugins/yubikey_spec.rb +1 -1
- data/spec/lib/pwn/plugins/zaproxy_namespace_audit_spec.rb +30 -0
- data/spec/lib/pwn/reports/empty_report_audit_spec.rb +18 -0
- data/spec/lib/pwn/reports/pdf_spec.rb +25 -0
- data/spec/lib/pwn/reports/provider_review_encoding_regression_spec.rb +35 -0
- data/spec/lib/pwn/sast/engine_runtime_regression_spec.rb +91 -0
- data/spec/lib/pwn/sast/filter_edge_regression_spec.rb +39 -0
- data/spec/lib/pwn/sast/formatter_review_fixes_spec.rb +178 -0
- data/spec/lib/pwn/sast/path_review_fixes_spec.rb +60 -0
- data/spec/lib/pwn/sast/pom_runtime_regression_spec.rb +37 -0
- data/spec/lib/pwn/sast/rules_runtime_regression_spec.rb +78 -0
- data/spec/lib/pwn/sast/sql_review_fixes_spec.rb +38 -0
- data/spec/lib/pwn/sdr/decoder/base_iq_spec.rb +21 -18
- data/spec/lib/pwn/sdr/decoder/base_review_fixes_spec.rb +49 -0
- data/spec/lib/pwn/sdr/decoder/base_validation_spec.rb +78 -0
- data/spec/lib/pwn/sdr/decoder/lora_spec.rb +9 -0
- data/spec/lib/pwn/sdr/flipper_zero_review_fixes_spec.rb +34 -0
- data/spec/lib/pwn/sdr/gqrx_operational_spec.rb +83 -0
- data/spec/lib/pwn/sdr/gqrx_review_fixes_spec.rb +22 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_review_fixes_spec.rb +113 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_serial_review_fixes_spec.rb +76 -0
- data/spec/lib/pwn/sdr/son_micro_rfid_spec.rb +39 -0
- data/spec/lib/pwn/sdr_spec.rb +5 -0
- data/spec/lib/pwn/session_cleanup_concurrency_spec.rb +21 -0
- data/spec/lib/pwn/session_cleanup_default_spec.rb +1 -1
- data/spec/lib/pwn/session_cleanup_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/session_cleanup_payload_spec.rb +3 -2
- data/spec/lib/pwn/session_trace_lifecycle_supplement_spec.rb +39 -0
- data/spec/lib/pwn/sessions_archive_closure_spec.rb +126 -0
- data/spec/lib/pwn/sessions_lifecycle_closure_spec.rb +373 -0
- data/spec/lib/pwn/sessions_lifecycle_supplement_spec.rb +204 -0
- data/spec/lib/pwn/setup_operational_regression_spec.rb +36 -0
- data/spec/lib/pwn/www/browser_review_fixes_spec.rb +70 -0
- data/spec/lib/pwn/www/browser_runtime_regression_spec.rb +100 -0
- data/spec/lib/pwn/www/hacker_one_runtime_regression_spec.rb +146 -0
- data/spec/lib/pwn/www/pagination_review_fixes_spec.rb +84 -0
- data/spec/spec_helper.rb +34 -5
- data/spec/support/namespace_controller_observability_fixture.rb +141 -0
- data/spec/support/sandbox.rb +8 -5
- data/third_party/pwn_rdoc.jsonl +83 -32
- metadata +7690 -7386
- data/etc/default_skills/pwn/aws/elastic_transcoder/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/lambda_preview/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/ops_works_cm/SKILL.md +0 -48
- data/etc/default_skills/pwn/aws/sms/SKILL.md +0 -48
- data/lib/pwn/aws/elastic_transcoder.rb +0 -95
- data/lib/pwn/aws/lambda_preview.rb +0 -95
- data/lib/pwn/aws/ops_works.rb +0 -95
- data/lib/pwn/aws/ops_works_cm.rb +0 -95
- data/lib/pwn/aws/sms.rb +0 -95
- data/spec/lib/pwn/aws/elastic_transcoder_spec.rb +0 -15
- data/spec/lib/pwn/aws/lambda_preview_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_cm_spec.rb +0 -15
- data/spec/lib/pwn/aws/ops_works_spec.rb +0 -15
- data/spec/lib/pwn/aws/sms_spec.rb +0 -15
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'PWN::Engagement storage boundaries' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
10
|
+
stub_const('PWN::AI::Agent::Engagement::ROOT', File.join(@tmp, 'engagements'))
|
|
11
|
+
stub_const('PWN::AI::Agent::Engagement::ACTIVE_FILE', File.join(@tmp, 'engagements', 'active'))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'rejects traversal names before reading or writing host and scan state' do
|
|
15
|
+
invalid = '../outside'
|
|
16
|
+
[
|
|
17
|
+
-> { PWN::Engagement.record_host(engagement: invalid, host: 'scope.invalid', override: true) },
|
|
18
|
+
-> { PWN::Engagement.hosts(name: invalid) },
|
|
19
|
+
-> { PWN::Engagement.record_scan(engagement: invalid, hosts: []) },
|
|
20
|
+
-> { PWN::Engagement.scans(name: invalid) }
|
|
21
|
+
].each do |operation|
|
|
22
|
+
expect(&operation).to raise_error(ArgumentError, /Invalid engagement name/)
|
|
23
|
+
end
|
|
24
|
+
expect(File).not_to exist(File.join(@tmp, 'outside'))
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'checks the explicit destination scope instead of the unrelated active engagement' do
|
|
28
|
+
PWN::Engagement.open(name: 'destination', scope_domains: ['destination.invalid'])
|
|
29
|
+
PWN::Engagement.open(name: 'current-engagement', scope_domains: ['active.invalid'])
|
|
30
|
+
result = PWN::Engagement.record_host(engagement: 'destination', host: 'destination.invalid', ports: [443])
|
|
31
|
+
expect(result).to include(host: 'destination.invalid', ports: [443])
|
|
32
|
+
expect(PWN::Engagement.hosts(engagement: 'destination')).to have_key(:'destination.invalid')
|
|
33
|
+
expect(PWN::Engagement.hosts(name: 'current-engagement')).to be_empty
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'uses the same destination when matching name aliases are supplied' do
|
|
37
|
+
PWN::Engagement.open(name: 'destination', scope_domains: ['destination.invalid'])
|
|
38
|
+
PWN::Engagement.open(name: 'other', scope_domains: ['other.invalid'])
|
|
39
|
+
result = PWN::Engagement.record_host(engagement: 'destination', name: 'destination', host: 'destination.invalid')
|
|
40
|
+
expect(result).to include(host: 'destination.invalid')
|
|
41
|
+
expect(PWN::Engagement.hosts(name: 'destination')).to have_key(:'destination.invalid')
|
|
42
|
+
expect(PWN::Engagement.hosts(name: 'other')).to be_empty
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -20,6 +20,25 @@ describe PWN::FFI::Capstone do
|
|
|
20
20
|
expect { described_class.disassemble(bytes: "\x90") }.to raise_error(RuntimeError, /libcapstone not available/)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
it 'releases decoded instructions and the handle when result conversion fails' do
|
|
24
|
+
allow(described_class).to receive(:available?).and_return(true)
|
|
25
|
+
allocation = FFI::MemoryPointer.new(:char)
|
|
26
|
+
handle = nil
|
|
27
|
+
allow(described_class).to receive(:cs_open) do |_arch, _mode, result|
|
|
28
|
+
handle = result
|
|
29
|
+
result.write_ulong(1)
|
|
30
|
+
0
|
|
31
|
+
end
|
|
32
|
+
allow(described_class).to receive(:cs_disasm) do |*_args, result|
|
|
33
|
+
result.write_pointer(allocation)
|
|
34
|
+
1
|
|
35
|
+
end
|
|
36
|
+
allow(described_class).to receive(:cs_version).and_raise(IOError, 'conversion failed')
|
|
37
|
+
expect(described_class).to receive(:cs_free).with(allocation, 1).once
|
|
38
|
+
expect(described_class).to(receive(:cs_close).once { |value| expect(value).to eq(handle) })
|
|
39
|
+
expect { described_class.disassemble(bytes: "\x90".b) }.to raise_error(IOError, 'conversion failed')
|
|
40
|
+
end
|
|
41
|
+
|
|
23
42
|
before(:each, :capstone_integration) do
|
|
24
43
|
expect(described_class.available?).to be(true),
|
|
25
44
|
"PWN_TEST_CAPSTONE=1 requires libcapstone. Load error: #{described_class.load_error}"
|
|
@@ -8,6 +8,25 @@ describe PWN::FFI::FFTW do
|
|
|
8
8
|
expect { described_class.rfft(samples: [1.0]) }.to raise_error(RuntimeError, /libfftw3f not available/)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
+
{ rfft: :fftwf_plan_dft_r2c_1d, cfft: :fftwf_plan_dft_1d }.each do |method, planner|
|
|
12
|
+
%i[allocation planning execution].each do |failure|
|
|
13
|
+
it "releases #{method} native allocations on #{failure} failure" do
|
|
14
|
+
allow(described_class).to receive(:available?).and_return(true)
|
|
15
|
+
input = FFI::MemoryPointer.new(:float, 4)
|
|
16
|
+
output = FFI::MemoryPointer.new(:float, 4)
|
|
17
|
+
plan = FFI::MemoryPointer.new(:char)
|
|
18
|
+
allow(described_class).to receive(:fftwf_malloc).and_return(input, failure == :allocation ? FFI::Pointer::NULL : output)
|
|
19
|
+
allow(described_class).to receive(planner).and_return(failure == :planning ? FFI::Pointer::NULL : plan)
|
|
20
|
+
allow(described_class).to receive(:fftwf_execute).and_raise(IOError, 'execution failed')
|
|
21
|
+
expect(described_class).to receive(:fftwf_free).with(input).once
|
|
22
|
+
expect(described_class).to receive(:fftwf_free).with(output).once unless failure == :allocation
|
|
23
|
+
expect(described_class).to receive(:fftwf_destroy_plan).with(plan).once if failure == :execution
|
|
24
|
+
expect { described_class.public_send(method, samples: [1.0, 0.0], iq: [1.0, 0.0]) }
|
|
25
|
+
.to raise_error(StandardError, /failed/)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
11
30
|
it 'should display information for authors' do
|
|
12
31
|
expect(PWN::FFI::FFTW).to respond_to :authors
|
|
13
32
|
end
|
|
@@ -20,6 +20,19 @@ describe PWN::FFI::Keystone do
|
|
|
20
20
|
expect { described_class.assemble(asm: 'nop') }.to raise_error(RuntimeError, /libkeystone not available/)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
it 'closes the native engine when assembly fails' do
|
|
24
|
+
allow(described_class).to receive(:available?).and_return(true)
|
|
25
|
+
engine = FFI::MemoryPointer.new(:char)
|
|
26
|
+
allow(described_class).to receive(:ks_open) do |_arch, _mode, result|
|
|
27
|
+
result.write_pointer(engine)
|
|
28
|
+
0
|
|
29
|
+
end
|
|
30
|
+
allow(described_class).to receive(:ks_asm).and_return(-1)
|
|
31
|
+
expect(described_class).to receive(:ks_close).with(engine).once
|
|
32
|
+
expect(described_class).not_to receive(:ks_free)
|
|
33
|
+
expect { described_class.assemble(asm: 'invalid fixture instruction') }.to raise_error(/ks_asm failed/)
|
|
34
|
+
end
|
|
35
|
+
|
|
23
36
|
before(:each, :keystone_integration) do
|
|
24
37
|
expect(described_class.available?).to be(true),
|
|
25
38
|
"PWN_TEST_KEYSTONE=1 requires libkeystone. Load error: #{described_class.load_error}"
|
|
@@ -9,6 +9,19 @@ describe PWN::FFI::SoapySDR do
|
|
|
9
9
|
expect { described_class.make(args: 'driver=mock') }.to raise_error(RuntimeError, /libSoapySDR not available/)
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
%i[setSampleRate setFrequency setGainMode setGain setBandwidth].each do |operation|
|
|
13
|
+
it "rejects failed #{operation} without publishing requested configuration as applied" do
|
|
14
|
+
operations = %i[setSampleRate setFrequency setGainMode setGain setBandwidth]
|
|
15
|
+
operations.each { |name| allow(described_class).to receive(:"SoapySDRDevice_#{name}").and_return(0) }
|
|
16
|
+
allow(described_class).to receive(:"SoapySDRDevice_#{operation}").and_return(-2)
|
|
17
|
+
handle = { device: :device, channel: 0, rate_hz: 12_000, freq_hz: 100_000_000 }
|
|
18
|
+
expect do
|
|
19
|
+
described_class.configure(handle: handle, rate_hz: 24_000, freq_hz: 101_000_000, gain_db: 12, bw_hz: 20_000)
|
|
20
|
+
end.to raise_error(RuntimeError, /#{operation}.*-2/)
|
|
21
|
+
expect(handle).to include(rate_hz: 12_000, freq_hz: 100_000_000)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
12
25
|
it 'reports close failure and retains the stream for cleanup retry' do
|
|
13
26
|
handle = { device: :device, stream: :stream }
|
|
14
27
|
allow(described_class).to receive(:SoapySDRDevice_deactivateStream).and_return(0)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'json_schemer'
|
|
5
|
+
|
|
6
|
+
RSpec.describe 'json_schemer regexp_parser compatibility' do
|
|
7
|
+
it 'loads and applies an ECMA pattern against the installed regexp_parser' do
|
|
8
|
+
schema = JSONSchemer.schema({ 'type' => 'string', 'pattern' => '^a+$' }, regexp_resolver: 'ecma')
|
|
9
|
+
expect(schema.valid?('aaa')).to be(true)
|
|
10
|
+
expect(schema.valid?("a\na")).to be(false)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -11,6 +11,31 @@ describe PWN::JSONText do
|
|
|
11
11
|
expect(described_class).to respond_to :help
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
%w[ISO-8859-1 UTF-16LE UTF-16BE].each do |encoding|
|
|
15
|
+
it "preserves characters in #{encoding} text through every JSON entry point" do
|
|
16
|
+
text = 'café'.encode(encoding).freeze
|
|
17
|
+
value = { text => [text] }
|
|
18
|
+
[JSON.generate(value), JSON.fast_generate(value), JSON.pretty_generate(value), JSON.dump(value), value.to_json].each do |wire|
|
|
19
|
+
expect(JSON.parse(wire)).to eq('café' => ['café'])
|
|
20
|
+
end
|
|
21
|
+
expect(described_class.prepare(value: text)).to eq('café')
|
|
22
|
+
expect(text.encoding.name).to eq(encoding)
|
|
23
|
+
expect(text).to eq('café'.encode(encoding))
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'rejects cycles and excessive container depth before unbounded JSON encoders run' do
|
|
28
|
+
cycle = []
|
|
29
|
+
cycle << cycle
|
|
30
|
+
expect { described_class.prepare(value: cycle) }.to raise_error(JSON::NestingError)
|
|
31
|
+
expect { JSON.dump(cycle) }.to raise_error(JSON::NestingError)
|
|
32
|
+
expect { JSON.generate(cycle, max_nesting: false) }.to raise_error(JSON::NestingError)
|
|
33
|
+
deep = Array.new(101) { [] }.inject('leaf') { |value, array| array << value }
|
|
34
|
+
expect { described_class.prepare(value: deep) }.to raise_error(JSON::NestingError)
|
|
35
|
+
branch = ['shared']
|
|
36
|
+
expect(JSON.parse(JSON.dump([branch, branch]))).to eq([['shared'], ['shared']])
|
|
37
|
+
end
|
|
38
|
+
|
|
14
39
|
it 'retags binary UTF-8 and scrubs malformed bytes before JSON encode' do
|
|
15
40
|
binary = "status \u2022 ok".b
|
|
16
41
|
malformed = "\xff\xfe".b
|
|
@@ -13,6 +13,29 @@ describe PWN::MemoryIndex do
|
|
|
13
13
|
expect(help_response).to respond_to :help
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
it 'persists removal of forgotten memories when no remaining embedding changes' do
|
|
17
|
+
Dir.mktmpdir('memory-index-') do |dir|
|
|
18
|
+
stub_const('PWN::MemoryIndex::INDEX_FILE', File.join(dir, 'memory.idx'))
|
|
19
|
+
allow(described_class).to receive(:embed).and_return([[1.0, 0.0]])
|
|
20
|
+
memory = { fixture: { category: 'fact', value: 'fixture text' } }
|
|
21
|
+
described_class.refresh(mem: memory)
|
|
22
|
+
expect(described_class.refresh(mem: {})).to eq({})
|
|
23
|
+
expect(JSON.parse(File.read(described_class::INDEX_FILE))).to eq({})
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it 'refreshes an embedding when the category changes with unchanged text' do
|
|
28
|
+
Dir.mktmpdir('memory-index-') do |dir|
|
|
29
|
+
stub_const('PWN::MemoryIndex::INDEX_FILE', File.join(dir, 'memory.idx'))
|
|
30
|
+
allow(described_class).to receive(:embed).with(texts: ['fact: fixture text']).and_return([[1.0, 0.0]])
|
|
31
|
+
allow(described_class).to receive(:embed).with(texts: ['lesson: fixture text']).and_return([[0.0, 1.0]])
|
|
32
|
+
described_class.refresh(mem: { fixture: { category: 'fact', value: 'fixture text' } })
|
|
33
|
+
updated = described_class.refresh(mem: { fixture: { category: 'lesson', value: 'fixture text' } })
|
|
34
|
+
expect(updated.dig(:fixture, :vec)).to eq([0.0, 1.0])
|
|
35
|
+
expect(described_class).to have_received(:embed).with(texts: ['lesson: fixture text']).once
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
16
39
|
it 'ranks a throttle-evasion document above an unrelated document' do
|
|
17
40
|
docs = [
|
|
18
41
|
'the cat sat on the mat',
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'PWN::ModuleSkills source parsing' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
it 'preserves predicate, bang and setter suffixes in generated public method names' do
|
|
9
|
+
lib = File.join(@tmp, 'lib')
|
|
10
|
+
FileUtils.mkdir_p(File.join(lib, 'pwn'))
|
|
11
|
+
File.write(File.join(lib, 'pwn', 'fixture.rb'), <<~RUBY)
|
|
12
|
+
module PWN
|
|
13
|
+
module Fixture
|
|
14
|
+
public_class_method def self.ready?(opts = {}); opts[:ready]; end
|
|
15
|
+
public_class_method def self.refresh!(opts = {}); opts[:refresh]; end
|
|
16
|
+
public_class_method def self.value=(value); @value = value; end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
RUBY
|
|
20
|
+
record = PWN::ModuleSkills.enumerate(lib_root: lib).first
|
|
21
|
+
expect(record[:methods]).to contain_exactly('ready?', 'refresh!', 'value=')
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'refuses to prune existing skills when the source tree has no modules' do
|
|
25
|
+
dest = File.join(@tmp, 'skills')
|
|
26
|
+
skill = File.join(dest, 'pwn', 'fixture', 'SKILL.md')
|
|
27
|
+
FileUtils.mkdir_p(File.dirname(skill))
|
|
28
|
+
File.write(skill, 'keep existing generated skill')
|
|
29
|
+
expect do
|
|
30
|
+
PWN::ModuleSkills.refresh!(lib_root: File.join(@tmp, 'missing-lib'), dest: dest)
|
|
31
|
+
end.to raise_error(ArgumentError, /no PWN modules/i)
|
|
32
|
+
expect(File.read(skill)).to eq('keep existing generated skill')
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -9,6 +9,7 @@ describe PWN::ModuleSkills do
|
|
|
9
9
|
it 'saves legacy generated edits and merges without discarding unrelated edits' do
|
|
10
10
|
script = File.read(File.expand_path('../../../build_gem.sh', __dir__))
|
|
11
11
|
recovery = script.split('generated_skills=()', 2).last.split('git checkout master', 2).first
|
|
12
|
+
expect(recovery).to include('git stash push')
|
|
12
13
|
Dir.mktmpdir('pwn_upgrade') do |dir|
|
|
13
14
|
git = lambda do |*args|
|
|
14
15
|
out, status = Open3.capture2e('git', *args, chdir: dir)
|
|
@@ -34,7 +35,16 @@ describe PWN::ModuleSkills do
|
|
|
34
35
|
File.write(File.join(dir, 'notes'), 'keep my edit')
|
|
35
36
|
_, blocked = Open3.capture2e('git', 'merge', '--ff-only', 'incoming', chdir: dir)
|
|
36
37
|
expect(blocked.success?).to be(false)
|
|
37
|
-
|
|
38
|
+
expect(script).to include("git stash push -m 'pwn upgrade: saved generated module skills'")
|
|
39
|
+
skills = git.call('diff', '--name-only', 'HEAD', '--', 'etc/default_skills/pwn').lines.map(&:chomp).select do |relative|
|
|
40
|
+
full = File.join(dir, relative)
|
|
41
|
+
next false unless relative.end_with?('/SKILL.md') && File.file?(full)
|
|
42
|
+
|
|
43
|
+
body = File.read(full)
|
|
44
|
+
body.match?(/^[[:space:]]*generated:[[:space:]]*true[[:space:]]*$/) &&
|
|
45
|
+
!body.match?(/^[[:space:]]*preserve:[[:space:]]*true[[:space:]]*$/)
|
|
46
|
+
end
|
|
47
|
+
out, status = Open3.capture2e('git', 'stash', 'push', '-m', 'pwn upgrade: saved generated module skills', '--', *skills, chdir: dir)
|
|
38
48
|
expect(status.success?).to be(true), out
|
|
39
49
|
git.call('merge', '--ff-only', 'incoming')
|
|
40
50
|
expect(File.read(path)).to eq("#{original}upstream\n")
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'digest'
|
|
5
|
+
|
|
6
|
+
RSpec.describe 'AISandbox mandatory write-grant review' do
|
|
7
|
+
include_context 'pwn tmp sandbox'
|
|
8
|
+
|
|
9
|
+
before do
|
|
10
|
+
@home = File.join(@tmp, 'home')
|
|
11
|
+
@work = File.join(@tmp, 'work')
|
|
12
|
+
@outputs = File.join(@tmp, 'outputs')
|
|
13
|
+
@source = File.join(@outputs, 'source')
|
|
14
|
+
@state = File.join(@outputs, 'controller-artifacts')
|
|
15
|
+
FileUtils.mkdir_p([@home, @work, @source, @state])
|
|
16
|
+
allow(Dir).to receive(:home).and_return(@home)
|
|
17
|
+
allow(PWN::Plugins::AISandbox).to receive(:protected_roots).and_return([@source, '/opt/pwn'])
|
|
18
|
+
stub_const('PWN::Plugins::ArtifactRegistry::ROOT', @state)
|
|
19
|
+
@saved_runtime = Thread.current[:pwn_request_runtime]
|
|
20
|
+
@source_file = File.join(@source, 'sentinel')
|
|
21
|
+
@state_file = File.join(@state, 'sentinel')
|
|
22
|
+
File.write(@source_file, 'original-source')
|
|
23
|
+
File.write(@state_file, 'original-state')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
after do
|
|
27
|
+
Thread.current[:pwn_request_runtime] = @saved_runtime
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def dispatch_boundary(request, &handler)
|
|
31
|
+
runtime = PWN::AI::Agent::RequestRuntime.new(request: request, session_id: 'sandbox-review', artifact_root: File.join(@tmp, 'request-state'), cwd: @work, trace: false, retrieve: false)
|
|
32
|
+
Thread.current[:pwn_request_runtime] = runtime
|
|
33
|
+
PWN::AI::Agent::Registry.register(name: 'sandbox_pbr01_boundary', toolset: 'fixture', schema: { name: 'sandbox_pbr01_boundary', parameters: { type: 'object' } }, handler: handler)
|
|
34
|
+
row = JSON.parse(PWN::AI::Agent::Dispatch.call(tool_call: { function: { name: 'sandbox_pbr01_boundary', arguments: '{}' } }))
|
|
35
|
+
[row, runtime]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
it '[PBR-01] denies source and controller writes despite an original-request sibling output', :aggregate_failures do
|
|
39
|
+
output = File.join(@outputs, 'requested.txt')
|
|
40
|
+
before = [@source_file, @state_file].to_h { |path| [path, Digest::SHA256.file(path).hexdigest] }
|
|
41
|
+
row, runtime = dispatch_boundary("Write the report to #{output}") do |_args|
|
|
42
|
+
attempts = [@source_file, @state_file].map do |path|
|
|
43
|
+
File.write(path, 'modified')
|
|
44
|
+
'allowed'
|
|
45
|
+
rescue Errno::EACCES, Errno::EPERM
|
|
46
|
+
'denied'
|
|
47
|
+
end
|
|
48
|
+
File.write(output, 'named')
|
|
49
|
+
{ attempts: attempts, named: File.read(output) }
|
|
50
|
+
end
|
|
51
|
+
expect(runtime.contract[:required_artifacts]).to eq([output])
|
|
52
|
+
expect(row.dig('result', 'attempts')).to eq(%w[denied denied])
|
|
53
|
+
expect(row.dig('result', 'named')).to eq('named')
|
|
54
|
+
expect([@source_file, @state_file].to_h { |path| [path, Digest::SHA256.file(path).hexdigest] }).to eq(before)
|
|
55
|
+
expect(File.read(output)).to eq('named')
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -253,31 +253,23 @@ describe PWN::Plugins::AISandbox do
|
|
|
253
253
|
end
|
|
254
254
|
end
|
|
255
255
|
|
|
256
|
-
it 'denies rm -rf
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
begin
|
|
262
|
-
out = described_class.exec(kind: :shell, payload: 'rm -rf /tmp/fake_root', mode: 'strict')
|
|
256
|
+
it 'denies rm -rf outside the artifact root in strict mode without touching disk' do
|
|
257
|
+
Dir.mktmpdir('pwn-strict-delete-') do |root|
|
|
258
|
+
marker = File.join(root, 'keep')
|
|
259
|
+
File.write(marker, 'safe')
|
|
260
|
+
out = described_class.exec(kind: :shell, payload: "rm -rf #{root}", mode: 'strict')
|
|
263
261
|
expect(out[:error].to_s).to match(/sandbox violation/i)
|
|
264
262
|
expect(File.file?(marker)).to be true
|
|
265
|
-
ensure
|
|
266
|
-
FileUtils.rm_rf(root)
|
|
267
263
|
end
|
|
268
264
|
end
|
|
269
265
|
|
|
270
|
-
it 'denies FileUtils.rm_rf
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
begin
|
|
276
|
-
out = described_class.exec(kind: :ruby, payload: "FileUtils.rm_rf('/tmp/fake_root')", mode: 'strict')
|
|
266
|
+
it 'denies FileUtils.rm_rf outside the artifact root in strict mode without touching disk' do
|
|
267
|
+
Dir.mktmpdir('pwn-strict-delete-') do |root|
|
|
268
|
+
marker = File.join(root, 'keep')
|
|
269
|
+
File.write(marker, 'safe')
|
|
270
|
+
out = described_class.exec(kind: :ruby, payload: "FileUtils.rm_rf(#{root.inspect})", mode: 'strict')
|
|
277
271
|
expect(out[:error].to_s).to match(/sandbox violation/i)
|
|
278
272
|
expect(File.file?(marker)).to be true
|
|
279
|
-
ensure
|
|
280
|
-
FileUtils.rm_rf(root)
|
|
281
273
|
end
|
|
282
274
|
end
|
|
283
275
|
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'rbconfig'
|
|
7
|
+
require 'timeout'
|
|
8
|
+
|
|
9
|
+
RSpec.describe PWN::Plugins::Android do
|
|
10
|
+
around do |example|
|
|
11
|
+
Dir.mktmpdir('android-review-') do |root|
|
|
12
|
+
@root = root
|
|
13
|
+
@adb = File.join(root, 'adb literal ; executable')
|
|
14
|
+
@calls = File.join(root, 'calls.jsonl')
|
|
15
|
+
File.write(@adb, "#!#{RbConfig.ruby}\nrequire 'json'\nFile.open(#{@calls.inspect}, 'a') { |f| f.puts(JSON.generate(ARGV)) }\nputs 'synthetic'\n")
|
|
16
|
+
File.chmod(0o700, @adb)
|
|
17
|
+
example.run
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'cancels and reaps only its owned process group, including TERM-resistant descendants' do
|
|
22
|
+
pidfile = File.join(@root, 'pids')
|
|
23
|
+
release = File.join(@root, 'release')
|
|
24
|
+
File.write(@adb, <<~RUBY)
|
|
25
|
+
#!#{RbConfig.ruby}
|
|
26
|
+
child = fork do
|
|
27
|
+
trap('TERM') {}
|
|
28
|
+
File.write(#{"#{pidfile}.ready".inspect}, '')
|
|
29
|
+
sleep 0.01 until File.exist?(#{release.inspect})
|
|
30
|
+
end
|
|
31
|
+
sleep 0.01 until File.exist?(#{"#{pidfile}.ready".inspect})
|
|
32
|
+
File.write(#{"#{pidfile}.tmp".inspect}, [Process.pid, child].join(' '))
|
|
33
|
+
File.rename(#{"#{pidfile}.tmp".inspect}, #{pidfile.inspect})
|
|
34
|
+
sleep 0.01 until File.exist?(#{release.inspect})
|
|
35
|
+
Process.wait(child)
|
|
36
|
+
RUBY
|
|
37
|
+
result = Queue.new
|
|
38
|
+
worker = Thread.new do
|
|
39
|
+
described_class.adb_sh(adb_path: @adb, command: 'synthetic')
|
|
40
|
+
rescue Interrupt => e
|
|
41
|
+
result << e
|
|
42
|
+
end
|
|
43
|
+
Timeout.timeout(5) { Thread.pass until File.exist?(pidfile) }
|
|
44
|
+
owned, descendant = File.read(pidfile).split.map(&:to_i)
|
|
45
|
+
worker.raise(Interrupt, 'synthetic cancellation')
|
|
46
|
+
expect(worker.join(2)).to equal(worker)
|
|
47
|
+
expect(result.pop(timeout: 0.1)).to be_a(Interrupt)
|
|
48
|
+
expect { Process.waitpid(owned, Process::WNOHANG) }.to raise_error(Errno::ECHILD)
|
|
49
|
+
Timeout.timeout(2) do
|
|
50
|
+
loop do
|
|
51
|
+
begin
|
|
52
|
+
state = File.read("/proc/#{descendant}/stat").split[2]
|
|
53
|
+
rescue Errno::ENOENT, Errno::ESRCH
|
|
54
|
+
break
|
|
55
|
+
end
|
|
56
|
+
break if state == 'Z'
|
|
57
|
+
|
|
58
|
+
Thread.pass
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
expect(Process.kill(0, Process.pid)).to eq(1)
|
|
62
|
+
ensure
|
|
63
|
+
File.write(release, '') if release
|
|
64
|
+
worker&.join(3)
|
|
65
|
+
worker&.kill if worker&.alive?
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'surfaces cleanup-only errors inside an unrelated caller rescue' do
|
|
69
|
+
allow(Process).to receive(:kill).and_call_original
|
|
70
|
+
allow(Process).to receive(:kill).with('TERM', kind_of(Integer)).and_raise(IOError, 'cleanup failure')
|
|
71
|
+
begin
|
|
72
|
+
raise 'unrelated caller error'
|
|
73
|
+
rescue RuntimeError
|
|
74
|
+
expect { described_class.adb_sh(adb_path: @adb, command: 'synthetic') }.to raise_error(IOError, 'cleanup failure')
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'bounds an owned child that closes stdout but never exits, without exposing its output' do
|
|
79
|
+
File.write(@adb, "#!#{RbConfig.ruby}\nSTDOUT.close\nsleep 20\n")
|
|
80
|
+
stub_const('PWN::Plugins::Android::COMMAND_TIMEOUT', 1)
|
|
81
|
+
owned = nil
|
|
82
|
+
allow(Process).to receive(:spawn).and_wrap_original do |original, *args, **kwargs|
|
|
83
|
+
owned = original.call(*args, **kwargs)
|
|
84
|
+
end
|
|
85
|
+
expect do
|
|
86
|
+
Timeout.timeout(3) { described_class.adb_sh(adb_path: @adb, command: 'synthetic') }
|
|
87
|
+
end.to raise_error(Timeout::Error, /adb command timed out/)
|
|
88
|
+
expect { Process.waitpid(owned, Process::WNOHANG) }.to raise_error(Errno::ECHILD)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it 'bounds capture output and suppresses private child stderr on failure' do
|
|
92
|
+
File.write(@adb, "#!#{RbConfig.ruby}\nSTDERR.puts 'synthetic-private'\nprint 'x' * 2048\n")
|
|
93
|
+
stub_const('PWN::Plugins::Android::MAX_OUTPUT_BYTES', 1024)
|
|
94
|
+
spawn_options = nil
|
|
95
|
+
allow(Process).to receive(:spawn).and_wrap_original do |original, *args, **kwargs|
|
|
96
|
+
spawn_options = kwargs
|
|
97
|
+
original.call(*args, **kwargs)
|
|
98
|
+
end
|
|
99
|
+
expect { described_class.adb_sh(adb_path: @adb, command: 'synthetic') }.to raise_error(IOError, 'adb output limit exceeded')
|
|
100
|
+
expect(spawn_options[:err]).to eq(File::NULL)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
%i[adb_sh adb_push adb_pull take_screenshot screen_record list_installed_apps dumpsys open_app close_app invoke_event_listener].each do |method|
|
|
104
|
+
['false', 'true', 1, nil].each do |flag|
|
|
105
|
+
it "rejects nonboolean #{flag.inspect} root consent in #{method} before spawning" do
|
|
106
|
+
expect { described_class.public_send(method, adb_path: @adb, as_root: flag) }.to raise_error(ArgumentError, /as_root/)
|
|
107
|
+
expect(File.exist?(@calls)).to be(false)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
[false, true, :omitted].each do |flag|
|
|
112
|
+
it "requires literal true for #{method} with #{flag}" do
|
|
113
|
+
options = { adb_path: @adb, command: 'synthetic', app: 'example.invalid', file: 'a', dest: 'b' }
|
|
114
|
+
options[:as_root] = flag unless flag == :omitted
|
|
115
|
+
described_class.public_send(method, options)
|
|
116
|
+
calls = File.readlines(@calls).map { |line| JSON.parse(line) }
|
|
117
|
+
expect(calls.include?(['root'])).to eq(flag == true)
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'json'
|
|
6
|
+
require 'rbconfig'
|
|
7
|
+
|
|
8
|
+
RSpec.describe PWN::Plugins::Android do
|
|
9
|
+
around do |example|
|
|
10
|
+
Dir.mktmpdir('adb-boundary-') do |root|
|
|
11
|
+
@adb = File.join(root, 'adb literal ; path')
|
|
12
|
+
@calls = File.join(root, 'calls')
|
|
13
|
+
@output = File.join(root, 'output')
|
|
14
|
+
@exit = File.join(root, 'exit')
|
|
15
|
+
File.write(@output, '')
|
|
16
|
+
File.write(@exit, '0')
|
|
17
|
+
File.write(@adb, <<~RUBY)
|
|
18
|
+
#!#{RbConfig.ruby}
|
|
19
|
+
require 'json'
|
|
20
|
+
File.open(#{@calls.inspect}, 'a') { |f| f.puts(JSON.generate(ARGV)) }
|
|
21
|
+
print File.binread(#{@output.inspect})
|
|
22
|
+
exit File.read(#{@exit.inspect}).to_i
|
|
23
|
+
RUBY
|
|
24
|
+
File.chmod(0o700, @adb)
|
|
25
|
+
example.run
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
%i[take_screenshot screen_record].each do |method|
|
|
30
|
+
[false, true].each do |root|
|
|
31
|
+
it "honors as_root: #{root} for #{method} at a real executable boundary" do
|
|
32
|
+
described_class.public_send(method, adb_path: @adb, as_root: root)
|
|
33
|
+
calls = File.readlines(@calls).map { |line| JSON.parse(line) }
|
|
34
|
+
expect(calls.include?(['root'])).to eq(root)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it 'passes host filenames as literal arguments rather than a local shell command' do
|
|
40
|
+
described_class.adb_push(adb_path: @adb, file: '/fixture/a b;literal', dest: '/sdcard/a b')
|
|
41
|
+
expect(JSON.parse(File.read(@calls))).to eq(['push', '/fixture/a b;literal', '/sdcard/a b'])
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'keeps intentional shell commands on Android rather than executing local shell operators' do
|
|
45
|
+
described_class.adb_sh(adb_path: @adb, command: 'printf fixture; id')
|
|
46
|
+
expect(JSON.parse(File.read(@calls))).to eq(['shell', 'printf fixture; id'])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it 'rejects a missing explicit adb executable instead of executing bare command names' do
|
|
50
|
+
expect { described_class.adb_sh(adb_path: '/fixture/not-present', command: 'id') }.to raise_error(ArgumentError, /adb_path/)
|
|
51
|
+
expect(File.exist?(@calls)).to be(false)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'strips the package marker from the first installed package too' do
|
|
55
|
+
File.write(@output, "package:one.example\npackage:two.example\n")
|
|
56
|
+
expect(described_class.list_installed_apps(adb_path: @adb)).to eq(%w[one.example two.example])
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it 'surfaces an unsuccessful adb exit without echoing command output' do
|
|
60
|
+
File.write(@output, 'private synthetic output')
|
|
61
|
+
File.write(@exit, '1')
|
|
62
|
+
expect { described_class.adb_pull(adb_path: @adb, file: '/sdcard/a', dest: '/fixture/a') }.to raise_error(IOError, /\Aadb command failed/)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
require 'rest-client'
|
|
7
|
+
|
|
8
|
+
RSpec.describe 'API import working-directory regression' do
|
|
9
|
+
let(:specification) { { openapi: '3.0.3', info: { title: 'Fixture', version: '1' }, servers: [{ url: 'https://example.invalid' }], paths: {} } }
|
|
10
|
+
|
|
11
|
+
around do |example|
|
|
12
|
+
previous_dir = Dir.pwd
|
|
13
|
+
Dir.mktmpdir('api-import-audit') do |dir|
|
|
14
|
+
Dir.chdir(dir)
|
|
15
|
+
FileUtils.mkdir_p('inputs')
|
|
16
|
+
File.write('inputs/spec.json', JSON.generate(specification))
|
|
17
|
+
example.run
|
|
18
|
+
ensure
|
|
19
|
+
Dir.chdir(previous_dir)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'loads a relative Burp import without changing the caller directory' do
|
|
24
|
+
mod = PWN::Plugins::BurpSuite
|
|
25
|
+
allow(mod).to receive(:stop)
|
|
26
|
+
allow(mod).to receive(:add_to_sitemap)
|
|
27
|
+
cwd = Dir.pwd
|
|
28
|
+
expect(mod.import_openapi_to_sitemap(burp_obj: {}, openapi_spec: 'inputs/spec.json')).to eq([])
|
|
29
|
+
expect(Dir.pwd).to eq(cwd)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'keeps OpenAPI output paths relative to the caller directory' do
|
|
33
|
+
allow(RestClient).to receive(:get).and_return('{"type":"object"}')
|
|
34
|
+
cwd = Dir.pwd
|
|
35
|
+
PWN::Plugins::OpenAPI.generate_spec(spec_paths: ['inputs/spec.json'], base_url: 'https://example.invalid', output_json_path: 'merged.json')
|
|
36
|
+
expect(Dir.pwd).to eq(cwd)
|
|
37
|
+
expect(File).to exist(File.join(cwd, 'merged.json'))
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'sends an absolute ZAP import path without changing the caller directory' do
|
|
41
|
+
mod = PWN::Plugins::Zaproxy
|
|
42
|
+
allow(mod).to receive(:stop)
|
|
43
|
+
allow(mod).to receive(:zap_rest_call).and_return(double('response', body: '{}'))
|
|
44
|
+
cwd = Dir.pwd
|
|
45
|
+
mod.import_openapi_to_sitemap(zap_obj: { api_key: 'fixture-token' }, openapi_spec: 'inputs/spec.json')
|
|
46
|
+
expect(Dir.pwd).to eq(cwd)
|
|
47
|
+
expect(mod).to have_received(:zap_rest_call).with(hash_including(params: hash_including(file: File.join(cwd, 'inputs/spec.json'))))
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::Plugins::ArtifactRegistry, 'session path regression' do
|
|
7
|
+
it 'rejects traversal session identifiers before registering a file' do
|
|
8
|
+
Dir.mktmpdir('artifact-audit') do |dir|
|
|
9
|
+
stub_const('PWN::Plugins::ArtifactRegistry::ROOT', File.join(dir, 'artifacts'))
|
|
10
|
+
source = File.join(dir, 'source.bin')
|
|
11
|
+
File.binwrite(source, 'fixture')
|
|
12
|
+
expect { described_class.register(session_id: '../outside', path: source) }.to raise_error(ArgumentError, /session_id/)
|
|
13
|
+
expect(File.exist?(File.join(dir, 'outside', 'source.bin'))).to be(false)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'rejects traversal session identifiers before listing an index' do
|
|
18
|
+
expect { described_class.list(session_id: '../outside') }.to raise_error(ArgumentError, /session_id/)
|
|
19
|
+
end
|
|
20
|
+
end
|