script_core 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (381) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.rubocop.yml +8 -6
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -1
  6. data/bin/sandbox +1 -1
  7. data/ext/enterprise_script_service/Rakefile +1 -1
  8. data/ext/enterprise_script_service/flags.rb +5 -0
  9. data/ext/enterprise_script_service/libseccomp/CHANGELOG +15 -0
  10. data/ext/enterprise_script_service/libseccomp/CREDITS +3 -0
  11. data/ext/enterprise_script_service/libseccomp/Makefile.am +1 -1
  12. data/ext/enterprise_script_service/libseccomp/README.md +1 -1
  13. data/ext/enterprise_script_service/libseccomp/SECURITY.md +45 -0
  14. data/ext/enterprise_script_service/libseccomp/configure.ac +3 -3
  15. data/ext/enterprise_script_service/libseccomp/doc/admin/MAINTAINER_PROCESS.md +95 -0
  16. data/ext/enterprise_script_service/libseccomp/{RELEASE_PROCESS.md → doc/admin/RELEASE_PROCESS.md} +9 -1
  17. data/ext/enterprise_script_service/libseccomp/include/Makefile.am +1 -1
  18. data/ext/enterprise_script_service/libseccomp/include/seccomp-syscalls.h +2292 -0
  19. data/ext/enterprise_script_service/libseccomp/include/seccomp.h.in +3 -1065
  20. data/ext/enterprise_script_service/libseccomp/src/arch-aarch64-syscalls.c +35 -3
  21. data/ext/enterprise_script_service/libseccomp/src/arch-arm-syscalls.c +35 -3
  22. data/ext/enterprise_script_service/libseccomp/src/arch-mips-syscalls.c +43 -11
  23. data/ext/enterprise_script_service/libseccomp/src/arch-mips64-syscalls.c +33 -1
  24. data/ext/enterprise_script_service/libseccomp/src/arch-mips64n32-syscalls.c +33 -1
  25. data/ext/enterprise_script_service/libseccomp/src/arch-parisc-syscalls.c +34 -2
  26. data/ext/enterprise_script_service/libseccomp/src/arch-ppc-syscalls.c +43 -11
  27. data/ext/enterprise_script_service/libseccomp/src/arch-ppc64-syscalls.c +44 -12
  28. data/ext/enterprise_script_service/libseccomp/src/arch-s390-syscalls.c +46 -14
  29. data/ext/enterprise_script_service/libseccomp/src/arch-s390.c +142 -18
  30. data/ext/enterprise_script_service/libseccomp/src/arch-s390x-syscalls.c +47 -15
  31. data/ext/enterprise_script_service/libseccomp/src/arch-s390x.c +143 -17
  32. data/ext/enterprise_script_service/libseccomp/src/arch-x32-syscalls.c +33 -1
  33. data/ext/enterprise_script_service/libseccomp/src/arch-x86-syscalls.c +94 -12
  34. data/ext/enterprise_script_service/libseccomp/src/arch-x86.c +142 -19
  35. data/ext/enterprise_script_service/libseccomp/src/arch-x86_64-syscalls.c +33 -1
  36. data/ext/enterprise_script_service/libseccomp/src/db.c +1 -0
  37. data/ext/enterprise_script_service/libseccomp/src/gen_bpf.c +10 -3
  38. data/ext/enterprise_script_service/libseccomp/src/python/Makefile.am +4 -4
  39. data/ext/enterprise_script_service/libseccomp/src/python/seccomp.pyx +2 -0
  40. data/ext/enterprise_script_service/libseccomp/tests/.gitignore +1 -0
  41. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.c +98 -0
  42. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.py +61 -0
  43. data/ext/enterprise_script_service/libseccomp/tests/50-sim-hash_collision.tests +18 -0
  44. data/ext/enterprise_script_service/libseccomp/tests/Makefile.am +6 -3
  45. data/ext/enterprise_script_service/libseccomp/tools/Makefile.am +0 -2
  46. data/ext/enterprise_script_service/libseccomp/tools/check-syntax +1 -0
  47. data/ext/enterprise_script_service/libseccomp/tools/scmp_bpf_sim.c +2 -0
  48. data/ext/enterprise_script_service/mruby-mpdecimal/src/ext.c +1 -1
  49. data/ext/enterprise_script_service/mruby/.gitignore +2 -2
  50. data/ext/enterprise_script_service/mruby/CONTRIBUTING.md +10 -3
  51. data/ext/enterprise_script_service/mruby/Doxyfile +2408 -0
  52. data/ext/enterprise_script_service/mruby/README.md +21 -8
  53. data/ext/enterprise_script_service/mruby/Rakefile +4 -13
  54. data/ext/enterprise_script_service/mruby/appveyor_config.rb +1 -1
  55. data/ext/enterprise_script_service/mruby/build_config.rb +3 -3
  56. data/ext/enterprise_script_service/mruby/doc/guides/compile.md +42 -42
  57. data/ext/enterprise_script_service/mruby/doc/guides/debugger.md +1 -1
  58. data/ext/enterprise_script_service/mruby/doc/guides/mrbconf.md +45 -6
  59. data/ext/enterprise_script_service/mruby/doc/guides/mrbgems.md +5 -0
  60. data/ext/enterprise_script_service/mruby/doc/limitations.md +88 -38
  61. data/ext/enterprise_script_service/mruby/doc/mruby_logo_red_icon.png +0 -0
  62. data/ext/enterprise_script_service/mruby/doc/opcode.md +94 -94
  63. data/ext/enterprise_script_service/mruby/include/mrbconf.h +74 -11
  64. data/ext/enterprise_script_service/mruby/include/mruby.h +242 -146
  65. data/ext/enterprise_script_service/mruby/include/mruby/array.h +7 -7
  66. data/ext/enterprise_script_service/mruby/include/mruby/boxing_nan.h +2 -9
  67. data/ext/enterprise_script_service/mruby/include/mruby/boxing_no.h +11 -10
  68. data/ext/enterprise_script_service/mruby/include/mruby/boxing_word.h +104 -69
  69. data/ext/enterprise_script_service/mruby/include/mruby/class.h +7 -5
  70. data/ext/enterprise_script_service/mruby/include/mruby/common.h +9 -7
  71. data/ext/enterprise_script_service/mruby/include/mruby/compile.h +6 -6
  72. data/ext/enterprise_script_service/mruby/include/mruby/data.h +5 -5
  73. data/ext/enterprise_script_service/mruby/include/mruby/debug.h +2 -2
  74. data/ext/enterprise_script_service/mruby/include/mruby/dump.h +3 -7
  75. data/ext/enterprise_script_service/mruby/include/mruby/error.h +34 -6
  76. data/ext/enterprise_script_service/mruby/include/mruby/gc.h +2 -2
  77. data/ext/enterprise_script_service/mruby/include/mruby/hash.h +4 -11
  78. data/ext/enterprise_script_service/mruby/include/mruby/irep.h +16 -4
  79. data/ext/enterprise_script_service/mruby/include/mruby/istruct.h +4 -4
  80. data/ext/enterprise_script_service/mruby/include/mruby/khash.h +2 -2
  81. data/ext/enterprise_script_service/mruby/include/mruby/numeric.h +41 -7
  82. data/ext/enterprise_script_service/mruby/include/mruby/object.h +8 -9
  83. data/ext/enterprise_script_service/mruby/include/mruby/opcode.h +2 -2
  84. data/ext/enterprise_script_service/mruby/include/mruby/ops.h +6 -6
  85. data/ext/enterprise_script_service/mruby/include/mruby/proc.h +19 -13
  86. data/ext/enterprise_script_service/mruby/include/mruby/range.h +10 -4
  87. data/ext/enterprise_script_service/mruby/include/mruby/re.h +2 -2
  88. data/ext/enterprise_script_service/mruby/include/mruby/string.h +130 -107
  89. data/ext/enterprise_script_service/mruby/include/mruby/throw.h +2 -2
  90. data/ext/enterprise_script_service/mruby/include/mruby/value.h +137 -49
  91. data/ext/enterprise_script_service/mruby/include/mruby/variable.h +3 -5
  92. data/ext/enterprise_script_service/mruby/include/mruby/version.h +24 -10
  93. data/ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb +2 -39
  94. data/ext/enterprise_script_service/mruby/lib/mruby/build.rb +32 -15
  95. data/ext/enterprise_script_service/mruby/lib/mruby/build/command.rb +63 -17
  96. data/ext/enterprise_script_service/mruby/lib/mruby/build/load_gems.rb +24 -10
  97. data/ext/enterprise_script_service/mruby/lib/mruby/gem.rb +11 -7
  98. data/ext/enterprise_script_service/mruby/lib/mruby/lockfile.rb +81 -0
  99. data/ext/enterprise_script_service/mruby/minirake +27 -11
  100. data/ext/enterprise_script_service/mruby/mrbgems/default.gembox +3 -0
  101. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrbgem.rake +0 -1
  102. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/mrblib/array.rb +47 -9
  103. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/src/array.c +3 -3
  104. data/ext/enterprise_script_service/mruby/mrbgems/mruby-array-ext/test/array.rb +50 -29
  105. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apibreak.c +3 -3
  106. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/apiprint.c +2 -2
  107. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/cmdprint.c +3 -3
  108. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.c +2 -2
  109. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdb.h +1 -1
  110. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/tools/mrdb/mrdbconf.h +4 -0
  111. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mirb/tools/mirb/mirb.c +28 -1
  112. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c +1 -2
  113. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/bintest/mruby.rb +75 -8
  114. data/ext/enterprise_script_service/mruby/mrbgems/mruby-bin-mruby/tools/mruby/mruby.c +134 -90
  115. data/ext/enterprise_script_service/mruby/mrbgems/mruby-class-ext/src/class.c +7 -8
  116. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/codegen.c +69 -46
  117. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/keywords +0 -3
  118. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/lex.def +51 -59
  119. data/ext/enterprise_script_service/mruby/mrbgems/mruby-compiler/core/parse.y +430 -241
  120. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrbgem.rake +10 -0
  121. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/mrblib/complex.rb +122 -0
  122. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/src/complex.c +249 -0
  123. data/ext/enterprise_script_service/mruby/mrbgems/mruby-complex/test/complex.rb +153 -0
  124. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/mrblib/chain.rb +19 -17
  125. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-chain/test/enum_chain.rb +41 -9
  126. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/mrblib/enum.rb +30 -4
  127. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enum-ext/test/enum.rb +8 -3
  128. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrbgem.rake +0 -1
  129. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/mrblib/enumerator.rb +46 -14
  130. data/ext/enterprise_script_service/mruby/mrbgems/mruby-enumerator/test/enumerator.rb +51 -2
  131. data/ext/enterprise_script_service/mruby/mrbgems/mruby-error/src/exception.c +10 -0
  132. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/src/eval.c +47 -44
  133. data/ext/enterprise_script_service/mruby/mrbgems/mruby-eval/test/eval.rb +2 -2
  134. data/ext/enterprise_script_service/mruby/mrbgems/mruby-exit/src/mruby-exit.c +9 -4
  135. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/src/fiber.c +16 -12
  136. data/ext/enterprise_script_service/mruby/mrbgems/mruby-fiber/test/fiber.rb +1 -1
  137. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrbgem.rake +0 -2
  138. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/mrblib/hash.rb +3 -0
  139. data/ext/enterprise_script_service/mruby/mrbgems/mruby-hash-ext/test/hash.rb +3 -7
  140. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/README.md +1 -3
  141. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrbgem.rake +1 -1
  142. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/file.rb +0 -5
  143. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/io.rb +24 -38
  144. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/mrblib/kernel.rb +16 -0
  145. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file.c +19 -18
  146. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/file_test.c +5 -16
  147. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/src/io.c +54 -42
  148. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb +24 -20
  149. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file_test.rb +4 -9
  150. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/io.rb +41 -35
  151. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/mruby_io_test.c +9 -36
  152. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrbgem.rake +1 -1
  153. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/src/kernel.c +9 -27
  154. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/test/kernel.rb +2 -0
  155. data/ext/enterprise_script_service/mruby/mrbgems/mruby-math/src/math.c +5 -2
  156. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/src/metaprog.c +39 -24
  157. data/ext/enterprise_script_service/mruby/mrbgems/mruby-metaprog/test/metaprog.rb +48 -17
  158. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/method.rb +0 -12
  159. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/src/method.c +134 -101
  160. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/test/method.rb +9 -1
  161. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/mrblib/numeric_ext.rb +1 -5
  162. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/src/numeric_ext.c +17 -37
  163. data/ext/enterprise_script_service/mruby/mrbgems/mruby-numeric-ext/test/numeric.rb +0 -8
  164. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrbgem.rake +1 -1
  165. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/mrblib/object.rb +15 -1
  166. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/src/object.c +35 -6
  167. data/ext/enterprise_script_service/mruby/mrbgems/mruby-object-ext/test/nil.rb +4 -0
  168. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/src/mruby_objectspace.c +1 -5
  169. data/ext/enterprise_script_service/mruby/mrbgems/mruby-objectspace/test/objectspace.rb +1 -1
  170. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/src/pack.c +28 -23
  171. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/test/pack.rb +43 -49
  172. data/ext/enterprise_script_service/mruby/mrbgems/mruby-print/mrblib/print.rb +3 -9
  173. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/src/proc.c +6 -9
  174. data/ext/enterprise_script_service/mruby/mrbgems/mruby-proc-ext/test/proc.rb +21 -5
  175. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.c +157 -124
  176. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/test/random.rb +72 -26
  177. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/mrblib/range.rb +38 -0
  178. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/src/range.c +26 -11
  179. data/ext/enterprise_script_service/mruby/mrbgems/mruby-range-ext/test/range.rb +111 -1
  180. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrbgem.rake +5 -0
  181. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/mrblib/rational.rb +117 -0
  182. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/src/rational.c +209 -0
  183. data/ext/enterprise_script_service/mruby/mrbgems/mruby-rational/test/rational.rb +308 -0
  184. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/README.md +1 -1
  185. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/src/socket.c +10 -9
  186. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/kernel.c +2 -2
  187. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sprintf/src/sprintf.c +22 -24
  188. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrbgem.rake +0 -1
  189. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/mrblib/string.rb +8 -4
  190. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/src/string.c +116 -117
  191. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/numeric.rb +29 -0
  192. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/range.rb +26 -0
  193. data/ext/enterprise_script_service/mruby/mrbgems/mruby-string-ext/test/string.rb +32 -50
  194. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb +5 -7
  195. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/src/struct.c +43 -57
  196. data/ext/enterprise_script_service/mruby/mrbgems/mruby-struct/test/struct.rb +16 -11
  197. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/src/symbol.c +2 -2
  198. data/ext/enterprise_script_service/mruby/mrbgems/mruby-symbol-ext/test/symbol.rb +1 -1
  199. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/driver.c +152 -1
  200. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/mrbgem.rake +4 -3
  201. data/ext/enterprise_script_service/mruby/mrbgems/mruby-test/vformat.c +200 -0
  202. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/include/mruby/time.h +2 -1
  203. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/src/time.c +199 -68
  204. data/ext/enterprise_script_service/mruby/mrbgems/mruby-time/test/time.rb +81 -46
  205. data/ext/enterprise_script_service/mruby/mrblib/array.rb +14 -16
  206. data/ext/enterprise_script_service/mruby/mrblib/enum.rb +13 -9
  207. data/ext/enterprise_script_service/mruby/mrblib/hash.rb +5 -7
  208. data/ext/enterprise_script_service/mruby/mrblib/kernel.rb +1 -1
  209. data/ext/enterprise_script_service/mruby/mrblib/numeric.rb +4 -4
  210. data/ext/enterprise_script_service/mruby/mrblib/range.rb +1 -1
  211. data/ext/enterprise_script_service/mruby/mrblib/string.rb +55 -112
  212. data/ext/enterprise_script_service/mruby/mruby-source.gemspec +1 -1
  213. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby.dict +105 -0
  214. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_fuzzer.options +5 -0
  215. data/ext/enterprise_script_service/mruby/oss-fuzz/config/mruby_proto_fuzzer.options +4 -0
  216. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_fuzzer.c +18 -0
  217. data/ext/enterprise_script_service/mruby/oss-fuzz/mruby_proto_fuzzer.cpp +44 -0
  218. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.cpp +455 -0
  219. data/ext/enterprise_script_service/mruby/oss-fuzz/proto_to_ruby.h +55 -0
  220. data/ext/enterprise_script_service/mruby/oss-fuzz/ruby.proto +201 -0
  221. data/ext/enterprise_script_service/mruby/src/array.c +95 -46
  222. data/ext/enterprise_script_service/mruby/src/backtrace.c +6 -8
  223. data/ext/enterprise_script_service/mruby/src/class.c +370 -278
  224. data/ext/enterprise_script_service/mruby/src/codedump.c +34 -34
  225. data/ext/enterprise_script_service/mruby/src/debug.c +2 -2
  226. data/ext/enterprise_script_service/mruby/src/dump.c +8 -6
  227. data/ext/enterprise_script_service/mruby/src/enum.c +1 -1
  228. data/ext/enterprise_script_service/mruby/src/error.c +157 -55
  229. data/ext/enterprise_script_service/mruby/src/etc.c +13 -46
  230. data/ext/enterprise_script_service/mruby/src/fmt_fp.c +2 -2
  231. data/ext/enterprise_script_service/mruby/src/gc.c +30 -11
  232. data/ext/enterprise_script_service/mruby/src/hash.c +23 -14
  233. data/ext/enterprise_script_service/mruby/src/kernel.c +16 -54
  234. data/ext/enterprise_script_service/mruby/src/load.c +40 -76
  235. data/ext/enterprise_script_service/mruby/src/numeric.c +164 -94
  236. data/ext/enterprise_script_service/mruby/src/object.c +16 -39
  237. data/ext/enterprise_script_service/mruby/src/pool.c +0 -2
  238. data/ext/enterprise_script_service/mruby/src/proc.c +47 -48
  239. data/ext/enterprise_script_service/mruby/src/range.c +22 -35
  240. data/ext/enterprise_script_service/mruby/src/state.c +5 -94
  241. data/ext/enterprise_script_service/mruby/src/string.c +874 -710
  242. data/ext/enterprise_script_service/mruby/src/symbol.c +73 -48
  243. data/ext/enterprise_script_service/mruby/src/variable.c +58 -38
  244. data/ext/enterprise_script_service/mruby/src/vm.c +133 -304
  245. data/ext/enterprise_script_service/mruby/tasks/doc.rake +48 -0
  246. data/ext/enterprise_script_service/mruby/tasks/toolchains/clang.rake +3 -4
  247. data/ext/enterprise_script_service/mruby/tasks/toolchains/gcc.rake +20 -19
  248. data/ext/enterprise_script_service/mruby/tasks/toolchains/visualcpp.rake +0 -12
  249. data/ext/enterprise_script_service/mruby/test/assert.rb +186 -25
  250. data/ext/enterprise_script_service/mruby/test/t/array.rb +34 -6
  251. data/ext/enterprise_script_service/mruby/test/t/class.rb +26 -0
  252. data/ext/enterprise_script_service/mruby/test/t/enumerable.rb +2 -2
  253. data/ext/enterprise_script_service/mruby/test/t/float.rb +17 -17
  254. data/ext/enterprise_script_service/mruby/test/t/hash.rb +2 -0
  255. data/ext/enterprise_script_service/mruby/test/t/integer.rb +14 -6
  256. data/ext/enterprise_script_service/mruby/test/t/kernel.rb +38 -19
  257. data/ext/enterprise_script_service/mruby/test/t/module.rb +87 -14
  258. data/ext/enterprise_script_service/mruby/test/t/numeric.rb +65 -23
  259. data/ext/enterprise_script_service/mruby/test/t/range.rb +4 -4
  260. data/ext/enterprise_script_service/mruby/test/t/string.rb +211 -49
  261. data/ext/enterprise_script_service/mruby/test/t/syntax.rb +19 -2
  262. data/ext/enterprise_script_service/mruby/test/t/vformat.rb +92 -0
  263. data/ext/enterprise_script_service/mruby/travis_config.rb +2 -2
  264. data/ext/enterprise_script_service/mruby_config.rb +10 -0
  265. data/ext/enterprise_script_service/mruby_engine.cpp +2 -2
  266. data/ext/enterprise_script_service/mruby_engine.gembox +1 -0
  267. data/ext/enterprise_script_service/msgpack/CHANGELOG.md +14 -0
  268. data/ext/enterprise_script_service/msgpack/Files.cmake +4 -0
  269. data/ext/enterprise_script_service/msgpack/README.md +1 -1
  270. data/ext/enterprise_script_service/msgpack/appveyor.yml +1 -1
  271. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple.hpp.erb +1 -1
  272. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_msgpack_tuple_decl.hpp.erb +1 -1
  273. data/ext/enterprise_script_service/msgpack/erb/v1/cpp03_zone.hpp.erb +3 -3
  274. data/ext/enterprise_script_service/msgpack/example/boost/asio_send_recv.cpp +1 -1
  275. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/cpp11/timespec.hpp +16 -0
  276. data/ext/enterprise_script_service/msgpack/include/msgpack/adaptor/wstring.hpp +15 -0
  277. data/ext/enterprise_script_service/msgpack/include/msgpack/object.h +2 -0
  278. data/ext/enterprise_script_service/msgpack/include/msgpack/pack_template.h +17 -9
  279. data/ext/enterprise_script_service/msgpack/include/msgpack/sysdep.h +27 -16
  280. data/ext/enterprise_script_service/msgpack/include/msgpack/type.hpp +2 -0
  281. data/ext/enterprise_script_service/msgpack/include/msgpack/unpack_template.h +5 -0
  282. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/array_ref.hpp +0 -1
  283. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/check_container_size.hpp +1 -1
  284. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/chrono.hpp +5 -5
  285. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/cpp11/timespec.hpp +140 -0
  286. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple.hpp +32 -32
  287. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp03_msgpack_tuple_decl.hpp +32 -32
  288. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple.hpp +6 -6
  289. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/detail/cpp11_msgpack_tuple_decl.hpp +10 -10
  290. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/ext.hpp +1 -1
  291. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/fixint.hpp +5 -4
  292. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int.hpp +40 -13
  293. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/int_decl.hpp +3 -2
  294. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/adaptor/wstring.hpp +121 -0
  295. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp03_zone.hpp +3 -3
  296. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/detail/cpp11_zone.hpp +3 -3
  297. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object.hpp +6 -6
  298. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/object_fwd.hpp +1 -1
  299. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/pack.hpp +40 -5
  300. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/unpack.hpp +11 -11
  301. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/vrefbuffer.hpp +7 -7
  302. data/ext/enterprise_script_service/msgpack/include/msgpack/v1/zbuffer.hpp +5 -5
  303. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/adaptor/int_decl.hpp +1 -1
  304. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/create_object_visitor.hpp +1 -1
  305. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/parse.hpp +13 -13
  306. data/ext/enterprise_script_service/msgpack/include/msgpack/v2/x3_parse.hpp +28 -26
  307. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/adaptor/int_decl.hpp +1 -1
  308. data/ext/enterprise_script_service/msgpack/include/msgpack/v3/parse.hpp +13 -13
  309. data/ext/enterprise_script_service/msgpack/include/msgpack/version_master.h +2 -2
  310. data/ext/enterprise_script_service/msgpack/include/msgpack/zbuffer.h +6 -6
  311. data/ext/enterprise_script_service/msgpack/include/msgpack/zone.h +1 -1
  312. data/ext/enterprise_script_service/msgpack/src/objectc.c +83 -148
  313. data/ext/enterprise_script_service/msgpack/src/unpack.c +73 -47
  314. data/ext/enterprise_script_service/msgpack/test/CMakeLists.txt +1 -1
  315. data/ext/enterprise_script_service/msgpack/test/array_ref.cpp +5 -0
  316. data/ext/enterprise_script_service/msgpack/test/boost_fusion.cpp +5 -0
  317. data/ext/enterprise_script_service/msgpack/test/boost_optional.cpp +7 -0
  318. data/ext/enterprise_script_service/msgpack/test/boost_string_ref.cpp +7 -0
  319. data/ext/enterprise_script_service/msgpack/test/boost_string_view.cpp +6 -0
  320. data/ext/enterprise_script_service/msgpack/test/boost_variant.cpp +15 -9
  321. data/ext/enterprise_script_service/msgpack/test/buffer.cpp +7 -0
  322. data/ext/enterprise_script_service/msgpack/test/carray.cpp +7 -0
  323. data/ext/enterprise_script_service/msgpack/test/cases.cpp +7 -1
  324. data/ext/enterprise_script_service/msgpack/test/convert.cpp +6 -0
  325. data/ext/enterprise_script_service/msgpack/test/fixint.cpp +7 -1
  326. data/ext/enterprise_script_service/msgpack/test/fixint_c.cpp +6 -1
  327. data/ext/enterprise_script_service/msgpack/test/fuzz_unpack_pack_fuzzer_cpp11.cpp +5 -0
  328. data/ext/enterprise_script_service/msgpack/test/iterator_cpp11.cpp +8 -2
  329. data/ext/enterprise_script_service/msgpack/test/json.cpp +6 -0
  330. data/ext/enterprise_script_service/msgpack/test/limit.cpp +7 -0
  331. data/ext/enterprise_script_service/msgpack/test/msgpack_basic.cpp +128 -6
  332. data/ext/enterprise_script_service/msgpack/test/msgpack_c.cpp +7 -2
  333. data/ext/enterprise_script_service/msgpack/test/msgpack_container.cpp +20 -3
  334. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp11.cpp +159 -0
  335. data/ext/enterprise_script_service/msgpack/test/msgpack_cpp17.cpp +5 -0
  336. data/ext/enterprise_script_service/msgpack/test/msgpack_stream.cpp +8 -3
  337. data/ext/enterprise_script_service/msgpack/test/msgpack_tuple.cpp +6 -0
  338. data/ext/enterprise_script_service/msgpack/test/msgpack_vref.cpp +5 -0
  339. data/ext/enterprise_script_service/msgpack/test/msgpack_x3_parse.cpp +23 -18
  340. data/ext/enterprise_script_service/msgpack/test/object.cpp +77 -45
  341. data/ext/enterprise_script_service/msgpack/test/object_with_zone.cpp +28 -10
  342. data/ext/enterprise_script_service/msgpack/test/pack_unpack.cpp +25 -18
  343. data/ext/enterprise_script_service/msgpack/test/pack_unpack_c.cpp +7 -0
  344. data/ext/enterprise_script_service/msgpack/test/raw.cpp +17 -12
  345. data/ext/enterprise_script_service/msgpack/test/reference.cpp +6 -0
  346. data/ext/enterprise_script_service/msgpack/test/reference_cpp11.cpp +6 -0
  347. data/ext/enterprise_script_service/msgpack/test/reference_wrapper_cpp11.cpp +6 -0
  348. data/ext/enterprise_script_service/msgpack/test/shared_ptr_cpp11.cpp +6 -0
  349. data/ext/enterprise_script_service/msgpack/test/size_equal_only.cpp +6 -2
  350. data/ext/enterprise_script_service/msgpack/test/streaming.cpp +10 -3
  351. data/ext/enterprise_script_service/msgpack/test/streaming_c.cpp +7 -0
  352. data/ext/enterprise_script_service/msgpack/test/unique_ptr_cpp11.cpp +6 -0
  353. data/ext/enterprise_script_service/msgpack/test/user_class.cpp +5 -0
  354. data/ext/enterprise_script_service/msgpack/test/version.cpp +6 -0
  355. data/ext/enterprise_script_service/msgpack/test/visitor.cpp +7 -0
  356. data/ext/enterprise_script_service/msgpack/test/zone.cpp +6 -0
  357. data/lib/script_core/version.rb +1 -1
  358. data/lib/tasks/mruby/engine.gembox.example +1 -0
  359. data/lib/tasks/script_core.rake +21 -3
  360. data/spec/dummy/app/helpers/fields_helper.rb +2 -2
  361. data/spec/dummy/mruby/engine.gembox +1 -0
  362. data/spec/script_core_spec.rb +1 -1
  363. metadata +38 -22
  364. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.gitignore +0 -1
  365. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/.travis.yml +0 -2
  366. data/ext/enterprise_script_service/mruby/mrbgems/mruby-io/run_test.rb +0 -26
  367. data/ext/enterprise_script_service/mruby/mrbgems/mruby-kernel-ext/mrblib/kernel.rb +0 -15
  368. data/ext/enterprise_script_service/mruby/mrbgems/mruby-method/mrblib/unbound_method.rb +0 -9
  369. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.gitignore +0 -5
  370. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/.travis.yml +0 -2
  371. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb +0 -157
  372. data/ext/enterprise_script_service/mruby/mrbgems/mruby-pack/run_test.rb +0 -26
  373. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.c +0 -224
  374. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/mt19937ar.h +0 -80
  375. data/ext/enterprise_script_service/mruby/mrbgems/mruby-random/src/random.h +0 -12
  376. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.gitignore +0 -4
  377. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis.yml +0 -29
  378. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/.travis_build_config.rb +0 -6
  379. data/ext/enterprise_script_service/mruby/mrbgems/mruby-sleep/Rakefile +0 -29
  380. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/.travis.yml +0 -4
  381. data/ext/enterprise_script_service/mruby/mrbgems/mruby-socket/run_test.rb +0 -28
