puppet 2.7.12 → 2.7.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ 2.7.13
2
+ ===
3
+ 1f58ea6 Stub mktmpdir and remove_entry_secure in os x package providers
4
+ b7553a5 (#13260) Spec test to verify that mktmpdir is used
5
+ 46e8dc0 (#13260) Use mktmpdir when downloading packages
6
+ b36bda9 Refactor pkgdmg specs
7
+ 91e7ce4 Remove telnet Output_log parameter
8
+ 0d6d299 Fix for bucket_path security vulnerability
9
+ 19bd30a Removed text/marshal support
10
+
1
11
  2.7.12
2
12
  ===
3
13
  36ca299 Update packaging spec files for 2.7.12
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
24
24
  # it's also a place to find top-level commands like 'debug'
25
25
 
26
26
  module Puppet
27
- PUPPETVERSION = '2.7.12'
27
+ PUPPETVERSION = '2.7.13'
28
28
 
29
29
  def Puppet.version
30
30
  PUPPETVERSION
@@ -77,33 +77,6 @@ Puppet::Network::FormatHandler.create_serialized_formats(:b64_zlib_yaml) do
77
77
  end
78
78
  end
79
79
 
80
-
81
- Puppet::Network::FormatHandler.create(:marshal, :mime => "text/marshal") do
82
- # Marshal doesn't need the class name; it's serialized.
83
- def intern(klass, text)
84
- Marshal.load(text)
85
- end
86
-
87
- # Marshal doesn't need the class name; it's serialized.
88
- def intern_multiple(klass, text)
89
- Marshal.load(text)
90
- end
91
-
92
- def render(instance)
93
- Marshal.dump(instance)
94
- end
95
-
96
- # Marshal monkey-patches Array, so this works.
97
- def render_multiple(instances)
98
- Marshal.dump(instances)
99
- end
100
-
101
- # Everything's supported
102
- def supported?(klass)
103
- true
104
- end
105
- end
106
-
107
80
  Puppet::Network::FormatHandler.create(:s, :mime => "text/plain", :extension => "txt")
108
81
 
109
82
  # A very low-weight format so it'll never get chosen automatically.
@@ -31,6 +31,7 @@ module Puppet::Network::HTTP::API::V1
31
31
  method = indirection_method(http_method, indirection)
32
32
 
33
33
  params[:environment] = Puppet::Node::Environment.new(environment)
34
+ params.delete(:bucket_path)
34
35
 
35
36
  raise ArgumentError, "No request key specified in #{uri}" if key == "" or key.nil?
36
37
 
@@ -50,23 +50,24 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
50
50
 
51
51
  def self.installpkgdmg(source, name)
52
52
  unless source =~ /\.dmg$/i
53
- self.fail "Mac OS X PKG DMG's must specificy a source string ending in .dmg"
53
+ self.fail "Mac OS X PKG DMG's must specify a source string ending in .dmg"
54
54
  end
55
55
  require 'open-uri'
56
56
  require 'facter/util/plist'
57
57
  cached_source = source
58
- if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
59
- cached_source = "/tmp/#{name}"
60
- begin
61
- curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
62
- Puppet.debug "Success: curl transfered [#{name}]"
63
- rescue Puppet::ExecutionFailure
64
- Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
65
- cached_source = source
58
+ tmpdir = Dir.mktmpdir
59
+ begin
60
+ if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
61
+ cached_source = File.join(tmpdir, name)
62
+ begin
63
+ curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
64
+ Puppet.debug "Success: curl transfered [#{name}]"
65
+ rescue Puppet::ExecutionFailure
66
+ Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
67
+ cached_source = source
68
+ end
66
69
  end
67
- end
68
70
 
69
- begin
70
71
  open(cached_source) do |dmg|
71
72
  xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-mountrandom", "/tmp", dmg.path
72
73
  ptable = Plist::parse_xml xml_str
@@ -87,8 +88,7 @@ Puppet::Type.type(:package).provide(:appdmg, :parent => Puppet::Provider::Packag
87
88
  end
88
89
  end
89
90
  ensure
90
- # JJM Remove the file if open-uri didn't already do so.
91
- File.unlink(cached_source) if File.exist?(cached_source)
91
+ FileUtils.remove_entry_secure(tmpdir, force=true)
92
92
  end
93
93
  end
94
94
 
@@ -39,11 +39,7 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
39
39
 
40
40
  def self.instances
41
41
  instance_by_name.collect do |name|
42
- new(
43
- :name => name,
44
- :provider => :pkgdmg,
45
- :ensure => :installed
46
- )
42
+ new(:name => name, :provider => :pkgdmg, :ensure => :installed)
47
43
  end
48
44
  end
49
45
 
@@ -58,22 +54,23 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
58
54
 
59
55
  def self.installpkgdmg(source, name)
60
56
  unless source =~ /\.dmg$/i || source =~ /\.pkg$/i
61
- raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file")
57
+ raise Puppet::Error.new("Mac OS X PKG DMG's must specify a source string ending in .dmg or flat .pkg file")
62
58
  end
63
59
  require 'open-uri'
64
60
  cached_source = source
65
- if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
66
- cached_source = "/tmp/#{name}"
67
- begin
68
- curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
69
- Puppet.debug "Success: curl transfered [#{name}]"
70
- rescue Puppet::ExecutionFailure
71
- Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
72
- cached_source = source
61
+ tmpdir = Dir.mktmpdir
62
+ begin
63
+ if %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://} =~ cached_source
64
+ cached_source = File.join(tmpdir, name)
65
+ begin
66
+ curl "-o", cached_source, "-C", "-", "-k", "-L", "-s", "--url", source
67
+ Puppet.debug "Success: curl transfered [#{name}]"
68
+ rescue Puppet::ExecutionFailure
69
+ Puppet.debug "curl did not transfer [#{name}]. Falling back to slower open-uri transfer methods."
70
+ cached_source = source
71
+ end
73
72
  end
74
- end
75
73
 
76
- begin
77
74
  if source =~ /\.dmg$/i
78
75
  File.open(cached_source) do |dmg|
79
76
  xml_str = hdiutil "mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", dmg.path
@@ -96,14 +93,11 @@ Puppet::Type.type(:package).provide :pkgdmg, :parent => Puppet::Provider::Packag
96
93
  end
97
94
  end
98
95
  end
99
- elsif source =~ /\.pkg$/i
100
- installpkg(cached_source, name, source)
101
96
  else
102
- raise Puppet::Error.new("Mac OS X PKG DMG's must specificy a source string ending in .dmg or flat .pkg file")
97
+ installpkg(cached_source, name, source)
103
98
  end
104
99
  ensure
105
- # JJM Remove the file if open-uri didn't already do so.
106
- File.unlink(cached_source) if File.exist?(cached_source)
100
+ FileUtils.remove_entry_secure(tmpdir, force=true)
107
101
  end
108
102
  end
109
103
 
@@ -15,7 +15,7 @@ class Puppet::Util::NetworkDevice::Transport::Telnet < Puppet::Util::NetworkDevi
15
15
  def connect
16
16
  @telnet = Net::Telnet::new("Host" => host, "Port" => port || 23,
17
17
  "Timeout" => 10,
18
- "Prompt" => default_prompt, "Output_log" => "/tmp/out.log")
18
+ "Prompt" => default_prompt)
19
19
  end
20
20
 
21
21
  def close
@@ -39,4 +39,4 @@ class Puppet::Util::NetworkDevice::Transport::Telnet < Puppet::Util::NetworkDevi
39
39
  def send(line)
40
40
  @telnet.puts(line)
41
41
  end
42
- end
42
+ end
@@ -162,49 +162,6 @@ describe "Puppet Network Format" do
162
162
 
163
163
  end
164
164
 
165
- it "should include a marshal format" do
166
- Puppet::Network::FormatHandler.format(:marshal).should_not be_nil
167
- end
168
-
169
- describe "marshal" do
170
- before do
171
- @marshal = Puppet::Network::FormatHandler.format(:marshal)
172
- end
173
-
174
- it "should have its mime type set to text/marshal" do
175
- Puppet::Network::FormatHandler.format(:marshal).mime.should == "text/marshal"
176
- end
177
-
178
- it "should be supported on Strings" do
179
- @marshal.should be_supported(String)
180
- end
181
-
182
- it "should render by calling 'Marshal.dump' on the instance" do
183
- instance = mock 'instance'
184
- Marshal.expects(:dump).with(instance).returns "foo"
185
- @marshal.render(instance).should == "foo"
186
- end
187
-
188
- it "should render multiple instances by calling 'to_marshal' on the array" do
189
- instances = [mock('instance')]
190
-
191
- Marshal.expects(:dump).with(instances).returns "foo"
192
- @marshal.render_multiple(instances).should == "foo"
193
- end
194
-
195
- it "should intern by calling 'Marshal.load'" do
196
- text = "foo"
197
- Marshal.expects(:load).with("foo").returns "bar"
198
- @marshal.intern(String, text).should == "bar"
199
- end
200
-
201
- it "should intern multiples by calling 'Marshal.load'" do
202
- text = "foo"
203
- Marshal.expects(:load).with("foo").returns "bar"
204
- @marshal.intern_multiple(String, text).should == "bar"
205
- end
206
- end
207
-
208
165
  describe "plaintext" do
209
166
  before do
210
167
  @text = Puppet::Network::FormatHandler.format(:s)
@@ -42,6 +42,14 @@ describe Puppet::Network::HTTP::API::V1 do
42
42
  @tester.uri2indirection("GET", "/env/foo/bar", {:environment => "otherenv"})[3][:environment].to_s.should == "env"
43
43
  end
44
44
 
45
+ it "should not pass a buck_path parameter through (See Bugs #13553, #13518, #13511)" do
46
+ @tester.uri2indirection("GET", "/env/foo/bar", { :bucket_path => "/malicious/path" })[3].should_not include({ :bucket_path => "/malicious/path" })
47
+ end
48
+
49
+ it "should pass allowed parameters through" do
50
+ @tester.uri2indirection("GET", "/env/foo/bar", { :allowed_param => "value" })[3].should include({ :allowed_param => "value" })
51
+ end
52
+
45
53
  it "should return the environment as a Puppet::Node::Environment" do
46
54
  @tester.uri2indirection("GET", "/env/foo/bar", {})[3][:environment].should be_a Puppet::Node::Environment
47
55
  end
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env rspec
2
+ require 'spec_helper'
3
+
4
+ describe Puppet::Type.type(:package).provider(:appdmg) do
5
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'foo', :provider => :appdmg) }
6
+ let(:provider) { described_class.new(resource) }
7
+
8
+ describe "when installing an appdmg" do
9
+ let(:fake_mountpoint) { "/tmp/dmg.foo" }
10
+ let(:empty_hdiutil_plist) { Plist::Emit.dump({}) }
11
+ let(:fake_hdiutil_plist) { Plist::Emit.dump({"system-entities" => [{"mount-point" => fake_mountpoint}]}) }
12
+
13
+ before do
14
+ fh = mock 'filehandle'
15
+ fh.stubs(:path).yields "/tmp/foo"
16
+ resource[:source] = "foo.dmg"
17
+ described_class.stubs(:open).yields fh
18
+ Dir.stubs(:mktmpdir).returns "/tmp/testtmp123"
19
+ FileUtils.stubs(:remove_entry_secure)
20
+ end
21
+
22
+ describe "from a remote source" do
23
+ let(:tmpdir) { "/tmp/good123" }
24
+
25
+ before :each do
26
+ resource[:source] = "http://fake.puppetlabs.com/foo.dmg"
27
+ end
28
+
29
+ it "should call tmpdir and use the returned directory" do
30
+ Dir.expects(:mktmpdir).returns tmpdir
31
+ Dir.stubs(:entries).returns ["foo.app"]
32
+ described_class.expects(:curl).with do |*args|
33
+ args[0] == "-o" and args[1].include? tmpdir
34
+ end
35
+ described_class.stubs(:hdiutil).returns fake_hdiutil_plist
36
+ described_class.expects(:installapp)
37
+
38
+ provider.install
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,83 +1,89 @@
1
1
  #!/usr/bin/env rspec
