immunio 1.2.1 → 2.0.2

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 (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,15 +0,0 @@
1
- MODULES := \
2
- ext/libinjection \
3
- ext/lpeg \
4
- ext/lua-cmsgpack \
5
- ext/lua-snapshot \
6
- ext/luautf8 \
7
- ext/perf \
8
- ext/sha1 \
9
- ext/sha2 \
10
- ext/sysutils
11
-
12
- SRC += \
13
- ext/all.c
14
-
15
- include $(patsubst %,%/module.mk,$(MODULES))
@@ -1,17 +0,0 @@
1
- // Lists the registration functions for all the modules
2
-
3
- #include "lua.h"
4
-
5
- LUALIB_API int luaopen_libinjection(lua_State *L);
6
- LUALIB_API int luaopen_utf8(lua_State *L);
7
- LUALIB_API int luaopen_lpeg (lua_State *L);
8
- LUALIB_API int luaopen_cmsgpack(lua_State *L);
9
- LUALIB_API int luaopen_snapshot(lua_State *L);
10
- LUALIB_API int luaopen_sha1(lua_State *L);
11
- LUALIB_API int luaopen_sha256(lua_State *L);
12
- LUALIB_API int luaopen_cpuload(lua_State *L);
13
- LUALIB_API int luaopen_loadavg(lua_State* L);
14
- LUALIB_API int luaopen_meminfo(lua_State *L);
15
- LUALIB_API int luaopen_luaos(lua_State *L);
16
- LUALIB_API int luaopen_sysutils(lua_State *L);
17
-
@@ -1,114 +0,0 @@
1
- #include <stdio.h>
2
- #include <unistd.h>
3
-
4
- #define LUA_LIB
5
- #include "lua.h"
6
- #include "lauxlib.h"
7
-
8
- /* Show overall CPU utilization of the system
9
- * This is a part of the post http://phoxis.org/2013/09/05/finding-overall-and-per-core-cpu-utilization
10
- */
11
-
12
- #define BUF_MAX 1024
13
-
14
- int
15
- read_fields (FILE *fp, unsigned long long int *fields) {
16
- int retval;
17
- char buffer[BUF_MAX];
18
- if (!fgets (buffer, BUF_MAX, fp)) {
19
- return 0;
20
- }
21
- retval = sscanf (buffer, "cpu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu %Lu",
22
- &fields[0],
23
- &fields[1],
24
- &fields[2],
25
- &fields[3],
26
- &fields[4],
27
- &fields[5],
28
- &fields[6],
29
- &fields[7],
30
- &fields[8],
31
- &fields[9]);
32
- if (retval < 4) {
33
- //fprintf (stderr, "Error reading /proc/stat cpu field\n");
34
- return 0;
35
- }
36
- return 1;
37
- }
38
-
39
- /* Immunio Lua bindings */
40
-
41
- static int
42
- lua_cpuload(lua_State *L) {
43
- FILE *fp;
44
- unsigned long long int fields[10], total_tick, total_tick_old, idle, idle_old, del_total_tick, del_idle;
45
- int i;
46
- double percent_usage;
47
- char str[100];
48
-
49
- fp = fopen ("/proc/stat", "r");
50
- if (fp == NULL) {
51
- return 0;
52
- }
53
-
54
- if (!read_fields (fp, fields)) {
55
- return 0;
56
- }
57
-
58
- for (i=0, total_tick = 0; i<10; i++) {
59
- total_tick += fields[i];
60
- }
61
- idle = fields[3]; /* idle ticks index */
62
- sleep (1);
63
- total_tick_old = total_tick;
64
- idle_old = idle;
65
- fseek (fp, 0, SEEK_SET);
66
- fflush (fp);
67
- if (!read_fields (fp, fields)) {
68
- return 0;
69
- }
70
-
71
- for (i=0, total_tick = 0; i<10; i++) {
72
- total_tick += fields[i];
73
- }
74
- idle = fields[3];
75
-
76
- del_total_tick = total_tick - total_tick_old;
77
- del_idle = idle - idle_old;
78
-
79
- percent_usage = ((del_total_tick - del_idle) / (double) del_total_tick) * 100; /* 3 is index of idle time */
80
- sprintf(str,"%f",percent_usage);
81
- lua_pushstring(L, str);
82
- fclose(fp);
83
- return 1;
84
- }
85
-
86
- static int
87
- lua_stat(lua_State *L) {
88
- FILE *fp;
89
- char buf[3000];
90
- if ((fp=fopen("/proc/stat","r"))==NULL) {
91
- return 0;
92
- }
93
- else {
94
- fread(buf, 1, 3000, fp);
95
- size_t fsize = ftell(fp);
96
- buf[fsize] = '\0';
97
- lua_pushstring(L, buf);
98
- }
99
- fclose(fp);
100
- return 1;
101
- }
102
-
103
- static const luaL_Reg libcpuload[] = {
104
- {"cpuload", lua_cpuload},
105
- {"stat", lua_stat},
106
- {NULL, NULL}
107
- };
108
-
109
- int
110
- luaopen_cpuload(lua_State *L) {
111
- // luaL_checkversion(L);
112
- luaL_register(L, "perf", libcpuload);
113
- return 1;
114
- }
@@ -1,40 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
-
4
- #define LUA_LIB
5
- #include "lua.h"
6
- #include "lauxlib.h"
7
-
8
-
9
- /*https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-loadavg.html
10
- Gives load average in regard to both the CPU and IO over time, as well as additional
11
- data used by uptime and other commands.
12
- */
13
-
14
- /* Immunio Lua bindings */
15
-
16
- static int
17
- lua_loadavg(lua_State *L) {
18
- char c[100];
19
- FILE *fp;
20
- if ((fp=fopen("/proc/loadavg","r"))==NULL) {
21
- return 0;
22
- }
23
- if (fgets(c, 100, fp) != NULL) {
24
- lua_pushstring(L, c);
25
- }
26
- fclose(fp);
27
- return 1;
28
- }
29
-
30
- static const luaL_Reg libloadavg[] = {
31
- {"loadavg", lua_loadavg},
32
- {NULL, NULL}
33
- };
34
-
35
- int
36
- luaopen_loadavg(lua_State *L) {
37
- // luaL_checkversion(L);
38
- luaL_register(L, "perf", libloadavg);
39
- return 1;
40
- }
@@ -1,38 +0,0 @@
1
- #include <stdio.h>
2
-
3
- #define LUA_LIB
4
- #include "lua.h"
5
- #include "lauxlib.h"
6
-
7
- /*https://www.centos.org/docs/5/html/5.1/Deployment_Guide/s2-proc-meminfo.html
8
- Gives information about RAM*/
9
- /* Immunio Lua bindings */
10
-
11
- static int
12
- lua_meminfo(lua_State *L) {
13
- FILE *fp;
14
- char buf[2000];
15
- if ((fp=fopen("/proc/meminfo","r"))==NULL) {
16
- return 0;
17
- }
18
- else {
19
- fread(buf, 1, 2000, fp);
20
- size_t fsize = ftell(fp);
21
- buf[fsize] = '\0';
22
- lua_pushstring(L,buf);
23
- }
24
- fclose(fp);
25
- return 1;
26
- }
27
-
28
- static const luaL_Reg libmeminfo[] = {
29
- {"meminfo", lua_meminfo},
30
- {NULL, NULL}
31
- };
32
-
33
- int
34
- luaopen_meminfo(lua_State *L) {
35
- // luaL_checkversion(L);
36
- luaL_register(L, "perf", libmeminfo);
37
- return 1;
38
- }
@@ -1,203 +0,0 @@
1
- #include <time.h>
2
- #include <string.h>
3
-
4
- #define lib_os_c
5
- #define LUA_LIB
6
-
7
- /*
8
- ** list of valid conversion specifiers for the 'strftime' function
9
- */
10
- #if !defined(LUA_STRFTIMEOPTIONS)
11
-
12
- #if !defined(LUA_USE_POSIX)
13
- #define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
14
- #else
15
- #define LUA_STRFTIMEOPTIONS \
16
- { "aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%", "" \
17
- "", "E", "cCxXyY", \
18
- "O", "deHImMSuUVwWy" }
19
- #endif
20
-
21
- #endif
22
-
23
- /*
24
- ** By default, Lua uses gmtime/localtime, except when POSIX is available,
25
- ** where it uses gmtime_r/localtime_r
26
- */
27
- #if defined(LUA_USE_GMTIME_R)
28
-
29
- #define l_gmtime(t,r) gmtime_r(t,r)
30
- #define l_localtime(t,r) localtime_r(t,r)
31
-
32
- #elif !defined(l_gmtime)
33
-
34
- #define l_gmtime(t,r) ((void)r, gmtime(t))
35
- #define l_localtime(t,r) ((void)r, localtime(t))
36
-
37
- #endif
38
-
39
- #include "lua.h"
40
- #include "lauxlib.h"
41
- #include "lj_err.h"
42
-
43
- static int os_clock(lua_State *L) {
44
- lua_Number clk = ((lua_Number)clock())*(1.0/(lua_Number)CLOCKS_PER_SEC);
45
- lua_pushnumber(L, clk);
46
- return 1;
47
- }
48
-
49
- /*
50
- ** {======================================================
51
- ** Time/Date operations
52
- ** { year=%Y, month=%m, day=%d, hour=%H, min=%M, sec=%S,
53
- ** wday=%w+1, yday=%j, isdst=? }
54
- ** =======================================================
55
- */
56
-
57
- static void setfield (lua_State *L, const char *key, int value) {
58
- lua_pushinteger(L, value);
59
- lua_setfield(L, -2, key);
60
- }
61
-
62
- static void setboolfield (lua_State *L, const char *key, int value) {
63
- if (value < 0) /* undefined? */
64
- return; /* does not set field */
65
- lua_pushboolean(L, value);
66
- lua_setfield(L, -2, key);
67
- }
68
-
69
- static int getboolfield(lua_State *L, const char *key) {
70
- int res;
71
- lua_getfield(L, -1, key);
72
- res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
73
- lua_pop(L, 1);
74
- return res;
75
- }
76
-
77
- static int getfield(lua_State *L, const char *key, int d) {
78
- int res;
79
- lua_getfield(L, -1, key);
80
- if (lua_isnumber(L, -1)) {
81
- res = (int)lua_tointeger(L, -1);
82
- } else {
83
- if (d < 0)
84
- lj_err_callerv(L, LJ_ERR_OSDATEF, key);
85
- res = d;
86
- }
87
- lua_pop(L, 1);
88
- return res;
89
- }
90
-
91
- static const char *checkoption (lua_State *L, const char *conv, char *buff) {
92
- static const char *const options[] = LUA_STRFTIMEOPTIONS;
93
- unsigned int i;
94
- for (i = 0; i < sizeof(options)/sizeof(options[0]); i += 2) {
95
- if (*conv != '\0' && strchr(options[i], *conv) != NULL) {
96
- buff[1] = *conv;
97
- if (*options[i + 1] == '\0') { /* one-char conversion specifier? */
98
- buff[2] = '\0'; /* end buffer */
99
- return conv + 1;
100
- }
101
- else if (*(conv + 1) != '\0' &&
102
- strchr(options[i + 1], *(conv + 1)) != NULL) {
103
- buff[2] = *(conv + 1); /* valid two-char conversion specifier */
104
- buff[3] = '\0'; /* end buffer */
105
- return conv + 2;
106
- }
107
- }
108
- }
109
- luaL_argerror(L, 1,
110
- lua_pushfstring(L, "invalid conversion specifier '%%%s'", conv));
111
- return conv; /* to avoid warnings */
112
- }
113
-
114
- static int os_date (lua_State *L) {
115
- const char *s = luaL_optstring(L, 1, "%c");
116
- time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
117
- struct tm tmr, *stm;
118
- if (*s == '!') { /* UTC? */
119
- stm = l_gmtime(&t, &tmr);
120
- s++; /* skip `!' */
121
- }
122
- else
123
- stm = l_localtime(&t, &tmr);
124
- if (stm == NULL) /* invalid date? */
125
- lua_pushnil(L);
126
- else if (strcmp(s, "*t") == 0) {
127
- lua_createtable(L, 0, 9); /* 9 = number of fields */
128
- setfield(L, "sec", stm->tm_sec);
129
- setfield(L, "min", stm->tm_min);
130
- setfield(L, "hour", stm->tm_hour);
131
- setfield(L, "day", stm->tm_mday);
132
- setfield(L, "month", stm->tm_mon+1);
133
- setfield(L, "year", stm->tm_year+1900);
134
- setfield(L, "wday", stm->tm_wday+1);
135
- setfield(L, "yday", stm->tm_yday+1);
136
- setboolfield(L, "isdst", stm->tm_isdst);
137
- }
138
- else {
139
- char cc[4];
140
- luaL_Buffer b;
141
- cc[0] = '%';
142
- luaL_buffinit(L, &b);
143
- while (*s) {
144
- if (*s != '%') /* no conversion specifier? */
145
- luaL_addchar(&b, *s++);
146
- else {
147
- size_t reslen;
148
- char buff[200]; /* should be big enough for any conversion result */
149
- s = checkoption(L, s + 1, cc);
150
- reslen = strftime(buff, sizeof(buff), cc, stm);
151
- luaL_addlstring(&b, buff, reslen);
152
- }
153
- }
154
- luaL_pushresult(&b);
155
- }
156
- return 1;
157
- }
158
-
159
- static int os_time(lua_State *L) {
160
- time_t t;
161
- if (lua_isnoneornil(L, 1)) { /* called without args? */
162
- t = time(NULL); /* get current time */
163
- } else {
164
- struct tm ts;
165
- luaL_checktype(L, 1, LUA_TTABLE);
166
- lua_settop(L, 1); /* make sure table is at the top */
167
- ts.tm_sec = getfield(L, "sec", 0);
168
- ts.tm_min = getfield(L, "min", 0);
169
- ts.tm_hour = getfield(L, "hour", 12);
170
- ts.tm_mday = getfield(L, "day", -1);
171
- ts.tm_mon = getfield(L, "month", -1) - 1;
172
- ts.tm_year = getfield(L, "year", -1) - 1900;
173
- ts.tm_isdst = getboolfield(L, "isdst");
174
- t = mktime(&ts);
175
- }
176
- if (t == (time_t)(-1))
177
- lua_pushnil(L);
178
- else
179
- lua_pushnumber(L, (lua_Number)t);
180
- return 1;
181
- }
182
-
183
- static int os_difftime(lua_State *L) {
184
- lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
185
- (time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
186
- return 1;
187
- }
188
-
189
- static const luaL_Reg libluaos[] = {
190
- {"clock", os_clock},
191
- {"time", os_time},
192
- {"difftime", os_difftime},
193
- {"date", os_date},
194
-
195
- {NULL, NULL}
196
- };
197
-
198
- int
199
- luaopen_luaos(lua_State *L) {
200
- // luaL_checkversion(L);
201
- luaL_register(L, "perf", libluaos);
202
- return 1;
203
- }
@@ -1,5 +0,0 @@
1
- SRC += \
2
- ext/perf/luacpu.c \
3
- ext/perf/lualoadavg.c \
4
- ext/perf/luameminfo.c \
5
- ext/perf/luaoslib.c
@@ -1,74 +0,0 @@
1
- #include <stdint.h>
2
- #include <stdio.h>
3
- #include <string.h>
4
-
5
- #define LUA_LIB
6
- #include "lua.h"
7
- #include "lauxlib.h"
8
-
9
- // Link this program with an external C or x86 compression function
10
- extern void sha1_compress(uint32_t state[5], const uint8_t block[64]);
11
-
12
- /* This function is implements the padding and blocking around the SHA1 compression function
13
- *
14
- * Copyright (c) 2014 Project Nayuki
15
- * http://www.nayuki.io/page/fast-sha1-hash-implementation-in-x86-assembly
16
- */
17
- static void
18
- sha1_hash(const uint8_t *message, uint32_t len, uint32_t hash[5]) {
19
- hash[0] = UINT32_C(0x67452301);
20
- hash[1] = UINT32_C(0xEFCDAB89);
21
- hash[2] = UINT32_C(0x98BADCFE);
22
- hash[3] = UINT32_C(0x10325476);
23
- hash[4] = UINT32_C(0xC3D2E1F0);
24
-
25
- uint32_t i;
26
- for (i = 0; len - i >= 64; i += 64)
27
- sha1_compress(hash, message + i);
28
-
29
- uint8_t block[64];
30
- uint32_t rem = len - i;
31
- memcpy(block, message + i, rem);
32
-
33
- block[rem] = 0x80;
34
- rem++;
35
- if (64 - rem >= 8)
36
- memset(block + rem, 0, 56 - rem);
37
- else {
38
- memset(block + rem, 0, 64 - rem);
39
- sha1_compress(hash, block);
40
- memset(block, 0, 56);
41
- }
42
-
43
- uint64_t longLen = ((uint64_t)len) << 3;
44
- for (i = 0; i < 8; i++)
45
- block[64 - 1 - i] = (uint8_t)(longLen >> (i * 8));
46
- sha1_compress(hash, block);
47
- }
48
-
49
- /* Immunio Lua bindings */
50
-
51
- static int
52
- lua_sha1(lua_State *L) {
53
- uint32_t hash[5] = {};
54
- char buf[41];
55
- size_t slen = 0;
56
-
57
- const char *input = luaL_checklstring(L, 1, &slen);
58
- sha1_hash(input, slen, hash);
59
- sprintf(buf, "%08x%08x%08x%08x%08x", hash[0], hash[1], hash[2], hash[3], hash[4]);
60
- lua_pushstring(L, buf);
61
- return 1;
62
- }
63
-
64
- static const luaL_Reg libsha1[] = {
65
- {"sha1", lua_sha1},
66
- {NULL, NULL}
67
- };
68
-
69
- int
70
- luaopen_sha1(lua_State *L) {
71
- // luaL_checkversion(L);
72
- luaL_register(L, "sha1", libsha1);
73
- return 1;
74
- }