Class: Mihari::Emitters::Webhook

Inherits:
Base
  • Object
show all
Defined in:
lib/mihari/emitters/webhook.rb

Constant Summary

Constants included from Mixins::Retriable

Mixins::Retriable::DEFAULT_ON

Instance Method Summary collapse

Methods inherited from Base

inherited, #initialize, #run

Methods included from Mixins::Retriable

#retry_on_error

Methods included from Mixins::Configurable

#configuration_values, #configured?

Constructor Details

This class inherits a constructor from Mihari::Emitters::Base

Instance Method Details

#emit(title:, description:, artifacts:, source:, tags:) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/mihari/emitters/webhook.rb', line 11

def emit(title:, description:, artifacts:, source:, tags:)
  return if artifacts.empty?

  headers = { "content-type": "application/x-www-form-urlencoded" }
  headers["content-type"] = "application/json" if use_json_body?

  emitter = Emitters::HTTP.new(uri: Mihari.config.webhook_url)
  emitter.emit(title: title, description: description, artifacts: artifacts, source: source, tags: tags)
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/mihari/emitters/webhook.rb', line 7

def valid?
  webhook_url?
end