add route
This commit is contained in:
parent
763de4b83d
commit
3a32d6086f
3 changed files with 9 additions and 2 deletions
|
@ -10,4 +10,9 @@ class CisaKnownExploitsController < ApplicationController
|
||||||
@cisa_known_exploit = CisaKnownExploit.cve_id(params[:cve_id])
|
@cisa_known_exploit = CisaKnownExploit.cve_id(params[:cve_id])
|
||||||
render json: @cisa_known_exploit.to_json
|
render json: @cisa_known_exploit.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def show_product
|
||||||
|
@cisa_known_exploits = CisaKnownExploit.by_product(params[:product_name])
|
||||||
|
render json: @cisa_known_exploits.to_json
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,6 +5,7 @@ class CisaKnownExploit < ActiveRecord::Base
|
||||||
find_by(cve_id: id)
|
find_by(cve_id: id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#TODO: i think i can just use postgrs sql jsonb ->> queries to better pull this data
|
||||||
def self.cve_id(cve_id)
|
def self.cve_id(cve_id)
|
||||||
last.vulnerabilities.select { |vuln| vuln if vuln.dig('cve_id') == cve_id }
|
last.vulnerabilities.select { |vuln| vuln if vuln.dig('cve_id') == cve_id }
|
||||||
end
|
end
|
||||||
|
@ -14,7 +15,7 @@ class CisaKnownExploit < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.by_product(product_name)
|
def self.by_product(product_name)
|
||||||
last.vulnerabilities.select {|vuln| vuln if vuln.dig('product') == product_name }
|
last.vulnerabilities.select {|vuln| vuln if vuln.dig('product') =~ /#{product_name}/ }
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.by_due_date(due_date)
|
def self.by_due_date(due_date)
|
||||||
|
|
|
@ -43,5 +43,6 @@ Rails.application.routes.draw do
|
||||||
get '/gsds/years/:year', to: 'gsds#show_year'
|
get '/gsds/years/:year', to: 'gsds#show_year'
|
||||||
|
|
||||||
get '/cisa_known_exploits', to: 'cisa_known_exploits#index'
|
get '/cisa_known_exploits', to: 'cisa_known_exploits#index'
|
||||||
get '/cisa_known_exploits/cve/:cve_id', to: 'cisa_known_exploits#show'
|
get '/cisa_known_exploits/vulnerabilities/:cve_id', to: 'cisa_known_exploits#show'
|
||||||
|
get '/cisa_known_exploits/vulnerabilities/product/:product_name', to: 'cisa_known_exploits#show_product'
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue