immunio 1.2.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (291) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -5
  3. data/ext/immunio/Rakefile +14 -6
  4. data/lib/immunio/context.rb +2 -0
  5. data/lib/immunio/plugins/action_view.rb +7 -668
  6. data/lib/immunio/plugins/action_view/action_view.rb +22 -0
  7. data/lib/immunio/plugins/action_view/active_support_hash.rb +29 -0
  8. data/lib/immunio/plugins/action_view/cache_store.rb +24 -0
  9. data/lib/immunio/plugins/action_view/erubi.rb +38 -0
  10. data/lib/immunio/plugins/action_view/erubis.rb +39 -0
  11. data/lib/immunio/plugins/action_view/fragment_caching.rb +29 -0
  12. data/lib/immunio/plugins/action_view/haml.rb +46 -0
  13. data/lib/immunio/plugins/action_view/slim.rb +42 -0
  14. data/lib/immunio/plugins/action_view/template.rb +431 -0
  15. data/lib/immunio/plugins/action_view/template_rendering.rb +45 -0
  16. data/lib/immunio/plugins/http_tracker.rb +2 -0
  17. data/lib/immunio/plugins/io.rb +34 -0
  18. data/lib/immunio/version.rb +1 -1
  19. data/lua-hooks/Makefile +36 -9
  20. data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
  21. data/lua-hooks/ext/luajit/Makefile +22 -15
  22. data/lua-hooks/ext/luajit/README +2 -2
  23. data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
  24. data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
  25. data/lua-hooks/ext/luajit/doc/changes.html +69 -3
  26. data/lua-hooks/ext/luajit/doc/contact.html +10 -3
  27. data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
  28. data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
  29. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
  30. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +3 -4
  31. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
  32. data/lua-hooks/ext/luajit/doc/ext_jit.html +3 -3
  33. data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
  34. data/lua-hooks/ext/luajit/doc/extensions.html +47 -20
  35. data/lua-hooks/ext/luajit/doc/faq.html +2 -2
  36. data/lua-hooks/ext/luajit/doc/install.html +74 -45
  37. data/lua-hooks/ext/luajit/doc/luajit.html +5 -5
  38. data/lua-hooks/ext/luajit/doc/running.html +3 -3
  39. data/lua-hooks/ext/luajit/doc/status.html +13 -8
  40. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
  41. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +1 -1
  42. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
  43. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +1 -1
  44. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +8 -5
  45. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +66 -11
  46. data/lua-hooks/ext/luajit/dynasm/dasm_mips64.lua +12 -0
  47. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
  48. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +1 -1
  49. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +1 -1
  50. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
  51. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +1 -1
  52. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +5 -1
  53. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +2 -2
  54. data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
  55. data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
  56. data/lua-hooks/ext/luajit/src/Makefile +15 -11
  57. data/lua-hooks/ext/luajit/src/Makefile.dep +16 -16
  58. data/lua-hooks/ext/luajit/src/host/buildvm.c +2 -2
  59. data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
  60. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +9 -4
  61. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +2 -2
  62. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
  63. data/lua-hooks/ext/luajit/src/host/buildvm_libbc.h +14 -3
  64. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +27 -3
  65. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
  66. data/lua-hooks/ext/luajit/src/host/genminilua.lua +6 -5
  67. data/lua-hooks/ext/luajit/src/host/minilua.c +1 -1
  68. data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
  69. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +8 -8
  70. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +2 -2
  71. data/lua-hooks/ext/luajit/src/jit/dis_arm64.lua +1216 -0
  72. data/lua-hooks/ext/luajit/src/jit/dis_arm64be.lua +12 -0
  73. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +35 -20
  74. data/lua-hooks/ext/luajit/src/jit/dis_mips64.lua +17 -0
  75. data/lua-hooks/ext/luajit/src/jit/dis_mips64el.lua +17 -0
  76. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
  77. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +2 -2
  78. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
  79. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +7 -4
  80. data/lua-hooks/ext/luajit/src/jit/dump.lua +17 -12
  81. data/lua-hooks/ext/luajit/src/jit/p.lua +3 -2
  82. data/lua-hooks/ext/luajit/src/jit/v.lua +2 -2
  83. data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
  84. data/lua-hooks/ext/luajit/src/lauxlib.h +14 -20
  85. data/lua-hooks/ext/luajit/src/lib_aux.c +38 -27
  86. data/lua-hooks/ext/luajit/src/lib_base.c +12 -5
  87. data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
  88. data/lua-hooks/ext/luajit/src/lib_debug.c +5 -5
  89. data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -2
  90. data/lua-hooks/ext/luajit/src/lib_init.c +16 -16
  91. data/lua-hooks/ext/luajit/src/lib_io.c +6 -7
  92. data/lua-hooks/ext/luajit/src/lib_jit.c +14 -4
  93. data/lua-hooks/ext/luajit/src/lib_math.c +1 -5
  94. data/lua-hooks/ext/luajit/src/lib_os.c +1 -1
  95. data/lua-hooks/ext/luajit/src/lib_package.c +14 -23
  96. data/lua-hooks/ext/luajit/src/lib_string.c +1 -5
  97. data/lua-hooks/ext/luajit/src/lib_table.c +21 -1
  98. data/lua-hooks/ext/luajit/src/lj.supp +3 -3
  99. data/lua-hooks/ext/luajit/src/lj_alloc.c +174 -83
  100. data/lua-hooks/ext/luajit/src/lj_api.c +97 -18
  101. data/lua-hooks/ext/luajit/src/lj_arch.h +54 -22
  102. data/lua-hooks/ext/luajit/src/lj_asm.c +172 -53
  103. data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
  104. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +19 -16
  105. data/lua-hooks/ext/luajit/src/lj_asm_arm64.h +2022 -0
  106. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +564 -158
  107. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +19 -18
  108. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +578 -92
  109. data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
  110. data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
  111. data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
  112. data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
  113. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
  114. data/lua-hooks/ext/luajit/src/lj_buf.c +1 -1
  115. data/lua-hooks/ext/luajit/src/lj_buf.h +1 -1
  116. data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
  117. data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
  118. data/lua-hooks/ext/luajit/src/lj_ccall.c +172 -7
  119. data/lua-hooks/ext/luajit/src/lj_ccall.h +21 -5
  120. data/lua-hooks/ext/luajit/src/lj_ccallback.c +71 -17
  121. data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
  122. data/lua-hooks/ext/luajit/src/lj_cconv.c +4 -2
  123. data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
  124. data/lua-hooks/ext/luajit/src/lj_cdata.c +7 -5
  125. data/lua-hooks/ext/luajit/src/lj_cdata.h +1 -1
  126. data/lua-hooks/ext/luajit/src/lj_clib.c +5 -5
  127. data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
  128. data/lua-hooks/ext/luajit/src/lj_cparse.c +11 -6
  129. data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
  130. data/lua-hooks/ext/luajit/src/lj_crecord.c +70 -14
  131. data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
  132. data/lua-hooks/ext/luajit/src/lj_ctype.c +1 -1
  133. data/lua-hooks/ext/luajit/src/lj_ctype.h +8 -8
  134. data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
  135. data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
  136. data/lua-hooks/ext/luajit/src/lj_def.h +6 -9
  137. data/lua-hooks/ext/luajit/src/lj_dispatch.c +3 -3
  138. data/lua-hooks/ext/luajit/src/lj_dispatch.h +2 -1
  139. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +5 -4
  140. data/lua-hooks/ext/luajit/src/lj_emit_arm64.h +419 -0
  141. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +100 -20
  142. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +4 -4
  143. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +116 -25
  144. data/lua-hooks/ext/luajit/src/lj_err.c +34 -13
  145. data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
  146. data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
  147. data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
  148. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +58 -49
  149. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
  150. data/lua-hooks/ext/luajit/src/lj_frame.h +33 -6
  151. data/lua-hooks/ext/luajit/src/lj_func.c +4 -2
  152. data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
  153. data/lua-hooks/ext/luajit/src/lj_gc.c +16 -7
  154. data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
  155. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +31 -1
  156. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
  157. data/lua-hooks/ext/luajit/src/lj_ir.c +69 -96
  158. data/lua-hooks/ext/luajit/src/lj_ir.h +29 -18
  159. data/lua-hooks/ext/luajit/src/lj_ircall.h +24 -30
  160. data/lua-hooks/ext/luajit/src/lj_iropt.h +9 -9
  161. data/lua-hooks/ext/luajit/src/lj_jit.h +67 -9
  162. data/lua-hooks/ext/luajit/src/lj_lex.c +1 -1
  163. data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
  164. data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
  165. data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
  166. data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
  167. data/lua-hooks/ext/luajit/src/lj_mcode.c +11 -10
  168. data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
  169. data/lua-hooks/ext/luajit/src/lj_meta.c +1 -1
  170. data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
  171. data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
  172. data/lua-hooks/ext/luajit/src/lj_obj.h +7 -3
  173. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
  174. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +84 -17
  175. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
  176. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +3 -3
  177. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +24 -22
  178. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +11 -6
  179. data/lua-hooks/ext/luajit/src/lj_opt_split.c +11 -2
  180. data/lua-hooks/ext/luajit/src/lj_parse.c +9 -7
  181. data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
  182. data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
  183. data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
  184. data/lua-hooks/ext/luajit/src/lj_record.c +201 -117
  185. data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
  186. data/lua-hooks/ext/luajit/src/lj_snap.c +72 -26
  187. data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
  188. data/lua-hooks/ext/luajit/src/lj_state.c +6 -6
  189. data/lua-hooks/ext/luajit/src/lj_state.h +2 -2
  190. data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
  191. data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
  192. data/lua-hooks/ext/luajit/src/lj_strfmt.c +7 -3
  193. data/lua-hooks/ext/luajit/src/lj_strfmt.h +1 -1
  194. data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +4 -3
  195. data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
  196. data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
  197. data/lua-hooks/ext/luajit/src/lj_tab.c +1 -2
  198. data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
  199. data/lua-hooks/ext/luajit/src/lj_target.h +3 -3
  200. data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
  201. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +239 -7
  202. data/lua-hooks/ext/luajit/src/lj_target_mips.h +111 -22
  203. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
  204. data/lua-hooks/ext/luajit/src/lj_target_x86.h +21 -4
  205. data/lua-hooks/ext/luajit/src/lj_trace.c +63 -18
  206. data/lua-hooks/ext/luajit/src/lj_trace.h +2 -1
  207. data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -1
  208. data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
  209. data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
  210. data/lua-hooks/ext/luajit/src/lj_vm.h +5 -1
  211. data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
  212. data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
  213. data/lua-hooks/ext/luajit/src/lj_vmmath.c +1 -1
  214. data/lua-hooks/ext/luajit/src/ljamalg.c +1 -1
  215. data/lua-hooks/ext/luajit/src/lua.h +9 -1
  216. data/lua-hooks/ext/luajit/src/luaconf.h +3 -7
  217. data/lua-hooks/ext/luajit/src/luajit.c +69 -54
  218. data/lua-hooks/ext/luajit/src/luajit.h +4 -4
  219. data/lua-hooks/ext/luajit/src/lualib.h +1 -1
  220. data/lua-hooks/ext/luajit/src/msvcbuild.bat +12 -4
  221. data/lua-hooks/ext/luajit/src/vm_arm.dasc +1 -1
  222. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +255 -32
  223. data/lua-hooks/ext/luajit/src/vm_mips.dasc +26 -23
  224. data/lua-hooks/ext/luajit/src/vm_mips64.dasc +5062 -0
  225. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +1 -1
  226. data/lua-hooks/ext/luajit/src/vm_x64.dasc +24 -25
  227. data/lua-hooks/ext/luajit/src/vm_x86.dasc +77 -4
  228. data/lua-hooks/libluahooks.darwin.a +0 -0
  229. data/lua-hooks/libluahooks.linux.a +0 -0
  230. data/lua-hooks/options.mk +1 -1
  231. metadata +37 -77
  232. data/lua-hooks/ext/all.c +0 -69
  233. data/lua-hooks/ext/libinjection/COPYING +0 -37
  234. data/lua-hooks/ext/libinjection/libinjection.h +0 -65
  235. data/lua-hooks/ext/libinjection/libinjection_html5.c +0 -847
  236. data/lua-hooks/ext/libinjection/libinjection_html5.h +0 -54
  237. data/lua-hooks/ext/libinjection/libinjection_sqli.c +0 -2301
  238. data/lua-hooks/ext/libinjection/libinjection_sqli.h +0 -295
  239. data/lua-hooks/ext/libinjection/libinjection_sqli_data.h +0 -9349
  240. data/lua-hooks/ext/libinjection/libinjection_xss.c +0 -531
  241. data/lua-hooks/ext/libinjection/libinjection_xss.h +0 -21
  242. data/lua-hooks/ext/libinjection/lualib.c +0 -145
  243. data/lua-hooks/ext/libinjection/module.mk +0 -5
  244. data/lua-hooks/ext/lpeg/HISTORY +0 -96
  245. data/lua-hooks/ext/lpeg/lpcap.c +0 -537
  246. data/lua-hooks/ext/lpeg/lpcap.h +0 -56
  247. data/lua-hooks/ext/lpeg/lpcode.c +0 -1014
  248. data/lua-hooks/ext/lpeg/lpcode.h +0 -40
  249. data/lua-hooks/ext/lpeg/lpeg-128.gif +0 -0
  250. data/lua-hooks/ext/lpeg/lpeg.html +0 -1445
  251. data/lua-hooks/ext/lpeg/lpprint.c +0 -244
  252. data/lua-hooks/ext/lpeg/lpprint.h +0 -36
  253. data/lua-hooks/ext/lpeg/lptree.c +0 -1303
  254. data/lua-hooks/ext/lpeg/lptree.h +0 -82
  255. data/lua-hooks/ext/lpeg/lptypes.h +0 -149
  256. data/lua-hooks/ext/lpeg/lpvm.c +0 -364
  257. data/lua-hooks/ext/lpeg/lpvm.h +0 -58
  258. data/lua-hooks/ext/lpeg/makefile +0 -55
  259. data/lua-hooks/ext/lpeg/module.mk +0 -6
  260. data/lua-hooks/ext/lpeg/re.html +0 -498
  261. data/lua-hooks/ext/lua-cmsgpack/.gitignore +0 -13
  262. data/lua-hooks/ext/lua-cmsgpack/CMakeLists.txt +0 -45
  263. data/lua-hooks/ext/lua-cmsgpack/README.md +0 -115
  264. data/lua-hooks/ext/lua-cmsgpack/lua_cmsgpack.c +0 -970
  265. data/lua-hooks/ext/lua-cmsgpack/module.mk +0 -2
  266. data/lua-hooks/ext/lua-cmsgpack/test.lua +0 -570
  267. data/lua-hooks/ext/lua-snapshot/LICENSE +0 -7
  268. data/lua-hooks/ext/lua-snapshot/Makefile +0 -12
  269. data/lua-hooks/ext/lua-snapshot/README.md +0 -18
  270. data/lua-hooks/ext/lua-snapshot/dump.lua +0 -15
  271. data/lua-hooks/ext/lua-snapshot/module.mk +0 -2
  272. data/lua-hooks/ext/lua-snapshot/snapshot.c +0 -462
  273. data/lua-hooks/ext/luautf8/README.md +0 -152
  274. data/lua-hooks/ext/luautf8/lutf8lib.c +0 -1274
  275. data/lua-hooks/ext/luautf8/module.mk +0 -2
  276. data/lua-hooks/ext/luautf8/unidata.h +0 -3064
  277. data/lua-hooks/ext/module.mk +0 -15
  278. data/lua-hooks/ext/modules.h +0 -17
  279. data/lua-hooks/ext/perf/luacpu.c +0 -114
  280. data/lua-hooks/ext/perf/lualoadavg.c +0 -40
  281. data/lua-hooks/ext/perf/luameminfo.c +0 -38
  282. data/lua-hooks/ext/perf/luaoslib.c +0 -203
  283. data/lua-hooks/ext/perf/module.mk +0 -5
  284. data/lua-hooks/ext/sha1/luasha1.c +0 -74
  285. data/lua-hooks/ext/sha1/module.mk +0 -5
  286. data/lua-hooks/ext/sha1/sha1.c +0 -145
  287. data/lua-hooks/ext/sha2/luasha256.c +0 -77
  288. data/lua-hooks/ext/sha2/module.mk +0 -5
  289. data/lua-hooks/ext/sha2/sha256.c +0 -196
  290. data/lua-hooks/ext/sysutils/lua_utils.c +0 -56
  291. data/lua-hooks/ext/sysutils/module.mk +0 -2
