Class: Mihari::Emitters::PayloadTemplate

Inherits:
ERB
  • Object
show all
Defined in:
lib/mihari/emitters/http.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title:, description:, artifacts:, source:, tags:, options: {}) ⇒ PayloadTemplate

Returns a new instance of PayloadTemplate.



30
31
32
33
34
35
36
37
38
39
# File 'lib/mihari/emitters/http.rb', line 30

def initialize(title:, description:, artifacts:, source:, tags:, options: {})
  @title = title
  @description = description
  @artifacts = artifacts
  @source = source
  @tags = tags

  @template = options.fetch(:template, self.class.template)
  super(@template)
end

Class Method Details

.templateObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mihari/emitters/http.rb', line 8

def self.template
  %{
          {
"title": "<%= @title %>",
"description": "<%= @description %>",
"source": "<%= @source %>",
"artifacts": [
  <% @artifacts.each_with_index do |artifact, idx| %>
    "<%= artifact.data %>"
    <%= ',' if idx < (@artifacts.length - 1) %>
  <% end %>
],
"tags": [
  <% @tags.each_with_index do |tag, idx| %>
    "<%= tag %>"
    <%= ',' if idx < (@tags.length - 1) %>
  <% end %>
]
          }
        }
end

Instance Method Details

#resultObject



41
42
43
# File 'lib/mihari/emitters/http.rb', line 41

def result
  super(binding)
end