Class: Aikido::Zen::Attack

Inherits:
Object
  • Object
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

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/aikido/zen/attack.rb', line 9

def context
  @context
end

#operationObject (readonly)

Returns the value of attribute operation.



10
11
12
# File 'lib/aikido/zen/attack.rb', line 10

def operation
  @operation
end

#sinkObject

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_jsonObject

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/aikido/zen/attack.rb', line 32

def as_json
  raise NotImplementedError, "implement in subclasses"
end

#blocked?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/aikido/zen/attack.rb', line 24

def blocked?
  @blocked
end

#exceptionObject

Raises:

  • (NotImplementedError)


36
37
38
# File 'lib/aikido/zen/attack.rb', line 36

def exception(*)
  raise NotImplementedError, "implement in subclasses"
end

#log_messageObject

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/aikido/zen/attack.rb', line 28

def log_message
  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