Sha256: 1b3ad3eae5d7b9038f71e12515f75f32952a469f5ea22b63a318d8c47fd3448e

Contents?: true

Size: 824 Bytes

Versions: 6

Compression:

Stored size: 824 Bytes

Contents

# frozen_string_literal: true

require "json"
require "http"

module Fushin
  class HybridAnalysis
    BASE_URL = "https://www.hybrid-analysis.com"
    VERSION = "v2"

    def quick_url_scan(url)
      payload = {
        scan_type: "all",
        url: url
      }
      res = HTTP.headers(default_headers).post(url_for("/quick-scan/url-to-file"), form: payload)
      res.code == 200 ? JSON.parse(res.body.to_s) : nil
    end

    def self.quick_url_scan(url)
      new.quick_url_scan(url)
    end

    private

    def api_key
      @api_key ||= ENV.fetch("HA_API_KEY")
    end

    def default_headers
      {
        "accept" => "application/json",
        "api-key" => api_key,
        "user-agent" => "Falcon Sandbox",
      }
    end

    def url_for(path)
      "#{BASE_URL}/api/#{VERSION}#{path}"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fushin-0.3.4 lib/fushin/hybrid_analysis.rb
fushin-0.3.3 lib/fushin/hybrid_analysis.rb
fushin-0.3.2 lib/fushin/hybrid_analysis.rb
fushin-0.3.1 lib/fushin/hybrid_analysis.rb
fushin-0.3.0 lib/fushin/hybrid_analysis.rb
fushin-0.2.0 lib/fushin/hybrid_analysis.rb