diff options
author | Alex Legler <alex@a3li.li> | 2016-06-01 19:46:31 +0200 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2016-06-01 19:46:31 +0200 |
commit | 4653dc87e9d00adf9c3b644bb5b997b74a486d9d (patch) | |
tree | f0361c40ff4b17f3a7b01fecbbbabc647b6e1ccc | |
parent | Add jbuilder (diff) | |
download | glsamaker-4653dc87e9d00adf9c3b644bb5b997b74a486d9d.tar.gz glsamaker-4653dc87e9d00adf9c3b644bb5b997b74a486d9d.tar.bz2 glsamaker-4653dc87e9d00adf9c3b644bb5b997b74a486d9d.zip |
JSONify /cve/info/
-rw-r--r-- | app/controllers/cve_controller.rb | 10 | ||||
-rw-r--r-- | app/views/cve/info.json.jbuilder | 5 |
2 files changed, 13 insertions, 2 deletions
diff --git a/app/controllers/cve_controller.rb b/app/controllers/cve_controller.rb index 8e0cd54..203dfad 100644 --- a/app/controllers/cve_controller.rb +++ b/app/controllers/cve_controller.rb @@ -51,7 +51,7 @@ class CveController < ApplicationController render :layout => false rescue Exception => e log_error e - render :text => e.message, :status => 500 + render :text => e.message, :status => 500 end def bug @@ -230,7 +230,13 @@ class CveController < ApplicationController # Popup methods def info - @cve = Cve.where(:cve_id => params[:id]).first + @cve = Cve.where(cve_id: params[:id]).first + fail ActionController::RoutingError, 'Not Found' unless @cve + + respond_to do |wants| + wants.html {} + wants.json {} + end end def general_info diff --git a/app/views/cve/info.json.jbuilder b/app/views/cve/info.json.jbuilder new file mode 100644 index 0000000..31408a0 --- /dev/null +++ b/app/views/cve/info.json.jbuilder @@ -0,0 +1,5 @@ +json.extract! @cve, :id, :cve_id, :summary, :cvss, :state, :published_at + +json.references @cve.references, :source, :title, :uri + +json.bugs @cve.assignments.map { |a| a.bug } |