immunio 1.1.2 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/lib/immunio/version.rb +1 -1
  3. data/lua-hooks/Makefile +56 -109
  4. data/lua-hooks/ext/all.c +3 -14
  5. data/lua-hooks/ext/libinjection/module.mk +5 -0
  6. data/lua-hooks/ext/lpeg/module.mk +6 -0
  7. data/lua-hooks/ext/lua-cmsgpack/module.mk +2 -0
  8. data/lua-hooks/ext/lua-snapshot/module.mk +2 -0
  9. data/lua-hooks/ext/luajit/COPYRIGHT +1 -1
  10. data/lua-hooks/ext/luajit/Makefile +2 -2
  11. data/lua-hooks/ext/luajit/README +2 -2
  12. data/lua-hooks/ext/luajit/doc/bluequad-print.css +1 -1
  13. data/lua-hooks/ext/luajit/doc/bluequad.css +1 -1
  14. data/lua-hooks/ext/luajit/doc/changes.html +15 -2
  15. data/lua-hooks/ext/luajit/doc/contact.html +3 -3
  16. data/lua-hooks/ext/luajit/doc/ext_c_api.html +2 -2
  17. data/lua-hooks/ext/luajit/doc/ext_ffi.html +2 -2
  18. data/lua-hooks/ext/luajit/doc/ext_ffi_api.html +2 -2
  19. data/lua-hooks/ext/luajit/doc/ext_ffi_semantics.html +4 -2
  20. data/lua-hooks/ext/luajit/doc/ext_ffi_tutorial.html +2 -2
  21. data/lua-hooks/ext/luajit/doc/ext_jit.html +2 -2
  22. data/lua-hooks/ext/luajit/doc/ext_profiler.html +2 -2
  23. data/lua-hooks/ext/luajit/doc/extensions.html +9 -2
  24. data/lua-hooks/ext/luajit/doc/faq.html +2 -2
  25. data/lua-hooks/ext/luajit/doc/install.html +22 -18
  26. data/lua-hooks/ext/luajit/doc/luajit.html +3 -3
  27. data/lua-hooks/ext/luajit/doc/running.html +2 -2
  28. data/lua-hooks/ext/luajit/doc/status.html +2 -2
  29. data/lua-hooks/ext/luajit/dynasm/dasm_arm.h +1 -1
  30. data/lua-hooks/ext/luajit/dynasm/dasm_arm.lua +4 -4
  31. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.h +1 -1
  32. data/lua-hooks/ext/luajit/dynasm/dasm_arm64.lua +4 -4
  33. data/lua-hooks/ext/luajit/dynasm/dasm_mips.h +1 -1
  34. data/lua-hooks/ext/luajit/dynasm/dasm_mips.lua +4 -4
  35. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.h +1 -1
  36. data/lua-hooks/ext/luajit/dynasm/dasm_ppc.lua +4 -4
  37. data/lua-hooks/ext/luajit/dynasm/dasm_proto.h +3 -3
  38. data/lua-hooks/ext/luajit/dynasm/dasm_x64.lua +1 -1
  39. data/lua-hooks/ext/luajit/dynasm/dasm_x86.h +34 -7
  40. data/lua-hooks/ext/luajit/dynasm/dasm_x86.lua +427 -102
  41. data/lua-hooks/ext/luajit/dynasm/dynasm.lua +5 -5
  42. data/lua-hooks/ext/luajit/etc/luajit.1 +1 -1
  43. data/lua-hooks/ext/luajit/etc/luajit.pc +1 -1
  44. data/lua-hooks/ext/luajit/src/Makefile +36 -21
  45. data/lua-hooks/ext/luajit/src/Makefile.dep +3 -1
  46. data/lua-hooks/ext/luajit/src/host/buildvm.c +1 -1
  47. data/lua-hooks/ext/luajit/src/host/buildvm.h +1 -1
  48. data/lua-hooks/ext/luajit/src/host/buildvm_asm.c +10 -1
  49. data/lua-hooks/ext/luajit/src/host/buildvm_fold.c +1 -1
  50. data/lua-hooks/ext/luajit/src/host/buildvm_lib.c +1 -1
  51. data/lua-hooks/ext/luajit/src/host/buildvm_peobj.c +1 -1
  52. data/lua-hooks/ext/luajit/src/host/genlibbc.lua +1 -1
  53. data/lua-hooks/ext/luajit/src/host/genminilua.lua +1 -1
  54. data/lua-hooks/ext/luajit/src/jit/bc.lua +1 -1
  55. data/lua-hooks/ext/luajit/src/jit/bcsave.lua +2 -2
  56. data/lua-hooks/ext/luajit/src/jit/dis_arm.lua +1 -1
  57. data/lua-hooks/ext/luajit/src/jit/dis_mips.lua +1 -1
  58. data/lua-hooks/ext/luajit/src/jit/dis_mipsel.lua +1 -1
  59. data/lua-hooks/ext/luajit/src/jit/dis_ppc.lua +1 -1
  60. data/lua-hooks/ext/luajit/src/jit/dis_x64.lua +1 -1
  61. data/lua-hooks/ext/luajit/src/jit/dis_x86.lua +163 -73
  62. data/lua-hooks/ext/luajit/src/jit/dump.lua +2 -1
  63. data/lua-hooks/ext/luajit/src/jit/p.lua +1 -1
  64. data/lua-hooks/ext/luajit/src/jit/v.lua +1 -1
  65. data/lua-hooks/ext/luajit/src/jit/zone.lua +1 -1
  66. data/lua-hooks/ext/luajit/src/lib_aux.c +1 -1
  67. data/lua-hooks/ext/luajit/src/lib_base.c +4 -5
  68. data/lua-hooks/ext/luajit/src/lib_bit.c +1 -1
  69. data/lua-hooks/ext/luajit/src/lib_debug.c +1 -1
  70. data/lua-hooks/ext/luajit/src/lib_ffi.c +2 -5
  71. data/lua-hooks/ext/luajit/src/lib_init.c +1 -1
  72. data/lua-hooks/ext/luajit/src/lib_io.c +2 -3
  73. data/lua-hooks/ext/luajit/src/lib_jit.c +1 -1
  74. data/lua-hooks/ext/luajit/src/lib_math.c +1 -1
  75. data/lua-hooks/ext/luajit/src/lib_os.c +2 -2
  76. data/lua-hooks/ext/luajit/src/lib_package.c +1 -1
  77. data/lua-hooks/ext/luajit/src/lib_string.c +1 -1
  78. data/lua-hooks/ext/luajit/src/lib_table.c +1 -1
  79. data/lua-hooks/ext/luajit/src/lj.supp +15 -0
  80. data/lua-hooks/ext/luajit/src/lj_alloc.c +1 -1
  81. data/lua-hooks/ext/luajit/src/lj_api.c +4 -1
  82. data/lua-hooks/ext/luajit/src/lj_arch.h +33 -7
  83. data/lua-hooks/ext/luajit/src/lj_asm.c +12 -5
  84. data/lua-hooks/ext/luajit/src/lj_asm.h +1 -1
  85. data/lua-hooks/ext/luajit/src/lj_asm_arm.h +3 -13
  86. data/lua-hooks/ext/luajit/src/lj_asm_mips.h +337 -71
  87. data/lua-hooks/ext/luajit/src/lj_asm_ppc.h +2 -2
  88. data/lua-hooks/ext/luajit/src/lj_asm_x86.h +2 -2
  89. data/lua-hooks/ext/luajit/src/lj_bc.c +1 -1
  90. data/lua-hooks/ext/luajit/src/lj_bc.h +1 -1
  91. data/lua-hooks/ext/luajit/src/lj_bcdump.h +1 -1
  92. data/lua-hooks/ext/luajit/src/lj_bcread.c +1 -1
  93. data/lua-hooks/ext/luajit/src/lj_bcwrite.c +1 -1
  94. data/lua-hooks/ext/luajit/src/lj_buf.c +2 -4
  95. data/lua-hooks/ext/luajit/src/lj_buf.h +1 -3
  96. data/lua-hooks/ext/luajit/src/lj_carith.c +1 -1
  97. data/lua-hooks/ext/luajit/src/lj_carith.h +1 -1
  98. data/lua-hooks/ext/luajit/src/lj_ccall.c +37 -14
  99. data/lua-hooks/ext/luajit/src/lj_ccall.h +3 -3
  100. data/lua-hooks/ext/luajit/src/lj_ccallback.c +16 -7
  101. data/lua-hooks/ext/luajit/src/lj_ccallback.h +1 -1
  102. data/lua-hooks/ext/luajit/src/lj_cconv.c +1 -1
  103. data/lua-hooks/ext/luajit/src/lj_cconv.h +1 -1
  104. data/lua-hooks/ext/luajit/src/lj_cdata.c +10 -1
  105. data/lua-hooks/ext/luajit/src/lj_cdata.h +3 -1
  106. data/lua-hooks/ext/luajit/src/lj_clib.c +1 -1
  107. data/lua-hooks/ext/luajit/src/lj_clib.h +1 -1
  108. data/lua-hooks/ext/luajit/src/lj_cparse.c +27 -6
  109. data/lua-hooks/ext/luajit/src/lj_cparse.h +1 -1
  110. data/lua-hooks/ext/luajit/src/lj_crecord.c +1 -1
  111. data/lua-hooks/ext/luajit/src/lj_crecord.h +1 -1
  112. data/lua-hooks/ext/luajit/src/lj_ctype.c +10 -8
  113. data/lua-hooks/ext/luajit/src/lj_ctype.h +1 -1
  114. data/lua-hooks/ext/luajit/src/lj_debug.c +1 -1
  115. data/lua-hooks/ext/luajit/src/lj_debug.h +1 -1
  116. data/lua-hooks/ext/luajit/src/lj_def.h +1 -1
  117. data/lua-hooks/ext/luajit/src/lj_dispatch.c +1 -1
  118. data/lua-hooks/ext/luajit/src/lj_dispatch.h +21 -4
  119. data/lua-hooks/ext/luajit/src/lj_emit_arm.h +1 -1
  120. data/lua-hooks/ext/luajit/src/lj_emit_mips.h +7 -5
  121. data/lua-hooks/ext/luajit/src/lj_emit_ppc.h +1 -1
  122. data/lua-hooks/ext/luajit/src/lj_emit_x86.h +1 -1
  123. data/lua-hooks/ext/luajit/src/lj_err.c +69 -31
  124. data/lua-hooks/ext/luajit/src/lj_err.h +1 -1
  125. data/lua-hooks/ext/luajit/src/lj_errmsg.h +1 -1
  126. data/lua-hooks/ext/luajit/src/lj_ff.h +1 -1
  127. data/lua-hooks/ext/luajit/src/lj_ffrecord.c +10 -40
  128. data/lua-hooks/ext/luajit/src/lj_ffrecord.h +1 -1
  129. data/lua-hooks/ext/luajit/src/lj_frame.h +12 -1
  130. data/lua-hooks/ext/luajit/src/lj_func.c +1 -1
  131. data/lua-hooks/ext/luajit/src/lj_func.h +1 -1
  132. data/lua-hooks/ext/luajit/src/lj_gc.c +2 -2
  133. data/lua-hooks/ext/luajit/src/lj_gc.h +1 -1
  134. data/lua-hooks/ext/luajit/src/lj_gdbjit.c +1 -1
  135. data/lua-hooks/ext/luajit/src/lj_gdbjit.h +1 -1
  136. data/lua-hooks/ext/luajit/src/lj_ir.c +31 -15
  137. data/lua-hooks/ext/luajit/src/lj_ir.h +1 -1
  138. data/lua-hooks/ext/luajit/src/lj_ircall.h +29 -1
  139. data/lua-hooks/ext/luajit/src/lj_iropt.h +2 -1
  140. data/lua-hooks/ext/luajit/src/lj_jit.h +2 -1
  141. data/lua-hooks/ext/luajit/src/lj_lex.c +28 -1
  142. data/lua-hooks/ext/luajit/src/lj_lex.h +1 -1
  143. data/lua-hooks/ext/luajit/src/lj_lib.c +1 -1
  144. data/lua-hooks/ext/luajit/src/lj_lib.h +1 -1
  145. data/lua-hooks/ext/luajit/src/lj_load.c +1 -1
  146. data/lua-hooks/ext/luajit/src/lj_mcode.c +1 -1
  147. data/lua-hooks/ext/luajit/src/lj_mcode.h +1 -1
  148. data/lua-hooks/ext/luajit/src/lj_meta.c +8 -8
  149. data/lua-hooks/ext/luajit/src/lj_meta.h +1 -1
  150. data/lua-hooks/ext/luajit/src/lj_obj.c +1 -1
  151. data/lua-hooks/ext/luajit/src/lj_obj.h +1 -1
  152. data/lua-hooks/ext/luajit/src/lj_opt_dce.c +1 -1
  153. data/lua-hooks/ext/luajit/src/lj_opt_fold.c +1 -1
  154. data/lua-hooks/ext/luajit/src/lj_opt_loop.c +1 -1
  155. data/lua-hooks/ext/luajit/src/lj_opt_mem.c +1 -1
  156. data/lua-hooks/ext/luajit/src/lj_opt_narrow.c +1 -1
  157. data/lua-hooks/ext/luajit/src/lj_opt_sink.c +1 -1
  158. data/lua-hooks/ext/luajit/src/lj_opt_split.c +10 -5
  159. data/lua-hooks/ext/luajit/src/lj_parse.c +1 -1
  160. data/lua-hooks/ext/luajit/src/lj_parse.h +1 -1
  161. data/lua-hooks/ext/luajit/src/lj_profile.c +1 -1
  162. data/lua-hooks/ext/luajit/src/lj_profile.h +1 -1
  163. data/lua-hooks/ext/luajit/src/lj_record.c +13 -5
  164. data/lua-hooks/ext/luajit/src/lj_record.h +1 -1
  165. data/lua-hooks/ext/luajit/src/lj_snap.c +20 -23
  166. data/lua-hooks/ext/luajit/src/lj_snap.h +1 -1
  167. data/lua-hooks/ext/luajit/src/lj_state.c +1 -1
  168. data/lua-hooks/ext/luajit/src/lj_state.h +1 -1
  169. data/lua-hooks/ext/luajit/src/lj_str.c +1 -1
  170. data/lua-hooks/ext/luajit/src/lj_str.h +1 -1
  171. data/lua-hooks/ext/luajit/src/lj_strfmt.c +12 -98
  172. data/lua-hooks/ext/luajit/src/lj_strfmt.h +4 -4
  173. data/lua-hooks/ext/luajit/src/lj_strfmt_num.c +591 -0
  174. data/lua-hooks/ext/luajit/src/lj_strscan.c +1 -1
  175. data/lua-hooks/ext/luajit/src/lj_strscan.h +1 -1
  176. data/lua-hooks/ext/luajit/src/lj_tab.c +1 -1
  177. data/lua-hooks/ext/luajit/src/lj_tab.h +1 -1
  178. data/lua-hooks/ext/luajit/src/lj_target.h +1 -1
  179. data/lua-hooks/ext/luajit/src/lj_target_arm.h +1 -1
  180. data/lua-hooks/ext/luajit/src/lj_target_arm64.h +1 -1
  181. data/lua-hooks/ext/luajit/src/lj_target_mips.h +30 -2
  182. data/lua-hooks/ext/luajit/src/lj_target_ppc.h +1 -1
  183. data/lua-hooks/ext/luajit/src/lj_target_x86.h +1 -1
  184. data/lua-hooks/ext/luajit/src/lj_trace.c +7 -2
  185. data/lua-hooks/ext/luajit/src/lj_trace.h +1 -1
  186. data/lua-hooks/ext/luajit/src/lj_traceerr.h +1 -3
  187. data/lua-hooks/ext/luajit/src/lj_udata.c +1 -1
  188. data/lua-hooks/ext/luajit/src/lj_udata.h +1 -1
  189. data/lua-hooks/ext/luajit/src/lj_vm.h +5 -3
  190. data/lua-hooks/ext/luajit/src/lj_vmevent.c +1 -1
  191. data/lua-hooks/ext/luajit/src/lj_vmevent.h +1 -1
  192. data/lua-hooks/ext/luajit/src/lj_vmmath.c +15 -15
  193. data/lua-hooks/ext/luajit/src/ljamalg.c +2 -1
  194. data/lua-hooks/ext/luajit/src/lua.h +1 -0
  195. data/lua-hooks/ext/luajit/src/luaconf.h +2 -2
  196. data/lua-hooks/ext/luajit/src/luajit.c +1 -1
  197. data/lua-hooks/ext/luajit/src/luajit.h +4 -4
  198. data/lua-hooks/ext/luajit/src/lualib.h +1 -1
  199. data/lua-hooks/ext/luajit/src/msvcbuild.bat +1 -1
  200. data/lua-hooks/ext/luajit/src/ps4build.bat +26 -6
  201. data/lua-hooks/ext/luajit/src/vm_arm.dasc +17 -9
  202. data/lua-hooks/ext/luajit/src/vm_arm64.dasc +1 -1
  203. data/lua-hooks/ext/luajit/src/vm_mips.dasc +1562 -656
  204. data/lua-hooks/ext/luajit/src/vm_ppc.dasc +3 -7
  205. data/lua-hooks/ext/luajit/src/vm_x64.dasc +10 -2
  206. data/lua-hooks/ext/luajit/src/vm_x86.dasc +5 -8
  207. data/lua-hooks/ext/luautf8/module.mk +2 -0
  208. data/lua-hooks/ext/module.mk +15 -0
  209. data/lua-hooks/ext/modules.h +17 -0
  210. data/lua-hooks/ext/perf/luacpu.c +1 -1
  211. data/lua-hooks/ext/perf/lualoadavg.c +1 -1
  212. data/lua-hooks/ext/perf/luameminfo.c +1 -1
  213. data/lua-hooks/ext/perf/luaoslib.c +124 -2
  214. data/lua-hooks/ext/perf/module.mk +5 -0
  215. data/lua-hooks/ext/sha1/luasha1.c +4 -2
  216. data/lua-hooks/ext/sha1/module.mk +5 -0
  217. data/lua-hooks/ext/sha2/luasha256.c +4 -2
  218. data/lua-hooks/ext/sha2/module.mk +5 -0
  219. data/lua-hooks/ext/sysutils/lua_utils.c +56 -0
  220. data/lua-hooks/ext/sysutils/module.mk +2 -0
  221. data/lua-hooks/lib/boot.lua +2 -1
  222. data/lua-hooks/lib/hooks/module.mk +31 -0
  223. data/lua-hooks/lib/hooks/xss/module.mk +4 -0
  224. data/lua-hooks/lib/lexers/module.mk +10 -0
  225. data/lua-hooks/lib/module.mk +38 -0
  226. data/lua-hooks/lib/schema/module.mk +3 -0
  227. data/lua-hooks/options.mk +59 -0
  228. metadata +21 -2