@@ -26,7 +26,7 @@ def each(&block)
26
26
  return self
27
27
  end
28
28
 
29
- if val.kind_of?(String) && last.kind_of?(String) # fixnums are special
29
+ if val.kind_of?(String) && last.kind_of?(String) # strings are special
30
30
  if val.respond_to? :upto
31
31
  return val.upto(last, exclude_end?, &block)
32
32
  else
@@ -3,24 +3,51 @@
3
3
  #
4
4
  # ISO 15.2.10
5
5
  class String
6
+ # ISO 15.2.10.3
6
7
  include Comparable
8
+
7
9
  ##
8
10
  # Calls the given block for each line
9
11
  # and pass the respective line.
10
12
  #
11
13
  # ISO 15.2.10.5.15
12
- def each_line(rs = "\n", &block)
13
- return to_enum(:each_line, rs, &block) unless block
14
- return block.call(self) if rs.nil?
15
- rs.__to_str
16
- offset = 0
17
- rs_len = rs.length
18
- this = dup
19
- while pos = this.index(rs, offset)
20
- block.call(this[offset, pos + rs_len - offset])
21
- offset = pos + rs_len
14
+ def each_line(separator = "\n", &block)
15
+ return to_enum(:each_line, separator) unless block
16
+
17
+ if separator.nil?
18
+ block.call(self)
19
+ return self
20
+ end
21
+ raise TypeError unless separator.is_a?(String)
22
+
23
+ paragraph_mode = false
24
+ if separator.empty?
25
+ paragraph_mode = true
26
+ separator = "\n\n"
27
+ end
28
+ start = 0
29
+ string = dup
30
+ self_len = length
31
+ sep_len = separator.length
32
+ should_yield_subclass_instances = self.class != String
33
+
34
+ while (pointer = string.index(separator, start))
35
+ pointer += sep_len
36
+ pointer += 1 while paragraph_mode && string[pointer] == "\n"
37
+ if should_yield_subclass_instances
38
+ block.call(self.class.new(string[start, pointer - start]))
39
+ else
40
+ block.call(string[start, pointer - start])
41
+ end
42
+ start = pointer
43
+ end
44
+ return self if start == self_len
45
+
46
+ if should_yield_subclass_instances
47
+ block.call(self.class.new(string[start, self_len - start]))
48
+ else
49
+ block.call(string[start, self_len - start])
22
50
  end
