Module: Uirusu::VTComment

Defined in:
lib/uirusu/vtcomment.rb

Overview

Module for submiting comments to Virustotal.com resources using the Virustotal.com public API

Constant Summary collapse

POST_URL =
Uirusu::VT_API + "/comments/put"

Class Method Summary collapse

Class Method Details

.post_comment(api_key, resource, comment) ⇒ JSON

Submits a comment to Virustotal.com for a specific resource

Parameters:

  • api_key (String)

    Virustotal.com API key

  • resource (String)

    MD5/sha1/sha256/scan_id to search for

  • comment (String)

    Comment to post to the resource

Returns:

  • (JSON)

    Parsed response



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/uirusu/vtcomment.rb', line 34

def self.post_comment(api_key, resource, comment)
	if api_key == nil
		raise "Invalid API Key"
	end

	if resource == nil
		raise "Invalid resource, must be a valid url"
	end

	if comment == nil
		raise "You must provide a comment to submit."
	end

	response = RestClient.post POST_URL, :apikey => api_key, :resource => resource, :comment => comment

	case response.code
		when 429, 204
			raise "Virustotal limit reached. Try again later."
		when 403
			raise "Invalid privileges, please check your API key."
		when 200
			JSON.parse(response)
		else
			raise "Unknown Server error."
	end
end