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.
Files changed (369) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/bin/pwn_autoinc_version +4 -5
  4. data/bin/pwn_web_cache_deception +40 -29
  5. data/documentation/AWS.md +15 -5
  6. data/documentation/Diagrams.md +1 -1
  7. data/documentation/Home.md +2 -2
  8. data/documentation/How-PWN-Works.md +1 -1
  9. data/documentation/What-is-PWN.md +1 -1
  10. data/documentation/diagrams/aws-cloud-security.svg +1 -1
  11. data/documentation/diagrams/dot/aws-cloud-security.dot +1 -1
  12. data/documentation/diagrams/dot/network-infra-testing.dot +1 -1
  13. data/documentation/diagrams/network-infra-testing.svg +1 -1
  14. data/etc/default_cron/session_cleanup.rb +84 -51
  15. data/lib/pwn/ai/agent/assembly.rb +0 -2
  16. data/lib/pwn/ai/agent/btc.rb +0 -2
  17. data/lib/pwn/ai/agent/burp_suite.rb +0 -2
  18. data/lib/pwn/ai/agent/curriculum.rb +2 -2
  19. data/lib/pwn/ai/agent/dispatch.rb +3 -0
  20. data/lib/pwn/ai/agent/engagement.rb +96 -41
  21. data/lib/pwn/ai/agent/extrospection/osint/bridges.rb +2 -0
  22. data/lib/pwn/ai/agent/extrospection.rb +50 -13
  23. data/lib/pwn/ai/agent/gqrx.rb +0 -2
  24. data/lib/pwn/ai/agent/hacker_one.rb +0 -2
  25. data/lib/pwn/ai/agent/learning.rb +45 -13
  26. data/lib/pwn/ai/agent/loop.rb +12 -11
  27. data/lib/pwn/ai/agent/metrics.rb +1 -1
  28. data/lib/pwn/ai/agent/mission.rb +6 -3
  29. data/lib/pwn/ai/agent/policy.rb +1 -1
  30. data/lib/pwn/ai/agent/policy_evaluation.rb +2 -2
  31. data/lib/pwn/ai/agent/reflect.rb +1 -0
  32. data/lib/pwn/ai/agent/request_runtime.rb +1 -1
  33. data/lib/pwn/ai/agent/reward.rb +155 -53
  34. data/lib/pwn/ai/agent/sast.rb +0 -2
  35. data/lib/pwn/ai/agent/task_dag.rb +5 -3
  36. data/lib/pwn/ai/agent/task_summarizer.rb +21 -11
  37. data/lib/pwn/ai/agent/tool_guard.rb +19 -0
  38. data/lib/pwn/ai/agent/tools/ruby_eval.rb +1 -1
  39. data/lib/pwn/ai/agent/tools/verify.rb +7 -3
  40. data/lib/pwn/ai/agent/transparent_browser.rb +0 -2
  41. data/lib/pwn/ai/agent/turn_finalizer.rb +3 -0
  42. data/lib/pwn/ai/anthropic.rb +3 -3
  43. data/lib/pwn/ai/context.rb +2 -1
  44. data/lib/pwn/ai/gemini.rb +7 -5
  45. data/lib/pwn/ai/grok.rb +37 -18
  46. data/lib/pwn/ai/mcp.rb +17 -5
  47. data/lib/pwn/ai/ollama.rb +76 -35
  48. data/lib/pwn/ai/open_ai.rb +7 -19
  49. data/lib/pwn/ai/open_web_ui.rb +76 -40
  50. data/lib/pwn/aws/cloud_search_domain.rb +6 -0
  51. data/lib/pwn/aws/iam.rb +2 -2
  52. data/lib/pwn/aws/workspaces.rb +2 -2
  53. data/lib/pwn/aws.rb +0 -5
  54. data/lib/pwn/bounty/lifecycle_authz_replay.rb +1 -1
  55. data/lib/pwn/config.rb +17 -10
  56. data/lib/pwn/corpus.rb +33 -5
  57. data/lib/pwn/cron.rb +60 -17
  58. data/lib/pwn/driver.rb +2 -3
  59. data/lib/pwn/engagement.rb +28 -10
  60. data/lib/pwn/ffi/capstone.rb +3 -2
  61. data/lib/pwn/ffi/fftw.rb +8 -6
  62. data/lib/pwn/ffi/keystone.rb +3 -2
  63. data/lib/pwn/ffi/soapy_sdr.rb +10 -6
  64. data/lib/pwn/json_text.rb +25 -13
  65. data/lib/pwn/memory_index.rb +6 -4
  66. data/lib/pwn/module_skills.rb +3 -1
  67. data/lib/pwn/plugins/aflplusplus.rb +1 -0
  68. data/lib/pwn/plugins/ai_sandbox.rb +42 -10
  69. data/lib/pwn/plugins/android.rb +429 -466
  70. data/lib/pwn/plugins/artifact_registry.rb +12 -2
  71. data/lib/pwn/plugins/assembly.rb +9 -42
  72. data/lib/pwn/plugins/authentication_helper.rb +4 -3
  73. data/lib/pwn/plugins/baresip.rb +70 -28
  74. data/lib/pwn/plugins/binary_analysis.rb +14 -5
  75. data/lib/pwn/plugins/binary_parser.rb +42 -7
  76. data/lib/pwn/plugins/black_duck_binary_analysis.rb +3 -3
  77. data/lib/pwn/plugins/burp_suite.rb +15 -12
  78. data/lib/pwn/plugins/bus_pirate.rb +3 -7
  79. data/lib/pwn/plugins/char.rb +9 -3
  80. data/lib/pwn/plugins/credit_card.rb +7 -0
  81. data/lib/pwn/plugins/dao_ldap.rb +2 -2
  82. data/lib/pwn/plugins/dao_mongo.rb +1 -1
  83. data/lib/pwn/plugins/debugger.rb +1 -1
  84. data/lib/pwn/plugins/defect_dojo.rb +7 -3
  85. data/lib/pwn/plugins/detect_os.rb +1 -1
  86. data/lib/pwn/plugins/detonate.rb +9 -19
  87. data/lib/pwn/plugins/exploit_db.rb +1 -1
  88. data/lib/pwn/plugins/file_fu.rb +4 -1
  89. data/lib/pwn/plugins/findings.rb +76 -2
  90. data/lib/pwn/plugins/fuzz.rb +12 -3
  91. data/lib/pwn/plugins/gdb.rb +7 -2
  92. data/lib/pwn/plugins/gdbmi.rb +10 -6
  93. data/lib/pwn/plugins/git.rb +18 -13
  94. data/lib/pwn/plugins/github.rb +11 -6
  95. data/lib/pwn/plugins/google_workspace.rb +11 -3
  96. data/lib/pwn/plugins/hacker_one.rb +5 -1
  97. data/lib/pwn/plugins/httpx.rb +24 -8
  98. data/lib/pwn/plugins/ip_info.rb +11 -8
  99. data/lib/pwn/plugins/irc.rb +73 -45
  100. data/lib/pwn/plugins/jenkins.rb +2 -2
  101. data/lib/pwn/plugins/jira_data_center.rb +13 -6
  102. data/lib/pwn/plugins/jobs.rb +62 -4
  103. data/lib/pwn/plugins/log.rb +1 -1
  104. data/lib/pwn/plugins/monkey_patch.rb +1 -1
  105. data/lib/pwn/plugins/msr206.rb +157 -182
  106. data/lib/pwn/plugins/nessus_cloud.rb +2 -2
  107. data/lib/pwn/plugins/nexpose_vuln_scan.rb +44 -33
  108. data/lib/pwn/plugins/nuclei.rb +24 -8
  109. data/lib/pwn/plugins/ocr.rb +3 -1
  110. data/lib/pwn/plugins/open_api.rb +0 -4
  111. data/lib/pwn/plugins/openvas.rb +31 -43
  112. data/lib/pwn/plugins/packet.rb +40 -25
  113. data/lib/pwn/plugins/pony.rb +2 -2
  114. data/lib/pwn/plugins/preflight_checker.rb +1 -1
  115. data/lib/pwn/plugins/process_tube.rb +17 -2
  116. data/lib/pwn/plugins/ps.rb +6 -1
  117. data/lib/pwn/plugins/repl/ai.rb +1 -0
  118. data/lib/pwn/plugins/repl/ai_console.rb +12 -5
  119. data/lib/pwn/plugins/repl/mesh.rb +10 -2
  120. data/lib/pwn/plugins/sbom.rb +59 -27
  121. data/lib/pwn/plugins/scannable_codes.rb +3 -1
  122. data/lib/pwn/plugins/serial.rb +102 -44
  123. data/lib/pwn/plugins/shodan.rb +4 -10
  124. data/lib/pwn/plugins/sock.rb +16 -11
  125. data/lib/pwn/plugins/ssn.rb +3 -1
  126. data/lib/pwn/plugins/transparent_browser.rb +43 -3
  127. data/lib/pwn/plugins/vault.rb +92 -30
  128. data/lib/pwn/plugins/vin.rb +2 -1
  129. data/lib/pwn/plugins/vsphere.rb +2 -1
  130. data/lib/pwn/plugins/xxd.rb +3 -5
  131. data/lib/pwn/plugins/yubikey/security_domain/scp.rb +4 -0
  132. data/lib/pwn/plugins/yubikey/transport.rb +42 -11
  133. data/lib/pwn/plugins/yubikey.rb +21 -6
  134. data/lib/pwn/plugins/zaproxy.rb +3 -4
  135. data/lib/pwn/reports/ai_red_team.rb +4 -4
  136. data/lib/pwn/reports/pdf.rb +9 -5
  137. data/lib/pwn/reports/sast.rb +4 -4
  138. data/lib/pwn/sast/keystore.rb +2 -2
  139. data/lib/pwn/sast/logger.rb +1 -1
  140. data/lib/pwn/sast/php_type_juggling.rb +3 -6
  141. data/lib/pwn/sast/pom_version.rb +12 -6
  142. data/lib/pwn/sast/port.rb +1 -1
  143. data/lib/pwn/sast/sql.rb +3 -7
  144. data/lib/pwn/sast/test_case_engine.rb +62 -16
  145. data/lib/pwn/sast/type_script_type_juggling.rb +3 -6
  146. data/lib/pwn/sdr/decoder/base.rb +8 -0
  147. data/lib/pwn/sdr/decoder/lora.rb +1 -1
  148. data/lib/pwn/sdr/flipper_zero.rb +4 -7
  149. data/lib/pwn/sdr/gqrx.rb +35 -16
  150. data/lib/pwn/sdr/son_micro_rfid.rb +44 -26
  151. data/lib/pwn/sdr.rb +1 -1
  152. data/lib/pwn/session_trace.rb +7 -2
  153. data/lib/pwn/sessions.rb +307 -39
  154. data/lib/pwn/setup.rb +4 -3
  155. data/lib/pwn/version.rb +1 -1
  156. data/lib/pwn/www/app_cobalt_io.rb +14 -2
  157. data/lib/pwn/www/bing.rb +13 -1
  158. data/lib/pwn/www/bug_crowd.rb +14 -2
  159. data/lib/pwn/www/checkip.rb +13 -1
  160. data/lib/pwn/www/coinbase_pro.rb +14 -2
  161. data/lib/pwn/www/duckduckgo.rb +13 -1
  162. data/lib/pwn/www/facebook.rb +14 -2
  163. data/lib/pwn/www/github.rb +14 -2
  164. data/lib/pwn/www/google.rb +13 -1
  165. data/lib/pwn/www/hacker_one.rb +117 -33
  166. data/lib/pwn/www/linkedin.rb +14 -2
  167. data/lib/pwn/www/pandora.rb +14 -2
  168. data/lib/pwn/www/pastebin.rb +13 -1
  169. data/lib/pwn/www/paypal.rb +16 -4
  170. data/lib/pwn/www/synack.rb +14 -2
  171. data/lib/pwn/www/torch.rb +17 -3
  172. data/lib/pwn/www/trading_view.rb +14 -2
  173. data/lib/pwn/www/twitter.rb +14 -2
  174. data/lib/pwn/www/uber.rb +14 -2
  175. data/lib/pwn/www/upwork.rb +14 -2
  176. data/lib/pwn/www/wayback_machine.rb +16 -2
  177. data/lib/pwn/www/youtube.rb +13 -1
  178. data/pwn.gemspec +4 -0
  179. data/spec/integration/authentication_helper_oath_spec.rb +1 -1
  180. data/spec/integration/autoinc_lifecycle_supplement_spec.rb +47 -0
  181. data/spec/integration/gemspec_deleted_files_spec.rb +43 -0
  182. data/spec/integration/spec_curriculum_isolation_spec.rb +41 -0
  183. data/spec/integration/verify_acceptance_eui_regression_spec.rb +162 -0
  184. data/spec/integration/web_cache_lifecycle_closure_spec.rb +89 -0
  185. data/spec/integration/web_cache_lifecycle_supplement_spec.rb +70 -0
  186. data/spec/lib/pwn/ai/agent/analysis_errors_regression_spec.rb +33 -0
  187. data/spec/lib/pwn/ai/agent/curriculum_cooldown_regression_spec.rb +19 -0
  188. data/spec/lib/pwn/ai/agent/curriculum_spec.rb +2 -0
  189. data/spec/lib/pwn/ai/agent/engagement_boundary_regression_spec.rb +42 -0
  190. data/spec/lib/pwn/ai/agent/engagement_dispatch_review_spec.rb +82 -0
  191. data/spec/lib/pwn/ai/agent/engagement_roe_regression_spec.rb +25 -0
  192. data/spec/lib/pwn/ai/agent/engagement_scope_regression_spec.rb +37 -0
  193. data/spec/lib/pwn/ai/agent/extrospection/osint/bridges_spec.rb +4 -0
  194. data/spec/lib/pwn/ai/agent/extrospection_input_regression_spec.rb +31 -0
  195. data/spec/lib/pwn/ai/agent/extrospection_review_spec.rb +61 -0
  196. data/spec/lib/pwn/ai/agent/extrospection_serial_review_spec.rb +42 -0
  197. data/spec/lib/pwn/ai/agent/extrospection_spec.rb +9 -0
  198. data/spec/lib/pwn/ai/agent/extrospection_verification_regression_spec.rb +39 -0
  199. data/spec/lib/pwn/ai/agent/learning_last_answer_regression_spec.rb +32 -0
  200. data/spec/lib/pwn/ai/agent/learning_lifecycle_closure_spec.rb +84 -0
  201. data/spec/lib/pwn/ai/agent/learning_prune_regression_spec.rb +17 -0
  202. data/spec/lib/pwn/ai/agent/learning_spec.rb +2 -1
  203. data/spec/lib/pwn/ai/agent/loop_execution_audit_spec.rb +30 -0
  204. data/spec/lib/pwn/ai/agent/metrics_usage_regression_spec.rb +20 -0
  205. data/spec/lib/pwn/ai/agent/mission_execution_audit_spec.rb +27 -0
  206. data/spec/lib/pwn/ai/agent/mission_namespace_spec.rb +210 -18
  207. data/spec/lib/pwn/ai/agent/policy_confidence_regression_spec.rb +16 -0
  208. data/spec/lib/pwn/ai/agent/policy_evaluation_spec.rb +1 -1
  209. data/spec/lib/pwn/ai/agent/policy_evaluation_tmp_regression_spec.rb +36 -0
  210. data/spec/lib/pwn/ai/agent/reflect_model_regression_spec.rb +15 -0
  211. data/spec/lib/pwn/ai/agent/request_runtime_execution_audit_spec.rb +43 -0
  212. data/spec/lib/pwn/ai/agent/reward_binding_review_spec.rb +129 -0
  213. data/spec/lib/pwn/ai/agent/reward_dispatch_review_spec.rb +154 -0
  214. data/spec/lib/pwn/ai/agent/reward_envelope_regression_spec.rb +45 -0
  215. data/spec/lib/pwn/ai/agent/reward_turn_regression_spec.rb +40 -0
  216. data/spec/lib/pwn/ai/agent/swarm_spec.rb +2 -2
  217. data/spec/lib/pwn/ai/agent/task_dag_execution_audit_spec.rb +45 -0
  218. data/spec/lib/pwn/ai/agent/task_summarizer_failure_regression_spec.rb +26 -0
  219. data/spec/lib/pwn/ai/agent/tools/verify_execution_audit_spec.rb +33 -0
  220. data/spec/lib/pwn/ai/context_range_audit_spec.rb +24 -0
  221. data/spec/lib/pwn/ai/gemini_roundtrip_audit_spec.rb +33 -0
  222. data/spec/lib/pwn/ai/grok_reasoning_effort_spec.rb +43 -0
  223. data/spec/lib/pwn/ai/mcp_session_audit_spec.rb +36 -0
  224. data/spec/lib/pwn/ai/ollama_spec.rb +6 -11
  225. data/spec/lib/pwn/ai/open_web_ui_spec.rb +6 -11
  226. data/spec/lib/pwn/ai/provider_history_audit_spec.rb +44 -0
  227. data/spec/lib/pwn/ai/provider_operations_audit_spec.rb +53 -0
  228. data/spec/lib/pwn/ai/provider_review_history_stream_regression_spec.rb +143 -0
  229. data/spec/lib/pwn/ai/provider_review_tls_regression_spec.rb +62 -0
  230. data/spec/lib/pwn/ai/provider_stream_audit_spec.rb +49 -0
  231. data/spec/lib/pwn/aws/iam_decoding_regression_spec.rb +23 -0
  232. data/spec/lib/pwn/aws/services_runtime_regression_spec.rb +51 -0
  233. data/spec/lib/pwn/aws_spec.rb +6 -0
  234. data/spec/lib/pwn/banner_operational_audit_spec.rb +105 -0
  235. data/spec/lib/pwn/bounty/lifecycle_authz_replay_spec.rb +17 -0
  236. data/spec/lib/pwn/config_redaction_regression_spec.rb +24 -0
  237. data/spec/lib/pwn/config_skills_regression_spec.rb +38 -0
  238. data/spec/lib/pwn/corpus_core_review_regression_spec.rb +96 -0
  239. data/spec/lib/pwn/corpus_spec.rb +13 -0
  240. data/spec/lib/pwn/cron_core_review_regression_spec.rb +95 -0
  241. data/spec/lib/pwn/cron_execution_spec.rb +75 -0
  242. data/spec/lib/pwn/driver_core_review_regression_spec.rb +38 -0
  243. data/spec/lib/pwn/driver_spec.rb +13 -0
  244. data/spec/lib/pwn/engagement_core_review_regression_spec.rb +88 -0
  245. data/spec/lib/pwn/engagement_storage_regression_spec.rb +44 -0
  246. data/spec/lib/pwn/ffi/capstone_spec.rb +19 -0
  247. data/spec/lib/pwn/ffi/fftw_spec.rb +19 -0
  248. data/spec/lib/pwn/ffi/keystone_spec.rb +13 -0
  249. data/spec/lib/pwn/ffi/soapy_sdr_spec.rb +13 -0
  250. data/spec/lib/pwn/json_text_spec.rb +25 -0
  251. data/spec/lib/pwn/memory_index_spec.rb +23 -0
  252. data/spec/lib/pwn/module_skills_parsing_regression_spec.rb +34 -0
  253. data/spec/lib/pwn/plugins/ai_sandbox_boundary_review_spec.rb +57 -0
  254. data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +10 -18
  255. data/spec/lib/pwn/plugins/android_review_fixes_spec.rb +121 -0
  256. data/spec/lib/pwn/plugins/android_transport_audit_spec.rb +64 -0
  257. data/spec/lib/pwn/plugins/api_import_namespace_audit_spec.rb +49 -0
  258. data/spec/lib/pwn/plugins/artifact_registry_namespace_audit_spec.rb +20 -0
  259. data/spec/lib/pwn/plugins/artifact_registry_review_fixes_spec.rb +63 -0
  260. data/spec/lib/pwn/plugins/assembly_namespace_audit_spec.rb +16 -0
  261. data/spec/lib/pwn/plugins/assembly_review_fixes_spec.rb +33 -0
  262. data/spec/lib/pwn/plugins/authentication_helper_spec.rb +14 -0
  263. data/spec/lib/pwn/plugins/baresip_review_fixes_spec.rb +127 -0
  264. data/spec/lib/pwn/plugins/baresip_transport_audit_spec.rb +59 -0
  265. data/spec/lib/pwn/plugins/binary_analysis_process_review_spec.rb +57 -0
  266. data/spec/lib/pwn/plugins/black_duck_namespace_audit_spec.rb +25 -0
  267. data/spec/lib/pwn/plugins/burp_suite_har_review_fixes_spec.rb +60 -0
  268. data/spec/lib/pwn/plugins/burp_suite_import_review_fixes_spec.rb +62 -0
  269. data/spec/lib/pwn/plugins/burp_suite_namespace_audit_spec.rb +37 -0
  270. data/spec/lib/pwn/plugins/bus_pirate_transport_audit_spec.rb +19 -0
  271. data/spec/lib/pwn/plugins/file_fu_namespace_audit_spec.rb +17 -0
  272. data/spec/lib/pwn/plugins/findings_structured_spec.rb +1 -1
  273. data/spec/lib/pwn/plugins/gdbmi_namespace_audit_spec.rb +28 -0
  274. data/spec/lib/pwn/plugins/gdbmi_review_fixes_spec.rb +73 -0
  275. data/spec/lib/pwn/plugins/github_argv_review_spec.rb +49 -0
  276. data/spec/lib/pwn/plugins/google_workspace_provider_review_oauth_spec.rb +80 -0
  277. data/spec/lib/pwn/plugins/irc_review_fixes_spec.rb +92 -0
  278. data/spec/lib/pwn/plugins/irc_transport_audit_spec.rb +37 -0
  279. data/spec/lib/pwn/plugins/jenkins_namespace_audit_spec.rb +12 -0
  280. data/spec/lib/pwn/plugins/jira_data_center_namespace_audit_spec.rb +44 -0
  281. data/spec/lib/pwn/plugins/jira_data_center_review_fixes_spec.rb +81 -0
  282. data/spec/lib/pwn/plugins/jsonl_elf_review_fixes_spec.rb +59 -0
  283. data/spec/lib/pwn/plugins/log_spec.rb +36 -20
  284. data/spec/lib/pwn/plugins/monkey_patch_spec.rb +16 -0
  285. data/spec/lib/pwn/plugins/msr206_readback_review_fixes_spec.rb +119 -0
  286. data/spec/lib/pwn/plugins/msr206_review_fixes_spec.rb +50 -0
  287. data/spec/lib/pwn/plugins/msr206_transport_audit_spec.rb +64 -0
  288. data/spec/lib/pwn/plugins/nessus_cloud_namespace_audit_spec.rb +14 -0
  289. data/spec/lib/pwn/plugins/nexpose_review_fixes_spec.rb +55 -0
  290. data/spec/lib/pwn/plugins/open_api_namespace_audit_spec.rb +22 -0
  291. data/spec/lib/pwn/plugins/packet_transport_audit_spec.rb +47 -0
  292. data/spec/lib/pwn/plugins/plugins_b_operational_regression_spec.rb +600 -0
  293. data/spec/lib/pwn/plugins/pony_namespace_audit_spec.rb +17 -0
  294. data/spec/lib/pwn/plugins/pony_review_fixes_spec.rb +33 -0
  295. data/spec/lib/pwn/plugins/process_tube_namespace_audit_spec.rb +19 -0
  296. data/spec/lib/pwn/plugins/ps_namespace_audit_spec.rb +12 -0
  297. data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +111 -0
  298. data/spec/lib/pwn/plugins/repl/ai_spec.rb +38 -0
  299. data/spec/lib/pwn/plugins/repl/mesh_spec.rb +52 -0
  300. data/spec/lib/pwn/plugins/sandbox_spec.rb +9 -7
  301. data/spec/lib/pwn/plugins/sbom_review_fixes_spec.rb +43 -0
  302. data/spec/lib/pwn/plugins/scannable_codes_namespace_audit_spec.rb +15 -0
  303. data/spec/lib/pwn/plugins/serial_review_fixes_spec.rb +76 -0
  304. data/spec/lib/pwn/plugins/serial_transport_audit_spec.rb +102 -0
  305. data/spec/lib/pwn/plugins/shodan_namespace_audit_spec.rb +10 -0
  306. data/spec/lib/pwn/plugins/sock_transport_audit_spec.rb +55 -0
  307. data/spec/lib/pwn/plugins/transparent_browser_navigation_review_spec.rb +21 -0
  308. data/spec/lib/pwn/plugins/vault_master_key_eui_regression_spec.rb +242 -0
  309. data/spec/lib/pwn/plugins/vault_spec.rb +58 -0
  310. data/spec/lib/pwn/plugins/vault_store_safety_spec.rb +1 -1
  311. data/spec/lib/pwn/plugins/xxd_namespace_audit_spec.rb +34 -0
  312. data/spec/lib/pwn/plugins/yubikey_hid_cleanup_review_fixes_spec.rb +52 -0
  313. data/spec/lib/pwn/plugins/yubikey_lifecycle_audit_spec.rb +65 -0
  314. data/spec/lib/pwn/plugins/yubikey_options_audit_spec.rb +30 -0
  315. data/spec/lib/pwn/plugins/yubikey_selector_audit_spec.rb +26 -0
  316. data/spec/lib/pwn/plugins/yubikey_spec.rb +1 -1
  317. data/spec/lib/pwn/plugins/zaproxy_namespace_audit_spec.rb +30 -0
  318. data/spec/lib/pwn/reports/empty_report_audit_spec.rb +18 -0
  319. data/spec/lib/pwn/reports/pdf_spec.rb +25 -0
  320. data/spec/lib/pwn/reports/provider_review_encoding_regression_spec.rb +45 -0
  321. data/spec/lib/pwn/sast/engine_runtime_regression_spec.rb +91 -0
  322. data/spec/lib/pwn/sast/filter_edge_regression_spec.rb +39 -0
  323. data/spec/lib/pwn/sast/formatter_review_fixes_spec.rb +178 -0
  324. data/spec/lib/pwn/sast/path_review_fixes_spec.rb +60 -0
  325. data/spec/lib/pwn/sast/pom_runtime_regression_spec.rb +37 -0
  326. data/spec/lib/pwn/sast/rules_runtime_regression_spec.rb +78 -0
  327. data/spec/lib/pwn/sast/sql_review_fixes_spec.rb +38 -0
  328. data/spec/lib/pwn/sdr/decoder/base_iq_spec.rb +21 -18
  329. data/spec/lib/pwn/sdr/decoder/base_review_fixes_spec.rb +49 -0
  330. data/spec/lib/pwn/sdr/decoder/base_validation_spec.rb +78 -0
  331. data/spec/lib/pwn/sdr/decoder/lora_spec.rb +9 -0
  332. data/spec/lib/pwn/sdr/flipper_zero_review_fixes_spec.rb +34 -0
  333. data/spec/lib/pwn/sdr/gqrx_operational_spec.rb +83 -0
  334. data/spec/lib/pwn/sdr/gqrx_review_fixes_spec.rb +22 -0
  335. data/spec/lib/pwn/sdr/son_micro_rfid_review_fixes_spec.rb +113 -0
  336. data/spec/lib/pwn/sdr/son_micro_rfid_serial_review_fixes_spec.rb +76 -0
  337. data/spec/lib/pwn/sdr/son_micro_rfid_spec.rb +39 -0
  338. data/spec/lib/pwn/sdr_spec.rb +5 -0
  339. data/spec/lib/pwn/session_cleanup_default_spec.rb +1 -1
  340. data/spec/lib/pwn/session_cleanup_lifecycle_supplement_spec.rb +39 -0
  341. data/spec/lib/pwn/session_cleanup_payload_spec.rb +3 -2
  342. data/spec/lib/pwn/session_trace_lifecycle_supplement_spec.rb +39 -0
  343. data/spec/lib/pwn/sessions_archive_closure_spec.rb +126 -0
  344. data/spec/lib/pwn/sessions_lifecycle_closure_spec.rb +373 -0
  345. data/spec/lib/pwn/sessions_lifecycle_supplement_spec.rb +204 -0
  346. data/spec/lib/pwn/setup_operational_regression_spec.rb +36 -0
  347. data/spec/lib/pwn/www/browser_review_fixes_spec.rb +70 -0
  348. data/spec/lib/pwn/www/browser_runtime_regression_spec.rb +100 -0
  349. data/spec/lib/pwn/www/hacker_one_runtime_regression_spec.rb +146 -0
  350. data/spec/lib/pwn/www/pagination_review_fixes_spec.rb +84 -0
  351. data/spec/support/namespace_controller_observability_fixture.rb +141 -0
  352. data/spec/support/sandbox.rb +8 -5
  353. data/third_party/pwn_rdoc.jsonl +73 -31
  354. metadata +137 -18
  355. data/etc/default_skills/pwn/aws/elastic_transcoder/SKILL.md +0 -48
  356. data/etc/default_skills/pwn/aws/lambda_preview/SKILL.md +0 -48
  357. data/etc/default_skills/pwn/aws/ops_works/SKILL.md +0 -48
  358. data/etc/default_skills/pwn/aws/ops_works_cm/SKILL.md +0 -48
  359. data/etc/default_skills/pwn/aws/sms/SKILL.md +0 -48
  360. data/lib/pwn/aws/elastic_transcoder.rb +0 -95
  361. data/lib/pwn/aws/lambda_preview.rb +0 -95
  362. data/lib/pwn/aws/ops_works.rb +0 -95
  363. data/lib/pwn/aws/ops_works_cm.rb +0 -95
  364. data/lib/pwn/aws/sms.rb +0 -95
  365. data/spec/lib/pwn/aws/elastic_transcoder_spec.rb +0 -15
  366. data/spec/lib/pwn/aws/lambda_preview_spec.rb +0 -15
  367. data/spec/lib/pwn/aws/ops_works_cm_spec.rb +0 -15
  368. data/spec/lib/pwn/aws/ops_works_spec.rb +0 -15
  369. data/spec/lib/pwn/aws/sms_spec.rb +0 -15
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'rest-client'
5
+ require 'tmpdir'
6
+
7
+ RSpec.describe PWN::AI::OpenAI, 'file API regressions' do
8
+ before do
9
+ stub_const('PWN::Env', { ai: { openai: { model: 'gpt-4o', key: 'fixture-key' } } })
10
+ allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
11
+ allow(RestClient::Request).to receive(:execute).and_raise('Unexpected fixture HTTP request')
12
+ end
13
+
14
+ describe 'provider failure propagation' do
15
+ [false, true].each do |quiet|
16
+ %i[chat chat_with_tools].each do |operation|
17
+ it "preserves an HTTP rejection for #{operation} (quiet=#{quiet})" do
18
+ response = instance_double(RestClient::Response, code: 400, body: 'fixture invalid schema', to_s: 'fixture invalid schema')
19
+ failure = RestClient::BadRequest.new(response)
20
+ allow(RestClient::Request).to receive(:execute).and_raise(failure)
21
+ args = operation == :chat ? { request: 'fixture' } : { messages: [{ role: 'user', content: 'fixture' }] }
22
+ expect { described_class.public_send(operation, args.merge(quiet: quiet)) }.to raise_error(RestClient::BadRequest) { |error|
23
+ expect(error).to equal(failure)
24
+ expect(error.response).to equal(response)
25
+ expect(error.message).to include('OpenAI', '400', 'fixture invalid schema')
26
+ }
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'preserves a transport error in quiet mode instead of calling its absent response method' do
32
+ failure = IOError.new('fixture connection interrupted')
33
+ allow(RestClient::Request).to receive(:execute).and_raise(failure)
34
+ expect { described_class.chat(request: 'fixture', quiet: true) }.to(raise_error { |error| expect(error).to equal(failure) })
35
+ end
36
+ end
37
+
38
+ %i[get_file delete_file].each do |operation|
39
+ it "#{operation} resolves the uploaded filename and forwards the timeout" do
40
+ Dir.mktmpdir('provider-file-audit-') do |dir|
41
+ path = File.join(dir, 'training.jsonl')
42
+ File.write(path, "{}\n")
43
+ expect(RestClient::Request).to receive(:execute).with(hash_including(method: :get, url: 'https://api.openai.com/v1/files', timeout: 7)).ordered.and_return(
44
+ { data: [{ filename: 'other.jsonl', id: 'file-other' }, { filename: 'training.jsonl', id: 'file-fixture' }] }.to_json
45
+ )
46
+ expect(RestClient::Request).to receive(:execute).with(hash_including(method: operation == :delete_file ? :delete : :get, url: 'https://api.openai.com/v1/files/file-fixture', timeout: 7)).ordered.and_return(
47
+ { id: 'file-fixture' }.to_json
48
+ )
49
+ expect(described_class.public_send(operation, file: path, timeout: 7)).to eq(id: 'file-fixture')
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,143 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'rest-client'
5
+ require 'net/http'
6
+ require 'stringio'
7
+
8
+ RSpec.shared_context 'provider review synthetic stream transport' do |key|
9
+ before do
10
+ stub_const('PWN::Env', { ai: { key => { model: 'fixture', key: 'fixture-key', base_uri: 'https://example.invalid', system_role_content: 'FIXTURE SYSTEM' } } })
11
+ allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
12
+ described_class.instance_variable_set(:@strict_system_cache, nil)
13
+ @show = JSON.generate(template: "raise_exception('System message must be at the beginning')")
14
+ @stream = "data: #{JSON.generate(choices: [{ delta: { content: 'Fixture answer' }, finish_reason: 'stop' }])}\n\ndata: [DONE]\n\n"
15
+ @wire = []
16
+ @status = '200'
17
+ allow_any_instance_of(Net::HTTP).to receive(:start) { |http, &block| block.call(http) }
18
+ allow_any_instance_of(Net::HTTP).to receive(:request) do |_http, request, body = nil, &block|
19
+ payload = request.body_stream ? request.body_stream.read : (body || request.body)
20
+ @wire << { path: request.path, body: payload }
21
+ content = request.path.end_with?('/show') ? @show : @stream
22
+ code = request.path.end_with?('/show') ? '200' : @status
23
+ io = Net::BufferedIO.new(StringIO.new("HTTP/1.1 #{code} Fixture\r\nContent-Length: #{content.bytesize}\r\n\r\n#{content}"))
24
+ response = Net::HTTPResponse.read_new(io)
25
+ response.reading_body(io, true) { block&.call(response) }
26
+ response
27
+ end
28
+ end
29
+
30
+ after { described_class.instance_variable_set(:@strict_system_cache, nil) }
31
+ end
32
+
33
+ { PWN::AI::Ollama => :ollama, PWN::AI::OpenWebUI => :openwebui }.each do |provider, key|
34
+ RSpec.describe provider, 'PR-LOG-02 stream framing' do
35
+ include_context 'provider review synthetic stream transport', key
36
+
37
+ ["\n", "\r\n", "\r"].each do |newline|
38
+ it "joins multiline SSE data at event boundaries with #{newline.inspect}" do
39
+ @stream = [': heartbeat', '', 'id: fixture', 'event: message', 'retry: 1000',
40
+ 'data: {"choices":', 'data: [{"delta":{"content":"Complete"},"finish_reason":"length"}],',
41
+ 'data: "usage":{"total_tokens":7}}', '', 'data: [DONE]', '', ''].join(newline)
42
+ result = described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1)
43
+ expect(result.dig(:assistant_message, :content)).to eq('Complete')
44
+ expect(result.dig(:choices, 0, :finish_reason)).to eq('length')
45
+ expect(result.dig(:usage, :total_tokens)).to eq(7)
46
+ end
47
+ end
48
+
49
+ it 'preserves a multiline SSE error and provider endpoint instead of partial output' do
50
+ @stream = +"data: {\"choices\":[{\"delta\":{\"content\":\"partial\"}}]}\n\n"
51
+ @stream << "data: {\"error\":\ndata: {\"message\":\"fixture backend failed\"}}\n\ndata: [DONE]\n\n"
52
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /stream error.*chat.*fixture backend failed/)
53
+ end
54
+
55
+ it 'preserves an earlier provider error even when a later SSE event is incomplete' do
56
+ @stream = "data: {\"error\":{\"message\":\"fixture original failure\"}}\n\ndata: {truncated"
57
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /stream error.*fixture original failure/)
58
+ end
59
+
60
+ it 'honors an SSE error event without a redundant error wrapper' do
61
+ @stream = "event: error\ndata: {\"message\":\"fixture event rejected\"}\n\n"
62
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /stream error.*fixture event rejected/)
63
+ end
64
+
65
+ ["{\"message\":{\"content\":\"partial\"},\"done\":false}\n{\"error\":\"truncated",
66
+ "{\"message\":{\"content\":\"partial\"},\"done\":false}\n",
67
+ "{\"message\":{\"content\":\"partial\"},\"done\":\"true\"}\n",
68
+ "{\"message\":{\"content\":\"partial\"},\"done\":true}\n{\"done\":false}\n",
69
+ "{\"message\":{\"content\":\"partial\"},\"done\":true}\ngarbage\n",
70
+ "{\"done\":true}\n",
71
+ "{\"message\":\"not an object\",\"done\":true}\n",
72
+ "[]\n"].each_with_index do |stream, index|
73
+ it "rejects malformed or incomplete native stream #{index}" do
74
+ @stream = stream
75
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /(?:malformed|incomplete).*stream.*chat/)
76
+ end
77
+ end
78
+
79
+ ["data: {\"choices\":[{\"delta\":{\"content\":\"partial\"}}]}\n\n",
80
+ "data: {\"choices\":[{\"delta\":{\"content\":\"partial\"}}]}\n\ndata: {bad}\n\ndata: [DONE]\n\n",
81
+ "data: {\"choices\":[{\"delta\":{\"content\":\"partial\"}}]}\n\ndata: [DONE]"].each_with_index do |stream, index|
82
+ it "rejects malformed or incomplete SSE stream #{index}" do
83
+ @stream = stream
84
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /(?:malformed|incomplete).*stream.*chat/)
85
+ end
86
+ end
87
+
88
+ it 'keeps the JSON parse exception as the cause of a malformed record' do
89
+ @stream = "{\"message\":{\"content\":\"partial\"},\"done\":false}\n{bad}\n"
90
+ expect { described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1) }.to raise_error(RuntimeError, /malformed.*stream.*chat/) do |error|
91
+ expect(error.cause).to be_a(JSON::ParserError)
92
+ end
93
+ end
94
+
95
+ it 'preserves a complete native terminal record without a final newline' do
96
+ @stream = "{\"message\":{\"content\":\"complete\"},\"done\":false}\n{\"done\":true,\"done_reason\":\"length\",\"eval_count\":7}"
97
+ result = described_class.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1)
98
+ expect(result).to include(done: true, done_reason: 'length', eval_count: 7)
99
+ expect(result.dig(:assistant_message, :content)).to eq('complete')
100
+ end
101
+ end
102
+
103
+ RSpec.describe provider, 'PR-LOG-01 strict-template history' do
104
+ include_context 'provider review synthetic stream transport', key
105
+
106
+ [false, true].each do |frozen_history|
107
+ [false, true].each do |string_keys|
108
+ it "folds once over three turns without mutating history (frozen=#{frozen_history}, string_keys=#{string_keys})" do
109
+ first = described_class.chat(request: 'First request', timeout: 1)
110
+ first = JSON.parse(JSON.generate(first)) if string_keys
111
+ if frozen_history
112
+ freeze_tree = lambda do |value|
113
+ if value.is_a?(Hash)
114
+ value.each do |k, v|
115
+ freeze_tree.call(k)
116
+ freeze_tree.call(v)
117
+ end
118
+ end
119
+ value.each { |v| freeze_tree.call(v) } if value.is_a?(Array)
120
+ value.freeze
121
+ end
122
+ freeze_tree.call(first)
123
+ end
124
+ original = Marshal.dump(first)
125
+ second = described_class.chat(request: 'Second request', response_history: first, timeout: 1)
126
+ expect(Marshal.dump(first)).to eq(original)
127
+ second_original = Marshal.dump(second)
128
+ third = described_class.chat(request: 'Third request', response_history: second, timeout: 1)
129
+ expect(Marshal.dump(second)).to eq(second_original)
130
+ users = third[:choices].select { |row| (row[:role] || row['role']) == 'user' }
131
+ expect(users.map { |row| row[:content] || row['content'] }).to eq(["FIXTURE SYSTEM\n\nFirst request", 'Second request', 'Third request'])
132
+ requests = @wire.reject { |row| row[:path].end_with?('/show') }
133
+ expect(requests.length).to eq(3)
134
+ requests.each do |row|
135
+ messages = JSON.parse(row[:body]).fetch('messages')
136
+ expect(messages.none? { |m| %w[system developer].include?(m['role']) }).to be(true)
137
+ expect(messages.first.fetch('content')).to eq("FIXTURE SYSTEM\n\nFirst request")
138
+ end
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'rest-client'
5
+ require 'net/http'
6
+ require 'stringio'
7
+
8
+ {
9
+ PWN::AI::OpenAI => %i[openai open_ai_rest_call],
10
+ PWN::AI::Gemini => %i[gemini gemini_rest_call],
11
+ PWN::AI::Grok => %i[grok grok_rest_call],
12
+ PWN::AI::Anthropic => %i[anthropic anthropic_rest_call],
13
+ PWN::AI::Ollama => %i[ollama ollama_rest_call],
14
+ PWN::AI::OpenWebUI => %i[openwebui openwebui_rest_call]
15
+ }.each do |provider, (key, helper)|
16
+ RSpec.describe provider, 'PR-SEC-01 peer verification' do
17
+ before do
18
+ stub_const('PWN::Env', { ai: { key => { model: 'fixture', key: 'fixture-key', base_uri: 'https://example.invalid' } } })
19
+ allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
20
+ @modes = []
21
+ allow_any_instance_of(Net::HTTP).to receive(:start) do |http, &block|
22
+ @modes << http.verify_mode
23
+ block.call(http)
24
+ end
25
+ allow_any_instance_of(Net::HTTP).to receive(:request) do |_http, _request, _body = nil, &block|
26
+ body = '{"models":[],"data":[],"message":{"role":"assistant","content":"ok"},"done":true}'
27
+ io = Net::BufferedIO.new(StringIO.new("HTTP/1.1 200 OK\r\nContent-Length: #{body.bytesize}\r\n\r\n#{body}"))
28
+ response = Net::HTTPResponse.read_new(io)
29
+ response.reading_body(io, true) { block&.call(response) }
30
+ response
31
+ end
32
+ end
33
+
34
+ it 'authenticates HTTPS model-list peers through installed RestClient' do
35
+ described_class.get_models
36
+ expect(@modes).not_to be_empty
37
+ expect(@modes).to all(eq(OpenSSL::SSL::VERIFY_PEER))
38
+ end
39
+
40
+ [{}, { multipart: true, fixture: 'value' }, { stream: true }].each do |body|
41
+ next if key == :gemini && body.key?(:multipart)
42
+
43
+ it "authenticates HTTPS POST peers for #{body.keys.inspect}" do
44
+ described_class.send(helper, rest_call: 'fixture', http_method: :post, http_body: body, timeout: 1)
45
+ expect(@modes).to eq([OpenSSL::SSL::VERIFY_PEER])
46
+ end
47
+ end
48
+
49
+ it 'propagates certificate rejection without an insecure fallback' do
50
+ error = OpenSSL::SSL::SSLError.new('fixture certificate verify failed')
51
+ allow_any_instance_of(Net::HTTP).to receive(:start) do |http|
52
+ @modes << http.verify_mode
53
+ raise error
54
+ end
55
+ expect { described_class.get_models }.to raise_error(RestClient::SSLCertificateNotVerified, /fixture certificate verify failed/) do |raised|
56
+ expect(raised.cause).to equal(error)
57
+ end
58
+ expect(@modes).not_to be_empty
59
+ expect(@modes).to all(eq(OpenSSL::SSL::VERIFY_PEER))
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'rest-client'
5
+ require 'net/http'
6
+
7
+ {
8
+ PWN::AI::Ollama => :ollama,
9
+ PWN::AI::OpenWebUI => :openwebui
10
+ }.each do |provider, key|
11
+ RSpec.describe provider, 'stream error regressions' do
12
+ before do
13
+ stub_const('PWN::Env', { ai: { key => { model: 'fixture', key: 'fixture-key', base_uri: 'https://example.test' } } })
14
+ allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
15
+ provider.instance_variable_set(:@strict_system_cache, nil)
16
+ allow(RestClient::Request).to receive(:execute) do |args|
17
+ if args[:url].end_with?('/show')
18
+ '{}'
19
+ else
20
+ response = instance_double(Net::HTTPResponse, code: '200')
21
+ allow(response).to receive(:read_body).and_yield(@stream)
22
+ args.fetch(:block_response).call(response)
23
+ end
24
+ end
25
+ end
26
+
27
+ after { provider.instance_variable_set(:@strict_system_cache, nil) }
28
+
29
+ ['fixture backend failed', { message: 'fixture backend failed', type: 'server_error' }].each do |error|
30
+ it "does not convert a native #{error.class} error frame to successful partial output" do
31
+ @stream = [
32
+ { message: { role: 'assistant', content: 'Partial answer' }, done: false }.to_json,
33
+ { error: error }.to_json
34
+ ].join("\n")
35
+ expect do
36
+ provider.chat_with_tools(messages: [{ role: 'user', content: 'fixture' }], timeout: 1)
37
+ end.to raise_error(RuntimeError, /#{key == :ollama ? 'Ollama' : 'Open WebUI'}.*fixture backend failed/)
38
+ end
39
+ end
40
+
41
+ if key == :openwebui
42
+ it 'preserves an SSE provider error instead of returning a successful partial answer' do
43
+ @stream = "data: #{JSON.generate(choices: [{ delta: { content: 'Partial' } }])}\n\n"
44
+ @stream << "data: #{JSON.generate(error: { message: 'fixture backend failed' })}\n\n"
45
+ expect { provider.chat(request: 'fixture', timeout: 1) }.to raise_error(RuntimeError, /Open WebUI.*fixture backend failed/)
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'base64'
5
+
6
+ RSpec.describe PWN::AWS::IAM, 'key decoding regressions' do
7
+ %i[secret_access_key sts_session_token].each do |type|
8
+ it "preserves case-sensitive Base64 bytes for #{type}" do
9
+ bytes = "fixture\x00payload\xff".b
10
+ encoded = Base64.strict_encode64(bytes)
11
+ result = described_class.decode_key(key: encoded, key_type: type)
12
+ expect(result[:decoded_key]).to eq(bytes)
13
+ expect(result[:key_type]).to eq(type)
14
+ expect(encoded).to eq(Base64.strict_encode64(bytes))
15
+ end
16
+ end
17
+
18
+ it 'keeps access-key Base32 decoding case-insensitive' do
19
+ suffix = "#{[0x800000000080].pack('Q>').byteslice(2, 6)}seed"
20
+ key = "AKIA#{Base32.encode(suffix)}"
21
+ expect(described_class.decode_key(key: key.downcase)).to eq(described_class.decode_key(key: key))
22
+ end
23
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'aws-sdk'
5
+
6
+ RSpec.describe 'AWS service runtime regressions' do
7
+ before do
8
+ allow(Aws).to receive(:shared_config).and_return(
9
+ Aws::SharedConfig.new(config_enabled: false, credentials_path: File::NULL, config_path: File::NULL)
10
+ )
11
+ allow(Aws).to receive(:config).and_return(stub_responses: true)
12
+ end
13
+
14
+ (PWN::AWS.constants(false) - [:STS]).sort.each do |name|
15
+ [nil, 'fixture-session'].each do |token|
16
+ it "constructs #{name} with #{token ? 'temporary' : 'static'} credentials using the installed SDK" do
17
+ sdk_name = name == :Workspaces ? :WorkSpaces : name
18
+ sdk_class = Aws.const_get(sdk_name)::Client
19
+ options = {
20
+ region: 'us-east-1', access_key_id: 'fixture-access', secret_access_key: 'fixture-secret',
21
+ sts_session_token: token
22
+ }
23
+ options[:endpoint] = 'https://search-fixture.us-east-1.cloudsearch.amazonaws.com' if name == :CloudSearchDomain
24
+ client = PWN::AWS.const_get(name).connect(options)
25
+ expect(client).to be_a(sdk_class)
26
+ expect(client.config.access_key_id).to eq('fixture-access')
27
+ expect(client.config.secret_access_key).to eq('fixture-secret')
28
+ expect(client.config.session_token).to eq(token)
29
+ expect(client.config.endpoint.to_s).to eq(options[:endpoint]) if options[:endpoint]
30
+ end
31
+ end
32
+ end
33
+
34
+ it 'preserves an SDK-configured CloudSearch endpoint when no wrapper override is supplied' do
35
+ endpoint = 'https://search-fixture.us-east-1.cloudsearch.amazonaws.com'
36
+ allow(Aws).to receive(:config).and_return(stub_responses: true, endpoint: endpoint)
37
+ client = PWN::AWS::CloudSearchDomain.connect(region: 'us-east-1', access_key_id: 'fixture-access', secret_access_key: 'fixture-secret')
38
+ expect(client.config.endpoint.to_s).to eq(endpoint)
39
+ end
40
+
41
+ it 'returns the STS credentials and forwards assume-role arguments to a stubbed SDK client' do
42
+ client = Aws::STS::Client.new(region: 'us-east-1', credentials: Aws::Credentials.new('fixture-access', 'fixture-secret'), stub_responses: true)
43
+ client.stub_responses(:assume_role, credentials: {
44
+ access_key_id: 'fixture-temporary', secret_access_key: 'fixture-secret', session_token: 'fixture-token', expiration: Time.utc(2030, 1, 1)
45
+ })
46
+ allow(Aws::STS::Client).to receive(:new).with(region: 'us-east-1').and_return(client)
47
+ result = PWN::AWS::STS.get_temp_credentials(region: 'us-east-1', role_arn: 'arn:aws:iam::123456789012:role/fixture', role_session_name: 'fixture', duration_seconds: 900)
48
+ expect(result.access_key_id).to eq('fixture-temporary')
49
+ expect(client.api_requests.last[:params]).to eq(role_arn: 'arn:aws:iam::123456789012:role/fixture', role_session_name: 'fixture', duration_seconds: 900)
50
+ end
51
+ end
@@ -3,6 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe PWN::AWS do
6
+ it 'does not advertise the removed legacy service wrappers' do
7
+ %i[ElasticTranscoder LambdaPreview OpsWorks OpsWorksCM SMS].each do |name|
8
+ expect(described_class.const_defined?(name, false)).to be(false)
9
+ end
10
+ end
11
+
6
12
  it 'should return data for help method' do
7
13
  help_response = PWN::AWS.help
8
14
  expect(help_response).not_to be_nil
@@ -0,0 +1,105 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ # Offline audit coverage: no terminal drawing, input, providers or devices.
6
+ describe PWN::Banner do
7
+ it 'returns finite, valid strings from every static banner and its metadata' do
8
+ modules = %i[Anon Bubble Cheshire CodeCave DontPanic ForkBomb FSociety JmpEsp Matrix Ninja OffTheAir Pirate Radare2 Radare2AI WhiteRabbit]
9
+ expect do
10
+ modules.each do |name|
11
+ banner = described_class.const_get(name)
12
+ text = banner.get
13
+ expect(text).to be_a(String)
14
+ expect(text.valid_encoding?).to be(true)
15
+ expect(text.length).to be_between(1, 100_000)
16
+ expect(banner.authors).to include('AUTHOR(S):')
17
+ end
18
+ end.to output('').to_stdout.and output('').to_stderr
19
+ modules.each do |name|
20
+ banner = described_class.const_get(name)
21
+ expect { expect(banner.help).to eq(banner.constants.sort) }.to output(/#{Regexp.escape(banner.name)}\.get/).to_stdout
22
+ end
23
+ end
24
+
25
+ it 'keeps zero, negative and tiny canvases bounded without constructing a replay' do
26
+ expect(described_class).not_to receive(:mini_replay)
27
+ (described_class.mini_names + [:pong]).product(%i[mini_frame mini_cells], [true, false]).each do |name, method, branding|
28
+ [-100, 0].each do |size|
29
+ expect(described_class.public_send(method, name: name, width: size, height: 8, branding: branding)).to eq([])
30
+ expect(described_class.public_send(method, name: name, width: 8, height: size, branding: branding)).to eq([])
31
+ end
32
+ [1, 2, 4].product([1, 3, 4]).each do |width, height|
33
+ rows = described_class.public_send(method, name: name, width: width, height: height, branding: branding)
34
+ expect(rows.length).to eq(height)
35
+ expect(rows.map(&:length)).to all(eq(width))
36
+ text = method == :mini_cells ? rows.flatten.map { |cell| cell[:glyph] }.join : rows.join
37
+ expect(text).to eq(' ' * width * height) unless branding
38
+ end
39
+ end
40
+ end
41
+
42
+ it 'rejects unknown animations consistently before rendering or stepping' do
43
+ %i[mini_frame mini_cells mini_frame_seconds].each do |method|
44
+ expect { described_class.public_send(method, name: :unknown) }.to raise_error(ArgumentError, /Unknown mini-banner/)
45
+ end
46
+ expect { described_class::MiniGame.new(name: :unknown, width: 8, height: 8) }.to raise_error(ArgumentError, /Unknown mini-banner/)
47
+ end
48
+ end
49
+
50
+ describe PWN::Banner::MiniGame do
51
+ it 'retains safe minimum and maximum dimensions for zero, negative and oversized playable panes' do
52
+ (PWN::Banner.mini_names + [:pong]).product([-10, 0, 10**20]).each do |name, size|
53
+ game = described_class.new(name: name, width: size, height: size)
54
+ cells = game.cells(game.step)
55
+ limit = %i[falling_blocks pacman galaga frogger].include?(name) ? 64 : 16
56
+ expected = size.clamp(5, limit)
57
+ expect(cells.length).to eq(expected)
58
+ expect(cells.map(&:length)).to all(eq(expected))
59
+ end
60
+ end
61
+
62
+ it 'bounds and drains pending controls without retaining an unbounded key history' do
63
+ game = described_class.new(name: :snake, width: 5, height: 5)
64
+ 1000.times { |index| game.key(index.even? ? :up : :right) }
65
+ expect(game.controls).to eq(Array.new(8) { %i[up right] }.flatten)
66
+ expect(game.controls).to eq([])
67
+ game.key(:left)
68
+ expect(game.controls).to eq([:left])
69
+ end
70
+
71
+ it 'yields beyond a replay lifetime without starting threads or accumulating frames' do
72
+ expect(Thread).not_to receive(:new)
73
+ expect(PWN::Banner).not_to receive(:sleep)
74
+ expect(PWN::Banner).not_to receive(:mini_replay)
75
+ expect do
76
+ (PWN::Banner.mini_names + [:pong]).product([false, true]).each do |name, demo|
77
+ game = described_class.new(name: name, width: 5, height: 5, seed: 3, demo: demo)
78
+ frame = nil
79
+ 1801.times { frame = game.step }
80
+ expect(frame).to include(:event, :state, :rows)
81
+ expect(game.length).to eq(0)
82
+ cells = game.cells(frame)
83
+ expect(cells.length).to eq(5)
84
+ expect(cells.map(&:length)).to all(eq(5))
85
+ cells.first.first[:glyph].replace('?')
86
+ expect(game.cells(frame).first.first[:glyph]).not_to eq('?')
87
+ end
88
+ end.to output('').to_stdout.and output('').to_stderr
89
+ end
90
+ end
91
+
92
+ describe PWN::Banner::Matrix do
93
+ it 'returns one fixed-size matrix without running the interactive loop' do
94
+ text = described_class.get.uncolorize
95
+ expect(text.lines.length).to eq(33)
96
+ expect(text.lines).to all(satisfy { |row| row.strip.split.length == 33 })
97
+ end
98
+
99
+ it 'propagates cancellation from a single intercepted animation tick' do
100
+ allow(described_class).to receive(:print)
101
+ allow(described_class).to receive(:puts)
102
+ expect(described_class).to receive(:sleep).with(0.09).once.and_raise(Interrupt)
103
+ expect { described_class.you? }.to raise_error(Interrupt)
104
+ end
105
+ end
@@ -4,6 +4,23 @@ require 'spec_helper'
4
4
  require 'tmpdir'
5
5
 
6
6
  RSpec.describe PWN::Bounty::LifecycleAuthzReplay do
7
+ it 'reloads its normalized YAML without losing nesting or scalar values' do
8
+ Dir.mktmpdir('lifecycle-yaml-audit-') do |dir|
9
+ plan = {
10
+ campaign: { id: 'fixture', notes: "first\n :nested: literal\nlast" },
11
+ actors: [{ id: 'reader', metadata: { enabled: false, retries: 2, label: '001' } }],
12
+ surfaces: [{ id: 'page', metadata: { flags: [true, nil, 'false'] } }],
13
+ checkpoints: %w[pre_change post_change_t0],
14
+ metadata: { 'nested-key' => { value: 'a:b' } }
15
+ }
16
+ original = Marshal.dump(plan)
17
+ run = described_class.start_run(plan: plan, output_dir: dir, run_id: 'fixture-run')
18
+ reloaded = described_class.load_plan(yaml_path: File.join(run[:run_root], 'plan.normalized.yaml'))
19
+ expect(reloaded).to eq(run[:plan])
20
+ expect(Marshal.dump(plan)).to eq(original)
21
+ end
22
+ end
23
+
7
24
  it 'builds a normalized evidence bundle and flags stale access' do
8
25
  Dir.mktmpdir('lifecycle-authz-replay-spec-') do |tmp_dir|
9
26
  run_obj = described_class.start_run(
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'PWN::Config recursive redaction' do
6
+ it 'rejects cyclic configuration safely without exposing secret contents' do
7
+ config = { password: 'synthetic fixture only' }
8
+ config[:cycle] = config
9
+ expect do
10
+ PWN::Config.redact_sensitive_artifacts(config: config)
11
+ end.to raise_error(JSON::NestingError, /configuration nesting limit/)
12
+ expect(config[:cycle]).to equal(config)
13
+ expect(config[:password]).to eq('synthetic fixture only')
14
+ end
15
+
16
+ it 'redacts both occurrences of shared acyclic branches without changing the caller' do
17
+ shared = { password: 'synthetic fixture only' }.freeze
18
+ config = { first: shared, second: [shared].freeze }.freeze
19
+ result = PWN::Config.redact_sensitive_artifacts(config: config)
20
+ expect(result[:first][:password]).to include('REDACTED')
21
+ expect(result[:second].first).to eq(result[:first])
22
+ expect(shared[:password]).to eq('synthetic fixture only')
23
+ end
24
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'PWN::Config skill loading failures' do
6
+ include_context 'pwn tmp sandbox'
7
+
8
+ before { stub_const('PWN::Skills', {}) }
9
+
10
+ it 'reads CRLF frontmatter without changing the skill body' do
11
+ body = "# Fixture\r\n\r\nKeep this body.\r\n"
12
+ parsed = PWN::Config.parse_skill_frontmatter(content: "---\r\nname: fixture\r\ndescription: Fixture instructions\r\n---\r\n#{body}")
13
+ expect(parsed[:frontmatter]).to include('name' => 'fixture', 'description' => 'Fixture instructions')
14
+ expect(parsed[:body]).to eq(body)
15
+ end
16
+
17
+ it 'reports a broken directory skill without aborting the remaining catalog' do
18
+ bad = File.join(@tmp, 'skills', 'broken', 'scripts')
19
+ good = File.join(@tmp, 'skills', 'healthy')
20
+ FileUtils.mkdir_p([bad, good])
21
+ File.write(File.join(File.dirname(bad), 'SKILL.md'), "# Broken\nFixture skill\n")
22
+ File.write(File.join(bad, 'missing_dependency.rb'), "require 'pwn_fixture_dependency_that_does_not_exist'\n")
23
+ File.write(File.join(good, 'SKILL.md'), "# Healthy\nFixture skill\n")
24
+ skills = PWN::Config.load_skills(pwn_skills_path: File.join(@tmp, 'skills'))
25
+ expect(skills[:broken]).to include(loaded: false)
26
+ expect(skills[:broken][:error]).to include('pwn_fixture_dependency_that_does_not_exist')
27
+ expect(skills).to have_key(:healthy)
28
+ end
29
+
30
+ it 'reports legacy Ruby syntax failures without aborting the catalog' do
31
+ File.write(File.join(@tmp, 'broken.rb'), "def fixture(\n")
32
+ File.write(File.join(@tmp, 'healthy.md'), "# Healthy\nFixture skill\n")
33
+ skills = PWN::Config.load_skills(pwn_skills_path: @tmp)
34
+ expect(skills[:broken]).to include(loaded: false)
35
+ expect(skills[:broken][:error]).not_to be_empty
36
+ expect(skills).to have_key(:healthy)
37
+ end
38
+ end