cloudsmith-api 0.52.79 → 0.53.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +3 -5
  3. data/README.md +15 -5
  4. data/build.json +1 -1
  5. data/docs/{EntitlmentTokenMetric.md → EntitlementTokenMetric.md} +1 -1
  6. data/docs/EntitlementsCreate.md +3 -0
  7. data/docs/EntitlementsPartialUpdate.md +3 -0
  8. data/docs/EntitlementsRefresh.md +3 -0
  9. data/docs/MetricsApi.md +81 -6
  10. data/docs/MetricsownerrepopackagesusageActivePackages.md +10 -0
  11. data/docs/PackageUsageMetric.md +11 -0
  12. data/docs/Quota.md +8 -0
  13. data/docs/QuotaApi.md +248 -0
  14. data/docs/QuotaHistory.md +8 -0
  15. data/docs/QuotaHistoryHistory.md +13 -0
  16. data/docs/RepositoryToken.md +6 -0
  17. data/docs/RepositoryTokenRefresh.md +6 -0
  18. data/docs/RepositoryTokenSyncTokens.md +6 -0
  19. data/lib/cloudsmith-api.rb +7 -1
  20. data/lib/cloudsmith-api/api/metrics_api.rb +79 -7
  21. data/lib/cloudsmith-api/api/quota_api.rb +227 -0
  22. data/lib/cloudsmith-api/models/{entitlment_token_metric.rb → entitlement_token_metric.rb} +1 -1
  23. data/lib/cloudsmith-api/models/entitlements_create.rb +31 -1
  24. data/lib/cloudsmith-api/models/entitlements_partial_update.rb +31 -1
  25. data/lib/cloudsmith-api/models/entitlements_refresh.rb +31 -1
  26. data/lib/cloudsmith-api/models/metricsownerrepopackagesusage_active_packages.rb +209 -0
  27. data/lib/cloudsmith-api/models/package_usage_metric.rb +243 -0
  28. data/lib/cloudsmith-api/models/quota.rb +194 -0
  29. data/lib/cloudsmith-api/models/quota_history.rb +196 -0
  30. data/lib/cloudsmith-api/models/quota_history_history.rb +239 -0
  31. data/lib/cloudsmith-api/models/repository_token.rb +61 -1
  32. data/lib/cloudsmith-api/models/repository_token_refresh.rb +61 -1
  33. data/lib/cloudsmith-api/models/repository_token_sync_tokens.rb +61 -1
  34. data/lib/cloudsmith-api/version.rb +1 -1
  35. data/spec/api/metrics_api_spec.rb +21 -3
  36. data/spec/api/quota_api_spec.rb +83 -0
  37. data/spec/models/{entitlment_token_metric_spec.rb → entitlement_token_metric_spec.rb} +6 -6
  38. data/spec/models/entitlements_create_spec.rb +18 -0
  39. data/spec/models/entitlements_partial_update_spec.rb +18 -0
  40. data/spec/models/entitlements_refresh_spec.rb +18 -0
  41. data/spec/models/metricsownerrepopackagesusage_active_packages_spec.rb +54 -0
  42. data/spec/models/package_usage_metric_spec.rb +60 -0
  43. data/spec/models/quota_history_history_spec.rb +72 -0
  44. data/spec/models/quota_history_spec.rb +42 -0
  45. data/spec/models/quota_spec.rb +42 -0
  46. data/spec/models/repository_token_refresh_spec.rb +36 -0
  47. data/spec/models/repository_token_spec.rb +36 -0
  48. data/spec/models/repository_token_sync_tokens_spec.rb +36 -0
  49. data/vendor/bundle/ruby/2.6.0/cache/crack-0.4.4.gem +0 -0
  50. data/vendor/bundle/ruby/2.6.0/cache/public_suffix-4.0.6.gem +0 -0
  51. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/autotest-fsevent-0.2.17/gem_make.out +1 -1
  52. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.13.1/gem_make.out +2 -2
  53. data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.3.1/gem_make.out +1 -1
  54. data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack.rb +0 -0
  55. data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/json.rb +5 -18
  56. data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/util.rb +0 -0
  57. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.4/lib/crack/version.rb +3 -0
  58. data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/xml.rb +0 -0
  59. data/vendor/bundle/ruby/2.6.0/gems/ffi-1.13.1/ext/ffi_c/Makefile +3 -3
  60. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.github/FUNDING.yml +0 -0
  61. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.github/workflows/tests.yml +1 -1
  62. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.gitignore +0 -0
  63. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.rubocop.yml +0 -0
  64. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.rubocop_opinionated.yml +1 -18
  65. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.travis.yml +1 -1
  66. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/.yardopts +0 -0
  67. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/2.0-Upgrade.md +0 -0
  68. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/CHANGELOG.md +7 -0
  69. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/Gemfile +1 -1
  70. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/LICENSE.txt +0 -0
  71. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/README.md +0 -0
  72. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/Rakefile +0 -0
  73. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/SECURITY.md +0 -0
  74. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/bin/console +0 -0
  75. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/codecov.yml +0 -2
  76. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/data/list.txt +312 -78
  77. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix.rb +0 -0
  78. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix/domain.rb +0 -0
  79. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix/errors.rb +0 -0
  80. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix/list.rb +0 -0
  81. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix/rule.rb +0 -0
  82. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/lib/public_suffix/version.rb +1 -1
  83. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/public_suffix.gemspec +0 -0
  84. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/.empty +0 -0
  85. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/acceptance_test.rb +2 -0
  86. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_find.rb +0 -0
  87. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_find_all.rb +0 -0
  88. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_names.rb +0 -0
  89. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_select.rb +0 -0
  90. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_select_incremental.rb +0 -0
  91. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/benchmarks/bm_valid.rb +0 -0
  92. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/domain_profiler.rb +0 -0
  93. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/find_profiler.rb +0 -0
  94. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/find_profiler_jp.rb +0 -0
  95. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/initialization_profiler.rb +0 -0
  96. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/list_profsize.rb +0 -0
  97. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/profilers/object_binsize.rb +0 -0
  98. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/psl_test.rb +1 -1
  99. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/test_helper.rb +0 -0
  100. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/tests.txt +0 -0
  101. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/unit/domain_test.rb +0 -0
  102. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/unit/errors_test.rb +0 -0
  103. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/unit/list_test.rb +0 -0
  104. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/unit/public_suffix_test.rb +0 -0
  105. data/vendor/bundle/ruby/2.6.0/gems/{public_suffix-4.0.5 → public_suffix-4.0.6}/test/unit/rule_test.rb +0 -0
  106. data/vendor/bundle/ruby/2.6.0/specifications/{crack-0.4.3.gemspec → crack-0.4.4.gemspec} +3 -15
  107. data/vendor/bundle/ruby/2.6.0/specifications/{public_suffix-4.0.5.gemspec → public_suffix-4.0.6.gemspec} +4 -4
  108. data/vendor/bundle/ruby/2.6.0/specifications/sys-uname-1.2.1.gemspec +1 -1
  109. metadata +174 -225
  110. data/vendor/bundle/ruby/2.6.0/bin/safe_yaml +0 -27
  111. data/vendor/bundle/ruby/2.6.0/cache/crack-0.4.3.gem +0 -0
  112. data/vendor/bundle/ruby/2.6.0/cache/public_suffix-4.0.5.gem +0 -0
  113. data/vendor/bundle/ruby/2.6.0/cache/safe_yaml-1.0.5.gem +0 -0
  114. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/.gitignore +0 -8
  115. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/.travis.yml +0 -14
  116. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/Gemfile +0 -5
  117. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/History +0 -25
  118. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/LICENSE +0 -20
  119. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/README.md +0 -46
  120. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/crack.gemspec +0 -20
  121. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/version.rb +0 -3
  122. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/bootstrap +0 -21
  123. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/release +0 -42
  124. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/test +0 -25
  125. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/large_dataset.json +0 -139988
  126. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/twittersearch-firefox.json +0 -1
  127. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/twittersearch-ie.json +0 -1
  128. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/hash_test.rb +0 -26
  129. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/json_test.rb +0 -91
  130. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/parser_test.rb +0 -27
  131. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/string_test.rb +0 -31
  132. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/test_helper.rb +0 -3
  133. data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/xml_test.rb +0 -514
  134. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/.gitignore +0 -3
  135. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/.travis.yml +0 -48
  136. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/CHANGES.md +0 -154
  137. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/Gemfile +0 -11
  138. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/LICENSE.txt +0 -22
  139. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/README.md +0 -191
  140. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/Rakefile +0 -26
  141. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/bin/safe_yaml +0 -75
  142. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh +0 -11
  143. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb +0 -94
  144. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb +0 -34
  145. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb +0 -36
  146. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb +0 -181
  147. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb +0 -37
  148. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb +0 -12
  149. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb +0 -26
  150. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb +0 -99
  151. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb +0 -52
  152. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb +0 -94
  153. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -29
  154. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +0 -39
  155. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb +0 -36
  156. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb +0 -43
  157. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb +0 -38
  158. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb +0 -41
  159. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb +0 -21
  160. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb +0 -13
  161. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb +0 -33
  162. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb +0 -26
  163. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb +0 -18
  164. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb +0 -17
  165. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb +0 -47
  166. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb +0 -3
  167. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh +0 -38
  168. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec +0 -19
  169. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.2.yaml +0 -2
  170. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.3.yaml +0 -2
  171. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/issue48.txt +0 -20
  172. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/issue49.yml +0 -0
  173. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/libyaml_checker_spec.rb +0 -69
  174. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/psych_resolver_spec.rb +0 -10
  175. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb +0 -278
  176. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/safe_yaml_spec.rb +0 -731
  177. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb +0 -42
  178. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/store_spec.rb +0 -57
  179. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/support/exploitable_back_door.rb +0 -29
  180. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/syck_resolver_spec.rb +0 -10
  181. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/base64_spec.rb +0 -11
  182. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_date_spec.rb +0 -60
  183. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_float_spec.rb +0 -42
  184. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_integer_spec.rb +0 -64
  185. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_symbol_spec.rb +0 -51
  186. data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/yaml_spec.rb +0 -15
  187. data/vendor/bundle/ruby/2.6.0/specifications/safe_yaml-1.0.5.gemspec +0 -23
