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, 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

#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

#changesetObject



38
39
40
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 38

def changeset
  @changeset
end

#filtered_body_paramsObject



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

def filtered_body_params
  @changeset.body_params
end

#filtered_query_paramsObject



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

def filtered_query_params
  @changeset.query_params
end

#matches_countObject



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_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_envObject



42
43
44
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 42

def original_env
  @original_env_parser.env
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



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_sObject



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

#urlObject



46
47
48
# File 'lib/sensitive_data_filter/middleware/occurrence.rb', line 46

def url
  SensitiveDataFilter::Mask.mask(@original_env_parser.url)
end