Class: Mihari::Emitters::PayloadTemplate
- Inherits:
-
ERB
- Object
- ERB
- Mihari::Emitters::PayloadTemplate
- Defined in:
- lib/mihari/emitters/webhook.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(artifacts:, rule:, options: {}) ⇒ PayloadTemplate
constructor
A new instance of PayloadTemplate.
- #result ⇒ Object
Constructor Details
#initialize(artifacts:, rule:, options: {}) ⇒ PayloadTemplate
32 33 34 35 36 37 38 |
# File 'lib/mihari/emitters/webhook.rb', line 32 def initialize(artifacts:, rule:, options: {}) @artifacts = artifacts @rule = rule @template = .fetch(:template, self.class.template) super(@template) end |
Class Method Details
.template ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mihari/emitters/webhook.rb', line 8 def self.template %{ { "rule": { "id": "<%= @rule.id %>", "title": "<%= @rule.title %>", "description": "<%= @rule.description %>" }, "artifacts": [ <% @artifacts.each_with_index do |artifact, idx| %> "<%= artifact.data %>" <%= ',' if idx < (@artifacts.length - 1) %> <% end %> ], "tags": [ <% @rule.tags.each_with_index do |tag, idx| %> "<%= tag %>" <%= ',' if idx < (@rule.tags.length - 1) %> <% end %> ] } } end |
Instance Method Details
#result ⇒ Object
40 41 42 |
# File 'lib/mihari/emitters/webhook.rb', line 40 def result super(binding) end |