2
2
  require 'spec_helper'
3
3
 
4
- provider = Puppet::Type.type(:package).provider(:pkgdmg)
4
+ describe Puppet::Type.type(:package).provider(:pkgdmg) do
5
+ let(:resource) { Puppet::Type.type(:package).new(:name => 'foo', :provider => :pkgdmg) }
6
+ let(:provider) { described_class.new(resource) }
5
7
 
6
- describe provider do
7
- before do
8
- @resource = stub 'resource', :[] => "dummypkgdmg"
9
- @provider = provider.new(@resource)
10
-
11
- @fakemountpoint = "/tmp/dmg.foo"
12
- @fakepkgfile = "/tmp/test.pkg"
13
- @fakehdiutilinfo = {"system-entities" => [{"mount-point" => @fakemountpoint}] }
14
- @fakehdiutilplist = Plist::Emit.dump(@fakehdiutilinfo)
15
-
16
- @hdiutilmountargs = ["mount", "-plist", "-nobrowse", "-readonly",
17
- "-noidme", "-mountrandom", "/tmp"]
18
- end
19
-
20
- it "should not be versionable" do
21
- provider.versionable?.should be_false
22
- end
23
-
24
- it "should not be uninstallable" do
25
- provider.uninstallable?.should be_false
26
- end
8
+ it { should_not be_versionable }
9
+ it { should_not be_uninstallable }
27
10
 