@@ -1,41 +0,0 @@
1
- require 'base64'
2
-
3
- module SafeYAML
4
- class Transform
5
- TRANSFORMERS = [
6
- Transform::ToSymbol.new,
7
- Transform::ToInteger.new,
8
- Transform::ToFloat.new,
9
- Transform::ToNil.new,
10
- Transform::ToBoolean.new,
11
- Transform::ToDate.new
12
- ]
13
-
14
- def self.to_guessed_type(value, quoted=false, options=nil)
15
- return value if quoted
16
-
17
- if value.is_a?(String)
18
- TRANSFORMERS.each do |transformer|
19
- success, transformed_value = transformer.method(:transform?).arity == 1 ?
20
- transformer.transform?(value) :
21
- transformer.transform?(value, options)
22
-
23
- return transformed_value if success
24
- end
25
- end
26
-
27
- value
28
- end
29
-
30
- def self.to_proper_type(value, quoted=false, tag=nil, options=nil)
31
- case tag
32
- when "tag:yaml.org,2002:binary", "x-private:binary", "!binary"
33
- decoded = Base64.decode64(value)
34
- decoded = decoded.force_encoding(value.encoding) if decoded.respond_to?(:force_encoding)
35
- decoded
36
- else
37
- self.to_guessed_type(value, quoted, options)
38
- end
39
- end
40
- end
41
- end
@@ -1,21 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToBoolean
4
- include TransformationMap
5
-
6
- set_predefined_values({
7
- "yes" => true,
8
- "on" => true,
9
- "true" => true,
10
- "no" => false,
11
- "off" => false,
12
- "false" => false
13
- })
14
-
15
- def transform?(value)
16
- return false if value.length > 5
17
- return PREDEFINED_VALUES.include?(value), PREDEFINED_VALUES[value]
18
- end
19
- end
20
- end
21
- end
@@ -1,13 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToDate
4
- def transform?(value)
5
- return true, Date.parse(value) if Parse::Date::DATE_MATCHER.match(value)
6
- return true, Parse::Date.value(value) if Parse::Date::TIME_MATCHER.match(value)
7
- false
8
- rescue ArgumentError
9
- return true, value
10
- end
11
- end
12
- end
13
- end
@@ -1,33 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToFloat
4
- Infinity = 1.0 / 0.0
5
- NaN = 0.0 / 0.0
6
-
7
- PREDEFINED_VALUES = {
8
- ".inf" => Infinity,
9
- ".Inf" => Infinity,
10
- ".INF" => Infinity,
11
- "-.inf" => -Infinity,
12
- "-.Inf" => -Infinity,
13
- "-.INF" => -Infinity,
14
- ".nan" => NaN,
15
- ".NaN" => NaN,
16
- ".NAN" => NaN,
17
- }.freeze
18
-
19
- MATCHER = /\A[-+]?(?:\d[\d_]*)?\.[\d_]+(?:[eE][-+][\d]+)?\Z/.freeze
20
-
21
- def transform?(value)
22
- return true, Float(value) if MATCHER.match(value)
23
- try_edge_cases?(value)
24
- end
25
-
26
- def try_edge_cases?(value)
27
- return true, PREDEFINED_VALUES[value] if PREDEFINED_VALUES.include?(value)
28
- return true, Parse::Sexagesimal.value(value) if Parse::Sexagesimal::FLOAT_MATCHER.match(value)
29
- return false
30
- end
31
- end
32
- end
33
- end
@@ -1,26 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToInteger
4
- MATCHERS = Deep.freeze([
5
- /\A[-+]?(0|([1-9][0-9_,]*))\Z/, # decimal
6
- /\A0[0-7]+\Z/, # octal
7
- /\A0x[0-9a-f]+\Z/i, # hexadecimal
8
- /\A0b[01_]+\Z/ # binary
9
- ])
10
-
11
- def transform?(value)
12
- MATCHERS.each_with_index do |matcher, idx|
13
- value = value.gsub(/[_,]/, "") if idx == 0
14
- return true, Integer(value) if matcher.match(value)
15
- end
16
- try_edge_cases?(value)
17
- end
18
-
19
- def try_edge_cases?(value)
20
- return true, Parse::Hexadecimal.value(value) if Parse::Hexadecimal::MATCHER.match(value)
21
- return true, Parse::Sexagesimal.value(value) if Parse::Sexagesimal::INTEGER_MATCHER.match(value)
22
- return false
23
- end
24
- end
25
- end
26
- end
@@ -1,18 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToNil
4
- include TransformationMap
5
-
6
- set_predefined_values({
7
- "" => nil,
8
- "~" => nil,
9
- "null" => nil
10
- })
11
-
12
- def transform?(value)
13
- return false if value.length > 4
14
- return PREDEFINED_VALUES.include?(value), PREDEFINED_VALUES[value]
15
- end
16
- end
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- class ToSymbol
4
- def transform?(value, options=SafeYAML::OPTIONS)
5
- if options[:deserialize_symbols] && value =~ /\A:./
6
- if value =~ /\A:(["'])(.*)\1\Z/
7
- return true, $2.sub(/^:/, "").to_sym
8
- else
9
- return true, value.sub(/^:/, "").to_sym
10
- end
11
- end
12
-
13
- return false
14
- end
15
- end
16
- end
17
- end
@@ -1,47 +0,0 @@
1
- module SafeYAML
2
- class Transform
3
- module TransformationMap
4
- def self.included(base)
5
- base.extend(ClassMethods)
6
- end
7
-
8
- class CaseAgnosticMap < Hash
9
- def initialize(*args)
10
- super
11
- end
12
-
13
- def include?(key)
14
- super(key.downcase)
15
- end
16
-
17
- def [](key)
18
- super(key.downcase)
19
- end
20
-
21
- # OK, I actually don't think it's all that important that this map be
22
- # frozen.
23
- def freeze
24
- self
25
- end
26
- end
27
-
28
- module ClassMethods
29
- def set_predefined_values(predefined_values)
30
- if SafeYAML::YAML_ENGINE == "syck"
31
- expanded_map = predefined_values.inject({}) do |hash, (key, value)|
32
- hash[key] = value
33
- hash[key.capitalize] = value
34
- hash[key.upcase] = value
35
- hash
36
- end
37
- else
38
- expanded_map = CaseAgnosticMap.new
39
- expanded_map.merge!(predefined_values)
40
- end
41
-
42
- self.const_set(:PREDEFINED_VALUES, expanded_map.freeze)
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,3 +0,0 @@
1
- module SafeYAML
2
- VERSION = "1.0.5"
3
- end
@@ -1,38 +0,0 @@
1
- #!/bin/bash
2
-
3
- [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
4
-
5
- rvm use 1.8.7
6
- bundle exec rake spec
7
-
8
- rvm use 1.9.2
9
- YAMLER=syck bundle exec rake spec
10
-
11
- YAMLER=psych bundle exec rake spec
12
-
13
- rvm use 1.9.3
14
- YAMLER=syck bundle exec rake spec
15
-
16
- YAMLER=psych bundle exec rake spec
17
-
18
- rvm use 2.0.0
19
- bundle exec rake spec
20
-
21
- rvm use 2.1.0
22
- bundle exec rake spec
23
-
24
- rvm use 2.1.1
25
- bundle exec rake spec
26
-
27
- rvm use 2.1.2
28
- bundle exec rake spec
29
-
30
- rvm use ruby-head
31
- bundle exec rake spec
32
-
33
- rvm use jruby
34
- JRUBY_OPTS=--1.8 bundle exec rake spec
35
-
36
- JRUBY_OPTS=--1.9 bundle exec rake spec
37
-
38
- JRUBY_OPTS=--2.0 bundle exec rake spec
@@ -1,19 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.join(File.dirname(__FILE__), "lib", "safe_yaml", "version")
3
-
4
- Gem::Specification.new do |gem|
5
- gem.name = "safe_yaml"
6
- gem.version = SafeYAML::VERSION
7
- gem.authors = "Dan Tao"
8
- gem.email = "daniel.tao@gmail.com"
9
- gem.description = %q{Parse YAML safely}
10
- gem.summary = %q{SameYAML provides an alternative implementation of YAML.load suitable for accepting user input in Ruby applications.}
11
- gem.homepage = "https://github.com/dtao/safe_yaml"
12
- gem.license = "MIT"
13
- gem.files = `git ls-files`.split($\)
14
- gem.test_files = gem.files.grep(%r{^spec/})
15
- gem.require_paths = ["lib"]
16
- gem.executables = ["safe_yaml"]
17
-
18
- gem.required_ruby_version = ">= 1.8.7"
19
- end
@@ -1,2 +0,0 @@
1
- --- !ruby/object:ExploitableBackDoor
2
- foo: bar
@@ -1,2 +0,0 @@
1
- --- !ruby/hash:ExploitableBackDoor
2
- foo: bar
@@ -1,20 +0,0 @@
1
- ---
2
- title: Blah
3
- key: value
4
- ---
5
-
6
- I'm going to inject a bunch of YAML-looking stuff below and it should all just get ignored.
7
-
8
- foo: bar
9
-
10
- - foo
11
- - bar
12
-
13
- :foo
14
- 42
15
- ~
16
-
17
- ---
18
- text: |
19
- Look, I'm another YAML document!
20
- ---
@@ -1,69 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe SafeYAML::LibyamlChecker do
4
- describe "check_libyaml_version" do
5
- REAL_YAML_ENGINE = SafeYAML::YAML_ENGINE
6
- REAL_LIBYAML_VERSION = SafeYAML::LibyamlChecker::LIBYAML_VERSION
7
-
8
- let(:libyaml_patched) { false }
9
-
10
- before :each do
11
- allow(SafeYAML::LibyamlChecker).to receive(:libyaml_patched?).and_return(libyaml_patched)
12
- end
13
-
14
- after :each do
15
- silence_warnings do
16
- SafeYAML::YAML_ENGINE = REAL_YAML_ENGINE
17
- SafeYAML::LibyamlChecker::LIBYAML_VERSION = REAL_LIBYAML_VERSION
18
- end
19
- end
20
-
21
- def test_libyaml_version_ok(expected_result, yaml_engine, libyaml_version=nil)
22
- silence_warnings do
23
- SafeYAML.const_set("YAML_ENGINE", yaml_engine)
24
- SafeYAML::LibyamlChecker.const_set("LIBYAML_VERSION", libyaml_version)
25
- expect(SafeYAML::LibyamlChecker.libyaml_version_ok?).to eq(expected_result)
26
- end
27
- end
28
-
29
- unless defined?(JRUBY_VERSION)
30
- it "issues no warnings when 'Syck' is the YAML engine" do
31
- test_libyaml_version_ok(true, "syck")
32
- end
33
-
34
- it "issues a warning if Psych::LIBYAML_VERSION is not defined" do
35
- test_libyaml_version_ok(false, "psych")
36
- end
37
-
38
- it "issues a warning if Psych::LIBYAML_VERSION is < 0.1.6" do
39
- test_libyaml_version_ok(false, "psych", "0.1.5")
40
- end
41
-
42
- it "issues no warning if Psych::LIBYAML_VERSION is == 0.1.6" do
43
- test_libyaml_version_ok(true, "psych", "0.1.6")
44
- end
45
-
46
- it "issues no warning if Psych::LIBYAML_VERSION is > 0.1.6" do
47
- test_libyaml_version_ok(true, "psych", "1.0.0")
48
- end
49
-
50
- it "does a proper version comparison (not just a string comparison)" do
51
- test_libyaml_version_ok(true, "psych", "0.1.10")
52
- end
53
-
54
- context "when the system has a known patched libyaml version" do
55
- let(:libyaml_patched) { true }
56
-
57
- it "issues no warning, even when Psych::LIBYAML_VERSION < 0.1.6" do
58
- test_libyaml_version_ok(true, "psych", "0.1.4")
59
- end
60
- end
61
- end
62
-
63
- if defined?(JRUBY_VERSION)
64
- it "issues no warning, as JRuby doesn't use libyaml" do
65
- test_libyaml_version_ok(true, "psych", "0.1.4")
66
- end
67
- end
68
- end
69
- end
@@ -1,10 +0,0 @@
1
- require "spec_helper"
2
-
3
- if SafeYAML::YAML_ENGINE == "psych"
4
- require "safe_yaml/psych_resolver"
5
-
6
- describe SafeYAML::PsychResolver do
7
- include ResolverSpecs
8
- let(:resolver) { SafeYAML::PsychResolver.new }
9
- end
10
- end
@@ -1,278 +0,0 @@
1
- module ResolverSpecs
2
- def self.included(base)
3
- base.module_eval do
4
- let(:resolver) { nil }
5
- let(:result) { @result }
6
-
7
- before :each do
8
- # See the comment in the first before :each block in safe_yaml_spec.rb.
9
- require "safe_yaml"
10
- end
11
-
12
- def parse(yaml)
13
- tree = YAML.parse(yaml.unindent)
14
- @result = resolver.resolve_node(tree)
15
- end
16
-
17
- # Isn't this how I should've been doing it all along?
18
- def parse_and_test(yaml)
19
- safe_result = parse(yaml)
20
-
21
- exception_thrown = nil
22
-
23
- unsafe_result = begin
24
- YAML.unsafe_load(yaml)
25
- rescue Exception => e
26
- exception_thrown = e
27
- end
28
-
29
- if exception_thrown
30
- # If the underlying YAML parser (e.g. Psych) threw an exception, I'm
31
- # honestly not sure what the right thing to do is. For now I'll just
32
- # print a warning. Should SafeYAML fail when Psych fails?
33
- Kernel.warn "\n"
34
- Kernel.warn "Discrepancy between SafeYAML and #{SafeYAML::YAML_ENGINE} on input:\n"
35
- Kernel.warn "#{yaml.unindent}\n"
36
- Kernel.warn "SafeYAML result:"
37
- Kernel.warn "#{safe_result.inspect}\n"
38
- Kernel.warn "#{SafeYAML::YAML_ENGINE} result:"
39
- Kernel.warn "#{exception_thrown.inspect}\n"
40
-
41
- else
42
- expect(safe_result).to eq(unsafe_result)
43
- end
44
- end
45
-
46
- context "by default" do
47
- it "translates maps to hashes" do
48
- parse <<-YAML
49
- potayto: potahto
50
- tomayto: tomahto
51
- YAML
52
-
53
- expect(result).to eq({
54
- "potayto" => "potahto",
55
- "tomayto" => "tomahto"
56
- })
57
- end
58
-
59
- it "translates sequences to arrays" do
60
- parse <<-YAML
61
- - foo
62
- - bar
63
- - baz
64
- YAML
65
-
66
- expect(result).to eq(["foo", "bar", "baz"])
67
- end
68
-
69
- it "translates most values to strings" do
70
- parse "string: value"
71
- expect(result).to eq({ "string" => "value" })
72
- end
73
-
74
- it "does not deserialize symbols" do
75
- parse ":symbol: value"
76
- expect(result).to eq({ ":symbol" => "value" })
77
- end
78
-
79
- it "translates valid integral numbers to integers" do
80
- parse "integer: 1"
81
- expect(result).to eq({ "integer" => 1 })
82
- end
83
-
84
- it "translates valid decimal numbers to floats" do
85
- parse "float: 3.14"
86
- expect(result).to eq({ "float" => 3.14 })
87
- end
88
-
89
- it "translates valid dates" do
90
- parse "date: 2013-01-24"
91
- expect(result).to eq({ "date" => Date.parse("2013-01-24") })
92
- end
93
-
94
- it "translates valid true/false values to booleans" do
95
- parse <<-YAML
96
- - yes
97
- - true
98
- - no
99
- - false
100
- YAML
101
-
102
- expect(result).to eq([true, true, false, false])
103
- end
104
-
105
- it "translates valid nulls to nil" do
106
- parse <<-YAML
107
- -
108
- - ~
109
- - null
110
- YAML
111
-
112
- expect(result).to eq([nil] * 3)
113
- end
114
-
115
- it "matches the behavior of the underlying YAML engine w/ respect to capitalization of boolean values" do
116
- parse_and_test <<-YAML
117
- - true
118
- - True
119
- - TRUE
120
- - tRue
121
- - TRue
122
- - False
123
- - FALSE
124
- - fAlse
125
- - FALse
126
- YAML
127
-
128
- # using Syck: [true, true, true, "tRue", "TRue", false, false, "fAlse", "FALse"]
129
- # using Psych: all booleans
130
- end
131
-
132
- it "matches the behavior of the underlying YAML engine w/ respect to capitalization of nil values" do
133
- parse_and_test <<-YAML
134
- - Null
135
- - NULL
136
- - nUll
137
- - NUll
138
- YAML
139
-
140
- # using Syck: [nil, nil, "nUll", "NUll"]
141
- # using Psych: all nils
142
- end
143
-
144
- it "translates quoted empty strings to strings (not nil)" do
145
- parse "foo: ''"
146
- expect(result).to eq({ "foo" => "" })
147
- end
148
-
149
- it "correctly reverse-translates strings encoded via #to_yaml" do
150
- parse "5.10".to_yaml
151
- expect(result).to eq("5.10")
152
- end
153
-
154
- it "does not specially parse any double-quoted strings" do
155
- parse <<-YAML
156
- - "1"
157
- - "3.14"
158
- - "true"
159
- - "false"
160
- - "2013-02-03"
161
- - "2013-02-03 16:27:00 -0600"
162
- YAML
163
-
164
- expect(result).to eq(["1", "3.14", "true", "false", "2013-02-03", "2013-02-03 16:27:00 -0600"])
165
- end
166
-
167
- it "does not specially parse any single-quoted strings" do
168
- parse <<-YAML
169
- - '1'
170
- - '3.14'
171
- - 'true'
172
- - 'false'
173
- - '2013-02-03'
174
- - '2013-02-03 16:27:00 -0600'
175
- YAML
176
-
177
- expect(result).to eq(["1", "3.14", "true", "false", "2013-02-03", "2013-02-03 16:27:00 -0600"])
178
- end
179
-
180
- it "deals just fine with nested maps" do
181
- parse <<-YAML
182
- foo:
183
- bar:
184
- marco: polo
185
- YAML
186
-
187
- expect(result).to eq({ "foo" => { "bar" => { "marco" => "polo" } } })
188
- end
189
-
190
- it "deals just fine with nested sequences" do
191
- parse <<-YAML
192
- - foo
193
- -
194
- - bar1
195
- - bar2
196
- -
197
- - baz1
198
- - baz2
199
- YAML
200
-
201
- expect(result).to eq(["foo", ["bar1", "bar2", ["baz1", "baz2"]]])
202
- end
203
-
204
- it "applies the same transformations to keys as to values" do
205
- parse <<-YAML
206
- foo: string
207
- :bar: symbol
208
- 1: integer
209
- 3.14: float
210
- 2013-01-24: date
211
- YAML
212
-
213
- expect(result).to eq({
214
- "foo" => "string",
215
- ":bar" => "symbol",
216
- 1 => "integer",
217
- 3.14 => "float",
218
- Date.parse("2013-01-24") => "date",
219
- })
220
- end
221
-
222
- it "applies the same transformations to elements in sequences as to all values" do
223
- parse <<-YAML
224
- - foo
225
- - :bar
226
- - 1
227
- - 3.14
228
- - 2013-01-24
229
- YAML
230
-
231
- expect(result).to eq(["foo", ":bar", 1, 3.14, Date.parse("2013-01-24")])
232
- end
233
- end
234
-
235
- context "for Ruby version #{RUBY_VERSION}" do
236
- it "translates valid time values" do
237
- parse "time: 2013-01-29 05:58:00 -0800"
238
- expect(result).to eq({ "time" => Time.utc(2013, 1, 29, 13, 58, 0) })
239
- end
240
-
241
- it "applies the same transformation to elements in sequences" do
242
- parse "- 2013-01-29 05:58:00 -0800"
243
- expect(result).to eq([Time.utc(2013, 1, 29, 13, 58, 0)])
244
- end
245
-
246
- it "applies the same transformation to keys" do
247
- parse "2013-01-29 05:58:00 -0800: time"
248
- expect(result).to eq({ Time.utc(2013, 1, 29, 13, 58, 0) => "time" })
249
- end
250
- end
251
-
252
- context "with symbol deserialization enabled" do
253
- before :each do
254
- SafeYAML::OPTIONS[:deserialize_symbols] = true
255
- end
256
-
257
- after :each do
258
- SafeYAML.restore_defaults!
259
- end
260
-
261
- it "translates values starting with ':' to symbols" do
262
- parse "symbol: :value"
263
- expect(result).to eq({ "symbol" => :value })
264
- end
265
-
266
- it "applies the same transformation to keys" do
267
- parse ":bar: symbol"
268
- expect(result).to eq({ :bar => "symbol" })
269
- end
270
-
271
- it "applies the same transformation to elements in sequences" do
272
- parse "- :bar"
273
- expect(result).to eq([:bar])
274
- end
275
- end
276
- end
277
- end
278
- end