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"
GET_URL =
Uirusu::VT_API + "/comments/get"

Class Method Summary collapse

Class Method Details

.get_comments(api_key, resource, before = nil) ⇒ JSON

Retrieve a list of comments to Virustotal.com for a specific resource

Parameters:

  • api_key (String)

    Virustotal.com API key

  • resource (String)

    MD5/sha1/sha256/scan_id/URL to search for

  • before (DateTime) (defaults to: nil)

    A datetime token that allows you to iterate over all comments on a specific item whenever it has been commented on more than 25 times

Returns:

  • (JSON)

    Parsed response



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/uirusu/vtcomment.rb', line 59

def self.get_comments(api_key, resource, before=nil)
	if resource == nil
		raise "Invalid resource, must be a valid url"
	end

	params = {
		apikey: api_key,
		resource: resource
	}
	params[:before] = before unless before.nil?
	Uirusu.query_api GET_URL, params
end

.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



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/uirusu/vtcomment.rb', line 35

def self.post_comment(api_key, resource, comment)
	if resource == nil
		raise "Invalid resource, must be a valid url"
	end

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

	params = {
		apikey: api_key,
		resource: resource,
		comment: comment
	}
	Uirusu.query_api POST_URL, params
end