sensu 0.22.2 → 0.23.0.beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,16 +2,16 @@ module Sensu
2
2
  module Server
3
3
  module Sandbox
4
4
  # Evaluate a Ruby expression within the context of a simple
5
- # "sandbox", a Proc in a module method. Use the Ruby `$SAFE`
6
- # level of 4 when the version of Ruby is less than 2.1.0. A
7
- # single value is provided to the "sandbox".
5
+ # "sandbox", a Proc in a module method. As of Ruby 2.3.0,
6
+ # `$SAFE` no longer supports levels > 1, so its use has been
7
+ # removed from this method. A single value is provided to the
8
+ # "sandbox".
8
9
  #
9
10
  # @param expression [String] to be evaluated.
10
11
  # @param value [Object] to provide the "sandbox" with.
11
12
  # @return [Object]
12
13
  def self.eval(expression, value=nil)
13
14
  result = Proc.new do
14
- $SAFE = (RUBY_VERSION < "2.1.0" ? 4 : 3)
15
15
  Kernel.eval(expression)
16
16
  end
17
17
  result.call
@@ -1,6 +1,4 @@
1
- gem "uuidtools", "2.1.5"
2
-
3
- require "uuidtools"
1
+ require "securerandom"
4
2
 
5
3
  module Sensu
6
4
  module Utilities
@@ -50,7 +48,7 @@ module Sensu
50
48
  #
51
49
  # @return [String] random UUID.
52
50
  def random_uuid
53
- UUIDTools::UUID.random_create.to_s
51
+ ::SecureRandom.uuid
54
52
  end
55
53
 
56
54
  # Remove sensitive information from a hash (eg. passwords). By
@@ -82,5 +80,43 @@ module Sensu
82
80
  end
83
81
  hash
84
82
  end
83
+
84
+ # Traverse a hash for an attribute value, with a fallback default
85
+ # value if nil.
86
+ #
87
+ # @param tree [Hash] to traverse.
88
+ # @param path [Array] of attribute keys.
89
+ # @param default [Object] value if attribute value is nil.
90
+ # @return [Object] attribute or fallback default value.
91
+ def find_attribute_value(tree, path, default)
92
+ attribute = tree[path.shift]
93
+ if attribute.is_a?(Hash)
94
+ find_attribute_value(attribute, path, default)
95
+ else
96
+ attribute.nil? ? default : attribute
97
+ end
98
+ end
99
+
100
+ # Substitute dot notation tokens (eg. :::db.name|production:::)
101
+ # with the associated definition attribute value. Tokens can
102
+ # provide a fallback default value, following a pipe.
103
+ #
104
+ # @param tokens [String]
105
+ # @param attributes [Hash]
106
+ # @return [Array] containing the string with tokens substituted
107
+ # and an array of unmatched tokens.
108
+ def substitute_tokens(tokens, attributes)
109
+ unmatched_tokens = []
110
+ substituted = tokens.gsub(/:::([^:].*?):::/) do
111
+ token, default = $1.to_s.split("|", -1)
112
+ path = token.split(".").map(&:to_sym)
113
+ matched = find_attribute_value(attributes, path, default)
114
+ if matched.nil?
115
+ unmatched_tokens << token
116
+ end
117
+ matched
118
+ end
119
+ [substituted, unmatched_tokens]
120
+ end
85
121
  end
86
122
  end
data/sensu.gemspec CHANGED
@@ -13,17 +13,15 @@ Gem::Specification.new do |s|
13
13
  s.license = "MIT"
14
14
  s.has_rdoc = false
15
15
 
16
- s.add_dependency "json" if RUBY_VERSION < "1.9"
17
- s.add_dependency "multi_json", "1.11.2"
18
- s.add_dependency "uuidtools", "2.1.5"
19
- s.add_dependency "eventmachine", "1.0.9.1"
20
- s.add_dependency "sensu-logger", "1.1.0"
21
- s.add_dependency "sensu-settings", "3.3.0"
16
+ s.add_dependency "eventmachine", "1.2.0.1"
17
+ s.add_dependency "sensu-json", "1.1.0"
18
+ s.add_dependency "sensu-logger", "1.2.0"
19
+ s.add_dependency "sensu-settings", "3.4.0"
22
20
  s.add_dependency "sensu-extension", "1.5.0"
23
- s.add_dependency "sensu-extensions", "1.4.0"
24
- s.add_dependency "sensu-transport", "4.0.0"
21
+ s.add_dependency "sensu-extensions", "1.5.0"
22
+ s.add_dependency "sensu-transport", "5.0.0"
25
23
  s.add_dependency "sensu-spawn", "1.8.0"
26
- s.add_dependency "em-redis-unified", "1.0.1"
24
+ s.add_dependency "sensu-redis", "1.2.0"
27
25
  s.add_dependency "sinatra", "1.4.6"
28
26
  s.add_dependency "async_sinatra", "1.2.0"
29
27
  s.add_dependency "thin", "1.6.3" unless RUBY_PLATFORM =~ /java/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.2
4
+ version: 0.23.0.beta
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
@@ -9,78 +9,64 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-10 00:00:00.000000000 Z
12
+ date: 2016-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: multi_json
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - '='
19
- - !ruby/object:Gem::Version
20
- version: 1.11.2
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - '='
26
- - !ruby/object:Gem::Version
27
- version: 1.11.2
28
- - !ruby/object:Gem::Dependency
29
- name: uuidtools
15
+ name: eventmachine
30
16
  requirement: !ruby/object:Gem::Requirement
31
17
  requirements:
32
18
  - - '='
33
19
  - !ruby/object:Gem::Version
34
- version: 2.1.5
20
+ version: 1.2.0.1
35
21
  type: :runtime