@@ -1,6 +1,6 @@
1
1
  |// Low-level VM code for PowerPC 32 bit or 32on64 bit mode.
2
2
  |// Bytecode interpreter, fast functions and helper functions.
3
- |// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
3
+ |// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
4
4
  |
5
5
  |.arch ppc
6
6
  |.section code_op, code_sub
@@ -2525,7 +2525,7 @@ static void build_subroutines(BuildCtx *ctx)
2525
2525
  |.if JIT
2526
2526
  | // RA = resultptr, RB = meta base
2527
2527
  | lwz INS, -4(PC)
2528
- | lwz TMP3, -20(RB) // Save previous trace number.
2528
+ | lwz TRACE:TMP2, -20(RB) // Save previous trace.
2529
2529
  | addic. TMP1, MULTRES, -8
2530
2530
  | decode_RA8 RC, INS // Call base.
2531
2531
  | beq >2
@@ -2540,15 +2540,11 @@ static void build_subroutines(BuildCtx *ctx)
2540
2540
  | decode_RA8 RA, INS
2541
2541
  | decode_RB8 RB, INS
2542
2542
  | add RA, RA, RB
2543
- | lwz TMP1, DISPATCH_J(trace)(DISPATCH)
2544
2543
  |3:
2545
2544
  | cmplw RA, RC
