summaryrefslogtreecommitdiff
path: root/app/jobs/fingerprint_lookup_job.rb
blob: 849d9cb32cc3b72e136d949c700213324d3f4643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class FingerprintLookupJob < ActiveJob::Base
  #ENDPOINT = "https://www.virustotal.com/vtapi/v2/file/report"
  ENDPOINT = "https://www.virustotal.com/api/get_file_report.json"
  queue_as :default

  def perform(fingerprint)
    response = Typhoeus.post(ENDPOINT, params: {
      resource: fingerprint,
      apiKey: ENV.fetch("VIRUS_TOTAL_API_KEY"),
    })
    report = JSON.parse(response.response_body)
    disposition = Disposition.find_by(fingerprint: fingerprint)
    disposition.file_reports.create!(data: report)
  end
end