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

« back to all changes in this revision

Viewing changes to .pc/2.7.11-Patch-CVE-2013-3567.patch/lib/puppet/transaction/event.rb

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2013-06-14 09:06:22 UTC
  • Revision ID: package-import@ubuntu.com-20130614090622-udg81hzxap7nxrow
Tags: 2.7.11-1ubuntu2.3
* SECURITY UPDATE: Remote code execution on master from unauthenticated
  clients
  - debian/patches/2.7.21-Patch-for-CVE-2013-3567.patch: upstream patch
    to use safe_yama.
  - CVE-2013-3567

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'puppet/transaction'
 
2
require 'puppet/util/tagging'
 
3
require 'puppet/util/logging'
 
4
 
 
5
# A simple struct for storing what happens on the system.
 
6
class Puppet::Transaction::Event
 
7
  include Puppet::Util::Tagging
 
8
  include Puppet::Util::Logging
 
9
 
 
10
  ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :file, :line, :source_description, :audited]
 
11
  YAML_ATTRIBUTES = %w{@audited @property @previous_value @desired_value @historical_value @message @name @status @time}
 
12
  attr_accessor *ATTRIBUTES
 
13
  attr_writer :tags
 
14
  attr_accessor :time
 
15
  attr_reader :default_log_level
 
16
 
 
17
  EVENT_STATUSES = %w{noop success failure audit}
 
18
 
 
19
  def initialize(options = {})
 
20
    @audited = false
 
21
    options.each { |attr, value| send(attr.to_s + "=", value) }
 
22
 
 
23
    @time = Time.now
 
24
  end
 
25
 
 
26
  def property=(prop)
 
27
    @property = prop.to_s
 
28
  end
 
29
 
 
30
  def resource=(res)
 
31
    if res.respond_to?(:[]) and level = res[:loglevel]
 
32
      @default_log_level = level
 
33
    end
 
34
    @resource = res.to_s
 
35
  end
 
36
 
 
37
  def send_log
 
38
    super(log_level, message)
 
39
  end
 
40
 
 
41
  def status=(value)
 
42
    raise ArgumentError, "Event status can only be #{EVENT_STATUSES.join(', ')}" unless EVENT_STATUSES.include?(value)
 
43
    @status = value
 
44
  end
 
45
 
 
46
  def to_s
 
47
    message
 
48
  end
 
49
 
 
50
  def to_yaml_properties
 
51
    (YAML_ATTRIBUTES.map {|ya| ya.to_s} & instance_variables.map{|iv| iv.to_s}).sort
 
52
  end
 
53
 
 
54
  private
 
55
 
 
56
  # If it's a failure, use 'err', else use either the resource's log level (if available)
 
57
  # or 'notice'.
 
58
  def log_level
 
59
    status == "failure" ? :err : (@default_log_level || :notice)
 
60
  end
 
61
 
 
62
  # Used by the Logging module
 
63
  def log_source
 
64
    source_description || property || resource
 
65
  end
 
66
end