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,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'open3'
|
|
6
|
+
require 'uri'
|
|
7
|
+
|
|
8
|
+
[PWN::Reports::SAST, PWN::Reports::AIRedTeam].each do |reporter|
|
|
9
|
+
RSpec.describe reporter, 'PR-SEC-02 inline AJAX encoding' do
|
|
10
|
+
[
|
|
11
|
+
'ordinary',
|
|
12
|
+
'fixture", "review": (globalThis.providerReviewMarker = 1), "unused": "',
|
|
13
|
+
"space &?#%+\"'\\\n雪\u2028\u2029",
|
|
14
|
+
'fixture</script><script>providerReviewMarker=1</script>'
|
|
15
|
+
].each do |name|
|
|
16
|
+
it "preserves the filename as URL data for #{name.inspect}" do
|
|
17
|
+
Dir.mktmpdir('pwn-report-encoding-') do |dir|
|
|
18
|
+
# Slash-containing input also exercises the literal HTML end tag.
|
|
19
|
+
FileUtils.mkdir_p(File.dirname(File.join(dir, "#{name}.html")))
|
|
20
|
+
described_class.generate(dir_path: dir, report_name: name)
|
|
21
|
+
html = File.read(File.join(dir, "#{name}.html"))
|
|
22
|
+
expect(JSON.parse(File.read(File.join(dir, "#{name}.json")))).to eq('report_name' => name, 'data' => [])
|
|
23
|
+
ajax = html.lines.find { |line| line.include?('"ajax":') }.strip.delete_suffix(',')
|
|
24
|
+
code = <<~JS
|
|
25
|
+
const vm = require('vm'), fs = require('fs'), context = {};
|
|
26
|
+
const value = vm.runInNewContext('({' + fs.readFileSync(0, 'utf8') + '})', context);
|
|
27
|
+
process.stdout.write(JSON.stringify({ajax: value.ajax, context}));
|
|
28
|
+
JS
|
|
29
|
+
stdout, stderr, status = Open3.capture3('node', '-e', code, stdin_data: ajax)
|
|
30
|
+
expect(status.success?).to be(true), stderr
|
|
31
|
+
result = JSON.parse(stdout)
|
|
32
|
+
expect(result.fetch('context')).to eq({})
|
|
33
|
+
url = result.fetch('ajax')
|
|
34
|
+
expect(url).not_to match(/[<>"'\\\s&#?]/)
|
|
35
|
+
expect(URI.parse(url).scheme).to be_nil
|
|
36
|
+
expect(URI.decode_www_form_component(url)).to eq("#{name}.json")
|
|
37
|
+
expect(ajax).not_to include('</script>', '<script>', "\u2028", "\u2029")
|
|
38
|
+
scripts = html.scan(%r{<script(?: [^>]*)?>(.*?)</script>}m).flatten.join("\n")
|
|
39
|
+
_, stderr, status = Open3.capture3('node', '-e', 'new (require("vm").Script)(require("fs").readFileSync(0,"utf8"))', stdin_data: scripts)
|
|
40
|
+
expect(status.success?).to be(true), stderr
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'open3'
|
|
5
|
+
require 'tmpdir'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
|
|
8
|
+
RSpec.describe PWN::SAST::TestCaseEngine, 'runtime boundaries' do
|
|
9
|
+
around do |example|
|
|
10
|
+
Dir.mktmpdir('pwn-sast-engine-') do |dir|
|
|
11
|
+
@source_dir = dir
|
|
12
|
+
example.run
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
before do
|
|
17
|
+
stub_const('PWN::Env', { ai: { module_reflection: false } })
|
|
18
|
+
allow(PWN::AI::Agent::SAST).to receive(:analyze).and_return(nil)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
let(:scan_options) do
|
|
22
|
+
{ dir_path: @source_dir, test_case_filter: 'grep -n -e fixture {PWN_SAST_SRC_TARGET}', security_references: { sast_module: 'Fixture' } }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'uses exclude_extensions rather than silently falling back to defaults' do
|
|
26
|
+
File.write(File.join(@source_dir, 'sample.txt'), "fixture\n")
|
|
27
|
+
expect(described_class.execute(scan_options.merge(exclude_extensions: ['.txt']))).to eq([])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'honors the documented exclusion option without mutating caller options' do
|
|
31
|
+
File.write(File.join(@source_dir, 'sample.txt'), "fixture\n")
|
|
32
|
+
options = scan_options.merge(exclude_extensions: ['.txt']).freeze
|
|
33
|
+
expect(described_class.execute(options)).to eq([])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'scans escaped filenames as files and preserves their literal names in findings' do
|
|
37
|
+
filename = "space ' quote & dollar$.txt"
|
|
38
|
+
File.write(File.join(@source_dir, filename), "fixture\n")
|
|
39
|
+
result = described_class.execute(scan_options)
|
|
40
|
+
expect(result.length).to eq(1)
|
|
41
|
+
expect(result.first[:filename][:entry]).to eq("./#{filename}")
|
|
42
|
+
expect(result.first[:line_no_and_contents].first[:contents]).to eq("fixture\n")
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'scans the original JavaScript when the optional beautifier is absent' do
|
|
46
|
+
File.write(File.join(@source_dir, 'source.js'), "fixture\n")
|
|
47
|
+
allow(described_class).to receive(:`).and_wrap_original do |original, command|
|
|
48
|
+
command.start_with?('js-beautify ') ? '' : original.call(command)
|
|
49
|
+
end
|
|
50
|
+
allow(Open3).to receive(:capture3).with('js-beautify', '-', stdin_data: "fixture\n").and_raise(Errno::ENOENT)
|
|
51
|
+
result = described_class.execute(scan_options)
|
|
52
|
+
expect(result.length).to eq(1)
|
|
53
|
+
expect(result.first[:filename][:entry]).to eq('./source.js')
|
|
54
|
+
expect(File.exist?(File.join(@source_dir, 'source.js.JS-BEAUTIFIED'))).to be(false)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
it 'surfaces a failing beautifier rather than reporting a clean JavaScript scan' do
|
|
58
|
+
File.write(File.join(@source_dir, 'source.js'), "fixture\n")
|
|
59
|
+
allow(described_class).to receive(:`).and_wrap_original do |original, command|
|
|
60
|
+
command.start_with?('js-beautify ') ? '' : original.call(command)
|
|
61
|
+
end
|
|
62
|
+
status = instance_double(Process::Status, success?: false, exitstatus: 2)
|
|
63
|
+
allow(Open3).to receive(:capture3).with('js-beautify', '-', stdin_data: "fixture\n").and_return(['', 'fixture failure', status])
|
|
64
|
+
expect { described_class.execute(scan_options) }.to raise_error(RuntimeError, /js-beautify.*failed/)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it 'scans successful beautifier output while leaving the original source unchanged' do
|
|
68
|
+
source = 'fixture;'
|
|
69
|
+
File.write(File.join(@source_dir, 'source.js'), source)
|
|
70
|
+
status = instance_double(Process::Status, success?: true)
|
|
71
|
+
expect(Open3).to receive(:capture3).with('js-beautify', '-', stdin_data: source).and_return(["\nfixture;\n", '', status])
|
|
72
|
+
result = described_class.execute(scan_options)
|
|
73
|
+
expect(result.first[:filename]).to include(entry: './source.js', entry_beautified: true)
|
|
74
|
+
expect(result.first[:line_no_and_contents].first[:line_no]).to eq('2')
|
|
75
|
+
expect(File.read(File.join(@source_dir, 'source.js'))).to eq(source)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'retains explicitly enabled AI analysis at the external boundary' do
|
|
79
|
+
stub_const('PWN::Env', { ai: { module_reflection: true } })
|
|
80
|
+
File.write(File.join(@source_dir, 'source.txt'), "fixture\n")
|
|
81
|
+
expect(PWN::AI::Agent::SAST).to receive(:analyze).with(request: kind_of(String)).and_return('fixture analysis')
|
|
82
|
+
expect(described_class.execute(scan_options).first[:line_no_and_contents].first[:ai_analysis]).to eq('fixture analysis')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it 'scans without AI configuration and never enters the optional analyzer' do
|
|
86
|
+
stub_const('PWN::Env', { driver_opts: {} })
|
|
87
|
+
expect(PWN::AI::Agent::SAST).not_to receive(:analyze)
|
|
88
|
+
File.write(File.join(@source_dir, 'sample.txt'), "fixture\n")
|
|
89
|
+
expect(described_class.execute(scan_options).first[:line_no_and_contents].first[:ai_analysis]).to eq('N/A')
|
|
90
|
+
end
|
|
91
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe 'SAST filter edge regressions' do
|
|
7
|
+
around do |example|
|
|
8
|
+
Dir.mktmpdir('pwn-sast-filters-') do |dir|
|
|
9
|
+
@source_dir = dir
|
|
10
|
+
example.run
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
stub_const('PWN::Env', { ai: { module_reflection: false } })
|
|
16
|
+
allow(PWN::AI::Agent::SAST).to receive(:analyze).and_return(nil)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'preserves the original Keystore scan exception' do
|
|
20
|
+
error = IOError.new('fixture scan failure')
|
|
21
|
+
allow(PWN::SAST::TestCaseEngine).to receive(:execute).and_raise(error)
|
|
22
|
+
expect { PWN::SAST::Keystore.scan(dir_path: @source_dir) }.to(raise_error { |actual| expect(actual).to equal(error) })
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
{ PHPTypeJuggling: '.php', TypeScriptTypeJuggling: '.ts' }.each do |name, extension|
|
|
26
|
+
it "detects loose comparisons on mixed strict/loose lines in #{name}" do
|
|
27
|
+
File.write(File.join(@source_dir, "source#{extension}"), "a === b || c == d\na !== b && c != d\na === b\na !== b\n")
|
|
28
|
+
result = PWN::SAST.const_get(name).scan(dir_path: @source_dir)
|
|
29
|
+
expect(result.length).to eq(1)
|
|
30
|
+
expect(result.first[:line_no_and_contents].map { |line| line[:line_no] }).to eq(%w[1 2])
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'retains SQL candidates because placeholder text does not establish safe binding' do
|
|
35
|
+
File.write(File.join(@source_dir, 'source.txt'), "#{"\n" * 10}SELECT name FROM users WHERE id = ?\nSELECT name FROM users WHERE id = :x\nSELECT name FROM users\n")
|
|
36
|
+
result = PWN::SAST::SQL.scan(dir_path: @source_dir)
|
|
37
|
+
expect(result.first[:line_no_and_contents].map { |line| line[:line_no] }).to eq(%w[11 12 13])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'digest'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
require 'open3'
|
|
7
|
+
require 'shellwords'
|
|
8
|
+
require 'tmpdir'
|
|
9
|
+
|
|
10
|
+
RSpec.describe PWN::SAST::TestCaseEngine, 'formatter review safeguards' do
|
|
11
|
+
around do |example|
|
|
12
|
+
Dir.mktmpdir('pwn-sast-formatter-') do |dir|
|
|
13
|
+
@root = dir
|
|
14
|
+
@sources = File.join(dir, 'sources')
|
|
15
|
+
FileUtils.mkdir_p(@sources)
|
|
16
|
+
@lock_path = File.expand_path('../../../../Gemfile.lock', __dir__)
|
|
17
|
+
@lock_before = File.binread(@lock_path)
|
|
18
|
+
@js_beautify_bin = Gem.bin_path('js-beautify', 'js-beautify')
|
|
19
|
+
saved_env = %w[BUNDLE_GEMFILE BUNDLE_LOCKFILE RUBYOPT BUNDLE_FROZEN].to_h { |key| [key, ENV.fetch(key, nil)] }
|
|
20
|
+
original_path = ENV.fetch('PATH')
|
|
21
|
+
# Fixture subprocesses must not inherit the checkout lock path. Clearing
|
|
22
|
+
# RUBYOPT keeps the child from booting Bundler against that disposable Gemfile.
|
|
23
|
+
ENV['BUNDLE_GEMFILE'] = File.join(@root, 'Gemfile')
|
|
24
|
+
ENV['BUNDLE_LOCKFILE'] = File.join(@root, 'Gemfile.lock')
|
|
25
|
+
File.write(ENV.fetch('BUNDLE_GEMFILE'), "# private formatter fixture\n")
|
|
26
|
+
File.write(ENV.fetch('BUNDLE_LOCKFILE'), '')
|
|
27
|
+
ENV.delete('RUBYOPT')
|
|
28
|
+
ENV.delete('BUNDLE_FROZEN')
|
|
29
|
+
example.run
|
|
30
|
+
expect(File.binread(@lock_path)).to eq(@lock_before)
|
|
31
|
+
ensure
|
|
32
|
+
saved_env&.each { |key, value| value.nil? ? ENV.delete(key) : ENV[key] = value }
|
|
33
|
+
ENV['PATH'] = original_path if original_path
|
|
34
|
+
File.binwrite(@lock_path, @lock_before) if @lock_before && File.binread(@lock_path) != @lock_before
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
before { stub_const('PWN::Env', { ai: { module_reflection: false } }) }
|
|
39
|
+
|
|
40
|
+
let(:options) do
|
|
41
|
+
{ dir_path: @sources, security_references: { sast_module: 'Fixture' },
|
|
42
|
+
test_case_filter: 'grep -n -e fixture {PWN_SAST_SRC_TARGET}' }.freeze
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def synthetic_formatter(body)
|
|
46
|
+
commands = File.join(@root, 'commands')
|
|
47
|
+
FileUtils.mkdir_p(commands)
|
|
48
|
+
launcher = File.join(commands, 'js-beautify')
|
|
49
|
+
File.write(launcher, "#!#{RbConfig.ruby}\n#{body}\n")
|
|
50
|
+
File.chmod(0o700, launcher)
|
|
51
|
+
ENV['PATH'] = "#{commands}:#{ENV.fetch('PATH')}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'SERVICES-REVIEW-002 leaves an attacker sidecar symlink and its target unchanged' do
|
|
55
|
+
original = "fixture;\n"
|
|
56
|
+
source = File.join(@sources, 'source.js')
|
|
57
|
+
sentinel = File.join(@root, 'sentinel')
|
|
58
|
+
File.write(source, original)
|
|
59
|
+
File.write(sentinel, 'unchanged sentinel')
|
|
60
|
+
File.symlink(sentinel, "#{source}.JS-BEAUTIFIED")
|
|
61
|
+
synthetic_formatter('print "\\n", STDIN.read')
|
|
62
|
+
|
|
63
|
+
result = described_class.execute(options)
|
|
64
|
+
|
|
65
|
+
expect(File.read(sentinel)).to eq('unchanged sentinel')
|
|
66
|
+
expect(File.readlink("#{source}.JS-BEAUTIFIED")).to eq(sentinel)
|
|
67
|
+
expect(File.read(source)).to eq(original)
|
|
68
|
+
expect(result.first[:filename]).to include(entry: './source.js', entry_beautified: true)
|
|
69
|
+
expect(result.first[:line_no_and_contents].first[:line_no]).to eq('2')
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'SERVICES-REVIEW-002 scans formatted text without creating a source-adjacent artifact' do
|
|
73
|
+
File.write(File.join(@sources, 'source.js'), "fixture;\n")
|
|
74
|
+
synthetic_formatter('print STDIN.read')
|
|
75
|
+
|
|
76
|
+
result = described_class.execute(options)
|
|
77
|
+
expect(result).not_to be_empty
|
|
78
|
+
temporary_path = Shellwords.split(result.first[:test_case_filter]).last
|
|
79
|
+
expect(File.exist?(temporary_path)).to be(false)
|
|
80
|
+
expect(Dir.children(@sources)).to eq(['source.js'])
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
['', " \n\t"].each do |output|
|
|
84
|
+
it "SERVICES-REVIEW-007 falls back to original input after blank formatter output #{output.inspect}" do
|
|
85
|
+
File.write(File.join(@sources, 'source.js'), "fixture;\n")
|
|
86
|
+
synthetic_formatter("print #{output.dump}")
|
|
87
|
+
|
|
88
|
+
result = described_class.execute(options)
|
|
89
|
+
|
|
90
|
+
expect(result.length).to eq(1)
|
|
91
|
+
expect(result.first[:filename]).to include(entry: './source.js', entry_beautified: false)
|
|
92
|
+
expect(result.first[:line_no_and_contents].first).to include(line_no: '1', contents: "fixture;\n")
|
|
93
|
+
expect(Dir.children(@sources)).to eq(['source.js'])
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it 'SERVICES-REVIEW-002 deletes its exact private formatter file after the filter fails' do
|
|
98
|
+
File.write(File.join(@sources, 'source.js'), "fixture;\n")
|
|
99
|
+
synthetic_formatter('print STDIN.read')
|
|
100
|
+
temporary_path = nil
|
|
101
|
+
allow(Tempfile).to receive(:new).and_wrap_original do |original, *args|
|
|
102
|
+
file = original.call(*args)
|
|
103
|
+
temporary_path = file.path
|
|
104
|
+
expect(file.stat.mode & 0o777).to eq(0o600)
|
|
105
|
+
file
|
|
106
|
+
end
|
|
107
|
+
allow(described_class).to receive(:`).and_wrap_original do |original, command|
|
|
108
|
+
raise IOError, 'fixture filter error' if command.start_with?('grep -n')
|
|
109
|
+
|
|
110
|
+
original.call(command)
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
expect { described_class.execute(options) }.to raise_error(IOError, 'fixture filter error')
|
|
114
|
+
expect(temporary_path).not_to be_nil
|
|
115
|
+
expect(File.exist?(temporary_path)).to be(false)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it 'SERVICES-REVIEW-001 does not pass JavaScript filenames to a shell' do
|
|
119
|
+
short_name = 'source;printf proof>review-marker;#.js'
|
|
120
|
+
long_name = 'long;printf proof>review-marker;#.js'
|
|
121
|
+
File.write(File.join(@sources, short_name), "var fixture={value:1};\n")
|
|
122
|
+
File.write(File.join(@sources, long_name), 'var fixture=1;\n' * 20)
|
|
123
|
+
commands = []
|
|
124
|
+
argv = []
|
|
125
|
+
allow(described_class).to receive(:`).and_wrap_original do |original, command|
|
|
126
|
+
commands << command
|
|
127
|
+
original.call(command)
|
|
128
|
+
end
|
|
129
|
+
allow(Open3).to receive(:capture3).and_wrap_original do |original, *args, **kwargs|
|
|
130
|
+
argv << args
|
|
131
|
+
original.call(*args, **kwargs)
|
|
132
|
+
end
|
|
133
|
+
synthetic_formatter('print STDIN.read')
|
|
134
|
+
|
|
135
|
+
result = described_class.execute(options)
|
|
136
|
+
|
|
137
|
+
joined = commands.join("\n")
|
|
138
|
+
[short_name, long_name].each do |name|
|
|
139
|
+
expect(joined).not_to include(name)
|
|
140
|
+
expect(joined).not_to include(Shellwords.escape(name))
|
|
141
|
+
expect(argv.flatten).not_to include(a_string_including(name))
|
|
142
|
+
end
|
|
143
|
+
expect(File.exist?(File.join(@sources, 'review-marker'))).to be(false)
|
|
144
|
+
expect(result.map { |row| row[:filename][:entry] }).to contain_exactly("./#{short_name}", "./#{long_name}")
|
|
145
|
+
expect(Digest::SHA256.file(@lock_path).hexdigest).to eq(Digest::SHA256.hexdigest(@lock_before))
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'SERVICES-REVIEW-001 keeps a malicious filename literal through the installed launcher' do
|
|
149
|
+
# Only a harmless marker inside the private source fixture can be created.
|
|
150
|
+
name = 'source;printf proof>review-marker;#.js'
|
|
151
|
+
source = 'var fixture={value:1};'
|
|
152
|
+
File.write(File.join(@sources, name), source)
|
|
153
|
+
commands_dir = File.join(@root, 'commands')
|
|
154
|
+
FileUtils.mkdir_p(commands_dir)
|
|
155
|
+
shell_commands = []
|
|
156
|
+
allow(described_class).to receive(:`).and_wrap_original do |original, command|
|
|
157
|
+
shell_commands << command
|
|
158
|
+
original.call(command)
|
|
159
|
+
end
|
|
160
|
+
# Load the actual gem launcher by its original path: it resolves its
|
|
161
|
+
# bundled parser relative to __FILE__, so symlinking that file breaks it.
|
|
162
|
+
launcher = File.join(commands_dir, 'js-beautify')
|
|
163
|
+
File.write(launcher, "#!#{RbConfig.ruby}\nload #{@js_beautify_bin.dump}\n")
|
|
164
|
+
File.chmod(0o700, launcher)
|
|
165
|
+
ENV['PATH'] = "#{commands_dir}:#{ENV.fetch('PATH')}"
|
|
166
|
+
|
|
167
|
+
result = described_class.execute(options)
|
|
168
|
+
|
|
169
|
+
expect(shell_commands.join("\n")).not_to include(name)
|
|
170
|
+
expect(shell_commands.join("\n")).not_to include(Shellwords.escape(name))
|
|
171
|
+
expect(File.exist?(File.join(@sources, 'review-marker'))).to be(false)
|
|
172
|
+
expect(result.length).to eq(1)
|
|
173
|
+
expect(result.first[:filename][:entry_beautified]).to be(true)
|
|
174
|
+
expect(result.first[:line_no_and_contents].first[:contents]).to include('var fixture = {')
|
|
175
|
+
expect(File.read(File.join(@sources, name))).to eq(source)
|
|
176
|
+
expect(Digest::SHA256.file(@lock_path).hexdigest).to eq(Digest::SHA256.hexdigest(@lock_before))
|
|
177
|
+
end
|
|
178
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
require 'tmpdir'
|
|
6
|
+
|
|
7
|
+
RSpec.describe 'SAST explicit test-path convention' do
|
|
8
|
+
around do |example|
|
|
9
|
+
Dir.mktmpdir('pwn-path-review-') do |dir|
|
|
10
|
+
@sources = dir
|
|
11
|
+
example.run
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before { stub_const('PWN::Env', { ai: { module_reflection: false } }) }
|
|
16
|
+
|
|
17
|
+
def write_source(name, contents)
|
|
18
|
+
path = File.join(@sources, name)
|
|
19
|
+
FileUtils.mkdir_p(File.dirname(path))
|
|
20
|
+
File.write(path, contents)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def execute(extra = {})
|
|
24
|
+
options = { dir_path: @sources, security_references: { sast_module: 'Fixture' },
|
|
25
|
+
test_case_filter: 'grep -n -e fixture {PWN_SAST_SRC_TARGET}' }.merge(extra).freeze
|
|
26
|
+
PWN::SAST::TestCaseEngine.execute(options)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'SERVICES-REVIEW-005 retains production paths with incidental test substrings in actual Logger scans' do
|
|
30
|
+
names = ['contest.rb', 'latest.js', 'latest_release/service.rb', 'testimony.rb']
|
|
31
|
+
names.each { |name| write_source(name, "#{"\n" * 20}logger.info(password);\n") }
|
|
32
|
+
|
|
33
|
+
expect(PWN::SAST::Logger.scan(dir_path: @sources).map { |row| row[:filename][:entry] }).to match_array(names.map { |name| "./#{name}" })
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'SERVICES-REVIEW-005 excludes only explicit directory and filename conventions' do
|
|
37
|
+
names = %w[test/source.rb tests/source.rb spec/source.rb specs/source.rb __tests__/source.rb src/test_source.rb src/source_test.rb src/source_spec.rb src/source.test.js src/source.spec.js]
|
|
38
|
+
names.each { |name| write_source(name, "#{"\n" * 20}fixture\n") }
|
|
39
|
+
|
|
40
|
+
expect(execute).to eq([])
|
|
41
|
+
expect(execute(exclude_test_paths: false).map { |row| row[:filename][:entry] }).to match_array(names.map { |name| "./#{name}" })
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'SERVICES-REVIEW-005 retains PomVersion production paths but excludes explicit test directories' do
|
|
45
|
+
%w[contest latest_release tests spec __tests__].each { |name| write_source("#{name}/pom.xml", "<version>1.2.3</version>\n") }
|
|
46
|
+
|
|
47
|
+
result = PWN::SAST::PomVersion.scan({ dir_path: @sources }.freeze)
|
|
48
|
+
|
|
49
|
+
expect(result.map { |row| row[:filename][:entry] }).to match_array(%w[./contest/pom.xml ./latest_release/pom.xml])
|
|
50
|
+
expect(result.map { |row| row[:line_no_and_contents].first[:line_no] }).to eq(%w[1 1])
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'SERVICES-REVIEW-005 allows explicit inclusion of test paths in PomVersion' do
|
|
54
|
+
write_source('tests/pom.xml', "<version>1.2.3</version>\n")
|
|
55
|
+
options = { dir_path: @sources, exclude_test_paths: false }.freeze
|
|
56
|
+
|
|
57
|
+
expect(PWN::SAST::PomVersion.scan(options).map { |row| row[:filename][:entry] }).to eq(['./tests/pom.xml'])
|
|
58
|
+
expect(options).to eq(dir_path: @sources, exclude_test_paths: false)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
RSpec.describe PWN::SAST::PomVersion, 'runtime regressions' do
|
|
8
|
+
around do |example|
|
|
9
|
+
Dir.mktmpdir('pwn-pom-') do |dir|
|
|
10
|
+
@source_dir = dir
|
|
11
|
+
example.run
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
stub_const('PWN::Env', { ai: { module_reflection: false } })
|
|
17
|
+
allow(PWN::AI::Agent::SAST).to receive(:analyze).and_return(nil)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'returns version matches and dependency context from the actual pom file' do
|
|
21
|
+
File.write(File.join(@source_dir, 'pom.xml'), "<dependency>\n<artifactId>fixture</artifactId>\n<version>1.2.3</version>\n</dependency>\n")
|
|
22
|
+
result = described_class.scan(dir_path: @source_dir)
|
|
23
|
+
expect(result.length).to eq(1)
|
|
24
|
+
expect(result.first[:raw_content]).to include('3:<version>1.2.3</version>')
|
|
25
|
+
expect(result.first[:line_no_and_contents]).to include(include(line_no: '2', contents: "<artifactId>fixture</artifactId>\n"))
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'works without AI configuration and with spaces in the pom directory' do
|
|
29
|
+
stub_const('PWN::Env', {})
|
|
30
|
+
expect(PWN::AI::Agent::SAST).not_to receive(:analyze)
|
|
31
|
+
FileUtils.mkdir_p(File.join(@source_dir, 'nested project'))
|
|
32
|
+
File.write(File.join(@source_dir, 'nested project/pom.xml'), "<version>2.0</version>\n")
|
|
33
|
+
result = described_class.scan(dir_path: @source_dir)
|
|
34
|
+
expect(result.first[:filename][:entry]).to eq('./nested project/pom.xml')
|
|
35
|
+
expect(result.first[:line_no_and_contents].first[:ai_analysis]).to eq('N/A')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
7
|
+
RSpec.describe 'SAST rule runtime regressions' do
|
|
8
|
+
around do |example|
|
|
9
|
+
Dir.mktmpdir('pwn-sast-rules-') do |dir|
|
|
10
|
+
@source_dir = dir
|
|
11
|
+
example.run
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
before do
|
|
16
|
+
stub_const('PWN::Env', { ai: { module_reflection: false } })
|
|
17
|
+
allow(PWN::AI::Agent::SAST).to receive(:analyze).and_return(nil)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
fixtures = {
|
|
21
|
+
AMQPConnectAsGuest: ['.txt', 'amqp guest'],
|
|
22
|
+
ApacheFileSystemUtilAPI: ['.java', 'import org.apache.commons.io.FileSystemUtils'],
|
|
23
|
+
AWS: ['.txt', 'access_key = fixture'],
|
|
24
|
+
BannedFunctionCallsC: ['.c', 'strcpy(dest, src);'],
|
|
25
|
+
Base64: ['.txt', 'Base64.decode(data)'],
|
|
26
|
+
BeefHook: ['.txt', 'hook.js'],
|
|
27
|
+
CmdExecutionGoLang: ['.go', 'exec.Command("fixture")'],
|
|
28
|
+
CmdExecutionJava: ['.java', 'new ProcessBuilder("fixture")'],
|
|
29
|
+
CmdExecutionPython: ['.py', 'os.system("fixture")'],
|
|
30
|
+
CmdExecutionRuby: ['.rb', 'eval("fixture")'],
|
|
31
|
+
CmdExecutionScala: ['.scala', 'Process("fixture")'],
|
|
32
|
+
CSRF: ['.txt', 'csrf_token'],
|
|
33
|
+
DeserialJava: ['.java', 'stream.readObject()'],
|
|
34
|
+
Emoticon: ['.txt', ':-)'],
|
|
35
|
+
Eval: ['.txt', 'eval("fixture")'],
|
|
36
|
+
Factory: ['.java', 'DocumentBuilderFactory.newInstance()'],
|
|
37
|
+
HTTPAuthorizationHeader: ['.txt', 'authorization = fixture'],
|
|
38
|
+
InnerHTML: ['.txt', 'node.innerHTML = input'],
|
|
39
|
+
Keystore: ['.txt', 'keystore'],
|
|
40
|
+
LocalStorage: ['.txt', 'localStorage.setItem("fixture", data)'],
|
|
41
|
+
LocationHash: ['.txt', 'location.hash'],
|
|
42
|
+
Log4J: ['.java', 'import org.apache.log4j.Logger'],
|
|
43
|
+
Logger: ['.txt', 'logger.info(password)'],
|
|
44
|
+
MD5: ['.txt', 'md5'],
|
|
45
|
+
OuterHTML: ['.txt', 'node.outerHTML = input'],
|
|
46
|
+
PaddingOracle: ['.txt', 'AES/CBC/PKCS5Padding'],
|
|
47
|
+
Password: ['.txt', 'password = fixture'],
|
|
48
|
+
PHPInputMechanisms: ['.php', '$_GET["fixture"]'],
|
|
49
|
+
PHPTypeJuggling: ['.php', '$a == $b'],
|
|
50
|
+
Port: ['.txt', 'localhost:8080'],
|
|
51
|
+
PostMessage: ['.txt', 'postMessage(data)'],
|
|
52
|
+
PrivateKey: ['.txt', 'PRIVATE KEY'],
|
|
53
|
+
Redirect: ['.txt', 'redirect_uri = input'],
|
|
54
|
+
ReDOS: ['.txt', '(a+)+'],
|
|
55
|
+
Shell: ['.txt', '/bin/sh'],
|
|
56
|
+
Signature: ['.txt', 'Signature'],
|
|
57
|
+
SQL: ['.txt', 'SELECT name FROM users'],
|
|
58
|
+
SSL: ['.txt', 'trustAll'],
|
|
59
|
+
Sudo: ['.txt', 'sudo'],
|
|
60
|
+
TaskTag: ['.txt', '# TODO: fixture'],
|
|
61
|
+
ThrowErrors: ['.txt', 'raise "fixture"'],
|
|
62
|
+
Token: ['.txt', 'oauth'],
|
|
63
|
+
TypeScriptTypeJuggling: ['.ts', 'a == b'],
|
|
64
|
+
UseAfterFree: ['.c', 'free(pointer);'],
|
|
65
|
+
Version: ['.txt', 'version = "1.0"'],
|
|
66
|
+
WindowLocationHash: ['.txt', 'window.location.hash']
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
fixtures.each do |name, (extension, source)|
|
|
70
|
+
it "runs #{name} through the real scanner and returns its numbered match" do
|
|
71
|
+
File.write(File.join(@source_dir, "sample#{extension}"), "#{source}\n")
|
|
72
|
+
result = PWN::SAST.const_get(name).scan(dir_path: @source_dir)
|
|
73
|
+
expect(result.length).to eq(1)
|
|
74
|
+
expect(result.first[:security_references][:sast_module]).to eq(PWN::SAST.const_get(name))
|
|
75
|
+
expect(result.first[:line_no_and_contents].first).to include(line_no: '1', contents: "#{source}\n", ai_analysis: 'N/A')
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PWN::SAST::SQL, 'candidate preservation' do
|
|
7
|
+
around do |example|
|
|
8
|
+
Dir.mktmpdir('pwn-sql-review-') do |dir|
|
|
9
|
+
@sources = dir
|
|
10
|
+
example.run
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before { stub_const('PWN::Env', { ai: { module_reflection: false } }) }
|
|
15
|
+
|
|
16
|
+
candidates = [
|
|
17
|
+
%q{db.execute("SELECT name FROM users WHERE name = '" + user_input + "' AND email LIKE '%@example.invalid'")},
|
|
18
|
+
'db.execute("SELECT name FROM users WHERE id = " + params[:x])',
|
|
19
|
+
'db.execute("SELECT name FROM users WHERE id = ? ORDER BY " + sort, [id])',
|
|
20
|
+
'db.execute("SELECT name FROM users WHERE id = :id ORDER BY " + sort, id: id)',
|
|
21
|
+
'db.execute("SELECT name FROM users WHERE id = $1 ORDER BY " + sort, [id])',
|
|
22
|
+
'db.execute("SELECT name FROM users WHERE id = :1 ORDER BY " + sort, [id])'
|
|
23
|
+
]
|
|
24
|
+
candidates.each_with_index do |source, index|
|
|
25
|
+
[1, 11].each do |line|
|
|
26
|
+
it "SERVICES-REVIEW-003 retains dynamic SQL candidate #{index} on line #{line} despite placeholder punctuation" do
|
|
27
|
+
File.write(File.join(@sources, 'source.rb'), "#{"\n" * (line - 1)}#{source}\n")
|
|
28
|
+
options = { dir_path: @sources }.freeze
|
|
29
|
+
|
|
30
|
+
result = described_class.scan(options)
|
|
31
|
+
|
|
32
|
+
expect(result.length).to eq(1)
|
|
33
|
+
expect(result.first[:line_no_and_contents]).to contain_exactly(include(line_no: line.to_s, contents: "#{source}\n"))
|
|
34
|
+
expect(options).to eq(dir_path: @sources)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'spec_helper'
|
|
4
|
+
require 'tempfile'
|
|
4
5
|
|
|
5
6
|
describe PWN::SDR::Decoder::Base do
|
|
6
7
|
it 'responds to run_iq / resolve_iq_source' do
|
|
@@ -11,24 +12,26 @@ describe PWN::SDR::Decoder::Base do
|
|
|
11
12
|
end
|
|
12
13
|
|
|
13
14
|
it 'resolves a cu8 capture file as an I/Q source' do
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
Tempfile.create(['pwn-iq-', '.cu8']) do |file|
|
|
16
|
+
file.binmode
|
|
17
|
+
file.write(([127, 127] * 1024).pack('C*'))
|
|
18
|
+
file.flush
|
|
19
|
+
src = PWN::SDR::Decoder::Base.resolve_iq_source(
|
|
20
|
+
freq_obj: { freq: 433_920_000 },
|
|
21
|
+
source: :file,
|
|
22
|
+
file: file.path,
|
|
23
|
+
sample_rate: 250_000
|
|
24
|
+
)
|
|
25
|
+
expect(src).to be_a(Hash)
|
|
26
|
+
expect(src[:kind]).to eq(:file)
|
|
27
|
+
expect(src[:format]).to eq(:cu8)
|
|
28
|
+
chunk = PWN::SDR::Decoder::Base.read_iq_chunk(source: src, bytes: 512)
|
|
29
|
+
expect(chunk.bytesize).to eq(512)
|
|
30
|
+
iq = PWN::SDR::Decoder::Base.unpack_iq(source: src, data: chunk)
|
|
31
|
+
expect(iq.length).to eq(512) # interleaved I/Q floats
|
|
32
|
+
ensure
|
|
33
|
+
PWN::SDR::Decoder::Base.close_iq_source(source: src)
|
|
34
|
+
end
|
|
32
35
|
end
|
|
33
36
|
end
|
|
34
37
|
|