Class: SensitiveDataFilter::Middleware::Occurrence

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sensitive_data_filter/middleware/occurrence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_env_parser, filtered_env_parser, matches) ⇒ Occurrence



12
13
14
15
16
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 12

def initialize(original_env_parser, filtered_env_parser, matches)
  @original_env_parser = original_env_parser
  @filtered_env_parser = filtered_env_parser
  @matches             = matches
end

Instance Attribute Details

#matchesObject (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

#filtered_body_paramsObject



34
35
36
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 34

def filtered_body_params
  @filtered_env_parser.body_params
end

#filtered_query_paramsObject



30
31
32
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 30

def filtered_query_params
  @filtered_env_parser.query_params
end

#matches_countObject



40
41
42
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 40

def matches_count
  @matches.map { |type, matches| [type, matches.count] }.to_h
end

#origin_ipObject



18
19
20
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 18

def origin_ip
  @original_env_parser.ip
end

#original_body_paramsObject



26
27
28
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 26

def original_body_params
  @original_env_parser.body_params
end

#original_query_paramsObject



22
23
24
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 22

def original_query_params
  @original_env_parser.query_params
end

#to_hObject



44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 44

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_sObject



57
58
59
60
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 57

def to_s
  "[SensitiveDataFilter] Sensitive Data detected and masked:\n" +
    to_h.map { |attribute, value| "#{attribute.to_s.titlecase}: #{value}" }.join("\n")
end