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,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::Policy, 'explicit confidence' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
it 'does not upgrade zero confidence to a full terminal reward' do
|
|
9
|
+
described_class.begin_episode(session_id: 'fixture', request: 'check the fixture')
|
|
10
|
+
step = described_class.observe_step(session_id: 'fixture', action: 'shell', action_id: 'checked', ok: true)
|
|
11
|
+
result = described_class.finish(session_id: 'fixture', score: 1.0, confidence: 0.0,
|
|
12
|
+
attribution: { source: 'independent_verifier', verified_action_ids: ['checked'] })
|
|
13
|
+
expect(result[:terminal_reward]).to eq(0.0)
|
|
14
|
+
expect(described_class.q(state: step[:state], action: 'shell')).to eq(0.0)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -10,7 +10,7 @@ require 'timeout'
|
|
|
10
10
|
# All snapshot reads/writes and subprocess HOME directories are disposable.
|
|
11
11
|
describe 'PWN::AI::Agent::PolicyEvaluation' do
|
|
12
12
|
around do |example|
|
|
13
|
-
Dir.mktmpdir('pwn-evaluation-spec-'
|
|
13
|
+
Dir.mktmpdir('pwn-evaluation-spec-') do |root|
|
|
14
14
|
@root = root
|
|
15
15
|
@baseline = File.join(root, 'baseline.json')
|
|
16
16
|
@candidate = File.join(root, 'candidate.json')
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::PolicyEvaluation, 'temporary directory isolation' do
|
|
6
|
+
it 'uses the configured temporary root before spawning an evaluator' do
|
|
7
|
+
Dir.mktmpdir('pwn-evaluator-tmp-spec-') do |root|
|
|
8
|
+
snapshot = File.join(root, 'snapshot.json')
|
|
9
|
+
File.write(snapshot, JSON.generate(q: {}, h: {}, visits: {}, returns: [], n_updates: 0, td_abs_sum: 0.0))
|
|
10
|
+
expected_parent = Dir.tmpdir
|
|
11
|
+
allow(Dir).to receive(:mktmpdir).and_wrap_original do |original, *args, &block|
|
|
12
|
+
expect(args[1] || Dir.tmpdir).to eq(expected_parent)
|
|
13
|
+
original.call(*args, &block)
|
|
14
|
+
end
|
|
15
|
+
result = described_class.evaluate(baseline: snapshot, candidate: snapshot)
|
|
16
|
+
expect(result[:isolation]).to include(environment_cleared: true, persistence_removed_on_exit: true)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it 'keeps the fresh worker inner sandbox within its configured temporary root' do
|
|
21
|
+
code = <<~RUBY
|
|
22
|
+
require #{described_class::RUNNER.inspect}
|
|
23
|
+
expected = Dir.tmpdir
|
|
24
|
+
original = Dir.method(:mktmpdir)
|
|
25
|
+
Dir.define_singleton_method(:mktmpdir) do |*args, &block|
|
|
26
|
+
raise 'temporary root ignored' unless (args[1] || Dir.tmpdir) == expected
|
|
27
|
+
original.call(*args, &block)
|
|
28
|
+
end
|
|
29
|
+
PWN::AI::Agent::PolicyEvaluation.send(:with_isolated) { |root| puts root }
|
|
30
|
+
RUBY
|
|
31
|
+
output, error, status = Open3.capture3({ 'HOME' => Dir.home, 'TMPDIR' => Dir.tmpdir, 'LANG' => 'C.UTF-8' }, RbConfig.ruby, '-e', code, unsetenv_others: true)
|
|
32
|
+
expect(status.success?).to be(true), error
|
|
33
|
+
expect(output.strip).to start_with("#{Dir.tmpdir}/")
|
|
34
|
+
expect(File).not_to exist(output.strip)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::Reflect, 'explicit model forwarding' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
it 'passes a per-call model to the provider even when provider configuration is frozen' do
|
|
9
|
+
PWN::Env[:ai] = { active: :ollama, module_reflection: true, ollama: { model: 'default-model' }.freeze }.freeze
|
|
10
|
+
expect(PWN::AI::Ollama).to receive(:chat).with(hash_including(request: 'fixture input', model: 'teacher-model')).and_return('fixture response')
|
|
11
|
+
expect(described_class.on(request: 'fixture input', model: 'teacher-model', suppress_pii_warning: true)).to eq('fixture response')
|
|
12
|
+
expect(PWN::Env[:ai][:ollama][:model]).to eq('default-model')
|
|
13
|
+
expect(Thread.current[:pwn_reflect_depth]).to be_nil
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::AI::Agent::RequestRuntime, 'tool result key parity' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
after do
|
|
13
|
+
Thread.current[:pwn_request_runtime] = nil
|
|
14
|
+
Thread.current[:pwn_artifact_contract] = nil
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
[
|
|
18
|
+
[{ ok: false }, 'uncertain'],
|
|
19
|
+
[{ 'ok' => false }, 'uncertain'],
|
|
20
|
+
[{ exit: 7, stdout: '' }, 'failed'],
|
|
21
|
+
[{ 'exit' => 7, 'stdout' => '' }, 'failed']
|
|
22
|
+
].each_with_index do |(result, state), index|
|
|
23
|
+
it "preserves failure and withholds artifact credit for result variant #{index}" do
|
|
24
|
+
path = File.join(@tmp, 'partial.txt')
|
|
25
|
+
runtime = described_class.new(request: "Write #{path}", session_id: 'key-parity', artifact_root: @tmp, trace: false)
|
|
26
|
+
Thread.current[:pwn_request_runtime] = runtime
|
|
27
|
+
Thread.current[:pwn_artifact_contract] = runtime.contract
|
|
28
|
+
call = { name: 'fixture', args: { path: path }, effect: :write, action_id: 'first' }
|
|
29
|
+
returned = runtime.execute_tool(call) do
|
|
30
|
+
File.write(path, 'partial effect')
|
|
31
|
+
result
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
expect(returned).to eq(result)
|
|
35
|
+
expect(runtime.events.last[:state]).to eq(state)
|
|
36
|
+
expect(runtime.observations).to be_empty
|
|
37
|
+
if state == 'uncertain'
|
|
38
|
+
denied = runtime.execute_tool(call) { raise 'must not replay an uncertain mutation' }
|
|
39
|
+
expect(denied).to include(error: 'uncertain_side_effect')
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::AI::Agent::Reward, 'immutable PRM binding review' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
10
|
+
@agent_cfg[:reward_llm] = true
|
|
11
|
+
@sid = PWN::Sessions.create(title: 'PRM identity fixture')[:id]
|
|
12
|
+
PWN::Sessions.append(session_id: @sid, role: 'user', content: 'original request')
|
|
13
|
+
PWN::Sessions.append(session_id: @sid, role: 'tool', content: 'shell → {"success":true,"result":{"exit":0}}')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def append_next_turn
|
|
17
|
+
PWN::Sessions.append(session_id: @sid, role: 'assistant', content: 'earlier answer')
|
|
18
|
+
PWN::Sessions.append(session_id: @sid, role: 'user', content: 'next request')
|
|
19
|
+
PWN::Sessions.append(session_id: @sid, role: 'tool', content: 'pwn_eval → {"success":false,"error":"next turn failed"}')
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'freezes captured action identity before handing the snapshot to delayed work' do
|
|
23
|
+
snapshot = described_class.prm_snapshot(session_id: @sid, request: 'original request')
|
|
24
|
+
expect { snapshot[:binding][:actions].first[:sha256].replace('0' * 64) }.to raise_error(FrozenError)
|
|
25
|
+
expect { snapshot[:trace].first.replace('different action') }.to raise_error(FrozenError)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'annotates the scored live action and Metrics after a new turn arrives during scoring' do
|
|
29
|
+
allow(PWN::AI::Ollama).to receive(:chat) do |opts|
|
|
30
|
+
expect(opts[:request]).to include('original request')
|
|
31
|
+
append_next_turn
|
|
32
|
+
'1'
|
|
33
|
+
end
|
|
34
|
+
result = described_class.prm(request: 'original request', session_id: @sid)
|
|
35
|
+
expect(result.first[:reward]).to eq(1)
|
|
36
|
+
tools = PWN::Sessions.load(session_id: @sid).select { |row| row[:role] == 'tool' }
|
|
37
|
+
expect(tools.map { |row| row[:step_reward] }).to eq([1, nil])
|
|
38
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(1)
|
|
39
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(0)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'rejects changed scored bytes instead of applying rewards to replacement actions' do
|
|
43
|
+
path = File.join(PWN::Sessions.sessions_dir, "#{@sid}.jsonl")
|
|
44
|
+
after = nil
|
|
45
|
+
allow(PWN::AI::Ollama).to receive(:chat) do
|
|
46
|
+
rows = PWN::Sessions.load(session_id: @sid)
|
|
47
|
+
rows.last[:content] = 'pwn_eval → {"success":false,"error":"replacement"}'
|
|
48
|
+
after = rows.map { |row| "#{JSON.generate(row)}\n" }.join
|
|
49
|
+
File.write(path, after)
|
|
50
|
+
'1'
|
|
51
|
+
end
|
|
52
|
+
described_class.prm(request: 'original request', session_id: @sid)
|
|
53
|
+
expect(File.binread(path)).to eq(after.b)
|
|
54
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(0)
|
|
55
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(0)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it 'does not annotate a supplied trace unrelated to the persisted action' do
|
|
59
|
+
allow(PWN::AI::Ollama).to receive(:chat).and_return('1')
|
|
60
|
+
described_class.prm(request: 'original request', session_id: @sid, trace: ['pwn_eval → {"success":true}'])
|
|
61
|
+
expect(PWN::Sessions.load(session_id: @sid).last[:step_reward]).to be_nil
|
|
62
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(0)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'captures the action identity before a deferred worker starts even for repeated request text' do
|
|
66
|
+
@agent_cfg[:auto_introspect] = true
|
|
67
|
+
@agent_cfg[:critic] = false
|
|
68
|
+
@agent_cfg[:verify_as_reward] = false
|
|
69
|
+
finalizer = PWN::AI::Agent::TurnFinalizer
|
|
70
|
+
started = Queue.new
|
|
71
|
+
release = Queue.new
|
|
72
|
+
first_worker = true
|
|
73
|
+
allow(Thread).to receive(:new).and_wrap_original do |original, *args, &block|
|
|
74
|
+
if first_worker
|
|
75
|
+
first_worker = false
|
|
76
|
+
original.call(*args) do
|
|
77
|
+
started << true
|
|
78
|
+
release.pop
|
|
79
|
+
block.call
|
|
80
|
+
end
|
|
81
|
+
else
|
|
82
|
+
original.call(*args, &block)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
prompts = Queue.new
|
|
86
|
+
allow(PWN::AI::Ollama).to receive(:chat) do |opts|
|
|
87
|
+
if opts[:system_role_content].to_s.include?('Process Reward')
|
|
88
|
+
prompts << opts[:request]
|
|
89
|
+
'1'
|
|
90
|
+
else
|
|
91
|
+
'{"score":0.8,"verdict":"solved","rationale":"offline scoring fixture","key_step":1}'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
finalizer.defer(session_id: @sid, request: 'original request', final: 'The requested observation is reported.')
|
|
95
|
+
Timeout.timeout(3) { started.pop }
|
|
96
|
+
PWN::Sessions.append(session_id: @sid, role: 'user', content: 'original request')
|
|
97
|
+
PWN::Sessions.append(session_id: @sid, role: 'tool', content: 'pwn_eval → {"success":false,"error":"different action"}')
|
|
98
|
+
release << true
|
|
99
|
+
finalizer.join_all!(timeout: 5)
|
|
100
|
+
tools = PWN::Sessions.load(session_id: @sid).select { |row| row[:role] == 'tool' }
|
|
101
|
+
expect(tools.map { |row| row[:step_reward] }).to eq([1, nil])
|
|
102
|
+
expect(prompts.size).to eq(1)
|
|
103
|
+
expect(prompts.pop).to include('shell')
|
|
104
|
+
ensure
|
|
105
|
+
release << true if release
|
|
106
|
+
finalizer&.join_all!(timeout: 5)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'binds copy-on-write retained annotations to the scored original action', :retained_binding_boundary do
|
|
110
|
+
learning = PWN::AI::Agent::Learning
|
|
111
|
+
old_body = old_path = nil
|
|
112
|
+
allow(PWN::AI::Ollama).to receive(:chat) do
|
|
113
|
+
append_next_turn
|
|
114
|
+
learning.note_outcome(task: 'original request', success: true, session_id: @sid)
|
|
115
|
+
learning.migrate_evidence(dry_run: false)
|
|
116
|
+
reference = learning.outcomes.first.fetch(:evidence_ref).fetch(:sha256)
|
|
117
|
+
old_path = File.join(File.dirname(learning::LEARNING_FILE), 'learning', 'evidence', "#{reference}.json")
|
|
118
|
+
old_body = File.binread(old_path)
|
|
119
|
+
File.rename(File.join(PWN::Sessions.sessions_dir, "#{@sid}.jsonl"), File.join(@tmp, 'retired-transcript-fixture'))
|
|
120
|
+
'1'
|
|
121
|
+
end
|
|
122
|
+
described_class.prm(request: 'original request', session_id: @sid)
|
|
123
|
+
tools = learning.session_evidence(session_id: @sid).select { |row| row[:role] == 'tool' }
|
|
124
|
+
expect(tools.map { |row| row[:step_reward] }).to eq([1, nil])
|
|
125
|
+
expect(File.binread(old_path)).to eq(old_body)
|
|
126
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(1)
|
|
127
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(0)
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'pwn/ai/agent/tools/ruby_eval'
|
|
5
|
+
require 'pwn/ai/agent/tools/shell'
|
|
6
|
+
|
|
7
|
+
RSpec.describe 'AI learning dispatch result review' do
|
|
8
|
+
include_context 'pwn tmp sandbox'
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
12
|
+
@agent_cfg[:reward_llm] = false
|
|
13
|
+
PWN::Env[:ai][:sandbox] = 'off'
|
|
14
|
+
@saved_runtime = Thread.current[:pwn_request_runtime]
|
|
15
|
+
Thread.current[:pwn_request_runtime] = nil
|
|
16
|
+
stub_const('PWN::AI::Agent::Engagement::ROOT', File.join(@tmp, 'engagements'))
|
|
17
|
+
stub_const('PWN::AI::Agent::Engagement::ACTIVE_FILE', File.join(@tmp, 'engagements', 'active'))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
after do
|
|
21
|
+
Thread.current[:pwn_request_runtime] = @saved_runtime
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def dispatch(name, args)
|
|
25
|
+
PWN::AI::Agent::Dispatch.call(tool_call: { id: 'outcome-fixture', function: { name: name, arguments: JSON.generate(args) } })
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
["{success: false, error: 'File.write failed in the fixture'}", "{'ok' => false}"].each do |code|
|
|
29
|
+
it "separates completed evaluation from application failure for #{code}" do
|
|
30
|
+
raw = dispatch('pwn_eval', code: code, timeout: 3)
|
|
31
|
+
result = JSON.parse(raw)
|
|
32
|
+
expect(result.dig('result', 'value')).to include('false')
|
|
33
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'pwn_eval', raw: raw)).to include(semantic_ok: false)
|
|
34
|
+
expect(result.dig('result', 'execution_success')).to be(true)
|
|
35
|
+
expect(result.dig('result', 'application_status')).to eq('failed')
|
|
36
|
+
state = PWN::AI::Agent::TaskSummarizer.fresh(request: 'Write the required report')
|
|
37
|
+
state[:plan] = ['Write the required report', 'Present the report']
|
|
38
|
+
PWN::AI::Agent::TaskSummarizer.record!(state: state, name: 'pwn_eval', args: { code: code }, result: raw)
|
|
39
|
+
expect(state[:plan_idx]).to eq(0)
|
|
40
|
+
expect(PWN::AI::Agent::Reward.prm(request: state[:request], trace: ["pwn_eval → #{raw}"]).first[:reward]).to eq(-1)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'does not let a provider override an observed application failure with positive credit' do
|
|
45
|
+
@agent_cfg[:reward_llm] = true
|
|
46
|
+
allow(PWN::AI::Ollama).to receive(:chat).and_return('1')
|
|
47
|
+
raw = dispatch('pwn_eval', code: '{success: false}', timeout: 3)
|
|
48
|
+
expect(PWN::AI::Agent::Reward.prm(request: 'original request', trace: ["pwn_eval → #{raw}"]).first[:reward]).to be <= 0
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'keeps a Loop-capped successful observation unknown rather than inventing a negative reward' do
|
|
52
|
+
PWN::Env[:ai][:active] = :openai
|
|
53
|
+
raw = dispatch('pwn_eval', code: "'a' * 1500", timeout: 3)
|
|
54
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'pwn_eval', raw: raw)[:semantic_ok]).to be(true)
|
|
55
|
+
conditioned = PWN::AI::Agent::Result.condition(content: raw, entry: PWN::AI::Agent::Registry.lookup(name: 'pwn_eval'))
|
|
56
|
+
cap = PWN::AI::Agent::Loop.send(:session_tool_budget, name: 'pwn_eval', result: conditioned)
|
|
57
|
+
sid = PWN::Sessions.create(title: 'capped result fixture')[:id]
|
|
58
|
+
PWN::Sessions.append(session_id: sid, role: 'user', content: 'original request')
|
|
59
|
+
PWN::Sessions.append(session_id: sid, role: 'tool', content: "pwn_eval → #{conditioned[0, cap]}")
|
|
60
|
+
rows = PWN::AI::Agent::Reward.prm(request: 'original request', session_id: sid)
|
|
61
|
+
expect(rows.first[:reward]).to be_nil
|
|
62
|
+
expect(PWN::Sessions.load(session_id: sid).last[:step_reward]).to be_nil
|
|
63
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(0)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'keeps malformed and untyped status evidence unknown even if a judge returns a score' do
|
|
67
|
+
@agent_cfg[:reward_llm] = true
|
|
68
|
+
allow(PWN::AI::Ollama).to receive(:chat).and_return('1')
|
|
69
|
+
['shell → {"success":true', 'shell → timeout success:false', 'shell → {"result":{"stdout":"success"}}'].each do |trace|
|
|
70
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'shell', raw: trace)).to include(semantic_ok: nil, shape: :unknown)
|
|
71
|
+
expect(PWN::AI::Agent::Reward.prm(request: 'original request', trace: [trace]).first[:reward]).to be_nil
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
it 'does not persist unknown capped observations as Loop mistakes or failure metrics' do
|
|
76
|
+
raw = dispatch('pwn_eval', code: "'a' * 1500", timeout: 3)
|
|
77
|
+
verdict = PWN::AI::Agent::Loop.send(:record_metrics, name: 'pwn_eval', raw: raw[0, 64], args: { code: 'inert fixture' })
|
|
78
|
+
expect(verdict).to include(ok: nil, mistake: nil)
|
|
79
|
+
expect(PWN::AI::Agent::Metrics.summary).to be_empty
|
|
80
|
+
expect(File).not_to exist(PWN::AI::Agent::Mistakes::MISTAKES_FILE)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it 'classifies an actual informational grep miss without a false timeout fingerprint' do
|
|
84
|
+
args = { command: 'grep absent /dev/null', timeout: 3 }
|
|
85
|
+
raw = dispatch('shell', args)
|
|
86
|
+
expect(JSON.parse(raw).dig('result', 'exit')).to eq(1)
|
|
87
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'shell', raw: raw, args: args)).to include(ok: false, semantic_ok: true, benign: true, shape: nil)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it 'preserves informational shell classification in the retained PRM trace without argv' do
|
|
91
|
+
raw = dispatch('shell', command: 'grep absent /dev/null', timeout: 3)
|
|
92
|
+
sid = PWN::Sessions.create(title: 'informational observation')[:id]
|
|
93
|
+
PWN::Sessions.append(session_id: sid, role: 'user', content: 'Find a matching record')
|
|
94
|
+
PWN::Sessions.append(session_id: sid, role: 'tool', content: "shell → #{raw}")
|
|
95
|
+
steps = PWN::AI::Agent::Reward.prm(request: 'Find a matching record', session_id: sid)
|
|
96
|
+
expect(steps.first[:reward]).to eq(0)
|
|
97
|
+
expect(PWN::Sessions.load(session_id: sid).last[:step_reward]).to eq(0)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
it 'keeps real failures distinct from timeout configuration and informational exits' do
|
|
101
|
+
['false', 'grep absent /dev/null | false', 'grep absent /nonexistent-fixture'].each do |command|
|
|
102
|
+
raw = dispatch('shell', command: command, timeout: 3)
|
|
103
|
+
verdict = PWN::AI::Agent::Reward.semantic_ok(name: 'shell', raw: raw, args: { command: command })
|
|
104
|
+
expect(verdict).to include(semantic_ok: false, benign: false)
|
|
105
|
+
expect(verdict[:shape]).not_to eq(:timeout)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it 'does not credit failed write text to a later real successful no-op' do
|
|
110
|
+
state = PWN::AI::Agent::TaskSummarizer.fresh(request: 'Write the required report')
|
|
111
|
+
state[:plan] = ['Write the required report', 'Present the report']
|
|
112
|
+
["{success: false, error: 'File.write could not create report'}", '1 + 1'].each do |code|
|
|
113
|
+
raw = dispatch('pwn_eval', code: code, timeout: 3)
|
|
114
|
+
PWN::AI::Agent::TaskSummarizer.record!(state: state, name: 'pwn_eval', args: { code: code }, result: raw)
|
|
115
|
+
expect(state[:plan_idx]).to eq(0)
|
|
116
|
+
end
|
|
117
|
+
expect(state[:events].map { |row| row[:ok] }).to eq([false, true])
|
|
118
|
+
expect(state[:request]).to eq('Write the required report')
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'does not treat mutation words in successful no-op output as an observed write effect' do
|
|
122
|
+
state = PWN::AI::Agent::TaskSummarizer.fresh(request: 'Write the required report')
|
|
123
|
+
state[:plan] = ['Write the required report', 'Present the report']
|
|
124
|
+
code = "'wrote the report'"
|
|
125
|
+
raw = dispatch('pwn_eval', code: code, timeout: 3)
|
|
126
|
+
PWN::AI::Agent::TaskSummarizer.record!(state: state, name: 'pwn_eval', args: { code: code }, result: raw)
|
|
127
|
+
expect(state[:plan_idx]).to eq(0)
|
|
128
|
+
expect(PWN::AI::Agent::TaskSummarizer.unfinished_tasks(state: state).map { |row| row[:idx] }).to include(0)
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'preserves typed application failure across the sandbox boundary', :sandbox_outcome_boundary do
|
|
132
|
+
PWN::Env[:ai][:sandbox] = 'permissive'
|
|
133
|
+
expect(PWN::Plugins::AISandbox.mode).to eq(:permissive)
|
|
134
|
+
raw = dispatch('pwn_eval', code: '{success: false}', timeout: 3)
|
|
135
|
+
expect(JSON.parse(raw).dig('result', 'execution_success')).to be(true)
|
|
136
|
+
expect(JSON.parse(raw).dig('result', 'application_status')).to eq('failed')
|
|
137
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'pwn_eval', raw: raw)[:semantic_ok]).to be(false)
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
it 'retains typed application and execution status even when a large result is paged' do
|
|
141
|
+
raw = dispatch('pwn_eval', code: "{success: false, details: 'x' * 10000}", timeout: 3)
|
|
142
|
+
parsed = JSON.parse(raw)
|
|
143
|
+
expect(parsed).to include('success' => false, 'execution_success' => true, 'application_status' => 'failed')
|
|
144
|
+
expect(parsed.dig('result', 'artifact')).not_to be_nil
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it 'does not interpret stdout or inspected string values as application status' do
|
|
148
|
+
raw = dispatch('pwn_eval', code: "puts '{\"success\":false}'; '{success: false}'", timeout: 3)
|
|
149
|
+
result = JSON.parse(raw)
|
|
150
|
+
expect(result.dig('result', 'execution_success')).to be(true)
|
|
151
|
+
expect(result.dig('result', 'application_status')).to eq('unknown')
|
|
152
|
+
expect(PWN::AI::Agent::Reward.semantic_ok(name: 'pwn_eval', raw: raw)).to include(semantic_ok: true)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::Reward, 'structured result envelopes' do
|
|
6
|
+
it 'classifies pretty printed JSON the same as compact JSON' do
|
|
7
|
+
raw = JSON.pretty_generate(success: true, result: { exit: 0, stdout: 'fixture', stderr: '' })
|
|
8
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(ok: true, semantic_ok: true, exit: 0)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'does not borrow a nested success flag for a failed dispatch' do
|
|
12
|
+
raw = JSON.generate(success: false, error: 'dispatch failed', result: { success: true })
|
|
13
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(ok: false, semantic_ok: false)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'recognizes negative exits rather than treating them as absent' do
|
|
17
|
+
raw = JSON.generate(success: true, result: { exit: -1, stdout: '', stderr: '' })
|
|
18
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(semantic_ok: false, exit: -1)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'does not classify observed timeout and invalid_payload text as an execution error' do
|
|
22
|
+
raw = JSON.generate(success: true, result: { exit: 0, stdout: 'documentation: timeout after 20s invalid_payload', stderr: '' })
|
|
23
|
+
expect(described_class.semantic_ok(name: 'shell', raw: "shell → #{raw}")).to include(semantic_ok: true)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'does not accept an explicitly failed nested result' do
|
|
27
|
+
raw = JSON.generate(success: true, result: { success: false, error: 'fixture failure' })
|
|
28
|
+
expect(described_class.semantic_ok(name: 'pwn_eval', raw: raw)).to include(ok: true, semantic_ok: false)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'does not treat a nested informational_exit flag as a dispatch envelope marker' do
|
|
32
|
+
raw = JSON.generate(success: false, result: { exit: 1, informational_exit: true, stdout: '', stderr: '' })
|
|
33
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(semantic_ok: false, benign: false, shape: :nonzero_exit)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'does not let an envelope informational_exit launder a nested false result' do
|
|
37
|
+
raw = JSON.generate(success: false, informational_exit: true, result: { exit: 1, success: false, stdout: '', stderr: '' })
|
|
38
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(semantic_ok: false, benign: false)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'keeps a dispatch envelope informational_exit benign without argv' do
|
|
42
|
+
raw = JSON.generate(success: false, informational_exit: true, result: { exit: 1, stdout: '', stderr: '' })
|
|
43
|
+
expect(described_class.semantic_ok(name: 'shell', raw: raw)).to include(ok: false, semantic_ok: true, benign: true, shape: nil)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::Reward, 'turn-scoped process rewards' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(described_class).to receive(:llm_prm).and_return(nil)
|
|
10
|
+
@sid = PWN::Sessions.create(title: 'offline process reward fixture')[:id]
|
|
11
|
+
[
|
|
12
|
+
['user', 'earlier request'],
|
|
13
|
+
['tool', 'shell → {"success":true,"result":{"exit":0}}'],
|
|
14
|
+
['assistant', 'earlier answer'],
|
|
15
|
+
['user', 'current request'],
|
|
16
|
+
['tool', 'pwn_eval → {"success":true,"result":{"exit":0}}'],
|
|
17
|
+
['assistant', 'current answer']
|
|
18
|
+
].each { |role, content| PWN::Sessions.append(session_id: @sid, role: role, content: content) }
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'annotates the same latest-turn tools that were scored in the live session' do
|
|
22
|
+
described_class.prm(request: 'current request', session_id: @sid)
|
|
23
|
+
tools = PWN::Sessions.load(session_id: @sid).select { |row| row[:role] == 'tool' }
|
|
24
|
+
expect(tools.map { |row| row[:step_reward] }).to eq([nil, 1])
|
|
25
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(0)
|
|
26
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(1)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'annotates the same latest-turn tools in retained immutable evidence' do
|
|
30
|
+
learning = PWN::AI::Agent::Learning
|
|
31
|
+
learning.note_outcome(task: 'current request', success: true, session_id: @sid)
|
|
32
|
+
learning.migrate_evidence(dry_run: false)
|
|
33
|
+
File.unlink(File.join(PWN::Sessions::SESSIONS_DIR, "#{@sid}.jsonl"))
|
|
34
|
+
described_class.prm(request: 'current request', session_id: @sid)
|
|
35
|
+
tools = learning.session_evidence(session_id: @sid).select { |row| row[:role] == 'tool' }
|
|
36
|
+
expect(tools.map { |row| row[:step_reward] }).to eq([nil, 1])
|
|
37
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'shell')).to eq(0)
|
|
38
|
+
expect(PWN::AI::Agent::Metrics.prm_n(name: 'pwn_eval')).to eq(1)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -242,9 +242,9 @@ describe PWN::AI::Agent::Swarm do
|
|
|
242
242
|
end
|
|
243
243
|
|
|
244
244
|
it 'maps several ports and returns a merged result set' do
|
|
245
|
+
expect(PWN::Plugins::Packet).to receive(:tcp_connect_scan).with(hosts: ['127.0.0.1'], ports: [1, 9, 22, 80]).and_return(results: [1, 9, 22, 80].map { |port| { host: '127.0.0.1', port: port, open: false } })
|
|
245
246
|
rows = described_class.map_targets(targets: '127.0.0.1', ports: '1,9,22,80')
|
|
246
|
-
expect(rows
|
|
247
|
-
expect(rows.map { |r| r[:port] }.uniq.length).to eq(4)
|
|
247
|
+
expect(rows).to eq([1, 9, 22, 80].map { |port| { host: '127.0.0.1', port: port, open: false } })
|
|
248
248
|
end
|
|
249
249
|
|
|
250
250
|
it 'allows only one live claim per unit' do
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe PWN::AI::Agent::TaskDAG, 'execution failure reporting' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it 'preserves Dispatch failure when a shell command exits nonzero without an error field' do
|
|
13
|
+
dag = described_class.plan(request: 'check command status', steps: [
|
|
14
|
+
{ id: 'probe', tool: 'shell', args: { command: 'exit 7', timeout: 5 } }
|
|
15
|
+
])
|
|
16
|
+
report = described_class.execute(dag: dag, root: @tmp, run_id: 'failed-exit')
|
|
17
|
+
|
|
18
|
+
expect(report[:results].first[:result]).to include(exit: 7)
|
|
19
|
+
expect(report[:results].first[:ok]).to be false
|
|
20
|
+
expect(report[:ok]).to be false
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it 'halts at failed prerequisites and retries them rather than skipping them on resume' do
|
|
24
|
+
ready = File.join(@tmp, 'ready')
|
|
25
|
+
output = File.join(@tmp, 'dependent.txt')
|
|
26
|
+
dag = described_class.plan(request: 'wait for readiness then record it', steps: [
|
|
27
|
+
{ id: 'ready', tool: 'shell', args: { command: "test -f #{Shellwords.escape(ready)}", timeout: 5 } },
|
|
28
|
+
{ id: 'dependent', tool: 'shell', args: { command: "printf ready > #{Shellwords.escape(output)}", timeout: 5 }, dependencies: ['ready'] }
|
|
29
|
+
])
|
|
30
|
+
report = described_class.execute(dag: dag, root: @tmp, run_id: 'retry-failed')
|
|
31
|
+
|
|
32
|
+
expect(report[:ok]).to be false
|
|
33
|
+
expect(File.exist?(output)).to be false
|
|
34
|
+
expect(report[:results].map { |row| row[:id] }).to eq(['ready'])
|
|
35
|
+
checkpoints = File.join(@tmp, 'retry-failed', 'checkpoints.jsonl')
|
|
36
|
+
expect(JSON.parse(File.read(checkpoints))).to include('id' => 'ready', 'status' => 'failed')
|
|
37
|
+
|
|
38
|
+
File.write(ready, 'ready')
|
|
39
|
+
resumed = described_class.resume(root: @tmp, run_id: 'retry-failed')
|
|
40
|
+
expect(resumed[:ok]).to be true
|
|
41
|
+
expect(resumed[:results].map { |row| row[:id] }).to eq(%w[ready dependent])
|
|
42
|
+
expect(File.read(output)).to eq('ready')
|
|
43
|
+
expect(File.readlines(checkpoints).map { |line| JSON.parse(line)['status'] }).to eq(%w[failed completed completed])
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe PWN::AI::Agent::TaskSummarizer, 'failed dispatch advancement' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
it 'does not mark a failed write as completed because its error mentions File.write' do
|
|
9
|
+
state = described_class.fresh(request: 'write the required report')
|
|
10
|
+
state[:plan] = ['Write the report', 'Present the report']
|
|
11
|
+
result = JSON.generate(success: false, error: 'File.write could not create report')
|
|
12
|
+
described_class.record!(state: state, name: 'pwn_eval', args: { code: 'File.write(report, content)' }, result: result)
|
|
13
|
+
expect(state[:events].last[:ok]).to be(false)
|
|
14
|
+
expect(state[:plan_idx]).to eq(0)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'does not advance through the phase-handoff fallback after failed dispatches' do
|
|
18
|
+
state = described_class.fresh(request: 'inspect then patch the report')
|
|
19
|
+
state[:plan] = ['Inspect the report', 'Patch the report', 'Present the result']
|
|
20
|
+
2.times do
|
|
21
|
+
described_class.record!(state: state, name: 'shell', args: { command: 'sed -i replacement report' }, result: '{"success":false,"error":"fixture failure"}')
|
|
22
|
+
end
|
|
23
|
+
expect(state[:plan_idx]).to eq(0)
|
|
24
|
+
expect(state[:last_prm_signal]).to eq(:hold_regress)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'verify file matching through Dispatch' do
|
|
6
|
+
include_context 'pwn tmp sandbox'
|
|
7
|
+
|
|
8
|
+
before do
|
|
9
|
+
allow(Dir).to receive(:home).and_return(@tmp)
|
|
10
|
+
PWN::AI::Agent::Registry.discover
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'does not verify missing or directory paths as empty files' do
|
|
14
|
+
[File.join(@tmp, 'missing.txt'), @tmp].each do |path|
|
|
15
|
+
response = JSON.parse(PWN::AI::Agent::Dispatch.call(
|
|
16
|
+
tool_call: { function: { name: 'verify', arguments: JSON.generate(checks: [{ type: 'file_grep', path: path, pattern: '\\A\\z' }]) } }
|
|
17
|
+
), symbolize_names: true)
|
|
18
|
+
|
|
19
|
+
expect(response.dig(:result, :passed)).to be(false), "incorrect verification for #{path}: #{response}"
|
|
20
|
+
expect(response.dig(:result, :results, 0)).to include(type: 'file_grep', passed: false, path: path)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'can verify an existing empty file with an empty-content expression' do
|
|
25
|
+
path = File.join(@tmp, 'empty.txt')
|
|
26
|
+
File.write(path, '')
|
|
27
|
+
response = JSON.parse(PWN::AI::Agent::Dispatch.call(
|
|
28
|
+
tool_call: { function: { name: 'verify', arguments: JSON.generate(checks: [{ type: 'file_grep', path: path, pattern: '\\A\\z' }]) } }
|
|
29
|
+
), symbolize_names: true)
|
|
30
|
+
|
|
31
|
+
expect(response.dig(:result, :passed)).to be true
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
require 'tmpdir'
|
|
5
|
+
require 'digest'
|
|
6
|
+
|
|
7
|
+
RSpec.describe PWN::AI::Context, 'byte range regressions' do
|
|
8
|
+
{ (0..0) => 'a', (1..3) => 'bcd', (1...3) => 'bc', (2...2) => '' }.each do |range, expected|
|
|
9
|
+
it "persists precisely the bytes selected by #{range.inspect}" do
|
|
10
|
+
Dir.mktmpdir('context-range-audit-') do |dir|
|
|
11
|
+
allow(Dir).to receive(:home).and_return(dir)
|
|
12
|
+
stub_const('PWN::Plugins::ArtifactRegistry::ROOT', File.join(dir, 'artifacts'))
|
|
13
|
+
path = File.join(dir, 'source.txt')
|
|
14
|
+
File.binwrite(path, 'abcdef')
|
|
15
|
+
result = described_class.attach_file(path: path, range: range, session_id: 'fixture-range')
|
|
16
|
+
expect(File.binread(result[:path])).to eq(expected)
|
|
17
|
+
expect(result[:chunks].join).to eq(expected)
|
|
18
|
+
expect(result[:size]).to eq(expected.bytesize)
|
|
19
|
+
expect(result[:sha256]).to eq(Digest::SHA256.hexdigest(expected))
|
|
20
|
+
expect(File.binread(path)).to eq('abcdef')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|