ratchetio 0.4.6 → 0.4.7

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.
data/.travis.yml CHANGED
@@ -10,3 +10,6 @@ rvm:
10
10
  - jruby-head
11
11
  - rbx-18mode
12
12
  - rbx-19mode
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ **0.4.7**
4
+ - Sensitive params now scrubbed out of requests. Param name list is customizable via the `scrub_fields` config option.
5
+
3
6
  **0.4.6**
4
7
  - Add support to play nicely with Goalie.
5
8
 
@@ -17,6 +17,7 @@ module Ratchetio
17
17
  attr_accessor :person_username_method
18
18
  attr_accessor :person_email_method
19
19
  attr_accessor :root
20
+ attr_accessor :scrub_fields
20
21
 
21
22
  DEFAULT_ENDPOINT = 'https://submit.ratchet.io/api/1/item/'
22
23
 
@@ -34,6 +35,7 @@ module Ratchetio
34
35
  @person_id_method = 'id'
35
36
  @person_username_method = 'username'
36
37
  @person_email_method = 'email'
38
+ @scrub_fields = [:passwd, :password, :secret]
37
39
  end
38
40
 
39
41
  # allow params to be read like a hash
@@ -35,6 +35,7 @@ module Ratchetio
35
35
 
36
36
  def ratchetio_filter_params(params)
37
37
  filtered = {}
38
+
38
39
  params.to_hash.each_pair do |k,v|
39
40
  if v.is_a? ActionDispatch::Http::UploadedFile
40
41
  # only save content_type, original_filename, and length
@@ -49,6 +50,8 @@ module Ratchetio
49
50
  end
50
51
  elsif v.is_a? Hash
51
52
  filtered[k] = ratchetio_filter_params v
53
+ elsif Ratchetio.configuration.scrub_fields.include? k
54
+ filtered[k] = "*" * v.length
52
55
  else
53
56
  filtered[k] = v
54
57
  end
@@ -1,3 +1,3 @@
1
1
  module Ratchetio
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
data/lib/ratchetio.rb CHANGED
@@ -24,6 +24,11 @@ module Ratchetio
24
24
  def configure
25
25
  yield(configuration)
26
26
  end
27
+
28
+ def reconfigure
29
+ @configuration = Configuration.new
30
+ yield(configuration)
31
+ end
27
32
 
28
33
  # Returns the configuration object.
29
34
  #
@@ -148,8 +153,11 @@ module Ratchetio
148
153
 
149
154
  uri = URI.parse(configuration.endpoint)
150
155
  http = Net::HTTP.new(uri.host, uri.port)
151
- http.use_ssl = true
152
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
156
+
157
+ if uri.scheme == 'https'
158
+ http.use_ssl = true
159
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
160
+ end
153
161
 
154
162
  request = Net::HTTP::Post.new(uri.request_uri)
155
163
  request.body = payload
@@ -3,7 +3,12 @@ require 'spec_helper'
3
3
  describe HomeController do
4
4
 
5
5
  before(:each) do
6
+ reset_configuration
6
7
  Ratchetio.configure do |config|
8
+ config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
9
+ config.environment = ::Rails.env
10
+ config.root = ::Rails.root
11
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
7
12
  config.logger = logger_mock
8
13
  end
9
14
  end
@@ -84,6 +89,42 @@ describe HomeController do
84
89
  filtered_file[:original_filename].should == file_hash[:filename]
85
90
  filtered_file[:size].should == file_hash[:tempfile].size
86
91
  end
92
+
93
+ it "should scrub the default scrub_fields" do
94
+ params = {
95
+ :passwd => "hidden",
96
+ :password => "hidden",
97
+ :secret => "hidden",
98
+ :notpass => "visible"
99
+ }
100
+
101
+ filtered = controller.send(:ratchetio_filter_params, params)
102
+
103
+ filtered[:passwd].should == "******"
104
+ filtered[:password].should == "******"
105
+ filtered[:secret].should == "******"
106
+ filtered[:notpass].should == "visible"
107
+ end
108
+
109
+ it "should scrub custom scrub_fields" do
110
+ Ratchetio.configure do |config|
111
+ config.scrub_fields = [:notpass, :secret]
112
+ end
113
+
114
+ params = {
115
+ :passwd => "visible",
116
+ :password => "visible",
117
+ :secret => "hidden",
118
+ :notpass => "hidden"
119
+ }
120
+
121
+ filtered = controller.send(:ratchetio_filter_params, params)
122
+
123
+ filtered[:passwd].should == "visible"
124
+ filtered[:password].should == "visible"
125
+ filtered[:secret].should == "******"
126
+ filtered[:notpass].should == "******"
127
+ end
87
128
  end
88
129
 
89
130
  context "ratchetio_request_url" do
@@ -285,27 +285,4 @@ describe Ratchetio do
285
285
  'aaaabbbbccccddddeeeeffff00001111'
286
286
  end
287
287
 
288
- def reset_configuration
289
- Ratchetio.configure do |config|
290
- config.access_token = nil
291
- config.branch = nil
292
- config.default_logger = lambda { Logger.new(STDERR) }
293
- config.enabled = true
294
- config.endpoint = Ratchetio::Configuration::DEFAULT_ENDPOINT
295
- config.environment = nil
296
- config.exception_level_filters = {
297
- 'ActiveRecord::RecordNotFound' => 'warning',
298
- 'AbstractController::ActionNotFound' => 'warning',
299
- 'ActionController::RoutingError' => 'warning'
300
- }
301
- config.framework = 'Plain'
302
- config.logger = nil
303
- config.person_method = 'current_user'
304
- config.person_id_method = 'id'
305
- config.person_username_method = 'username'
306
- config.person_email_method = 'email'
307
- config.root = nil
308
- end
309
- end
310
-
311
288
  end
data/spec/spec_helper.rb CHANGED
@@ -26,5 +26,10 @@ RSpec.configure do |config|
26
26
  config.after(:each) do
27
27
  DatabaseCleaner.clean
28
28
  end
29
+
29
30
  end
30
31
 
32
+ def reset_configuration
33
+ Ratchetio.reconfigure do |config|
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratchetio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2012-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails