Class: Fushin::Models::Attachment

Inherits:
Model
  • Object
show all
Defined in:
lib/fushin/models/attachment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Attachment

Returns a new instance of Attachment.



7
8
9
# File 'lib/fushin/models/attachment.rb', line 7

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/fushin/models/attachment.rb', line 6

def url
  @url
end

Instance Method Details



22
23
24
# File 'lib/fushin/models/attachment.rb', line 22

def ha_link
  "https://www.hybrid-analysis.com/sample/#{sha256}/"
end

#sha256Object



11
12
13
14
15
16
# File 'lib/fushin/models/attachment.rb', line 11

def sha256
  @sha256 ||= [].tap do |out|
    res = HybridAnalysis.quick_url_scan(url)
    out << res.dig("sha256")
  end.first
end

#titleObject



18
19
20
# File 'lib/fushin/models/attachment.rb', line 18

def title
  "HA: #{sha256}"
end

#to_attachementsObject



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fushin/models/attachment.rb', line 26

def to_attachements
  [
    {
      fallback: "HA link",
      title: title,
      title_link: ha_link,
      footer: "hybrid-analysis.com",
      footer_icon: "http://www.google.com/s2/favicons?domain=hybrid-analysis.com"
    }
  ]
end