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.
Files changed (384) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  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/Mission-Cancellation.md +6 -4
  10. data/documentation/Operability.md +1 -1
  11. data/documentation/What-is-PWN.md +1 -1
  12. data/documentation/diagrams/aws-cloud-security.svg +1 -1
  13. data/documentation/diagrams/dot/aws-cloud-security.dot +1 -1
  14. data/documentation/diagrams/dot/network-infra-testing.dot +1 -1
  15. data/documentation/diagrams/network-infra-testing.svg +1 -1
  16. data/etc/default_cron/session_cleanup.rb +84 -51
  17. data/etc/default_skills/pwn/ai/agent/mission_namespace/SKILL.md +6 -4
  18. data/lib/pwn/ai/agent/assembly.rb +0 -2
  19. data/lib/pwn/ai/agent/btc.rb +0 -2
  20. data/lib/pwn/ai/agent/burp_suite.rb +0 -2
  21. data/lib/pwn/ai/agent/curriculum.rb +2 -2
  22. data/lib/pwn/ai/agent/dispatch.rb +3 -0
  23. data/lib/pwn/ai/agent/engagement.rb +96 -41
  24. data/lib/pwn/ai/agent/extrospection/osint/bridges.rb +2 -0
  25. data/lib/pwn/ai/agent/extrospection.rb +50 -13
  26. data/lib/pwn/ai/agent/gqrx.rb +0 -2
  27. data/lib/pwn/ai/agent/hacker_one.rb +0 -2
  28. data/lib/pwn/ai/agent/learning.rb +45 -13
  29. data/lib/pwn/ai/agent/loop.rb +16 -11
  30. data/lib/pwn/ai/agent/metrics.rb +1 -1
  31. data/lib/pwn/ai/agent/mission.rb +6 -3
  32. data/lib/pwn/ai/agent/mission_namespace.rb +70 -14
  33. data/lib/pwn/ai/agent/policy.rb +1 -1
  34. data/lib/pwn/ai/agent/policy_evaluation.rb +2 -2
  35. data/lib/pwn/ai/agent/reflect.rb +1 -0
  36. data/lib/pwn/ai/agent/request_runtime.rb +1 -1
  37. data/lib/pwn/ai/agent/reward.rb +155 -53
  38. data/lib/pwn/ai/agent/sast.rb +0 -2
  39. data/lib/pwn/ai/agent/task_dag.rb +5 -3
  40. data/lib/pwn/ai/agent/task_summarizer.rb +21 -11
  41. data/lib/pwn/ai/agent/tool_guard.rb +19 -0
  42. data/lib/pwn/ai/agent/tools/ruby_eval.rb +1 -1
  43. data/lib/pwn/ai/agent/tools/verify.rb +7 -3
  44. data/lib/pwn/ai/agent/transparent_browser.rb +0 -2
  45. data/lib/pwn/ai/agent/turn_finalizer.rb +3 -0
  46. data/lib/pwn/ai/anthropic.rb +3 -3
  47. data/lib/pwn/ai/context.rb +2 -1
  48. data/lib/pwn/ai/gemini.rb +7 -5
  49. data/lib/pwn/ai/grok.rb +37 -18
  50. data/lib/pwn/ai/mcp.rb +17 -5
  51. data/lib/pwn/ai/ollama.rb +76 -35
  52. data/lib/pwn/ai/open_ai.rb +7 -19
  53. data/lib/pwn/ai/open_web_ui.rb +76 -40
  54. data/lib/pwn/aws/cloud_search_domain.rb +6 -0
  55. data/lib/pwn/aws/iam.rb +2 -2
  56. data/lib/pwn/aws/workspaces.rb +2 -2
  57. data/lib/pwn/aws.rb +0 -5
  58. data/lib/pwn/bounty/lifecycle_authz_replay.rb +1 -1
  59. data/lib/pwn/config.rb +17 -10
  60. data/lib/pwn/corpus.rb +33 -5
  61. data/lib/pwn/cron.rb +60 -17
  62. data/lib/pwn/driver.rb +2 -3
  63. data/lib/pwn/engagement.rb +28 -10
  64. data/lib/pwn/ffi/capstone.rb +3 -2
  65. data/lib/pwn/ffi/fftw.rb +8 -6
  66. data/lib/pwn/ffi/keystone.rb +3 -2
  67. data/lib/pwn/ffi/soapy_sdr.rb +10 -6
  68. data/lib/pwn/json_text.rb +25 -13
  69. data/lib/pwn/memory_index.rb +6 -4
  70. data/lib/pwn/module_skills.rb +3 -1
  71. data/lib/pwn/plugins/aflplusplus.rb +1 -0
  72. data/lib/pwn/plugins/ai_sandbox.rb +42 -10
  73. data/lib/pwn/plugins/android.rb +429 -466
  74. data/lib/pwn/plugins/artifact_registry.rb +12 -2
  75. data/lib/pwn/plugins/assembly.rb +9 -42
  76. data/lib/pwn/plugins/authentication_helper.rb +4 -3
  77. data/lib/pwn/plugins/baresip.rb +70 -28
  78. data/lib/pwn/plugins/binary_analysis.rb +14 -5
  79. data/lib/pwn/plugins/binary_parser.rb +42 -7
  80. data/lib/pwn/plugins/black_duck_binary_analysis.rb +3 -3
  81. data/lib/pwn/plugins/burp_suite.rb +15 -12
  82. data/lib/pwn/plugins/bus_pirate.rb +3 -7
  83. data/lib/pwn/plugins/char.rb +9 -3
  84. data/lib/pwn/plugins/credit_card.rb +7 -0
  85. data/lib/pwn/plugins/dao_ldap.rb +2 -2
  86. data/lib/pwn/plugins/dao_mongo.rb +1 -1
  87. data/lib/pwn/plugins/debugger.rb +1 -1
  88. data/lib/pwn/plugins/defect_dojo.rb +7 -3
  89. data/lib/pwn/plugins/detect_os.rb +1 -1
  90. data/lib/pwn/plugins/detonate.rb +9 -19
  91. data/lib/pwn/plugins/exploit_db.rb +1 -1
  92. data/lib/pwn/plugins/file_fu.rb +4 -1
  93. data/lib/pwn/plugins/findings.rb +76 -2
  94. data/lib/pwn/plugins/fuzz.rb +12 -3
  95. data/lib/pwn/plugins/gdb.rb +7 -2
  96. data/lib/pwn/plugins/gdbmi.rb +10 -6
  97. data/lib/pwn/plugins/git.rb +18 -13
  98. data/lib/pwn/plugins/github.rb +11 -6
  99. data/lib/pwn/plugins/google_workspace.rb +11 -3
  100. data/lib/pwn/plugins/hacker_one.rb +5 -1
  101. data/lib/pwn/plugins/httpx.rb +24 -8
  102. data/lib/pwn/plugins/ip_info.rb +11 -8
  103. data/lib/pwn/plugins/irc.rb +73 -45
  104. data/lib/pwn/plugins/jenkins.rb +2 -2
  105. data/lib/pwn/plugins/jira_data_center.rb +13 -6
  106. data/lib/pwn/plugins/jobs.rb +62 -4
  107. data/lib/pwn/plugins/log.rb +1 -1
  108. data/lib/pwn/plugins/monkey_patch.rb +1 -1
  109. data/lib/pwn/plugins/msr206.rb +157 -182
  110. data/lib/pwn/plugins/nessus_cloud.rb +2 -2
  111. data/lib/pwn/plugins/nexpose_vuln_scan.rb +44 -33
  112. data/lib/pwn/plugins/nuclei.rb +24 -8
  113. data/lib/pwn/plugins/ocr.rb +3 -1
  114. data/lib/pwn/plugins/open_api.rb +0 -4
  115. data/lib/pwn/plugins/openvas.rb +31 -43
  116. data/lib/pwn/plugins/packet.rb +40 -25
  117. data/lib/pwn/plugins/pony.rb +2 -2
  118. data/lib/pwn/plugins/preflight_checker.rb +1 -1
  119. data/lib/pwn/plugins/process_tube.rb +17 -2
  120. data/lib/pwn/plugins/ps.rb +6 -1
  121. data/lib/pwn/plugins/pwn_logger.rb +37 -1
  122. data/lib/pwn/plugins/repl/ai.rb +1 -0
  123. data/lib/pwn/plugins/repl/ai_console.rb +18 -6
  124. data/lib/pwn/plugins/repl/mesh.rb +51 -28
  125. data/lib/pwn/plugins/sbom.rb +59 -27
  126. data/lib/pwn/plugins/scannable_codes.rb +3 -1
  127. data/lib/pwn/plugins/serial.rb +102 -44
  128. data/lib/pwn/plugins/shodan.rb +4 -10
  129. data/lib/pwn/plugins/sock.rb +16 -11
  130. data/lib/pwn/plugins/ssn.rb +3 -1
  131. data/lib/pwn/plugins/transparent_browser.rb +43 -3
  132. data/lib/pwn/plugins/vault.rb +92 -30
  133. data/lib/pwn/plugins/vin.rb +2 -1
  134. data/lib/pwn/plugins/vsphere.rb +2 -1
  135. data/lib/pwn/plugins/xxd.rb +3 -5
  136. data/lib/pwn/plugins/yubikey/security_domain/scp.rb +4 -0
  137. data/lib/pwn/plugins/yubikey/transport.rb +42 -11
  138. data/lib/pwn/plugins/yubikey.rb +21 -6
  139. data/lib/pwn/plugins/zaproxy.rb +3 -4
  140. data/lib/pwn/reports/ai_red_team.rb +4 -4
  141. data/lib/pwn/reports/pdf.rb +9 -5
  142. data/lib/pwn/reports/sast.rb +4 -4
  143. data/lib/pwn/sast/keystore.rb +2 -2
  144. data/lib/pwn/sast/logger.rb +1 -1
  145. data/lib/pwn/sast/php_type_juggling.rb +3 -6
  146. data/lib/pwn/sast/pom_version.rb +12 -6
  147. data/lib/pwn/sast/port.rb +1 -1
  148. data/lib/pwn/sast/sql.rb +3 -7
  149. data/lib/pwn/sast/test_case_engine.rb +62 -16
  150. data/lib/pwn/sast/type_script_type_juggling.rb +3 -6
  151. data/lib/pwn/sdr/decoder/base.rb +8 -0
  152. data/lib/pwn/sdr/decoder/lora.rb +1 -1
  153. data/lib/pwn/sdr/flipper_zero.rb +4 -7
  154. data/lib/pwn/sdr/gqrx.rb +35 -16
  155. data/lib/pwn/sdr/son_micro_rfid.rb +44 -26
  156. data/lib/pwn/sdr.rb +1 -1
  157. data/lib/pwn/session_trace.rb +7 -2
  158. data/lib/pwn/sessions.rb +310 -41
  159. data/lib/pwn/setup.rb +4 -3
  160. data/lib/pwn/version.rb +1 -1
  161. data/lib/pwn/www/app_cobalt_io.rb +14 -2
  162. data/lib/pwn/www/bing.rb +13 -1
  163. data/lib/pwn/www/bug_crowd.rb +14 -2
  164. data/lib/pwn/www/checkip.rb +13 -1
  165. data/lib/pwn/www/coinbase_pro.rb +14 -2
  166. data/lib/pwn/www/duckduckgo.rb +13 -1
  167. data/lib/pwn/www/facebook.rb +14 -2
  168. data/lib/pwn/www/github.rb +14 -2
  169. data/lib/pwn/www/google.rb +13 -1
  170. data/lib/pwn/www/hacker_one.rb +117 -33
  171. data/lib/pwn/www/linkedin.rb +14 -2
  172. data/lib/pwn/www/pandora.rb +14 -2
  173. data/lib/pwn/www/pastebin.rb +13 -1
  174. data/lib/pwn/www/paypal.rb +16 -4
  175. data/lib/pwn/www/synack.rb +14 -2
  176. data/lib/pwn/www/torch.rb +17 -3
  177. data/lib/pwn/www/trading_view.rb +14 -2
  178. data/lib/pwn/www/twitter.rb +14 -2
  179. data/lib/pwn/www/uber.rb +14 -2
  180. data/lib/pwn/www/upwork.rb +14 -2
  181. data/lib/pwn/www/wayback_machine.rb +16 -2
  182. data/lib/pwn/www/youtube.rb +13 -1
  183. data/lib/pwn.rb +11 -0
  184. data/pwn.gemspec +4 -0
  185. data/spec/conventions_spec.rb +43 -0
  186. data/spec/integration/authentication_helper_oath_spec.rb +1 -1
  187. data/spec/integration/autoinc_lifecycle_supplement_spec.rb +47 -0
  188. data/spec/integration/gemspec_deleted_files_spec.rb +43 -0
  189. data/spec/integration/harness_evaluation_spec.rb +22 -31
  190. data/spec/integration/harness_live_spec.rb +8 -18
  191. data/spec/integration/spec_curriculum_isolation_spec.rb +41 -0
  192. data/spec/integration/verify_acceptance_eui_regression_spec.rb +162 -0
  193. data/spec/integration/web_cache_lifecycle_closure_spec.rb +89 -0
  194. data/spec/integration/web_cache_lifecycle_supplement_spec.rb +70 -0
  195. data/spec/lib/pwn/ai/agent/analysis_errors_regression_spec.rb +33 -0
  196. data/spec/lib/pwn/ai/agent/curriculum_cooldown_regression_spec.rb +19 -0
  197. data/spec/lib/pwn/ai/agent/curriculum_spec.rb +2 -0
  198. data/spec/lib/pwn/ai/agent/engagement_boundary_regression_spec.rb +42 -0
  199. data/spec/lib/pwn/ai/agent/engagement_dispatch_review_spec.rb +82 -0
  200. data/spec/lib/pwn/ai/agent/engagement_roe_regression_spec.rb +25 -0
  201. data/spec/lib/pwn/ai/agent/engagement_scope_regression_spec.rb +37 -0
  202. data/spec/lib/pwn/ai/agent/extrospection/osint/bridges_spec.rb +4 -0
  203. data/spec/lib/pwn/ai/agent/extrospection_input_regression_spec.rb +31 -0
  204. data/spec/lib/pwn/ai/agent/extrospection_review_spec.rb +61 -0
  205. data/spec/lib/pwn/ai/agent/extrospection_serial_review_spec.rb +42 -0
  206. data/spec/lib/pwn/ai/agent/extrospection_spec.rb +9 -0
  207. data/spec/lib/pwn/ai/agent/extrospection_verification_regression_spec.rb +39 -0
  208. data/spec/lib/pwn/ai/agent/learning_last_answer_regression_spec.rb +32 -0
  209. data/spec/lib/pwn/ai/agent/learning_lifecycle_closure_spec.rb +84 -0
  210. data/spec/lib/pwn/ai/agent/learning_prune_regression_spec.rb +17 -0
  211. data/spec/lib/pwn/ai/agent/learning_spec.rb +2 -1
  212. data/spec/lib/pwn/ai/agent/loop_execution_audit_spec.rb +30 -0
  213. data/spec/lib/pwn/ai/agent/metrics_usage_regression_spec.rb +20 -0
  214. data/spec/lib/pwn/ai/agent/mission_execution_audit_spec.rb +27 -0
  215. data/spec/lib/pwn/ai/agent/mission_namespace_spec.rb +218 -18
  216. data/spec/lib/pwn/ai/agent/policy_confidence_regression_spec.rb +16 -0
  217. data/spec/lib/pwn/ai/agent/policy_evaluation_spec.rb +1 -1
  218. data/spec/lib/pwn/ai/agent/policy_evaluation_tmp_regression_spec.rb +36 -0
  219. data/spec/lib/pwn/ai/agent/reflect_model_regression_spec.rb +15 -0
  220. data/spec/lib/pwn/ai/agent/request_runtime_execution_audit_spec.rb +43 -0
  221. data/spec/lib/pwn/ai/agent/reward_binding_review_spec.rb +129 -0
  222. data/spec/lib/pwn/ai/agent/reward_dispatch_review_spec.rb +154 -0
  223. data/spec/lib/pwn/ai/agent/reward_envelope_regression_spec.rb +45 -0
  224. data/spec/lib/pwn/ai/agent/reward_turn_regression_spec.rb +40 -0
  225. data/spec/lib/pwn/ai/agent/swarm_spec.rb +2 -2
  226. data/spec/lib/pwn/ai/agent/task_dag_execution_audit_spec.rb +45 -0
  227. data/spec/lib/pwn/ai/agent/task_summarizer_failure_regression_spec.rb +26 -0
  228. data/spec/lib/pwn/ai/agent/tools/verify_execution_audit_spec.rb +33 -0
  229. data/spec/lib/pwn/ai/context_range_audit_spec.rb +24 -0
  230. data/spec/lib/pwn/ai/gemini_roundtrip_audit_spec.rb +33 -0
  231. data/spec/lib/pwn/ai/grok_reasoning_effort_spec.rb +43 -0
  232. data/spec/lib/pwn/ai/mcp_session_audit_spec.rb +36 -0
  233. data/spec/lib/pwn/ai/ollama_spec.rb +6 -11
  234. data/spec/lib/pwn/ai/open_web_ui_spec.rb +6 -11
  235. data/spec/lib/pwn/ai/provider_history_audit_spec.rb +44 -0
  236. data/spec/lib/pwn/ai/provider_operations_audit_spec.rb +53 -0
  237. data/spec/lib/pwn/ai/provider_review_history_stream_regression_spec.rb +143 -0
  238. data/spec/lib/pwn/ai/provider_review_tls_regression_spec.rb +62 -0
  239. data/spec/lib/pwn/ai/provider_stream_audit_spec.rb +49 -0
  240. data/spec/lib/pwn/aws/iam_decoding_regression_spec.rb +23 -0
  241. data/spec/lib/pwn/aws/services_runtime_regression_spec.rb +51 -0
  242. data/spec/lib/pwn/aws_spec.rb +6 -0
  243. data/spec/lib/pwn/banner_operational_audit_spec.rb +105 -0
  244. data/spec/lib/pwn/bounty/lifecycle_authz_replay_spec.rb +17 -0
  245. data/spec/lib/pwn/config_redaction_regression_spec.rb +24 -0
  246. data/spec/lib/pwn/config_skills_regression_spec.rb +38 -0
  247. data/spec/lib/pwn/corpus_core_review_regression_spec.rb +96 -0
  248. data/spec/lib/pwn/corpus_spec.rb +13 -0
  249. data/spec/lib/pwn/cron_core_review_regression_spec.rb +95 -0
  250. data/spec/lib/pwn/cron_execution_spec.rb +75 -0
  251. data/spec/lib/pwn/driver_core_review_regression_spec.rb +38 -0
  252. data/spec/lib/pwn/driver_spec.rb +13 -0
  253. data/spec/lib/pwn/engagement_core_review_regression_spec.rb +88 -0
  254. data/spec/lib/pwn/engagement_storage_regression_spec.rb +44 -0
  255. data/spec/lib/pwn/ffi/capstone_spec.rb +19 -0
  256. data/spec/lib/pwn/ffi/fftw_spec.rb +19 -0
  257. data/spec/lib/pwn/ffi/keystone_spec.rb +13 -0
  258. data/spec/lib/pwn/ffi/soapy_sdr_spec.rb +13 -0
  259. data/spec/lib/pwn/json_schemer_regexp_parser_spec.rb +12 -0
  260. data/spec/lib/pwn/json_text_spec.rb +25 -0
  261. data/spec/lib/pwn/memory_index_spec.rb +23 -0
  262. data/spec/lib/pwn/module_skills_parsing_regression_spec.rb +34 -0
  263. data/spec/lib/pwn/module_skills_spec.rb +11 -1
  264. data/spec/lib/pwn/plugins/ai_sandbox_boundary_review_spec.rb +57 -0
  265. data/spec/lib/pwn/plugins/ai_sandbox_spec.rb +10 -18
  266. data/spec/lib/pwn/plugins/android_review_fixes_spec.rb +121 -0
  267. data/spec/lib/pwn/plugins/android_transport_audit_spec.rb +64 -0
  268. data/spec/lib/pwn/plugins/api_import_namespace_audit_spec.rb +49 -0
  269. data/spec/lib/pwn/plugins/artifact_registry_namespace_audit_spec.rb +20 -0
  270. data/spec/lib/pwn/plugins/artifact_registry_review_fixes_spec.rb +63 -0
  271. data/spec/lib/pwn/plugins/assembly_namespace_audit_spec.rb +16 -0
  272. data/spec/lib/pwn/plugins/assembly_review_fixes_spec.rb +33 -0
  273. data/spec/lib/pwn/plugins/authentication_helper_spec.rb +14 -0
  274. data/spec/lib/pwn/plugins/baresip_review_fixes_spec.rb +127 -0
  275. data/spec/lib/pwn/plugins/baresip_transport_audit_spec.rb +59 -0
  276. data/spec/lib/pwn/plugins/binary_analysis_process_review_spec.rb +57 -0
  277. data/spec/lib/pwn/plugins/black_duck_namespace_audit_spec.rb +25 -0
  278. data/spec/lib/pwn/plugins/burp_suite_har_review_fixes_spec.rb +60 -0
  279. data/spec/lib/pwn/plugins/burp_suite_import_review_fixes_spec.rb +62 -0
  280. data/spec/lib/pwn/plugins/burp_suite_namespace_audit_spec.rb +37 -0
  281. data/spec/lib/pwn/plugins/bus_pirate_transport_audit_spec.rb +19 -0
  282. data/spec/lib/pwn/plugins/file_fu_namespace_audit_spec.rb +17 -0
  283. data/spec/lib/pwn/plugins/findings_structured_spec.rb +1 -1
  284. data/spec/lib/pwn/plugins/gdbmi_namespace_audit_spec.rb +28 -0
  285. data/spec/lib/pwn/plugins/gdbmi_review_fixes_spec.rb +73 -0
  286. data/spec/lib/pwn/plugins/github_argv_review_spec.rb +49 -0
  287. data/spec/lib/pwn/plugins/google_workspace_provider_review_oauth_spec.rb +80 -0
  288. data/spec/lib/pwn/plugins/irc_review_fixes_spec.rb +92 -0
  289. data/spec/lib/pwn/plugins/irc_transport_audit_spec.rb +37 -0
  290. data/spec/lib/pwn/plugins/jenkins_namespace_audit_spec.rb +12 -0
  291. data/spec/lib/pwn/plugins/jira_data_center_namespace_audit_spec.rb +44 -0
  292. data/spec/lib/pwn/plugins/jira_data_center_review_fixes_spec.rb +81 -0
  293. data/spec/lib/pwn/plugins/jsonl_elf_review_fixes_spec.rb +59 -0
  294. data/spec/lib/pwn/plugins/log_spec.rb +36 -20
  295. data/spec/lib/pwn/plugins/monkey_patch_spec.rb +16 -0
  296. data/spec/lib/pwn/plugins/msr206_readback_review_fixes_spec.rb +119 -0
  297. data/spec/lib/pwn/plugins/msr206_review_fixes_spec.rb +50 -0
  298. data/spec/lib/pwn/plugins/msr206_transport_audit_spec.rb +64 -0
  299. data/spec/lib/pwn/plugins/nessus_cloud_namespace_audit_spec.rb +14 -0
  300. data/spec/lib/pwn/plugins/nexpose_review_fixes_spec.rb +55 -0
  301. data/spec/lib/pwn/plugins/open_api_namespace_audit_spec.rb +22 -0
  302. data/spec/lib/pwn/plugins/packet_transport_audit_spec.rb +47 -0
  303. data/spec/lib/pwn/plugins/plugins_b_operational_regression_spec.rb +600 -0
  304. data/spec/lib/pwn/plugins/pony_namespace_audit_spec.rb +17 -0
  305. data/spec/lib/pwn/plugins/pony_review_fixes_spec.rb +33 -0
  306. data/spec/lib/pwn/plugins/process_tube_namespace_audit_spec.rb +19 -0
  307. data/spec/lib/pwn/plugins/ps_namespace_audit_spec.rb +12 -0
  308. data/spec/lib/pwn/plugins/pwn_logger_spec.rb +30 -0
  309. data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +127 -0
  310. data/spec/lib/pwn/plugins/repl/ai_spec.rb +38 -0
  311. data/spec/lib/pwn/plugins/repl/mesh_spec.rb +52 -0
  312. data/spec/lib/pwn/plugins/repl_mesh_rx_errors_spec.rb +18 -0
  313. data/spec/lib/pwn/plugins/sandbox_spec.rb +9 -7
  314. data/spec/lib/pwn/plugins/sbom_review_fixes_spec.rb +43 -0
  315. data/spec/lib/pwn/plugins/scannable_codes_namespace_audit_spec.rb +15 -0
  316. data/spec/lib/pwn/plugins/serial_review_fixes_spec.rb +76 -0
  317. data/spec/lib/pwn/plugins/serial_transport_audit_spec.rb +102 -0
  318. data/spec/lib/pwn/plugins/shodan_namespace_audit_spec.rb +10 -0
  319. data/spec/lib/pwn/plugins/sock_transport_audit_spec.rb +55 -0
  320. data/spec/lib/pwn/plugins/transparent_browser_navigation_review_spec.rb +21 -0
  321. data/spec/lib/pwn/plugins/vault_master_key_eui_regression_spec.rb +242 -0
  322. data/spec/lib/pwn/plugins/vault_spec.rb +58 -0
  323. data/spec/lib/pwn/plugins/vault_store_safety_spec.rb +1 -1
  324. data/spec/lib/pwn/plugins/xxd_namespace_audit_spec.rb +34 -0
  325. data/spec/lib/pwn/plugins/yubikey_hid_cleanup_review_fixes_spec.rb +52 -0
  326. data/spec/lib/pwn/plugins/yubikey_lifecycle_audit_spec.rb +65 -0
  327. data/spec/lib/pwn/plugins/yubikey_options_audit_spec.rb +30 -0
  328. data/spec/lib/pwn/plugins/yubikey_selector_audit_spec.rb +26 -0
  329. data/spec/lib/pwn/plugins/yubikey_spec.rb +1 -1
  330. data/spec/lib/pwn/plugins/zaproxy_namespace_audit_spec.rb +30 -0
  331. data/spec/lib/pwn/reports/empty_report_audit_spec.rb +18 -0
  332. data/spec/lib/pwn/reports/pdf_spec.rb +25 -0
  333. data/spec/lib/pwn/reports/provider_review_encoding_regression_spec.rb +35 -0
  334. data/spec/lib/pwn/sast/engine_runtime_regression_spec.rb +91 -0
  335. data/spec/lib/pwn/sast/filter_edge_regression_spec.rb +39 -0
  336. data/spec/lib/pwn/sast/formatter_review_fixes_spec.rb +178 -0
  337. data/spec/lib/pwn/sast/path_review_fixes_spec.rb +60 -0
  338. data/spec/lib/pwn/sast/pom_runtime_regression_spec.rb +37 -0
  339. data/spec/lib/pwn/sast/rules_runtime_regression_spec.rb +78 -0
  340. data/spec/lib/pwn/sast/sql_review_fixes_spec.rb +38 -0
  341. data/spec/lib/pwn/sdr/decoder/base_iq_spec.rb +21 -18
  342. data/spec/lib/pwn/sdr/decoder/base_review_fixes_spec.rb +49 -0
  343. data/spec/lib/pwn/sdr/decoder/base_validation_spec.rb +78 -0
  344. data/spec/lib/pwn/sdr/decoder/lora_spec.rb +9 -0
  345. data/spec/lib/pwn/sdr/flipper_zero_review_fixes_spec.rb +34 -0
  346. data/spec/lib/pwn/sdr/gqrx_operational_spec.rb +83 -0
  347. data/spec/lib/pwn/sdr/gqrx_review_fixes_spec.rb +22 -0
  348. data/spec/lib/pwn/sdr/son_micro_rfid_review_fixes_spec.rb +113 -0
  349. data/spec/lib/pwn/sdr/son_micro_rfid_serial_review_fixes_spec.rb +76 -0
  350. data/spec/lib/pwn/sdr/son_micro_rfid_spec.rb +39 -0
  351. data/spec/lib/pwn/sdr_spec.rb +5 -0
  352. data/spec/lib/pwn/session_cleanup_concurrency_spec.rb +21 -0
  353. data/spec/lib/pwn/session_cleanup_default_spec.rb +1 -1
  354. data/spec/lib/pwn/session_cleanup_lifecycle_supplement_spec.rb +39 -0
  355. data/spec/lib/pwn/session_cleanup_payload_spec.rb +3 -2
  356. data/spec/lib/pwn/session_trace_lifecycle_supplement_spec.rb +39 -0
  357. data/spec/lib/pwn/sessions_archive_closure_spec.rb +126 -0
  358. data/spec/lib/pwn/sessions_lifecycle_closure_spec.rb +373 -0
  359. data/spec/lib/pwn/sessions_lifecycle_supplement_spec.rb +204 -0
  360. data/spec/lib/pwn/setup_operational_regression_spec.rb +36 -0
  361. data/spec/lib/pwn/www/browser_review_fixes_spec.rb +70 -0
  362. data/spec/lib/pwn/www/browser_runtime_regression_spec.rb +100 -0
  363. data/spec/lib/pwn/www/hacker_one_runtime_regression_spec.rb +146 -0
  364. data/spec/lib/pwn/www/pagination_review_fixes_spec.rb +84 -0
  365. data/spec/spec_helper.rb +34 -5
  366. data/spec/support/namespace_controller_observability_fixture.rb +141 -0
  367. data/spec/support/sandbox.rb +8 -5
  368. data/third_party/pwn_rdoc.jsonl +83 -32
  369. metadata +7690 -7386
  370. data/etc/default_skills/pwn/aws/elastic_transcoder/SKILL.md +0 -48
  371. data/etc/default_skills/pwn/aws/lambda_preview/SKILL.md +0 -48
  372. data/etc/default_skills/pwn/aws/ops_works/SKILL.md +0 -48
  373. data/etc/default_skills/pwn/aws/ops_works_cm/SKILL.md +0 -48
  374. data/etc/default_skills/pwn/aws/sms/SKILL.md +0 -48
  375. data/lib/pwn/aws/elastic_transcoder.rb +0 -95
  376. data/lib/pwn/aws/lambda_preview.rb +0 -95
  377. data/lib/pwn/aws/ops_works.rb +0 -95
  378. data/lib/pwn/aws/ops_works_cm.rb +0 -95
  379. data/lib/pwn/aws/sms.rb +0 -95
  380. data/spec/lib/pwn/aws/elastic_transcoder_spec.rb +0 -15
  381. data/spec/lib/pwn/aws/lambda_preview_spec.rb +0 -15
  382. data/spec/lib/pwn/aws/ops_works_cm_spec.rb +0 -15
  383. data/spec/lib/pwn/aws/ops_works_spec.rb +0 -15
  384. data/spec/lib/pwn/aws/sms_spec.rb +0 -15