2546
2545
  | bgt >9 // More results wanted?
2547
2546
  |
2548
- | slwi TMP2, TMP3, 2
2549
- | lwzx TRACE:TMP2, TMP1, TMP2
2550
- | cmpwi TRACE:TMP2, 0
2551
- | beq ->cont_nop
2547
+ | lhz TMP3, TRACE:TMP2->traceno
2552
2548
  | lhz RD, TRACE:TMP2->link
2553
2549
  | cmpw RD, TMP3
2554
2550
  | cmpwi cr1, RD, 0
@@ -1,6 +1,6 @@
1
1
  |// Low-level VM code for x64 CPUs in LJ_GC64 mode.
2
2
  |// Bytecode interpreter, fast functions and helper functions.
3
- |// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
3
+ |// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
4
4
  |
5
5
  |.arch x64
6
6
  |.section code_op, code_sub
@@ -531,7 +531,7 @@ static void build_subroutines(BuildCtx *ctx)
531
531
  | jmp >2
532
532
  |
533
533
  |->vm_growstack_v: // Grow stack for vararg Lua function.
534
- | sub RD, 8
534
+ | sub RD, 16 // LJ_FR2
535
535
  | jmp >1
536
536
  |
537
537
  |->vm_growstack_f: // Grow stack for fixarg Lua function.
