data_importer/app/models/cisa_known_exploit.rb

15 lines
382 B
Ruby

# frozen_string_literal: true
class CisaKnownExploit < ActiveRecord::Base
def self.find_by_id(id)
find_by(cve_id: id)
end
def self.cve_id(cve_id)
last.vulnerabilities.select { |vuln| vuln if vuln.dig('cve_id') == cve_id }
end
def self.cves_from_year(year)
last.vulnerabilities.select { |vuln| vuln if vuln.dig('cve_id') =~ /CVE-#{year}-\d{4,7}/ }
end
end