right_agent 2.4.1 → 2.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aa97d267e37f937d75b168f61595f4471ecfa5c
4
- data.tar.gz: 84807b3fb6847703f579eb823893bfe67cba9a4c
3
+ metadata.gz: 2f847073e46487c064b8b6f889f911cce5e4f108
4
+ data.tar.gz: 3d3e8c151fd4175d18925826183e06fa53492d1b
5
5
  SHA512:
6
- metadata.gz: 557cff491092e4a661ea21bfa169a7adbe824530eabed61d657ef90ef93fb25ebda7e0d52e49074171c9c554bcb5cf2677150f2b3cea95c845c1310b79ce4098
7
- data.tar.gz: ed3487e962eb4a1fbdf2199778c9168cc4e58b3a3e988d671b14dab290006c1bdd5c73ead3f08db4aba5bc8ffcac934d43646a9747324d1b75c9bf839f574575
6
+ metadata.gz: 9422e92a47df194278674c186abb7f0b28d8235b901ae01a5c1313f4e3955a66515717a6b2ef47acd90a8e838f4c6734399978b5d50a8ed24096bfcae0e8e7b3
7
+ data.tar.gz: ad341db3b0ff0a704ccee785966cefedc0c134ec7c71a259e6973969a968b05a6358b3685b90c4d76dd030b09ee0cd444f6d706aab7a00909b8ee864e127015f
@@ -59,6 +59,9 @@ module RightScale
59
59
  # Text used for filtered parameter value
60
60
  FILTERED_PARAM_VALUE = "<hidden>"
61
61
 
62
+ # Parameters whose contents are also to have filtering applied
63
+ CONTENT_FILTERED_PARAMS = ["payload"]
64
+
62
65
  # Environment variables to examine for proxy settings, in order
63
66
  PROXY_ENVIRONMENT_VARIABLES = ['HTTPS_PROXY', 'https_proxy', 'HTTP_PROXY', 'http_proxy', 'ALL_PROXY']
64
67
 
@@ -71,7 +74,8 @@ module RightScale
71
74
  # @option options [String] :health_check_path in URI for health check resource;
72
75
  # defaults to DEFAULT_HEALTH_CHECK_PATH
73
76
  # @option options [Array] :filter_params symbols or strings for names of request parameters
74
- # whose values are to be hidden when logging; can be augmented on individual requests
77
+ # whose values are to be hidden when logging; also applied to contents of any parameters
78
+ # in CONTENT_FILTERED_PARAMS; can be augmented on individual requests
75
79
  # @option options [Boolean] :non_blocking i/o is to be used for HTTP requests by applying
76
80
  # EM::HttpRequest and fibers instead of RestClient; requests remain synchronous
77
81
  def initialize(urls, options = {})
@@ -140,9 +144,9 @@ module RightScale
140
144
  # @option options [Numeric] :open_timeout maximum wait for connection; defaults to DEFAULT_OPEN_TIMEOUT
141
145
  # @option options [Numeric] :request_timeout maximum wait for response; defaults to DEFAULT_REQUEST_TIMEOUT
142
146
  # @option options [String] :request_uuid uniquely identifying request; defaults to random generated UUID
143
- # @option options [Array] :filter_params symbols or strings for names of request
144
- # parameters whose values are to be hidden when logging in addition to the ones
145
- # provided during object initialization
147
+ # @option options [Array] :filter_params symbols or strings for names of request parameters whose
148
+ # values are to be hidden when logging in addition to the ones provided during object initialization;
149
+ # also applied to contents of any parameters named :payload
146
150
  # @option options [Hash] :headers to be added to request
147
151
  # @option options [Numeric] :poll_timeout maximum wait for individual poll; defaults to :request_timeout
148
152
  # @option options [Symbol] :log_level to use when logging information about the request other than errors;
@@ -359,8 +363,7 @@ module RightScale
359
363
  #
360
364
  # @return [String] Log text
361
365
  def log_text(path, params, filter, host = nil, exception = nil)
362
- filtered_params = (exception || Log.level == :debug) ? filter(params, filter).inspect : nil
363
- text = filtered_params ? "#{path} #{filtered_params}" : path
366
+ text = "#{path} #{filter(params, filter).inspect}"
364
367
  text = "[#{host}#{text}]" if host
365
368
  text << " | #{self.class.exception_text(exception)}" if exception