@@ -1804,7 +1804,11 @@ static void build_subroutines(BuildCtx *ctx)
1804
1804
  | jmp ->fff_res1
1805
1805
  |
1806
1806
  |.ffunc_n math_frexp
1807
+ |.if X64WIN
1808
+ | lea CARG2, TMP1
1809
+ |.else
1807
1810
  | lea CARG1, TMP1
1811
+ |.endif
1808
1812
  | mov RB, BASE
1809
1813
  | call extern frexp
1810
1814
  | mov BASE, RB
@@ -1822,7 +1826,11 @@ static void build_subroutines(BuildCtx *ctx)
1822
1826
  | jmp ->fff_res
1823
1827
  |
1824
1828
  |.ffunc_n math_modf
1829
+ |.if X64WIN
1830
+ | lea CARG2, [BASE-16]
1831
+ |.else
1825
1832
  | lea CARG1, [BASE-16]
1833
+ |.endif
1826
1834
  | mov PC, [BASE-8]
1827
1835
  | mov RB, BASE
1828
1836
  | call extern modf
@@ -1,6 +1,6 @@
1
1
  |// Low-level VM code for x86 CPUs.
2
2
  |// Bytecode interpreter, fast functions and helper functions.
3
- |// Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
3
+ |// Copyright (C) 2005-2016 Mike Pall. See Copyright Notice in luajit.h
4
4
  |
