Class: Prevoty::ContentPayload

Inherits:
Object
  • Object
show all
Defined in:
lib/prevoty/content_payload.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ContentPayload

Returns a new instance of ContentPayload.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/prevoty/content_payload.rb', line 9

def initialize(data)
  @timestamp = data[:timestamp]
  @product = data[:product]
  @mode = data[:mode]
  @version = data[:version]
  @input = data[:input]
  @output = data[:output]
  @statistics = data[:statistics]
  @request_url = data[:request_url]
  @session_id = data[:session_id]
  @cookies = data[:cookies]
  @http_method = data[:http_method]
  @src_ip = data[:src_ip]
  @dest_host = data[:dest_host]
  @dest_port = data[:dest_port]
end

Instance Attribute Details

#cookiesObject

Returns the value of attribute cookies.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def cookies
  @cookies
end

#dest_hostObject

Returns the value of attribute dest_host.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def dest_host
  @dest_host
end

#dest_portObject

Returns the value of attribute dest_port.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def dest_port
  @dest_port
end

#http_methodObject

Returns the value of attribute http_method.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def http_method
  @http_method
end

#inputObject

Returns the value of attribute input.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def input
  @input
end

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def mode
  @mode
end

#outputObject

Returns the value of attribute output.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def output
  @output
end

#productObject

Returns the value of attribute product.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def product
  @product
end

#request_urlObject

Returns the value of attribute request_url.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def request_url
  @request_url
end

#session_idObject

Returns the value of attribute session_id.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def session_id
  @session_id
end

#src_ipObject

Returns the value of attribute src_ip.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def src_ip
  @src_ip
end

#statisticsObject

Returns the value of attribute statistics.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def statistics
  @statistics
end

#timestampObject

Returns the value of attribute timestamp.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def timestamp
  @timestamp
end

#versionObject

Returns the value of attribute version.



5
6
7
# File 'lib/prevoty/content_payload.rb', line 5

def version
  @version
end

Instance Method Details

#to_jsonObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/prevoty/content_payload.rb', line 26

def to_json
  case @mode
  when 'monitor'
    return {
      timestamp: @timestamp, product: @product, mode: @mode,
      version: @version, input: @input, statistics: @statistics,
      url: @request_url, session_id: @session_id, cookies: @cookies,
      http_method: @http_method, src_ip: @src_ip,
      dest_host: @dest_host, dest_port: @dest_port
    }.to_json
  when 'protect'
    return {
      timestamp: @timestamp, product: @product, mode: @mode,
      version: @version, input: @input, output: @output,
      statistics: @statistics, url: @request_url,
      session_id: @session_id, cookies: @cookies,
      http_method: @http_method, src_ip: @src_ip,
      dest_host: @dest_host, dest_port: @dest_port
    }.to_json
  end
end