~ubuntu-branches/ubuntu/precise/puppet/precise-security

« back to all changes in this revision

Viewing changes to .pc/2.7.17-Puppet-July-2012-CVE-fixes.patch/spec/shared_behaviours/file_serving.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-07-10 07:58:03 UTC
  • Revision ID: package-import@ubuntu.com-20120710075803-og8iubg2a90dtk7f
Tags: 2.7.11-1ubuntu2.1
* SECURITY UPDATE: Multiple July 2012 security issues
  - debian/patches/2.7.17-Puppet-July-2012-CVE-fixes.patch: upstream
    patch to fix multiple security issues.
  - CVE-2012-3864: arbitrary file read on master from authenticated
    clients
  - CVE-2012-3865: arbitrary file delete or denial of service on master
    from authenticated clients
  - CVE-2012-3866: last_run_report.yaml report file is world readable and
    leads to arbitrary file read on master by an agent
  - CVE-2012-3867: insufficient input validation for agent cert hostnames

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env rspec
 
2
shared_examples_for "Puppet::FileServing::Files" do
 
3
  it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do
 
4
    uri = "puppet://myhost/fakemod/my/file"
 
5
 
 
6
    # It appears that the mocking somehow interferes with the caching subsystem.
 
7
    # This mock somehow causes another terminus to get generated.
 
8
    term = @indirection.terminus(:rest)
 
9
    @indirection.stubs(:terminus).with(:rest).returns term
 
10
    term.expects(:find)
 
11
    @indirection.find(uri)
 
12
  end
 
13
 
 
14
  it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet' or 'apply'" do
 
15
    uri = "puppet:///fakemod/my/file"
 
16
    Puppet.settings.stubs(:value).returns "foo"
 
17
    Puppet.settings.stubs(:value).with(:name).returns("puppetd")
 
18
    Puppet.settings.stubs(:value).with(:modulepath).returns("")
 
19
    @indirection.terminus(:rest).expects(:find)
 
20
    @indirection.find(uri)
 
21
  end
 
22
 
 
23
  it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'puppet'" do
 
24
    uri = "puppet:///fakemod/my/file"
 
25
    Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
 
26
    Puppet.settings.stubs(:value).returns ""
 
27
    Puppet.settings.stubs(:value).with(:name).returns("puppet")
 
28
    Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
 
29
    @indirection.terminus(:file_server).expects(:find)
 
30
    @indirection.terminus(:file_server).stubs(:authorized?).returns(true)
 
31
    @indirection.find(uri)
 
32
  end
 
33
 
 
34
  it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'apply'" do
 
35
    uri = "puppet:///fakemod/my/file"
 
36
    Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing", :module => nil, :modulepath => []))
 
37
    Puppet.settings.stubs(:value).returns ""
 
38
    Puppet.settings.stubs(:value).with(:name).returns("apply")
 
39
    Puppet.settings.stubs(:value).with(:fileserverconfig).returns("/whatever")
 
40
    @indirection.terminus(:file_server).expects(:find)
 
41
    @indirection.terminus(:file_server).stubs(:authorized?).returns(true)
 
42
    @indirection.find(uri)
 
43
  end
 
44
 
 
45
  it "should use the file terminus when the 'file' URI scheme is used" do
 
46
    uri = Puppet::Util.path_to_uri(File.expand_path('/fakemod/my/other file'))
 
47
    uri.scheme.should == 'file'
 
48
    @indirection.terminus(:file).expects(:find)
 
49
    @indirection.find(uri.to_s)
 
50
  end
 
51
 
 
52
  it "should use the file terminus when a fully qualified path is provided" do
 
53
    uri = File.expand_path("/fakemod/my/file")
 
54
    @indirection.terminus(:file).expects(:find)
 
55
    @indirection.find(uri)
 
56
  end
 
57
 
 
58
  it "should use the configuration to test whether the request is allowed" do
 
59
    uri = "fakemod/my/file"
 
60
    mount = mock 'mount'
 
61
    config = stub 'configuration', :split_path => [mount, "eh"]
 
62
    @indirection.terminus(:file_server).stubs(:configuration).returns config
 
63
 
 
64
    @indirection.terminus(:file_server).expects(:find)
 
65
    mount.expects(:allowed?).returns(true)
 
66
    @indirection.find(uri, :node => "foo", :ip => "bar")
 
67
  end
 
68
end