5
5
  |.if P64
6
6
  |.arch x64
@@ -2667,8 +2667,8 @@ static void build_subroutines(BuildCtx *ctx)
2667
2667
  |->cont_stitch: // Trace stitching.
2668
2668
  |.if JIT
2669
2669
  | // BASE = base, RC = result, RB = mbase
2670
- | mov RA, [RB-24] // Save previous trace number.
2671
- | mov TMP1, RA
2670
+ | mov TRACE:RA, [RB-24] // Save previous trace.
2671
+ | mov TMP1, TRACE:RA
2672
2672
  | mov TMP3, DISPATCH // Need one more register.
2673
2673
  | mov DISPATCH, MULTRES
2674
2674
  | movzx RA, PC_RA
@@ -2699,11 +2699,8 @@ static void build_subroutines(BuildCtx *ctx)
2699
2699
  | ja >9 // More results wanted?
2700
2700
  |
2701
2701
  | mov DISPATCH, TMP3
2702
- | mov RB, TMP1 // Get previous trace number.
2703
- | mov RA, [DISPATCH+DISPATCH_J(trace)]
2704
- | mov TRACE:RD, [RA+RB*4]
2705
- | test TRACE:RD, TRACE:RD
2706
- | jz ->cont_nop
2702
+ | mov TRACE:RD, TMP1 // Get previous trace.
2703
+ | movzx RB, word TRACE:RD->traceno
2707
2704
  | movzx RD, word TRACE:RD->link
