Class: VirusTotal::API

Inherits:
Object
  • Object
show all
Defined in:
lib/virustotal/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: ENV["VIRUSTOTAL_API_KEY"]) ⇒ API

Returns a new instance of API.

Parameters:

  • key (String) (defaults to: ENV["VIRUSTOTAL_API_KEY"])

    VirusTotal API key

Raises:

  • (ArgumentError)

    When given an empty key



13
14
15
16
17
# File 'lib/virustotal/api.rb', line 13

def initialize(key: ENV["VIRUSTOTAL_API_KEY"])
  @key = key

  raise ArgumentError, "No API key has been found or provided! (setup your VIRUSTOTAL_API_KEY environment varialbe)" unless key
end

Instance Attribute Details

#keyString (readonly)

Returns VirusTotal API key.

Returns:

  • (String)

    VirusTotal API key



6
7
8
# File 'lib/virustotal/api.rb', line 6

def key
  @key
end

Instance Method Details

#analysisVirusTotal::Client::Analysis

Analyses API endpoint client



24
25
26
# File 'lib/virustotal/api.rb', line 24

def analysis
  @analysis ||= Client::Analysis.new(key: key)
end

#domainVirusTotal::Client::Domain

Domains API endpoint client



33
34
35
# File 'lib/virustotal/api.rb', line 33

def domain
  @domain ||= Client::Domain.new(key: key)
end

#fileVirusTotal::Client::File

Files API endpoint client



42
43
44
# File 'lib/virustotal/api.rb', line 42

def file
  @file ||= Client::File.new(key: key)
end

#graphVirusTotal::Client::Graph

Graphs API endpoint client



69
70
71
# File 'lib/virustotal/api.rb', line 69

def graph
  @graph ||= Client::Graph.new(key: key)
end

#ip_addressVirusTotal::Client::IPAddress

IP addresses API endpoint client



51
52
53
# File 'lib/virustotal/api.rb', line 51

def ip_address
  @ip_address ||= Client::IPAddress.new(key: key)
end

#urlVirusTotal::Client::URL

URLs API endpoint client



60
61
62
# File 'lib/virustotal/api.rb', line 60

def url
  @url ||= Client::URL.new(key: key)
end