28
11
  describe "when installing it should fail when" do
29
- it "no source is specified" do
30
- @resource.stubs(:[]).with(:source).returns nil
31
- lambda { @provider.install }.should raise_error(Puppet::Error)
12
+ before :each do
13
+ Puppet::Util.expects(:execute).never
32
14
  end
33
15
 
34
- it "no name is specified" do
35
- @resource.stubs(:[]).with(:name).returns nil
36
- lambda { @provider.install }.should raise_error(Puppet::Error)
16
+ it "no source is specified" do
17
+ expect { provider.install }.should raise_error(Puppet::Error, /must specify a package source/)
37
18
  end
38
19
 
39
20
  it "the source does not end in .dmg or .pkg" do
40
- @resource.stubs(:[]).with(:source).returns "notendingindotdmgorpkg"
41
- lambda { @provider.install }.should raise_error(Puppet::Error)
42
- end
43
-
44
- it "a disk image with no system entities is mounted" do
45
- @provider.stubs(:[]).with(:hdiutil).returns ""
46
- lambda { @provider.install }.should raise_error(Puppet::Error)
21
+ resource[:source] = "bar"
22
+ expect { provider.install }.should raise_error(Puppet::Error, /must specify a source string ending in .*dmg.*pkg/)
47
23
  end