23
- block.call(this[offset, this.size - offset]) if this.size > offset
24
51
  self
25
52
  end
26
53
 
@@ -103,18 +130,15 @@ def gsub!(*args, &block)
103
130
  self.replace(str)
104
131
  end
105
132
 
106
- ##
107
- # Calls the given block for each match of +pattern+
108
- # If no block is given return an array with all
109
- # matches of +pattern+.
110
- #
111
- # ISO 15.2.10.5.32
112
- def scan(reg, &block)
113
- ### *** TODO *** ###
114
- unless Object.const_defined?(:Regexp)
115
- raise NotImplementedError, "scan not available (yet)"
116
- end
117
- end
133
+ # ##
134
+ # # Calls the given block for each match of +pattern+
135
+ # # If no block is given return an array with all
136
+ # # matches of +pattern+.
137
+ # #
138
+ # # ISO 15.2.10.5.32
139
+ # def scan(pattern, &block)
140
+ # # TODO: String#scan is not implemented yet
141
+ # end
118
142
 
119
143
  ##
120
144
  # Replace only the first match of +pattern+ with
@@ -165,21 +189,10 @@ def sub!(*args, &block)
165
189
  self.replace(str)
166
190
  end
167
191
 
168
- ##
169
- # Call the given block for each character of
170
- # +self+.
171
- def each_char(&block)
172
- pos = 0
173
- while pos < self.size
174
- block.call(self[pos])
175
- pos += 1
176
- end
177
- self
178
- end
179
-
180
192
  ##
