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:) ⇒ Attack
Returns a new instance of Attack.
13
14
15
16
17
18
|
# File 'lib/aikido/zen/attack.rb', line 13
def initialize(context:, sink:, operation:)
@context = context
@operation = operation
@sink = sink
@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
44
45
46
47
48
49
50
51
|
# File 'lib/aikido/zen/attack.rb', line 44
def as_json
{
kind: kind,
blocked: blocked?,
metadata: metadata,
operation: @operation
}.merge(input.as_json)
end
|
#blocked? ⇒ Boolean
24
25
26
|
# File 'lib/aikido/zen/attack.rb', line 24
def blocked?
@blocked
end
|
#exception ⇒ Object
53
54
55
|
# File 'lib/aikido/zen/attack.rb', line 53
def exception(*)
raise NotImplementedError, "implement in subclasses"
end
|
#humanized_name ⇒ Object
28
29
30
|
# File 'lib/aikido/zen/attack.rb', line 28
def humanized_name
raise NotImplementedError, "implement in subclasses"
end
|
36
37
38
|
# File 'lib/aikido/zen/attack.rb', line 36
def input
raise NotImplementedError, "implement in subclasses"
end
|
#kind ⇒ Object
32
33
34
|
# File 'lib/aikido/zen/attack.rb', line 32
def kind
raise NotImplementedError, "implement in subclasses"
end
|
40
41
42
|
# File 'lib/aikido/zen/attack.rb', line 40
def metadata
raise NotImplementedError, "implement in subclasses"
end
|
#will_be_blocked! ⇒ Object
20
21
22
|
# File 'lib/aikido/zen/attack.rb', line 20
def will_be_blocked!
@blocked = true
end
|