Class: Aikido::Zen::Attack
- Inherits:
-
Object
- Object
- Aikido::Zen::Attack
show all
- Defined in:
- lib/aikido/zen/attack.rb
Overview
Attack objects gather information about a type of detected attack. They can be used in a few ways, like for reporting an attack event to the Aikido server, or can be raised as errors to block requests if blocking_mode is on.
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(context:, sink:, operation:, stack: nil) ⇒ Attack
Returns a new instance of Attack.
13
14
15
16
17
18
19
|
# File 'lib/aikido/zen/attack.rb', line 13
def initialize(context:, sink:, operation:, stack: nil)
@context = context
@operation = operation
@sink = sink
@stack = stack
@blocked = false
end
|
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
9
10
11
|
# File 'lib/aikido/zen/attack.rb', line 9
def context
@context
end
|
#operation ⇒ Object
Returns the value of attribute operation.
10
11
12
|
# File 'lib/aikido/zen/attack.rb', line 10
def operation
@operation
end
|
#sink ⇒ Object
Returns the value of attribute sink.
11
12
13
|
# File 'lib/aikido/zen/attack.rb', line 11
def sink
@sink
end
|
Instance Method Details
#as_json ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/aikido/zen/attack.rb', line 45
def as_json
{
kind: kind,
blocked: blocked?,
metadata: metadata,
operation: @operation,
stack: @stack
}.compact.merge(input.as_json)
end
|
#blocked? ⇒ Boolean
25
26
27
|
# File 'lib/aikido/zen/attack.rb', line 25
def blocked?
@blocked
end
|
#exception ⇒ Object
55
56
57
|
# File 'lib/aikido/zen/attack.rb', line 55
def exception(*)
raise NotImplementedError, "implement in subclasses"
end
|
#humanized_name ⇒ Object
29
30
31
|
# File 'lib/aikido/zen/attack.rb', line 29
def humanized_name
raise NotImplementedError, "implement in subclasses"
end
|
37
38
39
|
# File 'lib/aikido/zen/attack.rb', line 37
def input
raise NotImplementedError, "implement in subclasses"
end
|
#kind ⇒ Object
33
34
35
|
# File 'lib/aikido/zen/attack.rb', line 33
def kind
raise NotImplementedError, "implement in subclasses"
end
|
41
42
43
|
# File 'lib/aikido/zen/attack.rb', line 41
def metadata
raise NotImplementedError, "implement in subclasses"
end
|
#will_be_blocked! ⇒ Object
21
22
23
|
# File 'lib/aikido/zen/attack.rb', line 21
def will_be_blocked!
@blocked = true
end
|