mcollective-client 2.10.3 → 2.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/mcollective.rb CHANGED
@@ -59,7 +59,7 @@ module MCollective
59
59
 
60
60
  MCollective::Vendor.load_vendored
61
61
 
62
- VERSION="2.10.3"
62
+ VERSION="2.10.4"
63
63
 
64
64
  def self.version
65
65
  VERSION
@@ -225,7 +225,11 @@ module MCollective
225
225
 
226
226
  case serializer
227
227
  when "yaml"
228
- return YAML.load(msg)
228
+ if YAML.respond_to? :safe_load
229
+ return YAML.safe_load(msg, [Symbol])
230
+ else
231
+ raise "YAML.safe_load not supported by Ruby #{RUBY_VERSION}. Please update to Ruby 2.1+."
232
+ end
229
233
  else
230
234
  return Marshal.load(msg)
231
235
  end
@@ -223,7 +223,11 @@ module MCollective
223
223
 
224
224
  case serializer
225
225
  when "yaml"
226
- return YAML.load(msg)
226
+ if YAML.respond_to? :safe_load
227
+ return YAML.safe_load(msg, [Symbol])
228
+ else
229
+ raise "YAML.safe_load not supported by Ruby #{RUBY_VERSION}. Please update to Ruby 2.1+."
230
+ end
227
231
  else
228
232
  return Marshal.load(msg)
229
233
  end
@@ -38,6 +38,52 @@ module MCollective
38
38
  MCollective::Log.stubs(:warn)
39
39
  end
40
40
 
41
+ describe "#deserialize" do
42
+ let(:safe_payload) {
43
+ {:payload => "words", :ttl => 15}
44
+ }
45
+
46
+ class Sock
47
+ attr_reader :size
48
+ def initialize size
49
+ @size = size
50
+ end
51
+
52
+ def ==(another_sock)
53
+ self.size == another_sock.size
54
+ end
55
+ end
56
+
57
+ let(:unsafe_payload) {
58
+ {:payload => Sock.new(10)}
59
+ }
60
+
61
+ it "should accept marshal by default" do
62
+ expect(plugin.deserialize(Marshal.dump(unsafe_payload))).to eq(unsafe_payload)
63
+ expect(plugin.deserialize(Marshal.dump(safe_payload))).to eq(safe_payload)
64
+ end
65
+
66
+ context "yaml" do
67
+ before do
68
+ pluginconf['aes.serializer'] = 'yaml'
69
+ end
70
+
71
+ if YAML.respond_to? :safe_load
72
+ it "should round-trip yaml with symbols" do
73
+ expect(plugin.deserialize(YAML.dump(safe_payload))).to eq(safe_payload)
74
+ end
75
+
76
+ it "should reject yaml with other objects" do
77
+ expect{ plugin.deserialize(YAML.dump(unsafe_payload)) }.to raise_error(Psych::DisallowedClass)
78
+ end
79
+ else
80
+ it "should raise on older Ruby" do
81
+ expect{ plugin.deserialize(YAML.dump(safe_payload)) }.to raise_error("YAML.safe_load not supported by Ruby #{RUBY_VERSION}. Please update to Ruby 2.1+.")
82
+ end
83
+ end
84
+ end
85
+ end
86
+
41
87
  describe "#decodemsg" do
42
88
  let(:body) do
43
89
  {:sslpubkey => "ssl_public_key",
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env rspec
2
+
3
+ require 'spec_helper'
4
+ require 'mcollective/security/ssl'
5
+
6
+ module MCollective
7
+ module Security
8
+ # Clear the PluginManager so that security plugin tests do not conflict
9
+ PluginManager.clear
10
+ describe Ssl do
11
+ let(:pluginconf) do
12
+ {"ssl_server_public" => "server-public.pem",
13
+ "ssl_client_private" => "client-private.pem",
14
+ "ssl_client_public" => "client_public.pem"}
15
+ end
16
+
17
+ let(:config) do
18
+ conf = mock
19
+ conf.stubs(:identity).returns("test")
20
+ conf.stubs(:configured).returns(true)
21
+ conf.stubs(:pluginconf).returns(pluginconf)
22
+ conf
23
+ end
24
+
25
+ let(:plugin) do
26
+ Ssl.new
27
+ end
28
+
29
+ let(:msg) do
30
+ m = mock
31
+ m.stubs(:payload)
32
+ m
33
+ end
34
+
35
+ before :each do
36
+ stats = mock("stats")
37
+ MCollective::PluginManager << {:type => "global_stats", :class => stats}
38
+ MCollective::Config.stubs("instance").returns(config)
39
+ MCollective::Log.stubs(:debug)
40
+ MCollective::Log.stubs(:warn)
41
+ end
42
+
43
+ describe "#deserialize" do
44
+ let(:safe_payload) {
45
+ {:payload => "words", :ttl => 15}
46
+ }
47
+
48
+ class Sock
49
+ attr_reader :size
50
+ def initialize size
51
+ @size = size
52
+ end
53
+
54
+ def ==(another_sock)
55
+ self.size == another_sock.size
56
+ end
57
+ end
58
+
59
+ let(:unsafe_payload) {
60
+ {:payload => Sock.new(10)}
61
+ }
62
+
63
+ it "should accept marshal by default" do
64
+ expect(plugin.send(:deserialize, Marshal.dump(unsafe_payload))).to eq(unsafe_payload)
65
+ expect(plugin.send(:deserialize, Marshal.dump(safe_payload))).to eq(safe_payload)
66
+ end
67
+
68
+ context "yaml" do
69
+ before do
70
+ pluginconf['ssl_serializer'] = 'yaml'
71
+ end
72
+
73
+ if YAML.respond_to? :safe_load
74
+ it "should round-trip yaml with symbols" do
75
+ expect(plugin.send(:deserialize, YAML.dump(safe_payload))).to eq(safe_payload)
76
+ end
77
+
78
+ it "should reject yaml with other objects" do
79
+ expect{ plugin.send(:deserialize, YAML.dump(unsafe_payload)) }.to raise_error(Psych::DisallowedClass)
80
+ end
81
+ else
82
+ it "should raise on older Ruby" do
83
+ expect{ plugin.send(:deserialize, YAML.dump(safe_payload)) }.to raise_error("YAML.safe_load not supported by Ruby #{RUBY_VERSION}. Please update to Ruby 2.1+.")
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcollective-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.3
4
+ version: 2.10.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-05 00:00:00.000000000 Z
12
+ date: 2017-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: systemu
@@ -309,6 +309,7 @@ files:
309
309
  - spec/unit/mcollective/security/aes_security_spec.rb
310
310
  - spec/unit/mcollective/security/base_spec.rb
311
311
  - spec/unit/mcollective/security/psk_spec.rb
312
+ - spec/unit/mcollective/security/ssl_spec.rb
312
313
  - spec/unit/mcollective/shell_spec.rb
313
314
  - spec/unit/mcollective/ssl_spec.rb
314
315
  - spec/unit/mcollective/string_spec.rb
@@ -459,6 +460,7 @@ test_files:
459
460
  - spec/unit/mcollective/security/aes_security_spec.rb
460
461
  - spec/unit/mcollective/security/base_spec.rb
461
462
  - spec/unit/mcollective/security/psk_spec.rb
463
+ - spec/unit/mcollective/security/ssl_spec.rb
462
464
  - spec/unit/mcollective/shell_spec.rb
463
465
  - spec/unit/mcollective/ssl_spec.rb
464
466
  - spec/unit/mcollective/string_spec.rb