48
24
  end
49
25
 
50
26
  # These tests shouldn't be this messy. The pkgdmg provider needs work...
51
27
  describe "when installing a pkgdmg" do
28
+ let(:fake_mountpoint) { "/tmp/dmg.foo" }
29
+ let(:empty_hdiutil_plist) { Plist::Emit.dump({}) }
30
+ let(:fake_hdiutil_plist) { Plist::Emit.dump({"system-entities" => [{"mount-point" => fake_mountpoint}]}) }
31
+
52
32
  before do
53
33
  fh = mock 'filehandle'
54
34
  fh.stubs(:path).yields "/tmp/foo"
55
- @resource.stubs(:[]).with(:source).returns "foo.dmg"
35
+ resource[:source] = "foo.dmg"
56
36
  File.stubs(:open).yields fh
37
+ Dir.stubs(:mktmpdir).returns "/tmp/testtmp123"
38
+ FileUtils.stubs(:remove_entry_secure)
39
+ end
40
+
41
+ it "should fail when a disk image with no system entities is mounted" do
42
+ described_class.stubs(:hdiutil).returns(empty_hdiutil_plist)
43
+ expect { provider.install }.should raise_error(Puppet::Error, /No disk entities/)
57
44
  end
58
45
 
59
46
  it "should call hdiutil to mount and eject the disk image" do
60
47
  Dir.stubs(:entries).returns []
61
- @provider.class.expects(:hdiutil).with("eject", @fakemountpoint).returns 0
62
- @provider.class.expects(:hdiutil).with("mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", nil).returns @fakehdiutilplist
63
- @provider.install
48
+ provider.class.expects(:hdiutil).with("eject", fake_mountpoint).returns 0
49
+ provider.class.expects(:hdiutil).with("mount", "-plist", "-nobrowse", "-readonly", "-noidme", "-mountrandom", "/tmp", nil).returns fake_hdiutil_plist
50
+ provider.install
64
51
  end