@@ -14,6 +14,18 @@ describe PWN::Plugins::Log do
14
14
  expect(help_response).to respond_to :help
15
15
  end
16
16
 
17
+ describe 'unraised exception logging' do
18
+ include_context 'pwn tmp sandbox'
19
+
20
+ it 'persists an exception whose backtrace has not been populated' do
21
+ allow(Dir).to receive(:home).and_return(@tmp)
22
+ error = IOError.new('fixture unraised failure')
23
+ expect(error.backtrace).to be_nil
24
+ described_class.append(level: :warn, msg: error, which_self: 'fixture')
25
+ expect(File.read(File.join(@tmp, '.pwn', 'logs', 'pwn.log'))).to include('fixture unraised failure')
26
+ end
27
+ end
28
+
17
29
  describe 'pwn-ai debug session' do
18
30
  include_context 'pwn tmp sandbox'
19
31
 
@@ -59,7 +71,7 @@ describe PWN::Plugins::Log do
59
71
  expect(PWN::Plugins::Log).to respond_to(:quiet_tui!)
60
72
  expect(PWN::Plugins::Log).to respond_to(:loud_tui!)
61
73
  tee = StringIO.new
62
- path = PWN::Plugins::Log.start_debug(tee: tee, path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-quiet.log")
74
+ path = PWN::Plugins::Log.start_debug(tee: tee, path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-quiet.log")
63
75
  PWN::Plugins::Log.progress(msg: 'before-quiet', which_self: PWN::AI::Agent::Loop)
64
76
  PWN::Plugins::Log.quiet_tui!
65
77
  PWN::Plugins::Log.progress(msg: 'after-quiet', which_self: PWN::AI::Agent::Loop)
@@ -75,7 +87,7 @@ describe PWN::Plugins::Log do
75
87
  tee = StringIO.new
76
88
  PWN::Plugins::Log.start_debug(
77
89
  tee: tee,
78
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-ansi.log"
90
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-ansi.log"
79
91
  )
80
92
  PWN::Plugins::Log.progress(msg: 'stage-line', which_self: PWN::AI::Agent::Loop)
81
93
  shown = tee.string
@@ -88,7 +100,7 @@ describe PWN::Plugins::Log do
88
100
  it 'writes a multiline final body when keep_newlines is set' do
89
101
  path = PWN::Plugins::Log.start_debug(
90
102
  tee: StringIO.new,
91
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-finalbody.log"
103
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-finalbody.log"
92
104
  )
93
105
  PWN::Plugins::Log.progress(
94
106
  msg: "final text:\nline-one\nline-two",
@@ -103,7 +115,7 @@ describe PWN::Plugins::Log do
103
115
  it 'writes a full tool request/result with no char cap when cap is 0' do
104
116
  path = PWN::Plugins::Log.start_debug(
105
117
  tee: StringIO.new,
106
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-toolio.log"
118
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-toolio.log"
107
119
  )
108
120
  blob = 'x' * 8_000
109
121
  PWN::Plugins::Log.progress(
@@ -123,7 +135,7 @@ describe PWN::Plugins::Log do
123
135
  expect(PWN::Plugins::Log).to respond_to(:note_interrupt!)
124
136
  path = PWN::Plugins::Log.start_debug(
125
137
  tee: StringIO.new,
126
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-int.log"
138
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-int.log"
127
139
  )
128
140
  ok = PWN::Plugins::Log.note_interrupt!(where: 'CTRL+C')
129
141
  expect(ok).to eq true
@@ -136,7 +148,7 @@ describe PWN::Plugins::Log do
136
148
  it 'still timestamps Interrupt when progress reentrancy is stuck mid-write' do
137
149
  path = PWN::Plugins::Log.start_debug(
138
150
  tee: StringIO.new,
139
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-int-stuck.log"
151
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-int-stuck.log"
140
152
  )
141
153
  Thread.current[:pwn_log_progress] = true
142
154
  ok = PWN::Plugins::Log.note_interrupt!(where: 'CTRL+C')
@@ -152,7 +164,7 @@ describe PWN::Plugins::Log do
152
164
  it 'tees stderr Thread IOError dumps into the open request log' do
153
165
  path = PWN::Plugins::Log.start_debug(
154
166
  tee: StringIO.new,
155
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-ioerr.log"
167
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-ioerr.log"
156
168
  )
157
169
  $stderr.write("#<Thread:0xabc open3.rb:664 run> terminated with exception (report_on_exception is true):\n")
158
170
  $stderr.write("IOError stream closed in another thread\n")
@@ -166,7 +178,7 @@ describe PWN::Plugins::Log do
166
178
  it 'does not copy spinner frames from stderr into the request log' do
167
179
  path = PWN::Plugins::Log.start_debug(
168
180
  tee: StringIO.new,
169
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-spin.log"
181
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-spin.log"
170
182
  )
171
183
  $stderr.write("\r\e[1G⠴")
172
184
  $stderr.write("\r⠋")
@@ -182,7 +194,7 @@ describe PWN::Plugins::Log do
182
194
  expect(PWN::Plugins::Log).to respond_to(:note_exception!)
183
195
  path = PWN::Plugins::Log.start_debug(
184
196
  tee: StringIO.new,
185
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-exc.log"
197
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-exc.log"
186
198
  )
187
199
  err = NoMethodError.new("undefined method '+' for nil")
188
200
  err.set_backtrace(['/opt/pwn/lib/pwn/ai/grok.rb:470:in grok_rest_call', 'loop.rb:1'])
@@ -199,7 +211,7 @@ describe PWN::Plugins::Log do
199
211
  expect(PWN::Plugins::Log).to respond_to(:mirror_tui!)
200
212
  path = PWN::Plugins::Log.start_debug(
201
213
  tee: StringIO.new,
202
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-tui.log"
214
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-tui.log"
203
215
  )
204
216
  ok = PWN::Plugins::Log.mirror_tui!(
205
217
  msg: "\e[33m[ 2026-08-20 11:00:00-0600 → pwn-ai → pwn_eval ]\e[0m\n {\"code\":\"1+1\"}\n"
@@ -247,7 +259,7 @@ describe PWN::Plugins::Log do
247
259
  it 'does not TracePoint PWN calls unless trace: true' do
248
260
  path = PWN::Plugins::Log.start_debug(
249
261
  tee: StringIO.new,
250
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-notrace.log"
262
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-notrace.log"
251
263
  )
252
264
  PWN::AI::Agent::OpenGoal.current if defined?(PWN::AI::Agent::OpenGoal)
253
265
  body = File.read(path)
@@ -257,7 +269,7 @@ describe PWN::Plugins::Log do
257
269
  it 'traces Loop/Dispatch calls and not the rest of PWN::AI when trace: true' do
258
270
  path = PWN::Plugins::Log.start_debug(
259
271
  tee: StringIO.new,
260
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-#{Time.now.to_i}.log",
272
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-#{Time.now.to_i}.log",
261
273
  trace: true
262
274
  )
263
275
  PWN::AI::Agent::Dispatch.effect(name: 'skills_recall', args: {})
@@ -280,7 +292,7 @@ describe PWN::Plugins::Log do
280
292
  stub_const('PWN::AI::Agent::Loop::SymNameProbe', probe)
281
293
  PWN::Plugins::Log.start_debug(
282
294
  tee: StringIO.new,
283
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-sym.log",
295
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-sym.log",
284
296
  trace: true
285
297
  )
286
298
  expect { PWN::AI::Agent::Loop::SymNameProbe.ping }.not_to raise_error
@@ -295,7 +307,7 @@ describe PWN::Plugins::Log do
295
307
  stub_const('PWN::AI::Agent::Dispatch::ArgProbe', probe)
296
308
  path = PWN::Plugins::Log.start_debug(
297
309
  tee: StringIO.new,
298
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-args.log",
310
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-args.log",
299
311
  trace: true
300
312
  )
301
313
  PWN::AI::Agent::Dispatch::ArgProbe.echo(
@@ -320,7 +332,7 @@ describe PWN::Plugins::Log do
320
332
  stub_const('PWN::AI::Agent::Dispatch::ArgProbe', probe)
321
333
  path = PWN::Plugins::Log.start_debug(
322
334
  tee: StringIO.new,
323
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-redact.log",
335
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-redact.log",
324
336
  trace: true
325
337
  )
326
338
  PWN::AI::Agent::Dispatch::ArgProbe.echo(
@@ -343,6 +355,10 @@ describe PWN::Plugins::Log do
343
355
  end
344
356
 
345
357
  describe 'PWN::Plugins::Log toggle-trace step' do
358
+ include_context 'pwn tmp sandbox'
359
+
360
+ before { allow(Dir).to receive(:home).and_return(@tmp) }
361
+
346
362
  after do
347
363
  PWN::Plugins::Log.stop_debug if PWN::Plugins::Log.respond_to?(:stop_debug)
348
364
  end
@@ -351,7 +367,7 @@ describe 'PWN::Plugins::Log toggle-trace step' do
351
367
  io = StringIO.new("\n")
352
368
  path = PWN::Plugins::Log.start_debug(
353
369
  tee: StringIO.new,
354
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-step.log",
370
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-step.log",
355
371
  trace: true,
356
372
  step_io: io
357
373
  )
@@ -370,7 +386,7 @@ describe 'PWN::Plugins::Log toggle-trace step' do
370
386
  tee = StringIO.new
371
387
  PWN::Plugins::Log.start_debug(
372
388
  tee: tee,
373
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-enter-color.log",
389
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-enter-color.log",
374
390
  trace: true,
375
391
  step_io: io
376
392
  )
@@ -387,7 +403,7 @@ describe 'PWN::Plugins::Log toggle-trace step' do
387
403
  stub_const('PWN::AI::Agent::Dispatch::CfgProbe', probe)
388
404
  path = PWN::Plugins::Log.start_debug(
389
405
  tee: StringIO.new,
390
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-oauth.log",
406
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-oauth.log",
391
407
  trace: true
392
408
  )
393
409
  token = 'bnQe3hs8ZSP2KkHj3LSnwzIeDvDv0fmbTQEzsUx4XXW5g22D4Uu6hva_MYossX-GedInWt_dwTgGzpMxoKQECQ'
@@ -401,7 +417,7 @@ describe 'PWN::Plugins::Log toggle-trace step' do
401
417
  io = StringIO.new("\n")
402
418
  PWN::Plugins::Log.start_debug(
403
419
  tee: StringIO.new,
404
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-nostep.log",
420
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-nostep.log",
405
421
  step_io: io
406
422
  )
407
423
  expect(PWN::Plugins::Log.trace_enabled?).to eq(false)
@@ -410,7 +426,7 @@ describe 'PWN::Plugins::Log toggle-trace step' do
410
426
  PWN::Plugins::Log.stop_debug
411
427
  PWN::Plugins::Log.start_debug(
412
428
  tee: StringIO.new,
413
- path: "/tmp/pwn-ai-DEBUG-#{Process.pid}-nested.log",
429
+ path: "#{@tmp}/pwn-ai-DEBUG-#{Process.pid}-nested.log",
414
430
  trace: true,
415
431
  step_io: io
416
432
  )
@@ -13,6 +13,22 @@ describe PWN::Plugins::MonkeyPatch do
13
13
  expect(help_response).to respond_to :help
14
14
  end
15
15
 
16
+ it 'can install twice without replacing the original expression parser with its wrapper' do
17
+ require 'open3'
18
+ program = <<~RUBY
19
+ require 'pwn'
20
+ require 'pry'
21
+ 2.times { PWN::Plugins::MonkeyPatch.pry }
22
+ parser = Object.new.extend(MethodSource::CodeHelpers)
23
+ raise 'complete expression rejected' unless parser.complete_expression?('1 + 1')
24
+ raise 'incomplete expression accepted' if parser.complete_expression?('def fixture')
25
+ puts 'repeated installation preserves parser'
26
+ RUBY
27
+ stdout, stderr, status = Open3.capture3(RbConfig.ruby, '-Ilib', '-e', program)
28
+ expect(status.success?).to be(true), stderr
29
+ expect(stdout).to eq("repeated installation preserves parser\n")
30
+ end
31
+
16
32
  it 'routes CTRL+D in pwn-ai to leave_special_mode instead of exiting Pry' do
17
33
  src = File.read(described_class.method(:pry).source_location.first)
18
34
  expect(src).to include('leave_special_mode!')
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe PWN::Plugins::MSR206 do
6
+ before do
7
+ @commands = []
8
+ @log = StringIO.new
9
+ allow(described_class).to receive(:logger).and_return(Logger.new(@log))
10
+ allow(PWN::Plugins::Serial).to receive(:flush_session_data)
11
+ allow(PWN::Plugins::Serial).to receive(:request) { |options| @commands << options[:payload].dup }
12
+ allow(PWN::Plugins::Serial).to receive(:response) do
13
+ case @commands.last&.first
14
+ when 0x26 then ['3E']
15
+ when 0x51, 0x71, 0x55 then ['41 41 41']
16
+ when 0x52, 0x72, 0x56 then ['42 42 42']
17
+ when 0x53, 0x73, 0x57 then ['43 43 43']
18
+ else ['5E']
19
+ end
20
+ end
21
+ end
22
+
23
+ { iso: [[], [], []], iso_alt: [[0x31], [0x32], [0x33]], raw: [[0x5f, 0x35], [0x34], [0x37]] }.each do |encoding, formats|
24
+ it "verifies actual #{encoding} command parsing using exactly the written per-track formats" do
25
+ tracks = %w[AAA BBB CCC].each_with_index.map { |text, i| { decoded: text, track_format: formats[i] } }
26
+ original = Marshal.dump(tracks)
27
+ choice = { iso: 'I', iso_alt: 'A', raw: 'R' }.fetch(encoding)
28
+ allow(described_class).to receive(:gets).and_return("H\n", "H\n", "#{choice}\n")
29
+ result = nil
30
+ expect { result = described_class.write_card(msr206_obj: {}, encoding: encoding, track_data: tracks) }.not_to output(/AAA|BBB|CCC/).to_stdout
31
+ expect(result).to equal(tracks)
32
+ expect(Marshal.dump(tracks)).to eq(original)
33
+ readers = { iso: [0x51, 0x52, 0x53], iso_alt: [0x71, 0x72, 0x73], raw: [0x55, 0x56, 0x57] }.fetch(encoding)
34
+ expect(@commands.select { |cmd| readers.include?(cmd.first) }).to eq(readers.each_with_index.map { |cmd, i| [cmd] + formats[i] })
35
+ expect(@commands.last).to eq([0x7f])
36
+ expect(@commands).to include([encoding == :raw ? 0x40 : 0x5a])
37
+ expect(@log.string).not_to match(/AAA|BBB|CCC|41 41 41|42 42 42|43 43 43/)
38
+ end
39
+
40
+ it "rejects #{encoding} readback mismatches and does not replay or reset" do
41
+ tracks = %w[AAA BBB wrong].each_with_index.map { |text, i| { decoded: text, track_format: formats[i] } }
42
+ choice = { iso: 'I', iso_alt: 'A', raw: 'R' }.fetch(encoding)
43
+ allow(described_class).to receive(:gets).and_return("H\n", "H\n", "#{choice}\n")
44
+ expect { described_class.write_card(msr206_obj: {}, encoding: encoding, track_data: tracks) }.to raise_error(IOError, /readback mismatch/)
45
+ expect(@commands).not_to include([0x7f])
46
+ expect(@commands.count { |cmd| [0x41, 0x61, 0x45].include?(cmd.first) }).to eq(1)
47
+ end
48
+ end
49
+
50
+ %i[iso_alt raw].each do |encoding|
51
+ it "accepts actual #{encoding} backup candidates only with explicit format selections" do
52
+ choice = encoding == :iso_alt ? 'A' : 'R'
53
+ allow(described_class).to receive(:gets).and_return("#{choice}\n")
54
+ tracks = described_class.read_card(msr206_obj: {})
55
+ expect(tracks.length).to eq(encoding == :iso_alt ? 9 : 30)
56
+ @commands.clear
57
+ formats = encoding == :iso_alt ? [[0x31], [0x32], [0x33]] : [[0x33], [0x5f, 0x34], [0x37]]
58
+ allow(described_class).to receive(:gets).and_return("H\n", "H\n", "#{choice}\n")
59
+ expect(described_class.write_card(msr206_obj: {}, encoding: encoding, track_data: tracks, track_formats: formats)).to eq(tracks)
60
+ expect(@commands.last).to eq([0x7f])
61
+ end
62
+ end
63
+
64
+ it 'uses explicit format selections for three manual tracks without per-row format metadata' do
65
+ tracks = %w[AAA BBB CCC].map { |text| { decoded: text } }
66
+ formats = [[0x32], [0x31], [0x33]]
67
+ allow(described_class).to receive(:gets).and_return("H\n")
68
+ expect(described_class.write_card(msr206_obj: {}, encoding: :iso_alt, track_data: tracks, track_formats: formats)).to eq(tracks)
69
+ expect(@commands.select { |cmd| [0x71, 0x72, 0x73].include?(cmd.first) }).to eq([[0x71, 0x32], [0x72, 0x31], [0x73, 0x33]])
70
+ end
71
+
72
+ %i[clone_card load_card_from_file].each do |operation|
73
+ it "forwards explicit candidate formats through real #{operation} orchestration" do
74
+ Dir.mktmpdir('msr-backup-') do |root|
75
+ backup = File.join(root, 'synthetic.json')
76
+ allow(described_class).to receive(:gets).and_return("A\n", "#{backup}\n")
77
+ described_class.backup_card(msr206_obj: {}) if operation == :load_card_from_file
78
+ answers = operation == :clone_card ? ["A\n", "#{backup}\n", "H\n", "H\n"] : ["#{backup}\n", "H\n", "H\n"]
79
+ allow(described_class).to receive(:gets).and_return(*answers)
80
+ result = described_class.public_send(operation, msr206_obj: {}, track_formats: [[0x31], [0x32], [0x33]])
81
+ expect(result.length).to eq(9)
82
+ expect(@commands.last).to eq([0x7f])
83
+ end
84
+ end
85
+ end
86
+
87
+ it 'does not confuse command acknowledgments with track readback' do
88
+ allow(PWN::Plugins::Serial).to receive(:response).and_return(['5E'])
89
+ allow(described_class).to receive(:gets).and_return("H\n", "H\n", "I\n")
90
+ tracks = Array.new(3) { { decoded: '^' } }
91
+ expect { described_class.write_card(msr206_obj: {}, encoding: :iso, track_data: tracks) }.to raise_error(IOError, /readback/)
92
+ end
93
+
94
+ it 'does not disclose synthetic track bodies in the public update prompts' do
95
+ Dir.mktmpdir('msr-update-') do |root|
96
+ allow(described_class).to receive(:gets).and_return("I\n", "#{File.join(root, 'synthetic.json')}\n", "\n", "\n", "\n", "N\n")
97
+ result = nil
98
+ expect { result = described_class.update_card(msr206_obj: {}) }.not_to output(/AAA|BBB|CCC/).to_stdout
99
+ expect(result.map { |track| track[:decoded] }).to eq(%w[AAA BBB CCC])
100
+ expect(@log.string).not_to match(/AAA|BBB|CCC/)
101
+ end
102
+ end
103
+
104
+ it 'uses the prevalidated immutable batch even if the caller changes its source during prompts' do
105
+ tracks = %w[AAA BBB CCC].map { |text| { decoded: text } }
106
+ allow(described_class).to receive(:gets) do
107
+ tracks[0][:decoded] = 'changed'
108
+ "H\n"
109
+ end
110
+ # Old read_card prompts indefinitely on H; fail that old path without hardware.
111
+ allow(described_class).to receive(:read_card).and_wrap_original do |original, options|
112
+ raise IOError, 'readback was not format-correlated' unless options[:encoding]
113
+
114
+ original.call(options)
115
+ end
116
+ expect(described_class.write_card(msr206_obj: {}, encoding: :iso, track_data: tracks)).to eq(tracks)
117
+ expect(@commands).to include([0x41, 0x41, 0x41, 0x41, 0x04])
118
+ end
119
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe PWN::Plugins::MSR206 do
6
+ before do
7
+ @commands = []
8
+ @log = StringIO.new
9
+ allow(described_class).to receive(:logger).and_return(Logger.new(@log))
10
+ allow(PWN::Plugins::Serial).to receive(:request) { |options| @commands << options[:payload].dup }
11
+ allow(PWN::Plugins::Serial).to receive(:response).and_return(['5E'])
12
+ allow(PWN::Plugins::Serial).to receive(:flush_session_data)
13
+ allow(described_class).to receive(:gets).and_return("H\n")
14
+ allow(described_class).to receive(:read_card).and_return([{ decoded: 'A' }, { decoded: 'B' }, { decoded: 'C' }])
15
+ end
16
+
17
+ [nil, false].each do |selector|
18
+ it "rejects explicit #{selector.inspect} MSR selectors without substituting a device" do
19
+ allow(File).to receive(:exist?).and_call_original
20
+ allow(File).to receive(:exist?).with('/dev/ttyUSB0').and_return(true)
21
+ expect(UART).not_to receive(:open)
22
+ expect { described_class.connect(block_dev: selector) }.to raise_error(ArgumentError)
23
+ end
24
+ end
25
+
26
+ %i[iso_alt raw].each do |encoding|
27
+ [nil, false, 'invalid', [], [256], [0x5f], [0x31, 0x32]].each do |format|
28
+ it "prevalidates all #{encoding} formats including later malformed #{format.inspect}" do
29
+ tracks = [{ decoded: 'A' }, { decoded: 'B', track_format: format }, { decoded: 'C' }]
30
+ expect { described_class.write_card(msr206_obj: {}, encoding: encoding, track_data: tracks) }.to raise_error(ArgumentError)
31
+ expect(@commands).to be_empty
32
+ expect(described_class).not_to have_received(:gets)
33
+ end
34
+ end
35
+ end
36
+
37
+ %i[iso iso_alt raw].each do |encoding|
38
+ ["synthetic\x04", "synthetic\0", "synthetic\n", "synthetic\u00e9", 'A' * 1024].each do |payload|
39
+ it "rejects unencodable #{encoding} payloads before prompting or device commands" do
40
+ tracks = [{ decoded: 'A' }, { decoded: 'B' }, { decoded: payload }]
41
+ # The existing implementation can reach readback: keep that old path bounded.
42
+ allow(described_class).to receive(:read_card).and_return(tracks)
43
+ expect { described_class.write_card(msr206_obj: {}, encoding: encoding, track_data: tracks) }.to raise_error(ArgumentError)
44
+ expect(@commands).to be_empty
45
+ expect(described_class).not_to have_received(:gets)
46
+ expect(@log.string).not_to include(payload)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe PWN::Plugins::MSR206 do
6
+ let(:track_data) { [{ decoded: 'fixture-one' }, { decoded: 'fixture-two' }, { decoded: 'fixture-three' }] }
7
+
8
+ before do
9
+ @log = StringIO.new
10
+ allow(described_class).to receive(:logger).and_return(Logger.new(@log))
11
+ allow(PWN::Plugins::Serial).to receive(:flush_session_data)
12
+ end
13
+
14
+ it 'compares the readback to the requested track data, not write acknowledgments' do
15
+ allow(described_class).to receive(:gets).and_return("H\n")
16
+ allow(described_class).to receive(:exec).and_return(msg: :ack_command_completed)
17
+ allow(described_class).to receive(:wait_for_swipe).and_return([{ decoded: '^' }])
18
+ readback = track_data.each_with_index.map do |track, index|
19
+ track.merge(msg: :response, cmd: :"tx_iso_std_data_track#{index + 1}", encoding: :iso, track_format: [])
20
+ end
21
+ allow(described_class).to receive(:read_card).and_return(readback)
22
+ expect(described_class.write_card(msr206_obj: {}, encoding: :iso, track_data: track_data)).to eq(track_data)
23
+ end
24
+
25
+ it 'fails on a mismatching readback instead of returning apparent write success' do
26
+ allow(described_class).to receive(:gets).and_return("H\n")
27
+ allow(described_class).to receive(:exec).and_return(msg: :ack_command_completed)
28
+ allow(described_class).to receive(:wait_for_swipe).and_return([{ decoded: '^' }])
29
+ allow(described_class).to receive(:read_card).and_return([{ decoded: 'different' }])
30
+ expect { described_class.write_card(msr206_obj: {}, encoding: :iso, track_data: track_data) }.to raise_error(IOError, /readback/)
31
+ end
32
+
33
+ it 'validates the whole write batch before changing density or writing the first track' do
34
+ allow(described_class).to receive(:gets).and_return("H\n")
35
+ allow(described_class).to receive(:exec).and_raise('fixture guard: device write before validation')
36
+ expect { described_class.write_card(msr206_obj: {}, encoding: :iso, track_data: [{ decoded: 'partial' }]) }.to raise_error(ArgumentError, /three tracks/)
37
+ expect(described_class).not_to have_received(:exec)
38
+ end
39
+
40
+ it 'keeps command bytes and track responses out of diagnostic logs' do
41
+ allow(PWN::Plugins::Serial).to receive(:request)
42
+ allow(described_class).to receive(:parse_responses).and_return(decoded: 'fixture-private-track', hex: ['73 65 63 72 65 74'])
43
+ described_class.exec(msr206_obj: {}, cmd: :load_iso_std_data_for_writing_track1, params: [115, 101, 99, 114, 101, 116])
44
+ expect(@log.string).not_to include('fixture-private-track', '73 65 63 72 65 74', '[115, 101, 99, 114, 101, 116]')
45
+ end
46
+
47
+ %i[arm_to_read arm_to_write_no_raw].each do |type|
48
+ %i[iso iso_alt raw].each do |encoding|
49
+ it "keeps #{type} #{encoding} track payloads off diagnostic stdout" do
50
+ allow(described_class).to receive(:exec).and_return(msg: :ack_command_completed, decoded: 'fixture-private-track')
51
+ allow(described_class).to receive(:parse_responses).and_return(msg: :ack_command_completed)
52
+ expect do
53
+ described_class.send(:wait_for_swipe, msr206_obj: {}, type: type, encoding: encoding, track_data: track_data)
54
+ end.not_to output(/fixture-private-track|102, 105, 120, 116/).to_stdout
55
+ end
56
+ end
57
+ end
58
+
59
+ it 'rejects unknown protocol selectors rather than sending USI1' do
60
+ allow(described_class).to receive(:exec)
61
+ expect { described_class.set_protocol(msr206_obj: {}, protocol: :typo) }.to raise_error(ArgumentError, /protocol/)
62
+ expect(described_class).not_to have_received(:exec)
63
+ end
64
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'rest-client'
5
+
6
+ RSpec.describe PWN::Plugins::NessusCloud, 'credential defaults regression' do
7
+ it 'selects the documented Host SSH defaults when no filters are passed' do
8
+ allow(described_class).to receive(:sleep)
9
+ allow(PWN::Plugins::TransparentBrowser).to receive(:open).and_return(browser: RestClient)
10
+ response = double('response', body: { credentials: [{ category: 'Host', types: [{ name: 'SSH', id: 'ssh' }] }] }.to_json)
11
+ allow(RestClient::Request).to receive(:execute).and_return(response)
12
+ expect(described_class.get_credential_types(nessus_obj: {})).to eq(name: 'SSH', id: 'ssh')
13
+ end
14
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe PWN::Plugins::NexposeVulnScan do
6
+ let(:client) { double('nexpose') }
7
+ let(:logger) { described_class.class_variable_get(:@@logger) }
8
+
9
+ before do
10
+ allow(client).to receive(:list_sites).and_return([double('site', name: 'fixture', id: 7)])
11
+ allow(client).to receive(:scan_site).with(7).and_return(41)
12
+ allow(logger).to receive(:info)
13
+ end
14
+
15
+ it '[PBR-05] does not call an aborted activity row completed' do
16
+ allow(client).to receive(:scan_activity).and_return([double('scan', site_id: 7, status: 'aborted')])
17
+ expect(described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture', poll_interval: 0)).to be_nil
18
+ expect(logger).not_to have_received(:info).with(/Completed/)
19
+ end
20
+
21
+ it '[PBR-05] polls the launched site through active states to explicit success' do
22
+ foreign = double('foreign', site_id: 7, scan_id: 40, status: 'finished')
23
+ allow(client).to receive(:scan_activity).and_return(
24
+ [foreign, double('scan', site_id: 7, scan_id: 41, status: 'dispatched')],
25
+ [foreign, double('scan', site_id: 7, scan_id: 41, status: 'paused')],
26
+ [foreign, double('scan', site_id: 7, scan_id: 41, status: 'integrating')],
27
+ [foreign, double('scan', site_id: 7, scan_id: 41, status: 'finished')]
28
+ )
29
+ expect(described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture', poll_interval: 0)).to equal(client)
30
+ end
31
+
32
+ it '[PBR-05] bounds persistent active states and reports unknown, not success' do
33
+ allow(client).to receive(:scan_activity).and_return([double('scan', site_id: 7, scan_id: 41, status: 'running')])
34
+ expect { described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture', poll_interval: 0, max_polls: 2) }.to raise_error(IOError, /unknown.*poll limit/)
35
+ end
36
+
37
+ it '[PBR-05] bounds a blocked activity request' do
38
+ allow(client).to receive(:scan_activity) { sleep 1 }
39
+ expect { described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture', timeout: 0.01) }.to raise_error(IOError, /unknown.*deadline/)
40
+ end
41
+
42
+ [nil, 'unknown', 'SYNTHETIC-PRIVATE-STATUS'].each do |status|
43
+ it "[PBR-05] treats #{status.inspect} status as incomplete without echoing it" do
44
+ allow(client).to receive(:scan_activity).and_return([double('scan', site_id: 7, scan_id: 41, status: status)])
45
+ expect(described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture', poll_interval: 0)).to be_nil
46
+ expect(logger).not_to have_received(:info).with(/SYNTHETIC-PRIVATE-STATUS|Completed/)
47
+ end
48
+ end
49
+
50
+ it '[PBR-05] refuses a missing launch identity rather than polling unrelated activity' do
51
+ allow(client).to receive(:scan_site).and_return(nil)
52
+ expect(client).not_to receive(:scan_activity)
53
+ expect { described_class.scan_site_by_name(nsc_obj: client, site_name: 'fixture') }.to raise_error(IOError, /unknown.*identity/)
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'tmpdir'
5
+
6
+ RSpec.describe PWN::Plugins::OpenAPI, 'root path regression' do
7
+ it 'retains a root endpoint when normalizing server path prefixes' do
8
+ Dir.mktmpdir('openapi-audit') do |dir|
9
+ source = File.join(dir, 'input.json')
10
+ output = File.join(dir, 'output.json')
11
+ File.write(source, JSON.generate(openapi: '3.0.3', info: { title: 'Fixture', version: '1' }, paths: { '/' => { get: { responses: { '200' => { description: 'OK' } } } } }))
12
+ allow(RestClient).to receive(:get).and_return('{"type":"object"}')
13
+ previous_dir = Dir.pwd
14
+ begin
15
+ described_class.generate_spec(spec_paths: [source], base_url: 'https://example.invalid', output_json_path: output)
16
+ expect(JSON.parse(File.read(output))['paths']).to have_key('/')
17
+ ensure
18
+ Dir.chdir(previous_dir)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe PWN::Plugins::Packet, 'offline constructors' do
6
+ let(:options) do
7
+ { ip_saddr: '192.0.2.1', ip_daddr: '192.0.2.2', ipv6_saddr: '2001:db8::1', ipv6_daddr: '2001:db8::2',
8
+ eth_src: '00:11:22:33:44:55', eth_dst: '00:11:22:33:44:66', arp_src_mac: '00:11:22:33:44:55', arp_dst_mac: '00:11:22:33:44:66' }
9
+ end
10
+
11
+ before do
12
+ # Never let a constructor discover interfaces or send PacketFu's ARP probe.
13
+ allow(PacketFu::Utils).to receive(:whoami?).and_return({})
14
+ end
15
+
16
+ %i[arp eth hsrp icmp icmpv6 ip ipv6 tcp udp].each do |protocol|
17
+ it "constructs #{protocol} without network discovery" do
18
+ packet = described_class.public_send(:"construct_#{protocol}", options)
19
+ expect(packet.to_s).not_to be_empty
20
+ expect(PacketFu::Utils).not_to have_received(:whoami?)
21
+ end
22
+ end
23
+
24
+ it 'preserves distinct HSRP state and hello-time values' do
25
+ packet = described_class.construct_hsrp(options.merge(hsrp_state: 16, hsrp_hellotime: 7))
26
+ expect(packet.hsrp_state).to eq(16)
27
+ expect(packet.hsrp_hellotime).to eq(7)
28
+ end
29
+
30
+ it 'encodes IPv6 traffic class, flow label, next header and hop limit' do
31
+ packet = described_class.construct_ipv6(options.merge(ipv6_class: 42, ipv6_label: 1234, ipv6_next: 59, ipv6_hop: 7))
32
+ expect(packet.to_s.byteslice(14, 8).unpack('NnCC')).to eq([0x62a004d2, 0, 59, 7])
33
+ end
34
+
35
+ it 'uses the ICMPv6 packet class and caller checksum rather than IPv4 fields' do
36
+ packet = described_class.construct_icmpv6(options.merge(icmpv6_type: 129, icmpv6_sum: 0x1234))
37
+ expect(packet).to be_a(PacketFu::ICMPv6Packet)
38
+ expect(packet.to_s.byteslice(54, 4).unpack('CCn')).to eq([129, 0, 0x1234])
39
+ end
40
+
41
+ it 'forwards TCP flags and options into the serialized packet' do
42
+ flags = PacketFu::TcpFlags.new(syn: 1)
43
+ packet = described_class.construct_tcp(options.merge(tcp_flags: flags, tcp_opts: "\x01\x01\x01\x01".b))
44
+ expect(packet.tcp_flags.syn).to eq(1)
45
+ expect(packet.tcp_opts).to eq("\x01\x01\x01\x01".b)
46
+ end
47
+ end