From 763de4b83d71f4d43463226a305ef8136da24e20 Mon Sep 17 00:00:00 2001 From: Brendan McDevitt Date: Wed, 27 Apr 2022 01:20:40 -0500 Subject: [PATCH] added some methods for querying the vuln data --- app/models/cisa_known_exploit.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models/cisa_known_exploit.rb b/app/models/cisa_known_exploit.rb index 27e0b2c..4ae7e21 100644 --- a/app/models/cisa_known_exploit.rb +++ b/app/models/cisa_known_exploit.rb @@ -12,4 +12,12 @@ class CisaKnownExploit < ActiveRecord::Base def self.cves_from_year(year) last.vulnerabilities.select { |vuln| vuln if vuln.dig('cve_id') =~ /CVE-#{year}-\d{4,7}/ } end + + def self.by_product(product_name) + last.vulnerabilities.select {|vuln| vuln if vuln.dig('product') == product_name } + end + + def self.by_due_date(due_date) + last.vulnerabilities.select {|vuln| vuln if vuln.dig('due_date') == due_date } + end end