Class: Mihari::AlertViewer
- Inherits:
-
Object
- Object
- Mihari::AlertViewer
- Defined in:
- lib/mihari/alert_viewer.rb
Constant Summary collapse
- ALERT_KEYS =
%w(title description artifacts tags createdAt status).freeze
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#the_hive ⇒ Object
readonly
Returns the value of attribute the_hive.
Instance Method Summary collapse
-
#initialize(limit: 5) ⇒ AlertViewer
constructor
A new instance of AlertViewer.
- #list ⇒ Object
Constructor Details
#initialize(limit: 5) ⇒ AlertViewer
Returns a new instance of AlertViewer.
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
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/mihari/alert_viewer.rb', line 5 def limit @limit end |
#the_hive ⇒ Object (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
#list ⇒ Object
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 |