added route for cisa known exploits
This commit is contained in:
parent
db1ef2e01a
commit
01a9373cfd
3 changed files with 10 additions and 3 deletions
|
@ -7,7 +7,7 @@ class CisaKnownExploitsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@cisa_known_exploit = CisaKnownExploit.find(params[:cve_id])
|
||||
@cisa_known_exploit = CisaKnownExploit.cve_id(params[:cve_id])
|
||||
render json: @cisa_known_exploit.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,11 @@ class CisaKnownExploit < ActiveRecord::Base
|
|||
find_by(cve_id: id)
|
||||
end
|
||||
|
||||
def self.from_year(year)
|
||||
where('cve_id LIKE ?', "CVE-#{year}-%")
|
||||
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
|
||||
|
|
|
@ -41,4 +41,7 @@ Rails.application.routes.draw do
|
|||
get '/gsds', to: 'gsds#index'
|
||||
get '/gsds/:gsd_id', to: 'gsds#show'
|
||||
get '/gsds/years/:year', to: 'gsds#show_year'
|
||||
|
||||
get '/cisa_known_exploits', to: 'cisa_known_exploits#index'
|
||||
get '/cisa_known_exploits/cve/:cve_id', to: 'cisa_known_exploits#show'
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue