Class: Mihari::AlertViewer

Inherits:
Object
  • Object
show all
Defined in:
lib/mihari/alert_viewer.rb

Constant Summary collapse

ALERT_KEYS =
%w(title description artifacts tags createdAt status).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(limit: 5) ⇒ AlertViewer

Returns a new instance of AlertViewer.

Raises:



10
11
12
13
14
15
16
# File 'lib/mihari/alert_viewer.rb', line 10

def initialize(limit: 5)
  @limit = limit
  validate_limit

  @the_hive = TheHive.new
  raise Error, "Cannot connect to the TheHive instance" unless the_hive.valid?
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



5
6
7
# File 'lib/mihari/alert_viewer.rb', line 5

def limit
  @limit
end

#the_hiveObject (readonly)

Returns the value of attribute the_hive.



6
7
8
# File 'lib/mihari/alert_viewer.rb', line 6

def the_hive
  @the_hive
end

Instance Method Details

#listObject



18
19
20
21
22
# File 'lib/mihari/alert_viewer.rb', line 18

def list
  range = limit == "all" ? "all" : "0-#{limit}"
  alerts = the_hive.alert.list(range: range)
  alerts.map { |alert| convert alert }
end