366
369
  text
@@ -368,8 +371,9 @@ module RightScale
368
371
 
369
372
  # Apply parameter hiding filter
370
373
  #
371
- # @param [Hash, Object] params to be filtered
372
- # @param [Array] filter names of params as strings (not symbols) whose value is to be hidden
374
+ # @param [Hash, Object] params to be filtered with strings or symbols as keys
375
+ # @param [Array] filter names of params as strings (not symbols) whose value is to be hidden;
376
+ # also filter the contents of any CONTENT_FILTERED_PARAMS
373
377
  #
374
378
  # @return [Hash] filtered parameters
375
379
  def filter(params, filter)
@@ -377,7 +381,14 @@ module RightScale
377
381
  params
378
382
  else
379
383
  filtered_params = {}
380
- params.each { |k, p| filtered_params[k] = filter.include?(k.to_s) ? FILTERED_PARAM_VALUE : p }
384
+ params.each do |k, p|
385
+ s = k.to_s
386
+ if filter.include?(s)
387
+ filtered_params[k] = FILTERED_PARAM_VALUE
388
+ else
389
+ filtered_params[k] = CONTENT_FILTERED_PARAMS.include?(s) ? filter(p, filter) : p
390
+ end
391
+ end
381
392
  filtered_params
382
393
  end
383
394
  end
@@ -76,7 +76,8 @@ module RightScale
76
76
  # @option options [Boolean] :non_blocking i/o is to be used for HTTP requests by applying
77
77
  # EM::HttpRequest and fibers instead of RestClient; requests remain synchronous
78
78
  # @option options [Array] :filter_params symbols or strings for names of request parameters
79
- # whose values are to be hidden when logging; can be augmented on individual requests
79
+ # whose values are to be hidden when logging; also applied to contents of any parameters
80
+ # named :payload; can be augmented on individual requests
80
81
  #
81
82
  # @return [Boolean] whether currently connected
82
83
  #
@@ -49,8 +49,8 @@ module RightScale
49
49
  # @option options [Boolean] :non_blocking i/o is to be used for HTTP requests by applying
50
50
  # EM::HttpRequest and fibers instead of RestClient; requests remain synchronous
51
51
  # @option options [Boolean] :long_polling_only never attempt to create a WebSocket, always long-polling instead
52
- # @option options [Array] :filter_params symbols or strings for names of request parameters
53
- # whose values are to be hidden when logging
52
+ # @option options [Array] :filter_params symbols or strings for names of request parameters whose
53
+ # values are to be hidden when logging; also applied to contents of any parameters named :payload
54
54
  #
55
55
  # @return [TrueClass] always true
56
56
  #
@@ -88,6 +88,8 @@ module RightScale
88
88
  # @option options [Numeric] :reconnect_interval for reconnect attempts after lose connectivity
89
89
  # @option options [Boolean] :non_blocking i/o is to be used for HTTP requests by applying
90
90
  # EM::HttpRequest and fibers instead of RestClient; requests remain synchronous
91
+ # @option options [Array] :filter_params symbols or strings for names of request parameters whose
92
+ # values are to be hidden when logging; also applied to contents of any parameters named :payload
91
93
  #
92
94
  # @raise [ArgumentError] auth client does not support this client type
93
95
  def initialize(auth_client, options)
data/right_agent.gemspec CHANGED
@@ -25,8 +25,8 @@ require 'rbconfig'
25
25
 
26
26
  Gem::Specification.new do |spec|
27
27
  spec.name = 'right_agent'
28
- spec.version = '2.4.1'
29
- spec.date = '2014-08-25'
28
+ spec.version = '2.4.2'
29
+ spec.date = '2014-08-26'
30
30
  spec.authors = ['Lee Kirchhoff', 'Raphael Simon', 'Tony Spataro', 'Scott Messier']
31
31
  spec.email = 'lee@rightscale.com'
32
32
  spec.homepage = 'https://github.com/rightscale/right_agent'
@@ -123,26 +123,26 @@ describe RightScale::BalancedHttpClient do
123
123
  end
124
124
 
125
125
  it "uses specified request UUID" do
126
- @log.should_receive(:info).with("Requesting POST <my uuid> /foo/bar").once
126
+ @log.should_receive(:info).with("Requesting POST <my uuid> /foo/bar {}").once
127
127
  @log.should_receive(:info).with("Completed <my uuid> in 10ms | 200 [http://my.com/foo/bar] | 11 bytes")
