cloudsmith-api 0.53.3 → 0.53.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -4
- data/README.md +4 -4
- data/build.json +1 -1
- data/docs/EntitlementsCreate.md +3 -0
- data/docs/EntitlementsPartialUpdate.md +3 -0
- data/docs/EntitlementsRefresh.md +3 -0
- data/docs/RepositoryToken.md +4 -0
- data/docs/RepositoryTokenRefresh.md +4 -0
- data/docs/RepositoryTokenSyncTokens.md +4 -0
- data/lib/cloudsmith-api/models/entitlements_create.rb +31 -1
- data/lib/cloudsmith-api/models/entitlements_partial_update.rb +31 -1
- data/lib/cloudsmith-api/models/entitlements_refresh.rb +31 -1
- data/lib/cloudsmith-api/models/repository_token.rb +41 -1
- data/lib/cloudsmith-api/models/repository_token_refresh.rb +41 -1
- data/lib/cloudsmith-api/models/repository_token_sync_tokens.rb +41 -1
- data/lib/cloudsmith-api/version.rb +1 -1
- data/spec/models/entitlements_create_spec.rb +18 -0
- data/spec/models/entitlements_partial_update_spec.rb +18 -0
- data/spec/models/entitlements_refresh_spec.rb +18 -0
- data/spec/models/repository_token_refresh_spec.rb +24 -0
- data/spec/models/repository_token_spec.rb +24 -0
- data/spec/models/repository_token_sync_tokens_spec.rb +24 -0
- data/vendor/bundle/ruby/2.6.0/cache/crack-0.4.4.gem +0 -0
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/autotest-fsevent-0.2.17/gem_make.out +1 -1
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/ffi-1.13.1/gem_make.out +2 -2
- data/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-2.3.1/gem_make.out +1 -1
- data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack.rb +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/json.rb +5 -18
- data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/util.rb +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.4/lib/crack/version.rb +3 -0
- data/vendor/bundle/ruby/2.6.0/gems/{crack-0.4.3 → crack-0.4.4}/lib/crack/xml.rb +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/ffi-1.13.1/ext/ffi_c/Makefile +3 -3
- data/vendor/bundle/ruby/2.6.0/specifications/{crack-0.4.3.gemspec → crack-0.4.4.gemspec} +3 -15
- data/vendor/bundle/ruby/2.6.0/specifications/sys-uname-1.2.1.gemspec +1 -1
- metadata +102 -177
- data/vendor/bundle/ruby/2.6.0/bin/safe_yaml +0 -27
- data/vendor/bundle/ruby/2.6.0/cache/crack-0.4.3.gem +0 -0
- data/vendor/bundle/ruby/2.6.0/cache/safe_yaml-1.0.5.gem +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/.gitignore +0 -8
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/.travis.yml +0 -14
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/Gemfile +0 -5
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/History +0 -25
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/LICENSE +0 -20
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/README.md +0 -46
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/crack.gemspec +0 -20
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/lib/crack/version.rb +0 -3
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/bootstrap +0 -21
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/release +0 -42
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/script/test +0 -25
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/large_dataset.json +0 -139988
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/twittersearch-firefox.json +0 -1
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/data/twittersearch-ie.json +0 -1
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/hash_test.rb +0 -26
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/json_test.rb +0 -91
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/parser_test.rb +0 -27
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/string_test.rb +0 -31
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/test_helper.rb +0 -3
- data/vendor/bundle/ruby/2.6.0/gems/crack-0.4.3/test/xml_test.rb +0 -514
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/.gitignore +0 -3
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/.travis.yml +0 -48
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/CHANGES.md +0 -154
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/Gemfile +0 -11
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/LICENSE.txt +0 -22
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/README.md +0 -191
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/Rakefile +0 -26
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/bin/safe_yaml +0 -75
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/bundle_install_all_ruby_versions.sh +0 -11
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml.rb +0 -94
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/deep.rb +0 -34
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/libyaml_checker.rb +0 -36
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb +0 -181
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/date.rb +0 -37
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/hexadecimal.rb +0 -12
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/parse/sexagesimal.rb +0 -26
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_handler.rb +0 -99
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/psych_resolver.rb +0 -52
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/resolver.rb +0 -94
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/safe_to_ruby_visitor.rb +0 -29
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb +0 -39
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_hack.rb +0 -36
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_node_monkeypatch.rb +0 -43
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/syck_resolver.rb +0 -38
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform.rb +0 -41
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_boolean.rb +0 -21
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_date.rb +0 -13
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_float.rb +0 -33
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_integer.rb +0 -26
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_nil.rb +0 -18
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/to_symbol.rb +0 -17
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/transform/transformation_map.rb +0 -47
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/version.rb +0 -3
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/run_specs_all_ruby_versions.sh +0 -38
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/safe_yaml.gemspec +0 -19
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.2.yaml +0 -2
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/exploit.1.9.3.yaml +0 -2
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/issue48.txt +0 -20
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/issue49.yml +0 -0
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/libyaml_checker_spec.rb +0 -69
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/psych_resolver_spec.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb +0 -278
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/safe_yaml_spec.rb +0 -731
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb +0 -42
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/store_spec.rb +0 -57
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/support/exploitable_back_door.rb +0 -29
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/syck_resolver_spec.rb +0 -10
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/base64_spec.rb +0 -11
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_date_spec.rb +0 -60
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_float_spec.rb +0 -42
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_integer_spec.rb +0 -64
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/transform/to_symbol_spec.rb +0 -51
- data/vendor/bundle/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/yaml_spec.rb +0 -15
- data/vendor/bundle/ruby/2.6.0/specifications/safe_yaml-1.0.5.gemspec +0 -23
@@ -1,42 +0,0 @@
|
|
1
|
-
HERE = File.dirname(__FILE__) unless defined?(HERE)
|
2
|
-
ROOT = File.join(HERE, "..") unless defined?(ROOT)
|
3
|
-
|
4
|
-
$LOAD_PATH << File.join(ROOT, "lib")
|
5
|
-
$LOAD_PATH << File.join(HERE, "support")
|
6
|
-
|
7
|
-
require "yaml"
|
8
|
-
if ENV["YAMLER"] && defined?(YAML::ENGINE)
|
9
|
-
YAML::ENGINE.yamler = ENV["YAMLER"]
|
10
|
-
end
|
11
|
-
|
12
|
-
ruby_version = defined?(JRUBY_VERSION) ? "JRuby #{JRUBY_VERSION} in #{RUBY_VERSION} mode" : "Ruby #{RUBY_VERSION}"
|
13
|
-
yaml_engine = defined?(YAML::ENGINE) ? YAML::ENGINE.yamler : "syck"
|
14
|
-
libyaml_version = yaml_engine == "psych" && Psych.const_defined?("LIBYAML_VERSION", false) ? Psych::LIBYAML_VERSION : "N/A"
|
15
|
-
|
16
|
-
env_info = [
|
17
|
-
ruby_version,
|
18
|
-
"YAML: #{yaml_engine} (#{YAML::VERSION}) (libyaml: #{libyaml_version})",
|
19
|
-
"Monkeypatch: #{ENV['MONKEYPATCH_YAML']}"
|
20
|
-
]
|
21
|
-
|
22
|
-
puts env_info.join(", ")
|
23
|
-
|
24
|
-
# Caching references to these methods before loading safe_yaml in order to test
|
25
|
-
# that they aren't touched unless you actually require safe_yaml (see yaml_spec.rb).
|
26
|
-
ORIGINAL_YAML_LOAD = YAML.method(:load)
|
27
|
-
ORIGINAL_YAML_LOAD_FILE = YAML.method(:load_file)
|
28
|
-
|
29
|
-
require "safe_yaml/load"
|
30
|
-
require "ostruct"
|
31
|
-
require "hashie"
|
32
|
-
require "heredoc_unindent"
|
33
|
-
|
34
|
-
# Stolen from Rails:
|
35
|
-
# https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L10-25
|
36
|
-
def silence_warnings
|
37
|
-
$VERBOSE = nil; yield
|
38
|
-
ensure
|
39
|
-
$VERBOSE = true
|
40
|
-
end
|
41
|
-
|
42
|
-
require File.join(HERE, "resolver_specs")
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'safe_yaml/store'
|
4
|
-
|
5
|
-
describe SafeYAML::Store do
|
6
|
-
|
7
|
-
let(:file) { 'spec/store.yaml' }
|
8
|
-
let(:content) { "--- \nfoo: 42\n:bar: \"party\"\n" }
|
9
|
-
|
10
|
-
before do
|
11
|
-
# Rewrite file on every test, as its contents are potentially modified by
|
12
|
-
# SafeYAML::Store#transaction
|
13
|
-
File.open(file, 'w') { |f| f.write(content) }
|
14
|
-
end
|
15
|
-
|
16
|
-
def expect_safe_load(options = {})
|
17
|
-
load_args = [content, options]
|
18
|
-
load_args.insert(1, nil) if SafeYAML::YAML_ENGINE == 'psych'
|
19
|
-
|
20
|
-
expect(SafeYAML).to receive(:load).with(*load_args).and_call_original
|
21
|
-
expect(YAML).not_to receive(:load)
|
22
|
-
end
|
23
|
-
|
24
|
-
let(:init_args) { [file] }
|
25
|
-
subject { described_class.new(*init_args) }
|
26
|
-
|
27
|
-
it 'should be a YAML::Store' do
|
28
|
-
expect(subject).to be_a(YAML::Store)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'should be a SafeYAML::Store' do
|
32
|
-
expect(subject).to be_a(SafeYAML::Store)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should use SafeYAML.load instead of YAML.load' do
|
36
|
-
expect_safe_load
|
37
|
-
expect(subject.transaction { subject['foo'] }).to eq(42)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'preserves default SafeYAML behavior' do
|
41
|
-
expect(subject.transaction { subject[:bar] }).to eq(nil)
|
42
|
-
expect(subject.transaction { subject[':bar'] }).to eq('party')
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
describe 'with options' do
|
47
|
-
|
48
|
-
let(:init_args) { super().insert(2, :deserialize_symbols => true) }
|
49
|
-
|
50
|
-
it 'should accept options for SafeYAML.load' do
|
51
|
-
expect_safe_load(:deserialize_symbols => true)
|
52
|
-
expect(subject.transaction { subject[:bar] }).to eq('party')
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class ExploitableBackDoor
|
2
|
-
def exploited?
|
3
|
-
@exploited_through_setter || @exploited_through_init_with || @exploited_through_ivars
|
4
|
-
end
|
5
|
-
|
6
|
-
def exploited_through_setter?
|
7
|
-
@exploited_through_setter
|
8
|
-
end
|
9
|
-
|
10
|
-
def exploited_through_init_with?
|
11
|
-
@exploited_through_init_with
|
12
|
-
end
|
13
|
-
|
14
|
-
def exploited_through_ivars?
|
15
|
-
self.instance_variables.any?
|
16
|
-
end
|
17
|
-
|
18
|
-
def init_with(command)
|
19
|
-
# Note: this is how bad this COULD be.
|
20
|
-
# system("#{command}")
|
21
|
-
@exploited_through_init_with = true
|
22
|
-
end
|
23
|
-
|
24
|
-
def []=(command, arguments)
|
25
|
-
# Note: this is how bad this COULD be.
|
26
|
-
# system("#{command} #{arguments}")
|
27
|
-
@exploited_through_setter = true
|
28
|
-
end
|
29
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SafeYAML::Transform do
|
4
|
-
it "should return the same encoding when decoding Base64" do
|
5
|
-
value = "c3VyZS4="
|
6
|
-
decoded = SafeYAML::Transform.to_proper_type(value, false, "!binary")
|
7
|
-
|
8
|
-
expect(decoded).to eq("sure.")
|
9
|
-
expect(decoded.encoding).to eq(value.encoding) if decoded.respond_to?(:encoding)
|
10
|
-
end
|
11
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SafeYAML::Transform::ToDate do
|
4
|
-
it "returns true when the value matches a valid Date" do
|
5
|
-
expect(subject.transform?("2013-01-01")).to eq([true, Date.parse("2013-01-01")])
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns false when the value does not match a valid Date" do
|
9
|
-
expect(subject.transform?("foobar")).to be_falsey
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns false when the value does not end with a Date" do
|
13
|
-
expect(subject.transform?("2013-01-01\nNOT A DATE")).to be_falsey
|
14
|
-
end
|
15
|
-
|
16
|
-
it "returns false when the value does not begin with a Date" do
|
17
|
-
expect(subject.transform?("NOT A DATE\n2013-01-01")).to be_falsey
|
18
|
-
end
|
19
|
-
|
20
|
-
it "correctly parses the remaining formats of the YAML spec" do
|
21
|
-
equivalent_values = [
|
22
|
-
"2001-12-15T02:59:43.1Z", # canonical
|
23
|
-
"2001-12-14t21:59:43.10-05:00", # iso8601
|
24
|
-
"2001-12-14 21:59:43.10 -5", # space separated
|
25
|
-
"2001-12-15 2:59:43.10" # no time zone (Z)
|
26
|
-
]
|
27
|
-
|
28
|
-
equivalent_values.each do |value|
|
29
|
-
success, result = subject.transform?(value)
|
30
|
-
expect(success).to be_truthy
|
31
|
-
expect(result).to eq(Time.utc(2001, 12, 15, 2, 59, 43, 100000))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
it "converts times to the local timezone" do
|
36
|
-
success, result = subject.transform?("2012-12-01 10:33:45 +11:00")
|
37
|
-
expect(success).to be_truthy
|
38
|
-
expect(result).to eq(Time.utc(2012, 11, 30, 23, 33, 45))
|
39
|
-
expect(result.gmt_offset).to eq(Time.local(2012, 11, 30).gmt_offset)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns strings for invalid dates" do
|
43
|
-
expect(subject.transform?("0000-00-00")).to eq([true, "0000-00-00"])
|
44
|
-
expect(subject.transform?("2013-13-01")).to eq([true, "2013-13-01"])
|
45
|
-
expect(subject.transform?("2014-01-32")).to eq([true, "2014-01-32"])
|
46
|
-
end
|
47
|
-
|
48
|
-
it "returns strings for invalid date/times" do
|
49
|
-
expect(subject.transform?("0000-00-00 00:00:00 -0000")).to eq([true, "0000-00-00 00:00:00 -0000"])
|
50
|
-
expect(subject.transform?("2013-13-01 21:59:43 -05:00")).to eq([true, "2013-13-01 21:59:43 -05:00"])
|
51
|
-
expect(subject.transform?("2013-01-32 21:59:43 -05:00")).to eq([true, "2013-01-32 21:59:43 -05:00"])
|
52
|
-
expect(subject.transform?("2013-01-30 25:59:43 -05:00")).to eq([true, "2013-01-30 25:59:43 -05:00"])
|
53
|
-
expect(subject.transform?("2013-01-30 21:69:43 -05:00")).to eq([true, "2013-01-30 21:69:43 -05:00"])
|
54
|
-
|
55
|
-
# Interesting. It seems that in some older Ruby versions, the below actually parses successfully
|
56
|
-
# w/ DateTime.parse; but it fails w/ YAML.load. Whom to follow???
|
57
|
-
|
58
|
-
# subject.transform?("2013-01-30 21:59:63 -05:00").should == [true, "2013-01-30 21:59:63 -05:00"]
|
59
|
-
end
|
60
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SafeYAML::Transform::ToFloat do
|
4
|
-
it "returns true when the value matches a valid Float" do
|
5
|
-
expect(subject.transform?("20.00")).to eq([true, 20.0])
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns false when the value does not match a valid Float" do
|
9
|
-
expect(subject.transform?("foobar")).to be_falsey
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns false when the value spans multiple lines" do
|
13
|
-
expect(subject.transform?("20.00\nNOT A FLOAT")).to be_falsey
|
14
|
-
end
|
15
|
-
|
16
|
-
it "correctly parses all formats in the YAML spec" do
|
17
|
-
# canonical
|
18
|
-
expect(subject.transform?("6.8523015e+5")).to eq([true, 685230.15])
|
19
|
-
|
20
|
-
# exponentioal
|
21
|
-
expect(subject.transform?("685.230_15e+03")).to eq([true, 685230.15])
|
22
|
-
|
23
|
-
# fixed
|
24
|
-
expect(subject.transform?("685_230.15")).to eq([true, 685230.15])
|
25
|
-
|
26
|
-
# sexagesimal
|
27
|
-
expect(subject.transform?("190:20:30.15")).to eq([true, 685230.15])
|
28
|
-
|
29
|
-
# infinity
|
30
|
-
expect(subject.transform?("-.inf")).to eq([true, (-1.0 / 0.0)])
|
31
|
-
|
32
|
-
# not a number
|
33
|
-
# NOTE: can't use == here since NaN != NaN
|
34
|
-
success, result = subject.transform?(".NaN")
|
35
|
-
expect(success).to be_truthy; expect(result).to be_nan
|
36
|
-
end
|
37
|
-
|
38
|
-
# issue 29
|
39
|
-
it "returns false for the string '.'" do
|
40
|
-
expect(subject.transform?(".")).to be_falsey
|
41
|
-
end
|
42
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SafeYAML::Transform::ToInteger do
|
4
|
-
it "returns true when the value matches a valid Integer" do
|
5
|
-
expect(subject.transform?("10")).to eq([true, 10])
|
6
|
-
end
|
7
|
-
|
8
|
-
it "returns false when the value does not match a valid Integer" do
|
9
|
-
expect(subject.transform?("foobar")).to be_falsey
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns false when the value spans multiple lines" do
|
13
|
-
expect(subject.transform?("10\nNOT AN INTEGER")).to be_falsey
|
14
|
-
end
|
15
|
-
|
16
|
-
it "allows commas in the number" do
|
17
|
-
expect(subject.transform?("1,000")).to eq([true, 1000])
|
18
|
-
end
|
19
|
-
|
20
|
-
it "correctly parses numbers in octal format" do
|
21
|
-
expect(subject.transform?("010")).to eq([true, 8])
|
22
|
-
end
|
23
|
-
|
24
|
-
it "correctly parses numbers in hexadecimal format" do
|
25
|
-
expect(subject.transform?("0x1FF")).to eq([true, 511])
|
26
|
-
end
|
27
|
-
|
28
|
-
it "defaults to a string for a number that resembles octal format but is not" do
|
29
|
-
expect(subject.transform?("09")).to be_falsey
|
30
|
-
end
|
31
|
-
|
32
|
-
it "correctly parses 0 in decimal" do
|
33
|
-
expect(subject.transform?("0")).to eq([true, 0])
|
34
|
-
end
|
35
|
-
|
36
|
-
it "defaults to a string for a number that resembles hexadecimal format but is not" do
|
37
|
-
expect(subject.transform?("0x1G")).to be_falsey
|
38
|
-
end
|
39
|
-
|
40
|
-
it "correctly parses all formats in the YAML spec" do
|
41
|
-
# canonical
|
42
|
-
expect(subject.transform?("685230")).to eq([true, 685230])
|
43
|
-
|
44
|
-
# decimal
|
45
|
-
expect(subject.transform?("+685_230")).to eq([true, 685230])
|
46
|
-
|
47
|
-
# octal
|
48
|
-
expect(subject.transform?("02472256")).to eq([true, 685230])
|
49
|
-
|
50
|
-
# hexadecimal:
|
51
|
-
expect(subject.transform?("0x_0A_74_AE")).to eq([true, 685230])
|
52
|
-
|
53
|
-
# binary
|
54
|
-
expect(subject.transform?("0b1010_0111_0100_1010_1110")).to eq([true, 685230])
|
55
|
-
|
56
|
-
# sexagesimal
|
57
|
-
expect(subject.transform?("190:20:30")).to eq([true, 685230])
|
58
|
-
end
|
59
|
-
|
60
|
-
# see https://github.com/dtao/safe_yaml/pull/51
|
61
|
-
it "strips out underscores before parsing decimal values" do
|
62
|
-
expect(subject.transform?("_850_")).to eq([true, 850])
|
63
|
-
end
|
64
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe SafeYAML::Transform::ToSymbol do
|
4
|
-
def with_symbol_deserialization_value(value)
|
5
|
-
symbol_deserialization_flag = SafeYAML::OPTIONS[:deserialize_symbols]
|
6
|
-
SafeYAML::OPTIONS[:deserialize_symbols] = value
|
7
|
-
|
8
|
-
yield
|
9
|
-
|
10
|
-
ensure
|
11
|
-
SafeYAML::OPTIONS[:deserialize_symbols] = symbol_deserialization_flag
|
12
|
-
end
|
13
|
-
|
14
|
-
def with_symbol_deserialization(&block)
|
15
|
-
with_symbol_deserialization_value(true, &block)
|
16
|
-
end
|
17
|
-
|
18
|
-
def without_symbol_deserialization(&block)
|
19
|
-
with_symbol_deserialization_value(false, &block)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "returns true when the value matches a valid Symbol" do
|
23
|
-
with_symbol_deserialization { expect(subject.transform?(":foo")[0]).to be_truthy }
|
24
|
-
end
|
25
|
-
|
26
|
-
it "returns true when the value matches a valid String+Symbol" do
|
27
|
-
with_symbol_deserialization { expect(subject.transform?(':"foo"')[0]).to be_truthy }
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns true when the value matches a valid String+Symbol with 's" do
|
31
|
-
with_symbol_deserialization { expect(subject.transform?(":'foo'")[0]).to be_truthy }
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns true when the value has special characters and is wrapped in a String" do
|
35
|
-
with_symbol_deserialization { expect(subject.transform?(':"foo.bar"')[0]).to be_truthy }
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns false when symbol deserialization is disabled" do
|
39
|
-
without_symbol_deserialization { expect(subject.transform?(":foo")).to be_falsey }
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns false when the value does not match a valid Symbol" do
|
43
|
-
with_symbol_deserialization { expect(subject.transform?("foo")).to be_falsey }
|
44
|
-
end
|
45
|
-
|
46
|
-
it "returns false when the symbol does not begin the line" do
|
47
|
-
with_symbol_deserialization do
|
48
|
-
expect(subject.transform?("NOT A SYMBOL\n:foo")).to be_falsey
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# See https://github.com/dtao/safe_yaml/issues/47
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe YAML do
|
6
|
-
context "when you've only required safe_yaml/load", :libraries => true do
|
7
|
-
it "YAML.load doesn't get monkey patched" do
|
8
|
-
expect(YAML.method(:load)).to eq(ORIGINAL_YAML_LOAD)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "YAML.load_file doesn't get monkey patched" do
|
12
|
-
expect(YAML.method(:load_file)).to eq(ORIGINAL_YAML_LOAD_FILE)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: safe_yaml 1.0.5 ruby lib
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.name = "safe_yaml".freeze
|
6
|
-
s.version = "1.0.5"
|
7
|
-
|
8
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
-
s.require_paths = ["lib".freeze]
|
10
|
-
s.authors = ["Dan Tao".freeze]
|
11
|
-
s.date = "2019-02-22"
|
12
|
-
s.description = "Parse YAML safely".freeze
|
13
|
-
s.email = "daniel.tao@gmail.com".freeze
|
14
|
-
s.executables = ["safe_yaml".freeze]
|
15
|
-
s.files = ["bin/safe_yaml".freeze]
|
16
|
-
s.homepage = "https://github.com/dtao/safe_yaml".freeze
|
17
|
-
s.licenses = ["MIT".freeze]
|
18
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7".freeze)
|
19
|
-
s.rubygems_version = "3.0.3".freeze
|
20
|
-
s.summary = "SameYAML provides an alternative implementation of YAML.load suitable for accepting user input in Ruby applications.".freeze
|
21
|
-
|
22
|
-
s.installed_by_version = "3.0.3" if s.respond_to? :installed_by_version
|
23
|
-
end
|