@@ -1,7 +0,0 @@
1
- Copyright (c) 2012 codingow.com
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,12 +0,0 @@
1
- .PHONY : all linux mingw
2
-
3
- all : linux
4
-
5
- linux :
6
- gcc -g -Wall --shared -o snapshot.so snapshot.c
7
-
8
- mingw :
9
- gcc -g -Wall --shared -o snapshot.dll snapshot.c -I/usr/local/include -L/usr/local/bin -llua52
10
-
11
- mingw51 :
12
- gcc -g -Wall --shared -o snapshot.dll snapshot.c -I/usr/local/include -L/usr/local/bin -llua51
@@ -1,18 +0,0 @@
1
- lua-snapshot
2
- ============
3
-
4
- Make a snapshot for lua state to detect memory leaks.
5
-
6
- See dump.lua for example.
7
-
8
- Build
9
- =====
10
-
11
- make linux
12
-
13
- or
14
-
15
- make mingw (in windows)
16
-
17
-
18
-
@@ -1,15 +0,0 @@
1
- require "snapshot"
2
-
3
- snapshot.tron()
4
- local S1 = snapshot.snapshot()
5
-
6
- local tmp_local = {}
7
- tmp_global = {}
8
- local S2 = snapshot.snapshot()
9
- print('RESULT:')
10
- for k,v in pairs(S2) do
11
- if S1[k] == nil then
12
- print(k,v)
13
- end
14
- end
15
-
@@ -1,2 +0,0 @@
1
- SRC += \
2
- ext/lua-snapshot/snapshot.c
@@ -1,462 +0,0 @@
1
- #include "lua.h"
2
- #include "lauxlib.h"
3
- #ifdef LUAJIT
4
- // For access to Luajit internals
5
- # include "lj_obj.h"
6
- #endif
7
- static void mark_object(lua_State *L, lua_State *dL, const void * parent, const char * desc);
8
-
9
- static int trace = 0;
10
-
11
- #ifdef LUAJIT
12
- # define STACK_TOP ((mref(L->maxstack,char) == (char *)L->top) && (trace? 0!=printf("snapshot-trace: WARNING OUT OF STACK!\n"):1))
13
- #else
14
- # define STACK_TOP ((L->top >= L->ci->top) && (trace? 0!=printf("snapshot-trace: WARNING OUT OF STACK!\n"):1))
15
- #endif
16
- #define ISTABLE(offset) (lua_type(L, offset) == LUA_TTABLE )
17
- #define ISFUNCTION(offset) (lua_type(L, offset) == LUA_TFUNCTION )
18
- /* The default stack of 20 is too small. It's hard to imagine exceeding 200 */
19
- #define SNAPSHOT_STACK 200
20
- #if LUA_VERSION_NUM == 501
21
-
22
- static void
23
- luaL_checkversion(lua_State *L) {
24
- if (lua_pushthread(L) == 0) {
25
- luaL_error(L, "Must require in main thread");
26
- }
27
- lua_setfield(L, LUA_REGISTRYINDEX, "mainthread");
28
- }
29
-
30
- static void
31
- lua_rawsetp(lua_State *L, int idx, const void *p) {
32
- if (idx < 0) {
33
- idx += lua_gettop(L) + 1;
34
- }
35
- lua_pushlightuserdata(L, (void *)p);
36
- lua_insert(L, -2);
37
- lua_rawset(L, idx);
38
- }
39
-
40
- static void
41
- lua_rawgetp(lua_State *L, int idx, const void *p) {
42
- if (idx < 0) {
43
- idx += lua_gettop(L) + 1;
44
- }
45
- lua_pushlightuserdata(L, (void *)p);
46
- lua_rawget(L, idx);
47
- }
48
-
49
- static void
50
- lua_getuservalue(lua_State *L, int idx) {
51
- lua_getfenv(L, idx);
52
- }
53
-
54
-
55
- static int
56
- mark_function_env(lua_State *L, lua_State *dL, const void * t) {
57
- /* prevent fetching off the top of the stack */
58
- if (STACK_TOP) return 0;
59
- lua_getfenv(L,-1);
60
- if (lua_istable(L,-1)) {
61
- mark_object(L, dL, t, "[environment]");
62
- } else {
63
- lua_pop(L,1);
64
- }
65
- return 1;
66
- }
67
-
68
- #else
69
-
70
- #define mark_function_env(L,dL,t)
71
-
72
- #endif
73
-
74
- #include <stdbool.h>
75
- #include <stdio.h>
76
- #include <string.h>
77
-
78
- #define TABLE 1
79
- #define FUNCTION 2
80
- #define SOURCE 3
81
- #define THREAD 4
82
- #define USERDATA 5
83
- #define MARK 6
84
-
85
- static bool
86
- ismarked(lua_State *dL, const void *p) {
87
- lua_rawgetp(dL, MARK, p);
88
- if (lua_isnil(dL,-1)) {
89
- lua_pop(dL,1);
90
- lua_pushboolean(dL,1);
91
- lua_rawsetp(dL, MARK, p);
92
- return false;
93
- }
94
- lua_pop(dL,1);
95
- return true;
96
- }
97
-
98
- static const void *
99
- readobject(lua_State *L, lua_State *dL, const void *parent, const char *desc) {
100
- if ( trace ) {
101
- printf("snapshot-trace: readobject(%s)\n", desc);
102
- }
103
- int t = lua_type(L, -1);
104
- int tidx = 0;
105
- switch (t) {
106
- case LUA_TTABLE:
107
- tidx = TABLE;
108
- break;
109
- case LUA_TFUNCTION:
110
- tidx = FUNCTION;
111
- break;
112
- case LUA_TTHREAD:
113
- tidx = THREAD;
114
- break;
115
- case LUA_TUSERDATA:
116
- tidx = USERDATA;
117
- break;
118
- default:
119
- return NULL;
120
- }
121
-
122
- const void * p = lua_topointer(L, -1);
123
- if (ismarked(dL, p)) {
124
- lua_rawgetp(dL, tidx, p);
125
- if (!lua_isnil(dL,-1)) {
126
- lua_pushstring(dL,desc);
127
- lua_rawsetp(dL, -2, parent);
128
- }
129
- lua_pop(dL,1);
130
- lua_pop(L,1);
131
- return NULL;
132
- }
133
-
134
- lua_newtable(dL);
135
- lua_pushstring(dL,desc);
136
- lua_rawsetp(dL, -2, parent);
137
- lua_rawsetp(dL, tidx, p);
138
-
139
- return p;
140
- }
141
-
142
- static const char *
143
- keystring(lua_State *L, int index, char * buffer) {
144
- int t = lua_type(L,index);
145
- switch (t) {
146
- case LUA_TSTRING:
147
- return lua_tostring(L,index);
148
- case LUA_TNUMBER:
149
- sprintf(buffer,"[number:%lg]",lua_tonumber(L,index));
150
- break;
151
- case LUA_TBOOLEAN:
152
- sprintf(buffer,"[boolean:%s]",lua_toboolean(L,index) ? "true" : "false");
153
- break;
154
- case LUA_TNIL:
155
- sprintf(buffer,"[nil]");
156
- break;
157
- default:
158
- sprintf(buffer,"[%s:%p]",lua_typename(L,t),lua_topointer(L,index));
159
- break;
160
- }
161
- return buffer;
162
- }
163
-
164
- static void
165
- mark_table(lua_State *L, lua_State *dL, const void * parent, const char * desc) {
166
- if ( trace ) {
167
- printf("snapshot-trace: mark_table(%s)\n", desc);
168
- }
169
- const void * t = readobject(L, dL, parent, desc);
170
- if (t == NULL)
171
- return;
172
-
173
- bool weakk = false;
174
- bool weakv = false;
175
- if (!STACK_TOP && lua_getmetatable(L, -1)) {
176
- lua_pushliteral(L, "__mode");
177
- lua_rawget(L, -2);
178
- if (lua_isstring(L,-1)) {
179
- const char *mode = lua_tostring(L, -1);
180
- if (strchr(mode, 'k')) {
181
- weakk = true;
182
- }
183
- if (strchr(mode, 'v')) {
184
- weakv = true;
185
- }
186
- }
187
- lua_pop(L,1);
188
-
189
- mark_table(L, dL, t, "[metatable]");
190
- }
191
-
192
- lua_pushnil(L);
193
- while (ISTABLE(-2) && (lua_next(L, -2) != 0)) {
194
- if (weakv) {
195
- lua_pop(L,1);
196
- } else {
197
- char temp[32];
198
- const char * desc = keystring(L, -2, temp);
199
- mark_object(L, dL, t, desc);
200
- }
201
- if (!weakk && !STACK_TOP) {
202
- lua_pushvalue(L,-1);
203
- mark_object(L, dL, t , "[key]");
204
- }
205
- }
206
-
207
- lua_pop(L,1);
208
- }
209
-
210
- static void
211
- mark_userdata(lua_State *L, lua_State *dL, const void * parent, const char *desc) {
212
- if ( trace ) {
213
- printf("snapshot-trace: mark_userdata(%s)\n", desc);
214
- }
215
- const void * t = readobject(L, dL, parent, desc);
216
- if (t == NULL)
217
- return;
218
- if (!STACK_TOP && lua_getmetatable(L, -1)) {
219
- mark_table(L, dL, t, "[metatable]");
220
- }
221
-
222
- lua_getuservalue(L,-1);
223
- if (lua_isnil(L,-1)) {
224
- lua_pop(L,2);
225
- } else {
226
- mark_table(L, dL, t, "[uservalue]");
227
- lua_pop(L,1);
228
- }
229
- }
230
-
231
- static void
232
- mark_function(lua_State *L, lua_State *dL, const void * parent, const char *desc) {
233
- if ( trace ) {
234
- printf("snapshot-trace: mark_function(%s)\n", desc);
235
- }
236
- const void * t = readobject(L, dL, parent, desc);
237
- int i;
238
- if (t == NULL)
239
- return;
240
- // Asserts in agent ruby
241
- if (mark_function_env(L,dL,t)) {
242
- for (i=1;;i++) {
243
- if (STACK_TOP) break;
244
- const char *name = lua_getupvalue(L,-1,i);
245
- if (name == NULL)
246
- break;
247
- mark_object(L, dL, t, name[0] ? name : "[upvalue]");
248
- }
249
- }
250
- if (!STACK_TOP) {
251
- if (lua_iscfunction(L,-1)) {
252
- if (i==1) {
253
- // light c function
254
- lua_pushnil(dL);
255
- lua_rawsetp(dL, FUNCTION, t);
256
- }
257
- lua_pop(L,1);
258
- } else if (ISFUNCTION(-1)){
259
- lua_Debug ar;
260
- lua_getinfo(L, ">S", &ar);
261
- luaL_Buffer b;
262
- luaL_buffinit(dL, &b);
263
- luaL_addstring(&b, ar.short_src);
264
- char tmp[16];
265
- sprintf(tmp,":%d",ar.linedefined);
266
- luaL_addstring(&b, tmp);
267
- luaL_pushresult(&b);
268
- lua_rawsetp(dL, SOURCE, t);
269
- }
270
- }
271
- }
272
-
273
- static void
274
- mark_thread(lua_State *L, lua_State *dL, const void * parent, const char *desc) {
275
- if ( trace ) {
276
- printf("snapshot-trace: mark_thread(%s)\n", desc);
277
- }
278
- const void * t = readobject(L, dL, parent, desc);
279
- if (t == NULL)
280
- return;
281
- int level = 0;
282
- lua_State *cL = lua_tothread(L,-1);
283
- if (cL == L) {
284
- level = 1;
285
- }
286
- lua_Debug ar;
287
- luaL_Buffer b;
288
- luaL_buffinit(dL, &b);
289
- while (lua_getstack(cL, level, &ar)) {
290
- char tmp[128];
291
- lua_getinfo(cL, "Sl", &ar);
292
- luaL_addstring(&b, ar.short_src);
293
- if (ar.currentline >=0) {
294
- char tmp[16];
295
- sprintf(tmp,":%d ",ar.currentline);
296
- luaL_addstring(&b, tmp);
297
- }
298
-
299
- int i,j;
300
- for (j=1;j>-1;j-=2) {
301
- for (i=j;;i+=j) {
302
- const char * name = lua_getlocal(cL, &ar, i);
303
- if (name == NULL)
304
- break;
305
- snprintf(tmp, sizeof(tmp), "%s : %s:%d",name,ar.short_src,ar.currentline);
306
- mark_object(cL, dL, t, tmp);
307
- }
308
- }
309
-
310
- ++level;
311
- }
312
- luaL_pushresult(&b);
313
- lua_rawsetp(dL, SOURCE, t);
314
- lua_pop(L,1);
315
- }
316
-
317
- static void
318
- mark_object(lua_State *L, lua_State *dL, const void * parent, const char *desc) {
319
- if ( trace ) {
320
- printf("snapshot-trace: mark_object(%s)\n", desc);
321
- }
322
- if (STACK_TOP) return;
323
- int t = lua_type(L, -1);
324
- switch (t) {
325
- case LUA_TTABLE:
326
- mark_table(L, dL, parent, desc);
327
- break;
328
- case LUA_TUSERDATA:
329
- mark_userdata(L, dL, parent, desc);
330
- break;
331
- case LUA_TFUNCTION:
332
- mark_function(L, dL, parent, desc);
333
- break;
334
- case LUA_TTHREAD:
335
- mark_thread(L, dL, parent, desc);
336
- break;
337
- default:
338
- lua_pop(L,1);
339
- break;
340
- }
341
- }
342
-
343
- static int
344
- count_table(lua_State *L, int idx) {
345
- int n = 0;
346
- lua_pushnil(L);
347
- while (lua_next(L, idx) != 0) {
348
- ++n;
349
- lua_pop(L,1);
350
- }
351
- return n;
352
- }
353
-
354
- static void
355
- gen_table_desc(lua_State *dL, luaL_Buffer *b, const void * parent, const char *desc) {
356
- char tmp[32];
357
- size_t l = sprintf(tmp," table: %p; key: ",parent);
358
- luaL_addlstring(b, tmp, l);
359
- luaL_addstring(b, desc);
360
- luaL_addchar(b, '\n');
361
- }
362
-
363
- static void
364
- pdesc(lua_State *L, lua_State *dL, int idx, const char * typename) {
365
- lua_pushnil(dL);
366
- while (!STACK_TOP && lua_next(dL, idx) != 0) {
367
- luaL_Buffer b;
368
- luaL_buffinit(L, &b);
369
- const void * key = lua_touserdata(dL, -2);
370
- if (idx == FUNCTION) {
371
- lua_rawgetp(dL, SOURCE, key);
372
- if (lua_isnil(dL, -1)) {
373
- luaL_addstring(&b,"type: cfunction\n");
374
- } else {
375
- luaL_addstring(&b,"type: function@");
376
- size_t l = 0;
377
- const char * s = lua_tolstring(dL, -1, &l);
378
- luaL_addlstring(&b,s,l);
379
- luaL_addchar(&b,'\n');
380
- }
381
- lua_pop(dL, 1);
382
- } else if (idx == THREAD) {
383
- luaL_addstring(&b,"type: thread@");
384
- lua_rawgetp(dL, SOURCE, key);
385
- size_t l = 0;
386
- const char * s = lua_tolstring(dL, -1, &l);
387
- luaL_addlstring(&b,s,l);
388
- luaL_addchar(&b,'\n');
389
- lua_pop(dL, 1);
390
- } else {
391
- luaL_addstring(&b,"type: ");
392
- luaL_addstring(&b, typename);
393
- luaL_addchar(&b,'\n');
394
- }
395
- lua_pushnil(dL);
396
- luaL_addstring(&b,"REFERENCES:\n");
397
- while (lua_next(dL, -2) != 0) {
398
- const void * parent = lua_touserdata(dL,-2);
399
- const char * desc = luaL_checkstring(dL,-1);
400
- gen_table_desc(dL, &b, parent, desc);
401
- lua_pop(dL,1);
402
- }
403
- luaL_pushresult(&b);
404
- lua_rawsetp(L, -2, key);
405
- lua_pop(dL,1);
406
- }
407
- }
408
-
409
- static void
410
- gen_result(lua_State *L, lua_State *dL) {
411
- int count = 0;
412
- count += count_table(dL, TABLE);
413
- count += count_table(dL, FUNCTION);
414
- count += count_table(dL, USERDATA);
415
- count += count_table(dL, THREAD);
416
- lua_createtable(L, 0, count);
417
- pdesc(L, dL, TABLE, "table");
418
- pdesc(L, dL, USERDATA, "userdata");
419
- pdesc(L, dL, FUNCTION, "function");
420
- pdesc(L, dL, THREAD, "thread");
421
- }
422
-
423
- static int
424
- snapshot(lua_State *L) {
425
- int i;
426
- lua_State *dL = luaL_newstate();
427
- if (!lua_checkstack(L, SNAPSHOT_STACK) && trace) printf("snapshot-trace: WARNING: Unable to grow Lua stack for L");
428
- for (i=0;i<MARK;i++) {
429
- lua_newtable(dL);
430
- }
431
- lua_pushvalue(L, LUA_REGISTRYINDEX);
432
- mark_table(L, dL, NULL, "[registry]");
433
- gen_result(L, dL);
434
- lua_close(dL);
435
- return 1;
436
- }
437
-
438
- static int tron(lua_State *L) {
439
- trace = 1;
440
- printf("snapshot-trace: tracing ON\n");
441
- return 1;
442
- }
443
-
444
- static int troff(lua_State *L) {
445
- trace = 0;
446
- printf("snapshot-trace: tracing OFF\n");
447
- return 1;
448
- }
449
-
450
- static const luaL_Reg libsnapshot[] = {
451
- {"snapshot", snapshot},
452
- {"tron", tron},
453
- {"troff", troff},
454
- {NULL, NULL}
455
- };
456
-
457
- int
458
- luaopen_snapshot(lua_State *L) {
459
- luaL_checkversion(L);
460
- luaL_register(L, "snapshot", libsnapshot);
461
- return 1;
462
- }