mcollective-client 2.8.8 → 2.8.9
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.
- checksums.yaml +4 -4
- data/lib/mcollective.rb +1 -1
- data/lib/mcollective/matcher.rb +33 -8
- data/lib/mcollective/matcher/scanner.rb +30 -32
- data/lib/mcollective/ssl.rb +1 -1
- data/spec/unit/mcollective/matcher/parser_spec.rb +2 -2
- data/spec/unit/mcollective/matcher_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67b38bbfce7f0aba03c8178a28501d99894e3d2f
|
4
|
+
data.tar.gz: 657509db5b28a31967dfd16fc333da90c12eb605
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70b87a2142b39da0f78d9096b75f6a4177cefcc26cd15a42779973dcf6823a78ce7aa035431938c1bb93711ce0430f4eda062e771bb438e790f5c3b32d54e3b
|
7
|
+
data.tar.gz: 671f207d9cddb69f948499413c2867719a919252cf054af3fcb65e91b741fee6de75498be1900a49fc453cd2ef294da0ef34365a2c86eb554973c051efde5813
|
data/lib/mcollective.rb
CHANGED
data/lib/mcollective/matcher.rb
CHANGED
@@ -157,11 +157,6 @@ module MCollective
|
|
157
157
|
return false
|
158
158
|
end
|
159
159
|
|
160
|
-
# Escape strings for evaluation
|
161
|
-
if (l_compare.is_a?(String) && !(function_hash["operator"] =~ /=~|!=~/))
|
162
|
-
r_compare = "\"#{r_compare}\""
|
163
|
-
end
|
164
|
-
|
165
160
|
# Do a regex comparison if right compare string is a regex
|
166
161
|
if operator=~ /(=~|!=~)/
|
167
162
|
# Fail if left compare value isn't a string
|
@@ -177,10 +172,40 @@ module MCollective
|
|
177
172
|
return !!result
|
178
173
|
end
|
179
174
|
end
|
180
|
-
# Otherwise
|
175
|
+
# Otherwise do a normal comparison while taking the type into account
|
181
176
|
else
|
182
|
-
|
183
|
-
|
177
|
+
if l_compare.is_a? String
|
178
|
+
r_compare = r_compare.to_s
|
179
|
+
elsif r_compare.is_a? String
|
180
|
+
if l_compare.is_a? Numeric
|
181
|
+
r_compare = r_compare.strip
|
182
|
+
begin
|
183
|
+
r_compare = Integer(r_compare)
|
184
|
+
rescue ArgumentError
|
185
|
+
begin
|
186
|
+
r_compare = Float(r_compare)
|
187
|
+
rescue ArgumentError
|
188
|
+
raise ArgumentError, "invalid numeric value: #{r_compare}"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
elsif l_compare.is_a? TrueClass or l_compare.is_a? FalseClass
|
192
|
+
r_compare = r_compare.strip
|
193
|
+
if r_compare == true.to_s
|
194
|
+
r_compare = true
|
195
|
+
elsif r_compare == false.to_s
|
196
|
+
r_compare = false
|
197
|
+
else
|
198
|
+
raise ArgumentError, "invalid boolean value: #{r_compare}"
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
operator = operator.strip
|
203
|
+
if operator =~ /(?:(!=|<=|>=|<|>)|==?)/
|
204
|
+
operator = $1 ? $1.to_sym : :==
|
205
|
+
else
|
206
|
+
raise ArgumentError, "invalid operator: #{operator}"
|
207
|
+
end
|
208
|
+
result = l_compare.send(operator, r_compare)
|
184
209
|
return result
|
185
210
|
end
|
186
211
|
end
|
@@ -65,7 +65,6 @@ module MCollective
|
|
65
65
|
current_token_value = ""
|
66
66
|
j = @token_index
|
67
67
|
escaped = false
|
68
|
-
escaped_with = ""
|
69
68
|
|
70
69
|
begin
|
71
70
|
if (@arguments[j] == "/")
|
@@ -117,47 +116,46 @@ module MCollective
|
|
117
116
|
break
|
118
117
|
end
|
119
118
|
|
120
|
-
if @arguments[j
|
119
|
+
if @arguments[j] == "("
|
121
120
|
func = true
|
122
|
-
be_greedy = true
|
123
|
-
end
|
124
|
-
|
125
|
-
if @arguments[j+1] == '"' || @arguments[j+1] == "'"
|
126
|
-
func = false
|
127
|
-
be_greedy = true
|
128
|
-
escaped = true
|
129
|
-
escaped_with = @arguments[j+1]
|
130
|
-
end
|
131
121
|
|
132
|
-
|
122
|
+
current_token_value << @arguments[j]
|
123
|
+
j += 1
|
133
124
|
|
134
|
-
|
135
|
-
|
136
|
-
|
125
|
+
while j < @arguments.size
|
126
|
+
current_token_value << @arguments[j]
|
127
|
+
if @arguments[j] == ')'
|
137
128
|
j += 1
|
138
|
-
|
129
|
+
break
|
139
130
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
131
|
+
j += 1
|
132
|
+
end
|
133
|
+
elsif @arguments[j] == '"' || @arguments[j] == "'"
|
134
|
+
escaped = true
|
135
|
+
escaped_with = @arguments[j]
|
136
|
+
|
137
|
+
j += 1 # step over first " or '
|
138
|
+
@white_spaces += 1
|
139
|
+
# identified "..." or '...'
|
140
|
+
while j < @arguments.size
|
141
|
+
if @arguments[j] == '\\'
|
142
|
+
# eat the escape char but don't add it to the token, or we
|
143
|
+
# end up with \\\"
|
144
|
+
j += 1
|
145
|
+
@white_spaces += 1
|
146
|
+
unless j < @arguments.size
|
147
|
+
break
|
151
148
|
end
|
152
|
-
|
149
|
+
elsif @arguments[j] == escaped_with
|
153
150
|
j += 1
|
151
|
+
@white_spaces += 1
|
152
|
+
break
|
154
153
|
end
|
155
|
-
|
154
|
+
current_token_value << @arguments[j]
|
155
|
+
j += 1
|
156
156
|
end
|
157
|
-
|
158
|
-
j += 1
|
159
|
-
be_greedy = false
|
160
157
|
else
|
158
|
+
current_token_value << @arguments[j]
|
161
159
|
j += 1
|
162
160
|
end
|
163
161
|
|
data/lib/mcollective/ssl.rb
CHANGED
@@ -218,7 +218,7 @@ module MCollective
|
|
218
218
|
def self.uuid(string=nil)
|
219
219
|
string ||= OpenSSL::Random.random_bytes(16).unpack('H*').shift
|
220
220
|
|
221
|
-
uuid_name_space_dns =
|
221
|
+
uuid_name_space_dns = [0x6b, 0xa7, 0xb8, 0x10, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8].map {|b| b.chr}.join
|
222
222
|
|
223
223
|
sha1 = Digest::SHA1.new
|
224
224
|
sha1.update(uuid_name_space_dns)
|
@@ -105,8 +105,8 @@ module MCollective
|
|
105
105
|
end
|
106
106
|
|
107
107
|
it "should parse complex fstatements and statements with operators seperated by whitespaces" do
|
108
|
-
parser = Parser.new(
|
109
|
-
parser.execution_stack.should == [{"fstatement"=>"foo('bar').value=1"}, {"and"=>"and"}, {"statement"=>"foo=bar"}, {"or"=>"or"}, {"statement"=>"foo=bar"}]
|
108
|
+
parser = Parser.new(%q(foo('bar').value = 1 and foo=bar or foo = bar and baz("abc") = "xyz"))
|
109
|
+
parser.execution_stack.should == [{"fstatement"=>"foo('bar').value=1"}, {"and"=>"and"}, {"statement"=>"foo=bar"}, {"or"=>"or"}, {"statement"=>"foo=bar"}, {"and"=>"and"}, {"fstatement"=>'baz("abc")=xyz'}]
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should parse statements where classes are mixed with fact comparisons and fstatements" do
|
@@ -262,6 +262,22 @@ module MCollective
|
|
262
262
|
result.should == true
|
263
263
|
end
|
264
264
|
|
265
|
+
it "should handle integer literals" do
|
266
|
+
Matcher.expects(:execute_function).returns(10)
|
267
|
+
@function_hash["r_compare"] = "0xa"
|
268
|
+
@function_hash["operator"] = "="
|
269
|
+
result = Matcher.eval_compound_fstatement(@function_hash)
|
270
|
+
result.should == true
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should handle float literals" do
|
274
|
+
Matcher.expects(:execute_function).returns(50)
|
275
|
+
@function_hash["r_compare"] = "0.5e2"
|
276
|
+
@function_hash["operator"] = "="
|
277
|
+
result = Matcher.eval_compound_fstatement(@function_hash)
|
278
|
+
result.should == true
|
279
|
+
end
|
280
|
+
|
265
281
|
it "should return true if we do a false=false comparison" do
|
266
282
|
Matcher.expects(:execute_function).returns(false)
|
267
283
|
@function_hash["r_compare"] = false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcollective-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Labs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: systemu
|