Sha256: e87bcf8ef1f75b1965c0da4733c544155d639fca3745b2e0e6a78659e4f89df9
Contents?: true
Size: 1.17 KB
Versions: 3
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require "uri" module Miteru class Attachement attr_reader :url def initialize(url) @url = url end def to_a [ { text: defanged_url, fallback: "VT & urlscan.io links", actions: actions } ] end private def actions [vt_link, urlscan_link].compact end def vt_link return nil unless _vt_link { type: "button", text: "Lookup on VirusTotal", url: _vt_link } end def urlscan_link return nil unless _urlscan_link { type: "button", text: "Lookup on urlscan.io", url: _urlscan_link } end def defanged_url @defanged_url ||= url.to_s.gsub(/\./, "[.]") end def domain @domain ||= [].tap do |out| out << URI(url).hostname rescue URI::Error => _e out << nil end.first end def _urlscan_link return nil unless domain "https://urlscan.io/domain/#{domain}" end def _vt_link return nil unless domain "https://www.virustotal.com/#/domain/#{domain}" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
miteru-1.2.2 | lib/miteru/attachement.rb |
miteru-1.2.1 | lib/miteru/attachement.rb |
miteru-1.2.0 | lib/miteru/attachement.rb |