class Mihari::Emitters::Slack
Public Instance Methods
emit(title:, description:, artifacts:, tags: [], **_options)
click to toggle source
# File lib/mihari/emitters/slack.rb, line 153 def emit(title:, description:, artifacts:, tags: [], **_options) return if artifacts.empty? attachments = to_attachments(artifacts) text = to_text(title: title, description: description, tags: tags) notifier.notify(text: text, attachments: attachments) end
notifier()
click to toggle source
# File lib/mihari/emitters/slack.rb, line 113 def notifier @notifier ||= Notifiers::Slack.new end
to_attachments(artifacts)
click to toggle source
Build attachements
@param [Array<Mihari::Artifact>] artifacts
@return [Array<Mihari::Emitters::Attachment>]
# File lib/mihari/emitters/slack.rb, line 128 def to_attachments(artifacts) artifacts.map do |artifact| Attachment.new(data: artifact.data, data_type: artifact.data_type).to_a end.flatten end
to_text(title:, description:, tags: [])
click to toggle source
Build a text
@param [String] title @param [String] description @param [Array<String>] tags
@return [String]
# File lib/mihari/emitters/slack.rb, line 143 def to_text(title:, description:, tags: []) tags = ["N/A"] if tags.empty? [ "*#{title}*", "*Desc.*: #{description}", "*Tags*: #{tags.join(", ")}" ].join("\n") end
valid?()
click to toggle source
# File lib/mihari/emitters/slack.rb, line 117 def valid? notifier.valid? end
Private Instance Methods
configuration_keys()
click to toggle source
# File lib/mihari/emitters/slack.rb, line 164 def configuration_keys %w[slack_webhook_url] end