36
22
  prerelease: false
37
23
  version_requirements: !ruby/object:Gem::Requirement
38
24
  requirements:
39
25
  - - '='
40
26
  - !ruby/object:Gem::Version
41
- version: 2.1.5
27
+ version: 1.2.0.1
42
28
  - !ruby/object:Gem::Dependency
43
- name: eventmachine
29
+ name: sensu-json
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - '='
47
33
  - !ruby/object:Gem::Version
48
- version: 1.0.9.1
34
+ version: 1.1.0
49
35
  type: :runtime
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
39
  - - '='
54
40
  - !ruby/object:Gem::Version
55
- version: 1.0.9.1
41
+ version: 1.1.0
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: sensu-logger
58
44
  requirement: !ruby/object:Gem::Requirement
59
45
  requirements:
60
46
  - - '='
61
47
  - !ruby/object:Gem::Version
62
- version: 1.1.0
48
+ version: 1.2.0
63
49
  type: :runtime
64
50
  prerelease: false
65
51
  version_requirements: !ruby/object:Gem::Requirement
66
52
  requirements:
67
53
  - - '='
68
54
  - !ruby/object:Gem::Version
69
- version: 1.1.0
55
+ version: 1.2.0
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: sensu-settings
72
58
  requirement: !ruby/object:Gem::Requirement
73
59
  requirements:
74
60
  - - '='
75
61
  - !ruby/object:Gem::Version
76
- version: 3.3.0
62
+ version: 3.4.0
77
63
  type: :runtime
78
64
  prerelease: false
79
65
  version_requirements: !ruby/object:Gem::Requirement
80
66
  requirements:
81
67
  - - '='
82
68
  - !ruby/object:Gem::Version
83
- version: 3.3.0
69
+ version: 3.4.0
84
70
  - !ruby/object:Gem::Dependency
85
71
  name: sensu-extension
86
72
  requirement: !ruby/object:Gem::Requirement
@@ -101,28 +87,28 @@ dependencies:
101
87
  requirements:
102
88
  - - '='
103
89
  - !ruby/object:Gem::Version
104
- version: 1.4.0
90
+ version: 1.5.0
105
91
  type: :runtime
106
92
  prerelease: false
107
93
  version_requirements: !ruby/object:Gem::Requirement
108
94
  requirements:
109
95
  - - '='
110
96
  - !ruby/object:Gem::Version
111
- version: 1.4.0
97
+ version: 1.5.0
112
98
  - !ruby/object:Gem::Dependency
113
99
  name: sensu-transport
114
100
  requirement: !ruby/object:Gem::Requirement
115
101
  requirements:
116
102
  - - '='
117
103
  - !ruby/object:Gem::Version
118
- version: 4.0.0
104
+ version: 5.0.0
119
105
  type: :runtime
120
106
  prerelease: false
121
107
  version_requirements: !ruby/object:Gem::Requirement
122
108
  requirements:
123
109
  - - '='
124
110
  - !ruby/object:Gem::Version
125
- version: 4.0.0
111
+ version: 5.0.0
126
112
  - !ruby/object:Gem::Dependency
127
113
  name: sensu-spawn
128
114
  requirement: !ruby/object:Gem::Requirement
@@ -138,19 +124,19 @@ dependencies:
138
124
  - !ruby/object:Gem::Version
139
125
  version: 1.8.0
140
126
  - !ruby/object:Gem::Dependency
141
- name: em-redis-unified
127
+ name: sensu-redis
142
128
  requirement: !ruby/object:Gem::Requirement
143
129
  requirements:
144
130
  - - '='
145
131
  - !ruby/object:Gem::Version
146
- version: 1.0.1
132
+ version: 1.2.0
147
133
  type: :runtime
148
134
  prerelease: false
149
135
  version_requirements: !ruby/object:Gem::Requirement
150
136
  requirements:
151
137
  - - '='
152
138
  - !ruby/object:Gem::Version
153
- version: 1.0.1
139
+ version: 1.2.0
154
140
  - !ruby/object:Gem::Dependency
155
141
  name: sinatra
156
142
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +261,6 @@ files:
275
261
  - lib/sensu/client/socket.rb
276
262
  - lib/sensu/constants.rb
277
263
  - lib/sensu/daemon.rb
278
- - lib/sensu/redis.rb
279
264
  - lib/sensu/server/filter.rb
280
265
  - lib/sensu/server/handle.rb
281
266
  - lib/sensu/server/mutate.rb
@@ -299,9 +284,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
299
284
  version: '0'
300
285
  required_rubygems_version: !ruby/object:Gem::Requirement
301
286
  requirements:
302
- - - ">="
287
+ - - ">"
303
288
  - !ruby/object:Gem::Version
304
- version: '0'
289
+ version: 1.3.1
305
290
  requirements: []
306
291
  rubyforge_project:
307
292
  rubygems_version: 2.4.5.1
data/lib/sensu/redis.rb DELETED
@@ -1,25 +0,0 @@
1
- gem "em-redis-unified", "1.0.1"
2
-
3
- require "em-redis-unified"
4
-
5
- module Sensu
6
- class Redis
7
- # Connect to Redis and ensure that the Redis version is at least
8
- # 1.3.14, in order to support certain commands.
9
- #
10
- # @param options [Hash]
11
- # @return [Object] Redis connection object.
12
- def self.connect(options={})
13
- options ||= {}
14
- connection = EM::Protocols::Redis.connect(options)
15
- connection.info do |info|
16
- if info[:redis_version] < "1.3.14"
17
- klass = EM::Protocols::Redis::RedisError
18
- message = "redis version must be >= 2.0 RC 1"
19
- connection.error(klass, message)
20
- end
21
- end
22
- connection
23
- end
24
- end
25
- end