Class: SensitiveDataFilter::Middleware::Occurrence
- Inherits:
-
Object
- Object
- SensitiveDataFilter::Middleware::Occurrence
- Extended by:
- Forwardable
- Defined in:
- lib/sensitive_data_filter/middleware/occurrence.rb
Instance Attribute Summary collapse
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
Instance Method Summary collapse
- #changeset ⇒ Object
- #filtered_body_params ⇒ Object
- #filtered_query_params ⇒ Object
-
#initialize(original_env_parser, changeset, matches) ⇒ Occurrence
constructor
A new instance of Occurrence.
- #matches_count ⇒ Object
- #origin_ip ⇒ Object
- #original_body_params ⇒ Object
- #original_env ⇒ Object
- #original_query_params ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize(original_env_parser, changeset, matches) ⇒ Occurrence
Returns a new instance of Occurrence.
12 13 14 15 16 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 12 def initialize(original_env_parser, changeset, matches) @original_env_parser = original_env_parser @changeset = changeset @matches = matches end |
Instance Attribute Details
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
10 11 12 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 10 def matches @matches end |
Instance Method Details
#changeset ⇒ Object
38 39 40 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 38 def changeset @changeset end |
#filtered_body_params ⇒ Object
34 35 36 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 34 def filtered_body_params @changeset.body_params end |
#filtered_query_params ⇒ Object
30 31 32 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 30 def filtered_query_params @changeset.query_params end |
#matches_count ⇒ Object
52 53 54 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 52 def matches_count @matches.map { |type, matches| [type, matches.count] }.to_h end |
#origin_ip ⇒ Object
18 19 20 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 18 def origin_ip @original_env_parser.ip end |
#original_body_params ⇒ Object
26 27 28 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 26 def original_body_params @original_env_parser.body_params end |
#original_env ⇒ Object
42 43 44 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 42 def original_env @original_env_parser.env end |
#original_query_params ⇒ Object
22 23 24 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 22 def original_query_params @original_env_parser.query_params end |
#to_h ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 56 def to_h { origin_ip: origin_ip, request_method: request_method, url: url, content_type: content_type, filtered_query_params: filtered_query_params, filtered_body_params: filtered_body_params, session: session, matches_count: matches_count } end |
#to_s ⇒ Object
69 70 71 72 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 69 def to_s "[SensitiveDataFilter] Sensitive Data detected and masked:\n" + to_h.map { |attribute, value| "#{attribute.to_s.titlecase}: #{value}" }.join("\n") end |
#url ⇒ Object
46 47 48 |
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 46 def url SensitiveDataFilter::Mask.mask(@original_env_parser.url) end |