2708
2705
  | cmp RD, RB
2709
2706
  | je ->cont_nop // Blacklisted.
@@ -0,0 +1,2 @@
1
+ SRC += \
2
+ ext/luautf8/lutf8lib.c
@@ -0,0 +1,15 @@
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))
@@ -0,0 +1,17 @@
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
+
@@ -108,7 +108,7 @@ static const luaL_Reg libcpuload[] = {
108
108
 
109
109
  int
110
110
  luaopen_cpuload(lua_State *L) {
111
- luaL_checkversion(L);
111
+ // luaL_checkversion(L);
112
112
  luaL_register(L, "perf", libcpuload);
113
113
  return 1;
114
114
  }
@@ -34,7 +34,7 @@ static const luaL_Reg libloadavg[] = {
34
34
 
35
35
  int
36
36
  luaopen_loadavg(lua_State *L) {
37
- luaL_checkversion(L);
37
+ // luaL_checkversion(L);
38
38
  luaL_register(L, "perf", libloadavg);
39
39
  return 1;
40
40
  }
@@ -32,7 +32,7 @@ static const luaL_Reg libmeminfo[] = {
32
32
 
33
33
  int
34
34
  luaopen_meminfo(lua_State *L) {
35
- luaL_checkversion(L);
35
+ // luaL_checkversion(L);
36
36
  luaL_register(L, "perf", libmeminfo);
37
37
  return 1;
38
38
  }
@@ -1,8 +1,41 @@
1
1
  #include <time.h>
2
+ #include <string.h>
2
3
 
3
4
  #define lib_os_c
4
5
  #define LUA_LIB
5
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
+
6
39
  #include "lua.h"
7
40
  #include "lauxlib.h"
8
41
  #include "lj_err.h"
@@ -13,6 +46,26 @@ static int os_clock(lua_State *L) {
13
46
  return 1;
14
47
  }
15
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
+
16
69
  static int getboolfield(lua_State *L, const char *key) {
17
70
  int res;
18
71
  lua_getfield(L, -1, key);
@@ -35,6 +88,74 @@ static int getfield(lua_State *L, const char *key, int d) {
35
88
  return res;
36
89
  }
37
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
+
38
159
  static int os_time(lua_State *L) {
39
160
  time_t t;
40
161
  if (lua_isnoneornil(L, 1)) { /* called without args? */
@@ -61,7 +182,7 @@ static int os_time(lua_State *L) {
61
182
 
62
183
  static int os_difftime(lua_State *L) {
63
184
  lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)),
64
- (time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
185
+ (time_t)(luaL_optnumber(L, 2, (lua_Number)0))));
65
186
  return 1;
66
187
  }
67
188
 
@@ -69,13 +190,14 @@ static const luaL_Reg libluaos[] = {
69
190
  {"clock", os_clock},
70
191
  {"time", os_time},
71
192
  {"difftime", os_difftime},
193
+ {"date", os_date},
72
194
 
73
195
  {NULL, NULL}
74
196
  };
75
197
 
76
198
  int
77
199
  luaopen_luaos(lua_State *L) {
78
- luaL_checkversion(L);
200
+ // luaL_checkversion(L);
79
201
  luaL_register(L, "perf", libluaos);
80
202
  return 1;
81
203
  }
@@ -0,0 +1,5 @@
1
+ SRC += \
2
+ ext/perf/luacpu.c \
3
+ ext/perf/lualoadavg.c \
4
+ ext/perf/luameminfo.c \
5
+ ext/perf/luaoslib.c
@@ -1,4 +1,6 @@
1
+ #include <stdint.h>
1
2
  #include <stdio.h>
3
+ #include <string.h>
2
4
 
3
5
  #define LUA_LIB
4
6
  #include "lua.h"
@@ -66,7 +68,7 @@ static const luaL_Reg libsha1[] = {
66
68
 
67
69
  int
68
70
  luaopen_sha1(lua_State *L) {
69
- luaL_checkversion(L);
71
+ // luaL_checkversion(L);
70
72
  luaL_register(L, "sha1", libsha1);
71
73
  return 1;
72
- }
74
+ }
@@ -0,0 +1,5 @@
1
+ SRC += \
2
+ ext/sha1/luasha1.c
3
+
4
+ SPECIAL_SRC += \
5
+ ext/sha1/sha1.c
@@ -1,4 +1,6 @@
1
+ #include <stdint.h>
1
2
  #include <stdio.h>
3
+ #include <string.h>
2
4
 
3
5
  #define LUA_LIB
4
6
  #include "lua.h"
@@ -69,7 +71,7 @@ static const luaL_Reg libsha256[] = {
69
71
 
70
72
  int
71
73
  luaopen_sha256(lua_State *L) {
72
- luaL_checkversion(L);
74
+ // luaL_checkversion(L);
73
75
  luaL_register(L, "sha2", libsha256);
74
76
  return 1;
75
- }
77
+ }
@@ -0,0 +1,5 @@
1
+ SRC += \
2
+ ext/sha2/luasha256.c
3
+
4
+ SPECIAL_SRC += \
5
+ ext/sha2/sha256.c
@@ -0,0 +1,56 @@
1
+ #define LUA_LIB
2
+ #include <lua.h>
3
+ #include <lauxlib.h>
4
+
5
+ #ifdef _WIN32
6
+ #define WIN32_LEAN_AND_MEAN
7
+ #include <windows.h>
8
+ #else
9
+ #include <sys/utsname.h>
10
+ #endif /* _WIN32 */
11
+
12
+ static int lua_uname(lua_State *L)
13
+ {
14
+ #ifdef _WIN32
15
+ const char *name;
16
+ SYSTEM_INFO info;
17
+ lua_pushliteral(L, "Windows");
18
+ name = getenv("COMPUTERNAME");
19
+ lua_pushstring(L, name ? name : "");
20
+ memset(&info, 0, sizeof(info));
21
+ GetSystemInfo(&info);
22
+ if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
23
+ lua_pushliteral(L, "AMD64");
24
+ else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
25
+ lua_pushliteral(L, "X86");
26
+ else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM)
27
+ lua_pushliteral(L, "ARM");
28
+ else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
29
+ lua_pushliteral(L, "IA64");
30
+ else if (info.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64)
31
+ lua_pushstring(L, "");
32
+ return 3;
33
+ #else
34
+ struct utsname info;
35
+ if (uname(&info) >= 0)
36
+ {
37
+ lua_pushstring(L, info.sysname);
38
+ lua_pushstring(L, info.nodename);
39
+ lua_pushstring(L, info.machine);
40
+ return 3;
41
+ }
42
+ lua_pushstring(L, "Unknown");
43
+ return 1;
44
+ #endif
45
+ }
46
+
47
+ static const luaL_Reg sys_utils[] = {
48
+ {"uname", lua_uname},
49
+ {NULL, NULL}
50
+ };
51
+
52
+ int luaopen_sysutils(lua_State *L) {
53
+ // luaL_checkversion(L);
54
+ luaL_register(L, "sysutils", sys_utils);
55
+ return 1;
56
+ }