sensitive_data_filter 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70cedcd682fd58e3d8682c603bc8326c36e7b8ec
4
- data.tar.gz: aee8dcf45f48b651e85507a6d0e0b02fe8fbb071
3
+ metadata.gz: 0a727bd4717ff795773bc06f5c9095ac86fa6deb
4
+ data.tar.gz: af91b7050220d8899957e9f1014710d4a0bbc374
5
5
  SHA512:
6
- metadata.gz: fc6618c4cdad98edb6899779d93b15a1cbfc5c8b650d2cce604f40b2c9178d24cf9000753ecf512ee82b99a17e580f8750cf3019ac6f0777532a417d32ffc8d9
7
- data.tar.gz: 1f126f0eec67bc0c8bc74d7bb50e6121056a8113ce35454ba2fc7d1c36d6db74ede0736050515b96e53467d433844f6eef1a545554a01d58898fef0d117bf9eb
6
+ metadata.gz: 817f86816d181448c51edce12b6b43c4a341ed805e03523254c76cc7da8680af14fdfb7c3c5ef05b1ca0800337231af24c06699e6f1ebbf3070cf926eedf79d1
7
+ data.tar.gz: e8863e690284d3e479069bf9e0730448bf437c234d8e6e0ceb79e4f12e464f631e5468d596d158b810c28a408177c2ffde72cbcccd4c0785f779c28600bfd9d6
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This changelog adheres to [Keep a CHANGELOG](http://keepachangelog.com/).
5
5
 
6
+ ## [0.2.1] - 2016-12-19
7
+ ### Changed
8
+ - Updates README for usage with Rails
9
+
10
+ ### Fixed
11
+ - Handles JSON parsing exceptions gracefully
12
+
6
13
  ## [0.2.0] - 2016-12-13
7
14
  ### Added
8
15
  - Occurrence exposes content type
data/README.md CHANGED
@@ -28,11 +28,13 @@ Or install it yourself as:
28
28
 
29
29
  ### Enable the middleware
30
30
 
31
+ Insert the middleware in the stack before any parameter parsing is performed
32
+
31
33
  E.g. for Rails, add the following in application.rb
32
34
 
33
35
  ```ruby
34
36
  # --- Sensitive Data Filtering ---
35
- config.middleware.use SensitiveDataFilter::Middleware::Filter
37
+ config.middleware.insert_before 'ActionDispatch::ParamsParser', SensitiveDataFilter::Middleware::Filter
36
38
  ```
37
39
 
38
40
  ### Configuration
@@ -97,7 +99,9 @@ The arguments for `config.register_parser` are:
97
99
  * a parser for the parameters
98
100
  * an unparser to convert parameters back to the encoded format
99
101
 
100
- The parser and unparser must be objects that respond to `call` and accept the parameters as an argument (e.g. procs or lambdas).
102
+ The parser and unparser must be objects that respond to `call` and accept the parameters as an argument (e.g. procs or lambdas).
103
+ The parser should handle parsing exceptions gracefully by returning the arguments.
104
+ This ensures that sensitive data scanning and masking is applied on the raw parameters.
101
105
 
102
106
  ## Development
103
107
 
@@ -40,9 +40,23 @@ module SensitiveDataFilter
40
40
  ->(params) { Rack::Utils.parse_query(params) },
41
41
  ->(params) { Rack::Utils.build_query(params) }),
42
42
  new('json', # e.g.: 'application/json'
43
- ->(params) { JSON.parse(params) },
44
- ->(params) { JSON.unparse(params) })
43
+ ->(params) { JsonParser.parse(params) },
44
+ ->(params) { JsonParser.unparse(params) })
45
45
  ].freeze
46
+
47
+ class JsonParser
48
+ def self.parse(params)
49
+ JSON.parse(params)
50
+ rescue JSON::ParserError
51
+ params
52
+ end
53
+
54
+ def self.unparse(params)
55
+ JSON.unparse(params)
56
+ rescue JSON::GeneratorError
57
+ params
58
+ end
59
+ end
46
60
  end
47
61
  end
48
62
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SensitiveDataFilter
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensitive_data_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Berardi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-12-13 00:00:00.000000000 Z
12
+ date: 2016-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack