Class: Wafris::WafrisRequest
- Inherits:
-
Object
- Object
- Wafris::WafrisRequest
- Defined in:
- lib/wafris/wafris_request.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#request_timestamp ⇒ Object
readonly
Returns the value of attribute request_timestamp.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
- #data(treatment:, category:, rule:) ⇒ Object
-
#initialize(request, env) ⇒ WafrisRequest
constructor
A new instance of WafrisRequest.
Constructor Details
#initialize(request, env) ⇒ WafrisRequest
Returns a new instance of WafrisRequest.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/wafris/wafris_request.rb', line 8 def initialize(request, env) @ip = encode_to_utf8(IpResolver.new(request).resolve) @user_agent = encode_to_utf8(request.user_agent) @path = encode_to_utf8(request.path) @parameters = encode_to_utf8(Rack::Utils.build_query(request.params)) @host = encode_to_utf8(request.host.to_s) @method = encode_to_utf8(request.request_method) @headers = extract_headers(env) @request_id = env.fetch("action_dispatch.request_id", SecureRandom.uuid.to_s) @request_timestamp = Time.now.utc.to_i end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def host @host end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def ip @ip end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def method @method end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def parameters @parameters end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def path @path end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def request_id @request_id end |
#request_timestamp ⇒ Object (readonly)
Returns the value of attribute request_timestamp.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def @request_timestamp end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
5 6 7 |
# File 'lib/wafris/wafris_request.rb', line 5 def user_agent @user_agent end |
Instance Method Details
#data(treatment:, category:, rule:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wafris/wafris_request.rb', line 20 def data(treatment:, category:, rule:) { ip: @ip, user_agent: @user_agent, path: @path, parameter: @parameters, host: @host, method: @method, request_id: @request_id, timestamp: @request_timestamp, treatment: treatment, category: category, rule: rule } end |