Class: Mihari::Emitters::TheHive
- Inherits:
-
Base
- Object
- Base
- Mihari::Emitters::TheHive
show all
- Defined in:
- lib/mihari/emitters/the_hive.rb
Constant Summary
Mixins::Retriable::DEFAULT_ON
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Base
inherited, #run
#retry_on_error
#configuration_values, #configured?
Constructor Details
#initialize(*args, **kwargs) ⇒ TheHive
Returns a new instance of TheHive.
17
18
19
20
21
22
23
|
# File 'lib/mihari/emitters/the_hive.rb', line 17
def initialize(*args, **kwargs)
super(*args, **kwargs)
@api_endpoint = kwargs[:api_endpoint] || Mihari.config.thehive_api_endpoint
@api_key = kwargs[:api_key] || Mihari.config.thehive_api_key
@api_version = kwargs[:api_version] || Mihari.config.thehive_api_version
end
|
Instance Attribute Details
#api_endpoint ⇒ String?
9
10
11
|
# File 'lib/mihari/emitters/the_hive.rb', line 9
def api_endpoint
@api_endpoint
end
|
#api_key ⇒ String?
12
13
14
|
# File 'lib/mihari/emitters/the_hive.rb', line 12
def api_key
@api_key
end
|
#api_version ⇒ String?
15
16
17
|
# File 'lib/mihari/emitters/the_hive.rb', line 15
def api_version
@api_version
end
|
Instance Method Details
#emit(title:, description:, artifacts:, tags: [], **_options) ⇒ Object
30
31
32
33
34
35
|
# File 'lib/mihari/emitters/the_hive.rb', line 30
def emit(title:, description:, artifacts:, tags: [], **_options)
return if artifacts.empty?
payload = payload(title: title, description: description, artifacts: artifacts, tags: tags)
api.alert.create(**payload)
end
|
#normalized_api_version ⇒ String?
Normalize API version for API client
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/mihari/emitters/the_hive.rb', line 44
def normalized_api_version
@normalized_api_version ||= [].tap do |out|
table = {
"" => nil,
"v4" => nil,
"v5" => "v1"
}
out << table[api_version.to_s.downcase]
end.first
end
|
#valid? ⇒ Boolean
26
27
28
|
# File 'lib/mihari/emitters/the_hive.rb', line 26
def valid?
api_endpont? && api_key? && ping?
end
|