181
193
  # Call the given block for each byte of +self+.
182
194
  def each_byte(&block)
195
+ return to_enum(:each_byte, &block) unless block
183
196
  bytes = self.bytes
184
197
  pos = 0
185
198
  while pos < bytes.size
@@ -189,86 +202,16 @@ def each_byte(&block)
189
202
  self
190
203
  end
191
204
 
192
- ##
193
- # Modify +self+ by replacing the content of +self+.
194
- # The portion of the string affected is determined using the same criteria as +String#[]+.
195
- def []=(*args)
196
- anum = args.size
197
- if anum == 2
198
- pos, value = args
199
- case pos
200
- when String
201
- posnum = self.index(pos)
202
- if posnum
203
- b = self[0, posnum.to_i]
204
- a = self[(posnum + pos.length)..-1]
205
- self.replace([b, value, a].join(''))
206
- else
207
- raise IndexError, "string not matched"
208
- end
209
- when Range
210
- head = pos.begin
211
- tail = pos.end
212
- tail += self.length if tail < 0
213
- unless pos.exclude_end?
214
- tail += 1
215
- end
216
- return self[head, tail-head]=value
217
- else
218
- pos += self.length if pos < 0
219
- if pos < 0 || pos > self.length
220
- raise IndexError, "index #{args[0]} out of string"
221
- end
222
- b = self[0, pos.to_i]
223
- a = self[pos + 1..-1]
224
- self.replace([b, value, a].join(''))
225
- end
226
- return value
227
- elsif anum == 3
228
- pos, len, value = args
229
- pos += self.length if pos < 0
230
- if pos < 0 || pos > self.length
231
- raise IndexError, "index #{args[0]} out of string"
232
- end
233
- if len < 0
234
- raise IndexError, "negative length #{len}"
235
- end
236
- b = self[0, pos.to_i]
237
- a = self[pos + len..-1]
238
- self.replace([b, value, a].join(''))
239
- return value
240
- else
241
- raise ArgumentError, "wrong number of arguments (#{anum} for 2..3)"
242
- end
243
- end
244
-
205
+ # those two methods requires Regexp that is optional in mruby
245
206
  ##