65
52
 
66
53
  it "should call installpkg if a pkg/mpkg is found on the dmg" do
67
54
  Dir.stubs(:entries).returns ["foo.pkg"]
68
- @provider.class.stubs(:hdiutil).returns @fakehdiutilplist
69
- @provider.class.expects(:installpkg).with("#{@fakemountpoint}/foo.pkg", @resource[:name], "foo.dmg").returns ""
70
- @provider.install
55
+ provider.class.stubs(:hdiutil).returns fake_hdiutil_plist
56
+ provider.class.expects(:installpkg).with("#{fake_mountpoint}/foo.pkg", resource[:name], "foo.dmg").returns ""
57
+ provider.install
58
+ end
59
+
60
+ describe "from a remote source" do
61
+ let(:tmpdir) { "/tmp/good123" }
62
+
63
+ before :each do
64
+ resource[:source] = "http://fake.puppetlabs.com/foo.dmg"
65
+ end
66
+
67
+ it "should call tmpdir and use the returned directory" do
68
+ Dir.expects(:mktmpdir).returns tmpdir
69
+ Dir.stubs(:entries).returns ["foo.pkg"]
70
+ described_class.expects(:curl).with do |*args|
71
+ args[0] == "-o" and args[1].include? tmpdir
72
+ end
73
+ described_class.stubs(:hdiutil).returns fake_hdiutil_plist
74
+ described_class.expects(:installpkg)
75
+
76
+ provider.install
77
+ end
71
78
  end
72
79
  end
73
80
 
74
81
  describe "when installing flat pkg file" do
75
82
  it "should call installpkg if a flat pkg file is found instead of a .dmg image" do
76
- @resource.stubs(:[]).with(:source).returns "/tmp/test.pkg"
77
- @resource.stubs(:[]).with(:name).returns "testpkg"
78
- @provider.class.expects(:installpkgdmg).with("#{@fakepkgfile}", "testpkg").returns ""
79
- @provider.install
80
- end
83
+ resource[:source] = "/tmp/test.pkg"
84
+ resource[:name] = "testpkg"
85
+ provider.class.expects(:installpkgdmg).with("/tmp/test.pkg", "testpkg").returns ""
86
+ provider.install
87
+ end
81
88
  end
82
-
83
89
  end
@@ -6,6 +6,7 @@ require 'puppet/util/network_device/transport/telnet'
6
6
  describe Puppet::Util::NetworkDevice::Transport::Telnet do
7
7
 
8
8
  before(:each) do
9
+ TCPSocket.stubs(:open).returns stub_everything('tcp')
9
10
  @transport = Puppet::Util::NetworkDevice::Transport::Telnet.new()
10
11
  end
11
12
 
@@ -13,6 +14,14 @@ describe Puppet::Util::NetworkDevice::Transport::Telnet do
13
14
  @transport.should_not be_handles_login
14
15
  end
15
16
 
17
+ it "should not open any files" do
18
+ File.expects(:open).never
19
+ @transport.host = "localhost"
20
+ @transport.port = 23
21
+
22
+ @transport.connect
23
+ end
24
+
16
25
  it "should connect to the given host and port" do
17
26
  Net::Telnet.expects(:new).with { |args| args["Host"] == "localhost" && args["Port"] == 23 }.returns stub_everything
18
27
  @transport.host = "localhost"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 7
9
- - 12
10
- version: 2.7.12
9
+ - 13
10
+ version: 2.7.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Puppet Labs
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-12 00:00:00 Z
18
+ date: 2012-04-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: facter
@@ -1594,6 +1594,7 @@ files:
1594
1594
  - spec/unit/provider/nameservice/directoryservice_spec.rb
1595
1595
  - spec/unit/provider/network_device_spec.rb
1596
1596
  - spec/unit/provider/package/aix_spec.rb
1597
+ - spec/unit/provider/package/appdmg_spec.rb
1597
1598
  - spec/unit/provider/package/apt_spec.rb
1598
1599
  - spec/unit/provider/package/dpkg_spec.rb
1599
1600
  - spec/unit/provider/package/freebsd_spec.rb