128
128
  @client.request(:post, @path, @params, :request_uuid => "my uuid")
129
129
  end
130
130
 
131
131
  it "generates request UUID if none specified" do
132
- @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar").once
132
+ @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar {}").once
133
133
  @log.should_receive(:info).with("Completed <random uuid> in 10ms | 200 [http://my.com/foo/bar] | 11 bytes").once
134
134
  @client.request(:post, @path)
135
135
  end
136
136
 
137
137
  it "logs request before sending it" do
138
- @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar").once
138
+ @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar {}").once
139
139
  flexmock(@http_client).should_receive(:request).and_raise(RuntimeError).once
140
140
  @client.request(:post, @path) rescue nil
141
141
  end
142
142
 
143
143
  it "logs using specified :log_level" do
144
144
  @params = {:some => "data"}
145
- @log.should_receive(:debug).with("Requesting POST <random uuid> /foo/bar").once
145
+ @log.should_receive(:debug).with("Requesting POST <random uuid> /foo/bar {:some=>\"data\"}").once
146
146
  @log.should_receive(:debug).with("Completed <random uuid> in 10ms | 200 [http://my.com/foo/bar] | 11 bytes").once
147
147
  @client.request(:post, @path, @params, :log_level => :debug)
148
148
  end
@@ -170,7 +170,7 @@ describe RightScale::BalancedHttpClient do
170
170
  end
171
171
 
172
172
  it "logs successful completion of request" do
173
- @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar")
173
+ @log.should_receive(:info).with("Requesting POST <random uuid> /foo/bar {}")
174
174
  @log.should_receive(:info).with("Completed <random uuid> in 10ms | 200 [http://my.com/foo/bar] | 11 bytes").once
175
175
  @client.request(:post, @path, @params, @options)
176
176
  end
@@ -530,27 +530,10 @@ describe RightScale::BalancedHttpClient do
530
530
  end
531
531
 
532
532
  context "when no exception" do
533
-
534
- context "and Log.level is :info with no host" do
535
- it "generates text containing path" do
536
- text = @client.send(:log_text, @path, {:value => 123}, [])
537
- text.should == "/foo/bar"
538
- end
539
- end
540
-
541
- context "and Log.level is :info with host" do
542
- it "generates text containing host and path" do
543
- text = @client.send(:log_text, @path, {:value => 123}, [], @url)
544
- text.should == "[http://my.com/foo/bar]"
545
- end
546
- end
547
-
548
- context "and Log.level is :debug" do
549
- it "generates text containing containing host, path, and filtered parameters" do
550
- @log.should_receive(:level).and_return(:debug)
551
- text = @client.send(:log_text, @path, {:some => "data", :secret => "data"}, ["secret"], @url)
552
- text.should == "[http://my.com/foo/bar {:some=>\"data\", :secret=>\"<hidden>\"}]"
553
- end
533
+ it "generates text containing containing host, path, and filtered parameters" do
534
+ @log.should_receive(:level).and_return(:debug)
535
+ text = @client.send(:log_text, @path, {:some => "data", :secret => "data"}, ["secret"], @url)
536
+ text.should == "[http://my.com/foo/bar {:some=>\"data\", :secret=>\"<hidden>\"}]"
554
537
  end
555
538
  end
556
539
 
@@ -593,6 +576,13 @@ describe RightScale::BalancedHttpClient do
593
576
  it "does not filter if params is not a hash" do
594
577
  @client.send(:filter, "params", ["secret"]).should == "params"
595
578
  end
579
+
580
+ it "also applies filters to any parameter named :payload or 'payload'" do
581
+ filter = ["secret", "very_secret"]
582
+ params = {:some => 1, :payload => {:secret => "data"}, "payload" => {:very_secret => "data"}, :secret => "data"}
583
+ @client.send(:filter, params, filter).should == {:some => 1, :payload => {:secret => "<hidden>"},
584
+ "payload" => { :very_secret => "<hidden>"}, :secret => "<hidden>"}
585
+ end
596
586
  end
597
587
 
598
588
  context :split do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Kirchhoff
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-08-25 00:00:00.000000000 Z
14
+ date: 2014-08-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: right_support