246
207
  # ISO 15.2.10.5.3
247
- def =~(re)
248
- re =~ self
249
- end
208
+ #def =~(re)
209
+ # re =~ self
210
+ #end
250
211
 
251
212
  ##
252
213
  # ISO 15.2.10.5.27
253
- def match(re, &block)
254
- if String === re
255
- if Object.const_defined?(:Regexp)
256
- r = Regexp.new(re)
257
- r.match(self, &block)
258
- else
259
- raise NotImplementedError, "String#match needs Regexp class"
260
- end
261
- else
262
- re.match(self, &block)
263
- end
264
- end
265
- end
266
-
267
- ##
268
- # String is comparable
269
- #
270
- # ISO 15.2.10.3
271
- module Comparable; end
272
- class String
273
- include Comparable
214
+ #def match(re, &block)
215
+ # re.match(self, &block)
216
+ #end
274
217
  end
@@ -10,7 +10,7 @@
10
10
 
11
11
  spec.summary = %q{MRuby source code wrapper.}
12
12
  spec.description = %q{MRuby source code wrapper for use with Ruby libs.}
13
- spec.homepage = "http://www.mruby.org/"
13
+ spec.homepage = "https://mruby.org"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -0,0 +1,105 @@
1
+ keyword___ENCODING__="__ENCODING__"
2
+ keyword___FILE__="__FILE__"
3
+ keyword___LINE__="__LINE__"
4
+ keyword_BEGIN="BEGIN"
5
+ keyword_END="END"
6
+ keyword_alias="alias"
7
+ keyword_and="and"
8
+ keyword_begin="begin"
9
+ keyword_break="break"
10
+ keyword_case="case"
11
+ keyword_class="class"
12
+ keyword_def="def"
13
+ keyword_do="do"
14
+ keyword_else="else"
15
+ keyword_elsif="elsif"
16
+ keyword_end="end"
17
+ keyword_ensure="ensure"
18
+ keyword_false="false"
19
+ keyword_for="for"
20
+ keyword_if="if"
21
+ keyword_in="in"
22
+ keyword_module="module"
23
+ keyword_next="next"
24
+ keyword_nil="nil"
25
+ keyword_not="not"
26
+ keyword_or="or"
27
+ keyword_redo="redo"
28
+ keyword_rescue="rescue"
29
+ keyword_retry="retry"
30
+ keyword_return="return"
31
+ keyword_self="self"
32
+ keyword_super="super"
33
+ keyword_then="then"
34
+ keyword_true="true"
35
+ keyword_undef="undef"
36
+ keyword_unless="unless"
37
+ keyword_until="until"
38
+ keyword_when="when"
39
+ keyword_while="while"
40
+ keyword_yield="yield"
41
+
42
+ operator_a=" !"
43
+ operator_b=" ~"
44
+ operator_c=" +"
45
+ operator_d=" -"
46
+ operator_e=" []"
47
+ operator_f=" []="
48
+ operator_g=" *"
49
+ operator_h=" /"
50
+ operator_i=" %"
51
+ operator_j=" +-"
52
+ operator_k=" >>"
53
+ operator_l=" <<"
54
+ operator_m=" &"
55
+ operator_n=" ^"
56
+ operator_o=" |"
57
+ operator_p=" <="
58
+ operator_q=" <>"
59
+ operator_r=" >="
60
+ operator_s=" <=>"
61
+ operator_t=" =="
62
+ operator_u=" ==="
63
+ operator_v=" !="
64
+ operator_w=" =~"
65
+ operator_x=" !~"
66
+ operator_y=" &&"
67
+ operator_z=" ||"
68
+ operator_aa=" .."
69
+ operator_ab=" ..."
70
+ operator_ac=" ?"
71
+ operator_ad=" :"
72
+ operator_ae=" ="
73
+ operator_af=" %="
74
+ operator_ag=" /="
75
+ operator_ah=" -="
76
+ operator_ai=" +="
77
+ operator_aj=" |="
78
+ operator_ak=" &="
79
+ operator_al=" >>="
80
+ operator_am=" <<="
81
+ operator_an=" *="
82
+ operator_ao=" &&="
83
+ operator_ap=" ||="
84
+ operator_aq=" **="
85
+ operator_ar=" ^="
86
+ operator_as=" not"
87
+ operator_at=" or"
88
+ operator_au=" and"
89
+ operator_av=" if"
90
+ operator_aw=" unless"
91
+ operator_ax=" while"
92
+ operator_ay=" until"
93
+ operator_az=" begin"
94
+ operator_ba=" end"
95
+
96
+ snippet_1eq1=" 1=1"
97
+ snippet_dollar=" $1"
98
+ snippet_at=" @a"
99
+ snippet_symbol=" :a"
100
+ snippet_array=" [1,2]"
101
+ snippet_block=" 1.times{|x| x}"
102
+ snippet_multi=" 1*1"
103
+
104
+ string_single_q=" 'a'"
105
+ string_dbl_q=" \"a\""
@@ -0,0 +1,5 @@
1
+ [libfuzzer]
2
+ close_fd_mask = 3
3
+ dict = mruby.dict
4
+ fork = 1
5
+ only_ascii = 1
@@ -0,0 +1,4 @@
1
+ [libfuzzer]
2
+ close_fd_mask = 3
3
+ dict = mruby.dict
4
+ fork = 1
@@ -0,0 +1,18 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+ #include <mruby.h>
4
+ #include <mruby/compile.h>
5
+
6
+ int LLVMFuzzerTestOneInput(uint8_t *Data, size_t size) {
7
+ if (size < 1) {
8
+ return 0;
9
+ }
10
+ char *code = malloc(size+1);
11
+ memcpy(code, Data, size);
12
+ code[size] = '\0';
13
+ mrb_state *mrb = mrb_open();
14
+ mrb_load_string(mrb, code);
15
+ mrb_close(mrb);
16
+ free(code);
17
+ return 0;
18
+ }
@@ -0,0 +1,44 @@
1
+ #include <string>
2
+ #include <iostream>
3
+ #include <fstream>
4
+
5
+ #include <mruby.h>
6
+ #include <mruby/compile.h>
7
+
8
+ #include "libprotobuf-mutator/src/libfuzzer/libfuzzer_macro.h"
9
+ #include "ruby.pb.h"
10
+ #include "proto_to_ruby.h"
11
+
12
+ using namespace ruby_fuzzer;
13
+ using namespace std;
14
+
15
+ int FuzzRB(const uint8_t *Data, size_t size) {
16
+ mrb_value v;
17
+ mrb_state *mrb = mrb_open();
18
+ if (!mrb)
19
+ return 0;
20
+
21
+ char *code = (char *)malloc(size+1);
22
+ if (!code)
23
+ return 0;
24
+ memcpy(code, Data, size);
25
+ code[size] = '\0';
26
+
27
+ if (const char *dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) {
28
+ // With libFuzzer binary run this to generate an RB file x.rb:
29
+ // PROTO_FUZZER_DUMP_PATH=x.rb ./a.out proto-input
30
+ std::ofstream of(dump_path);
31
+ of.write(code, size);
32
+ }
33
+ v = mrb_load_string(mrb, code);
34
+ mrb_close(mrb);
35
+
36
+ free(code);
37
+ return 0;
38
+ }
39
+
40
+ DEFINE_PROTO_FUZZER(const Function &function) {
41
+ protoConverter converter;
42
+ auto s = converter.FunctionToString(function);
43
+ (void)FuzzRB((const uint8_t*)s.data(), s.size());
44
+ }
@@ -0,0 +1,455 @@
1
+ #include "proto_to_ruby.h"
2
+
3
+ using namespace ruby_fuzzer;
4
+
5
+ std::string protoConverter::removeSpecial(const std::string &x)
6
+ {
7
+ std::string tmp(x);
8
+ if (!tmp.empty())
9
+ tmp.erase(std::remove_if(tmp.begin(), tmp.end(),
10
+ [](char c) { return !(std::isalpha(c) || std::isdigit(c)); } ), tmp.end());
11
+ return tmp;
12
+ }
13
+
14
+ void protoConverter::visit(ArrType const& x)
15
+ {
16
+ if (x.elements_size() > 0) {
17
+ int i = x.elements_size();
18
+ m_output << "[";
19
+ for (auto &e : x.elements()) {
20
+ i--;
21
+ if (i == 0) {
22
+ visit(e);
23
+ } else {
24
+ visit(e);
25
+ m_output << ", ";
26
+ }
27
+ }
28
+ m_output << "]";
29
+ } else {
30
+ m_output << "[1]";
31
+ }
32
+ }
33
+
34
+ void protoConverter::visit(Array const& x)
35
+ {
36
+ switch (x.arr_func()) {
37
+ case Array::FLATTEN:
38
+ visit(x.arr_arg());
39
+ m_output << ".flatten";
40
+ break;
41
+ case Array::COMPACT:
42
+ visit(x.arr_arg());
43
+ m_output << ".compact";
44
+ break;
45
+ case Array::FETCH:
46
+ visit(x.arr_arg());
47
+ m_output << ".fetch";
48
+ break;
49
+ case Array::FILL:
50
+ visit(x.arr_arg());
51
+ m_output << ".fill";
52
+ break;
53
+ case Array::ROTATE:
54
+ visit(x.arr_arg());
55
+ m_output << ".rotate";
56
+ break;
57
+ case Array::ROTATE_E:
58
+ visit(x.arr_arg());
59
+ m_output << ".rotate!";
60
+ break;
61
+ case Array::DELETEIF:
62
+ visit(x.arr_arg());
63
+ m_output << ".delete_if";
64
+ break;
65
+ case Array::INSERT:
66
+ visit(x.arr_arg());
67
+ m_output << ".insert";
68
+ break;
69
+ case Array::BSEARCH:
70
+ visit(x.arr_arg());
71
+ m_output << ".bsearch";
72
+ break;
73
+ case Array::KEEPIF:
74
+ visit(x.arr_arg());
75
+ m_output << ".keep_if";
76
+ break;
77
+ case Array::SELECT:
78
+ visit(x.arr_arg());
79
+ m_output << ".select";
80
+ break;
81
+ case Array::VALUES_AT:
82
+ visit(x.arr_arg());
83
+ m_output << ".values_at";
84
+ break;
85
+ case Array::BLOCK:
86
+ visit(x.arr_arg());
87
+ m_output << ".index";
88
+ break;
89
+ case Array::DIG:
90
+ visit(x.arr_arg());
91
+ m_output << ".dig";
92
+ break;
93
+ case Array::SLICE:
94
+ visit(x.arr_arg());
95
+ m_output << ".slice";
96
+ break;
97
+ case Array::PERM:
98
+ visit(x.arr_arg());
99
+ m_output << ".permutation";
100
+ break;
101
+ case Array::COMB:
102
+ visit(x.arr_arg());
103
+ m_output << ".combination";
104
+ break;
105
+ case Array::ASSOC:
106
+ visit(x.arr_arg());
107
+ m_output << ".assoc";
108
+ break;
109
+ case Array::RASSOC:
110
+ visit(x.arr_arg());
111
+ m_output << ".rassoc";
112
+ break;
113
+ }
114
+ m_output << "(";
115
+ visit(x.val_arg());
116
+ m_output << ")";
117
+ }
118
+
119
+ void protoConverter::visit(AssignmentStatement const& x)
120
+ {
121
+ m_output << "var_" << m_numLiveVars << " = ";
122
+ visit(x.rvalue());
123
+ m_numVarsPerScope.top()++;
124
+ m_numLiveVars++;
125
+ m_output << "\n";
126
+ }
127
+
128
+ void protoConverter::visit(BinaryOp const& x)
129
+ {
130
+ m_output << "(";
131
+ visit(x.left());
132
+ switch (x.op()) {
133
+ case BinaryOp::ADD: m_output << " + "; break;
134
+ case BinaryOp::SUB: m_output << " - "; break;
135
+ case BinaryOp::MUL: m_output << " * "; break;
136
+ case BinaryOp::DIV: m_output << " / "; break;
137
+ case BinaryOp::MOD: m_output << " % "; break;
138
+ case BinaryOp::XOR: m_output << " ^ "; break;
139
+ case BinaryOp::AND: m_output << " and "; break;
140
+ case BinaryOp::OR: m_output << " or "; break;
141
+ case BinaryOp::EQ: m_output << " == "; break;
142
+ case BinaryOp::NE: m_output << " != "; break;
143
+ case BinaryOp::LE: m_output << " <= "; break;
144
+ case BinaryOp::GE: m_output << " >= "; break;
145
+ case BinaryOp::LT: m_output << " < "; break;
146
+ case BinaryOp::GT: m_output << " > "; break;
147
+ case BinaryOp::RS: m_output << " >> "; break;
148
+ }
149
+ visit(x.right());
150
+ m_output << ")";
151
+ }
152
+
153
+ void protoConverter::visit(BuiltinFuncs const& x)
154
+ {
155
+ switch (x.bifunc_oneof_case()) {
156
+ case BuiltinFuncs::kOs:
157
+ visit(x.os());
158
+ break;
159
+ case BuiltinFuncs::kTime:
160
+ visit(x.time());
161
+ break;
162
+ case BuiltinFuncs::kArr:
163
+ visit(x.arr());
164
+ break;
165
+ case BuiltinFuncs::kMops:
166
+ visit(x.mops());
167
+ break;
168
+ case BuiltinFuncs::BIFUNC_ONEOF_NOT_SET:
169
+ m_output << "1";
170
+ break;
171
+ }
172
+ m_output << "\n";
173
+ }
174
+
175
+ void protoConverter::visit(Const const& x)
176
+ {
177
+ switch (x.const_oneof_case()) {
178
+ case Const::kIntLit:
179
+ m_output << "(" << (x.int_lit() % 13) << ")";
180
+ break;
181
+ case Const::kBoolVal:
182
+ m_output << "(" << x.bool_val() << ")";
183
+ break;
184
+ case Const::CONST_ONEOF_NOT_SET:
185
+ m_output << "1";
186
+ break;
187
+ }
188
+ }
189
+
190
+ void protoConverter::visit(Function const& x)
191
+ {
192
+ m_output << "def foo()\nvar_0 = 1\n";
193
+ visit(x.statements());
194
+ m_output << "end\n";
195
+ m_output << "foo\n";
196
+ }
197
+
198
+ void protoConverter::visit(HashType const& x)
199
+ {
200
+ if (x.keyval_size() > 0) {
201
+ int i = x.keyval_size();
202
+ m_output << "{";
203
+ for (auto &e : x.keyval()) {
204
+ i--;
205
+ if (i == 0) {
206
+ visit(e);
207
+ }
208
+ else {
209
+ visit(e);
210
+ m_output << ", ";
211
+ }
212
+ }
213
+ m_output << "}";
214
+ }
215
+ }
216
+
217
+ void protoConverter::visit(IfElse const& x)
218
+ {
219
+ m_output << "if ";
220
+ visit(x.cond());
221
+ m_output << "\n";
222
+ visit(x.if_body());
223
+ m_output << "\nelse\n";
224
+ visit(x.else_body());
225
+ m_output << "\nend\n";
226
+ }
227
+
228
+ void protoConverter::visit(KVPair const& x)
229
+ {
230
+ m_output << "\"" << removeSpecial(x.key()) << "\"";
231
+ m_output << " => ";
232
+ m_output << "\"" << removeSpecial(x.val()) << "\"";
233
+ }
234
+
235
+ void protoConverter::visit(MathConst const& x)
236
+ {
237
+ switch (x.math_const()) {
238
+ case MathConst::PI:
239
+ m_output << "Math::PI";
240
+ break;
241
+ case MathConst::E:
242
+ m_output << "Math::E";
243
+ break;
244
+ }
245
+ }
246
+
247
+ void protoConverter::visit(MathOps const& x)
248
+ {
249
+ switch (x.math_op()) {
250
+ case MathOps::CBRT:
251
+ m_output << "Math.cbrt(";
252
+ visit(x.math_arg());
253
+ m_output << ")";
254
+ break;
255
+ case MathOps::COS:
256
+ m_output << "Math.cos(";
257
+ visit(x.math_arg());
258
+ m_output << ")";
259
+ break;
260
+ case MathOps::ERF:
261
+ m_output << "Math.erf(";
262
+ visit(x.math_arg());
263
+ m_output << ")";
264
+ break;
265
+ case MathOps::ERFC:
266
+ m_output << "Math.erfc(";
267
+ visit(x.math_arg());
268
+ m_output << ")";
269
+ break;
270
+ case MathOps::LOG:
271
+ m_output << "Math.log(";
272
+ visit(x.math_arg());
273
+ m_output << ")";
274
+ break;
275
+ case MathOps::LOG10:
276
+ m_output << "Math.log10(";
277
+ visit(x.math_arg());
278
+ m_output << ")";
279
+ break;
280
+ case MathOps::LOG2:
281
+ m_output << "Math.log2(";
282
+ visit(x.math_arg());
283
+ m_output << ")";
284
+ break;
285
+ case MathOps::SIN:
286
+ m_output << "Math.sin(";
287
+ visit(x.math_arg());
288
+ m_output << ")";
289
+ break;
290
+ case MathOps::SQRT:
291
+ m_output << "Math.sqrt(";
292
+ visit(x.math_arg());
293
+ m_output << ")";
294
+ break;
295
+ case MathOps::TAN:
296
+ m_output << "Math.tan(";
297
+ visit(x.math_arg());
298
+ m_output << ")";
299
+ break;
300
+ }
301
+ }
302
+
303
+ void protoConverter::visit(MathType const& x)
304
+ {
305
+ switch (x.math_arg_oneof_case()) {
306
+ case MathType::kMathRval:
307
+ visit(x.math_rval());
308
+ break;
309
+ case MathType::kMathConst:
310
+ visit(x.math_const());
311
+ break;
312
+ case MathType::MATH_ARG_ONEOF_NOT_SET:
313
+ m_output << "1";
314
+ break;
315
+ }
316
+ }
317
+
318
+ void protoConverter::visit(ObjectSpace const& x)
319
+ {
320
+ switch (x.os_func()) {
321
+ case ObjectSpace::COUNT:
322
+ m_output << "ObjectSpace.count_objects";
323
+ break;
324
+ }
325
+ m_output << "(";
326
+ visit(x.os_arg());
327
+ m_output << ")" << "\n";
328
+ }
329
+
330
+ void protoConverter::visit(Rvalue const& x)
331
+ {
332
+ switch (x.rvalue_oneof_case()) {
333
+ case Rvalue::kVarref:
334
+ visit(x.varref());
335
+ break;
336
+ case Rvalue::kCons:
337
+ visit(x.cons());
338
+ break;
339
+ case Rvalue::kBinop:
340
+ visit(x.binop());
341
+ break;
342
+ case Rvalue::RVALUE_ONEOF_NOT_SET:
343
+ m_output << "1";
344
+ break;
345
+ }
346
+ }
347
+
348
+ void protoConverter::visit(Statement const& x)
349
+ {
350
+ switch (x.stmt_oneof_case()) {
351
+ case Statement::kAssignment:
352
+ visit(x.assignment());
353
+ break;
354
+ case Statement::kIfelse:
355
+ visit(x.ifelse());
356
+ break;
357
+ case Statement::kTernaryStmt:
358
+ visit(x.ternary_stmt());
359
+ break;
360
+ case Statement::kBuiltins:
361
+ visit(x.builtins());
362
+ break;
363
+ case Statement::kBlockstmt:
364
+ visit(x.blockstmt());
365
+ break;
366
+ case Statement::STMT_ONEOF_NOT_SET:
367
+ break;
368
+ }
369
+ m_output << "\n";
370
+ }
371
+
372
+ void protoConverter::visit(StatementSeq const& x)
373
+ {
374
+ if (x.statements_size() > 0) {
375
+ m_numVarsPerScope.push(0);
376
+ m_output << "@scope ||= begin\n";
377
+ for (auto &st : x.statements())
378
+ visit(st);
379
+ m_output << "end\n";
380
+ m_numLiveVars -= m_numVarsPerScope.top();
381
+ m_numVarsPerScope.pop();
382
+ }
383
+ }
384
+
385
+ void protoConverter::visit(StringExtNoArg const& x)
386
+ {
387
+ m_output << "\"" << removeSpecial(x.str_arg()) << "\"";
388
+ switch (x.str_op()) {
389
+ case StringExtNoArg::DUMP:
390
+ m_output << ".dump";
391
+ break;
392
+ case StringExtNoArg::STRIP:
393
+ m_output << ".strip";
394
+ break;
395
+ case StringExtNoArg::LSTRIP:
396
+ m_output << ".lstrip";
397
+ break;
398
+ case StringExtNoArg::RSTRIP:
399
+ m_output << ".rstrip";
400
+ break;
401
+ case StringExtNoArg::STRIPE:
402
+ m_output << ".strip!";
403
+ break;
404
+ case StringExtNoArg::LSTRIPE:
405
+ m_output << ".lstrip!";
406
+ break;
407
+ case StringExtNoArg::RSTRIPE:
408
+ m_output << ".rstrip!";
409
+ break;
410
+ case StringExtNoArg::SWAPCASE:
411
+ m_output << ".swapcase";
412
+ break;
413
+ case StringExtNoArg::SWAPCASEE:
414
+ m_output << ".swapcase!";
415
+ break;
416
+ case StringExtNoArg::SQUEEZE:
417
+ m_output << ".squeeze";
418
+ break;
419
+ }
420
+ }
421
+
422
+ void protoConverter::visit(Ternary const& x)
423
+ {
424
+ m_output << "(";
425
+ visit(x.tern_cond());
426
+ m_output << " ? ";
427
+ visit(x.t_branch());
428
+ m_output << " : ";
429
+ visit(x.f_branch());
430
+ m_output << ")\n";
431
+ }
432
+
433
+ void protoConverter::visit(Time const& x)
434
+ {
435
+ switch (x.t_func()) {
436
+ case Time::AT:
437
+ m_output << "Time.at";
438
+ break;
439
+ case Time::GM:
440
+ m_output << "Time.gm";
441
+ break;
442
+ }
443
+ m_output << "(" << (x.t_arg()% 13) << ")" << "\n";
444
+ }
445
+
446
+ void protoConverter::visit(VarRef const& x)
447
+ {
448
+ m_output << "var_" << (static_cast<uint32_t>(x.varnum()) % m_numLiveVars);
449
+ }
450
+
451
+ std::string protoConverter::FunctionToString(Function const& input)
452
+ {
453
+ visit(input);
454
+ return m_output.str();
455
+ }