summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/application.css1
-rw-r--r--app/assets/stylesheets/screen.css11
-rw-r--r--app/controllers/search_controller.rb25
-rw-r--r--app/helpers/application_helper.rb6
-rw-r--r--app/helpers/search_helper.rb2
-rw-r--r--app/models/bug.rb6
-rw-r--r--app/models/cve.rb8
-rw-r--r--app/models/cve_comment.rb5
-rw-r--r--app/models/glsa.rb4
-rw-r--r--app/models/revision.rb12
-rw-r--r--app/views/layouts/application.html.erb34
-rw-r--r--app/views/search/_cve_row.html.erb6
-rw-r--r--app/views/search/_cves.html.erb13
-rw-r--r--app/views/search/_glsas.html.erb14
-rw-r--r--app/views/search/results.html.erb13
15 files changed, 141 insertions, 19 deletions
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index 58fbcb5..fc3f853 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -6,4 +6,5 @@
*= require screen
*= require admin
*= require modalbox
+ *= require cve
*/ \ No newline at end of file
diff --git a/app/assets/stylesheets/screen.css b/app/assets/stylesheets/screen.css
index 77b5c7f..e9956d9 100644
--- a/app/assets/stylesheets/screen.css
+++ b/app/assets/stylesheets/screen.css
@@ -149,6 +149,7 @@ div#menu #search {
right: 200px;
font-size: 80%;
margin-top: 17px;
+ color: white;
}
div#menu #search input {
@@ -556,4 +557,14 @@ table.glsamaker-table td {
padding-bottom: .4em;
border-right: 1px dotted #4C3E61;
border-bottom: 1px solid #4C3E61;
+}
+
+/** search **/
+span.match {
+ color: #4C3E61;
+ font-weight: bold;
+}
+
+.nowrap {
+ white-space: nowrap;
} \ No newline at end of file
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
new file mode 100644
index 0000000..ee5440a
--- /dev/null
+++ b/app/controllers/search_controller.rb
@@ -0,0 +1,25 @@
+class SearchController < ApplicationController
+ def index
+ end
+
+ def results
+ search = ThinkingSphinx.search params[:q], :max_matches => 1000, :per_page => 1000
+
+ @results = {}
+ search.each do |result|
+ klass = result.class.to_s
+ @results[klass] = [] unless @results.include? klass
+ @results[klass] << result
+ end
+
+ if @results.include? 'Revision'
+ @results['Glsa'] = [] unless @results['Glsa']
+
+ @results['Revision'].each do |rev|
+ @results['Glsa'] << rev.glsa
+ end
+
+ @results['Glsa'].uniq!
+ end
+ end
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 778d8f6..de8366d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,7 +1,7 @@
# ===GLSAMaker v2
-# Copyright (C) 2009-10 Alex Legler <a3li@gentoo.org>
-# Copyright (C) 2006-2007 Jean-Philippe Lang
-# Copyright (C) 2008 Robert Buchholz <rbug@gentoo.org> and Tobias Heinlein <keytoaster@gentoo.org>
+# Copyright (C) 2009-11 Alex Legler <a3li@gentoo.org>
+# Copyright (C) 2006-07 Jean-Philippe Lang
+# Copyright (C) 2008 Robert Buchholz <rbu@gentoo.org> and Tobias Heinlein <keytoaster@gentoo.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
new file mode 100644
index 0000000..b3ce20a
--- /dev/null
+++ b/app/helpers/search_helper.rb
@@ -0,0 +1,2 @@
+module SearchHelper
+end
diff --git a/app/models/bug.rb b/app/models/bug.rb
index 00e2d6d..9772d2a 100644
--- a/app/models/bug.rb
+++ b/app/models/bug.rb
@@ -13,6 +13,12 @@
class Bug < ActiveRecord::Base
belongs_to :revision
+ define_index do
+ indexes title
+
+ has revision_id
+ end
+
def cc
self.arches
end
diff --git a/app/models/cve.rb b/app/models/cve.rb
index 9b46bab..47c3167 100644
--- a/app/models/cve.rb
+++ b/app/models/cve.rb
@@ -17,6 +17,14 @@ class Cve < ActiveRecord::Base
has_many :cve_changes, :class_name => "CveChange", :foreign_key => "cve_id"
has_many :assignments, :class_name => "CveAssignment", :foreign_key => "cve_id"
+ define_index do
+ indexes cve_id, :sortable => true
+ indexes state, :sortable => true
+ indexes summary
+
+ has published_at, last_changed_at
+ end
+
def to_s(line_length = 78)
str = "#{self.cve_id} #{"(%s):" % url}\n"
str += " " + Glsamaker::help.word_wrap(self.summary, line_length-2).gsub(/\n/, "\n ")
diff --git a/app/models/cve_comment.rb b/app/models/cve_comment.rb
index 4c6b8c1..9ce0e31 100644
--- a/app/models/cve_comment.rb
+++ b/app/models/cve_comment.rb
@@ -1,4 +1,9 @@
class CveComment < ActiveRecord::Base
belongs_to :cve
belongs_to :user, :class_name => "User", :foreign_key => "user_id"
+
+ define_index do
+ indexes comment
+ has user_id, cve_id
+ end
end \ No newline at end of file
diff --git a/app/models/glsa.rb b/app/models/glsa.rb
index ab1ff18..f06b0c9 100644
--- a/app/models/glsa.rb
+++ b/app/models/glsa.rb
@@ -20,6 +20,10 @@ class Glsa < ActiveRecord::Base
has_many :revisions
has_many :comments
+
+ define_index do
+ indexes glsa_id, :sortable => true
+ end
# Returns the last revision object, referring to the current state of things
def last_revision
diff --git a/app/models/revision.rb b/app/models/revision.rb
index 3e029ba..5715b94 100644
--- a/app/models/revision.rb
+++ b/app/models/revision.rb
@@ -33,6 +33,18 @@ class Revision < ActiveRecord::Base
end
end
+ define_index do
+ indexes title
+ indexes synopsis
+ indexes description
+ indexes impact
+ indexes workaround
+ indexes resolution
+ indexes is_release
+
+ has glsa_id, revid, release_revision
+ end
+
# Returns an Array of Integers of the bugs linked to this revision
def get_linked_bugs
self.bugs.map do |bug|
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 144c814..4e4cb41 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -29,25 +29,27 @@
<map name="m_logo" id="m_logo">
<area shape="rect" coords="95,0,252,42" href="#" alt="Home" />
</map>
- <!--<div id="search"> TODO
- <form action="/search/index/glsamaker2" method="get">
- <a href="/search/index/glsamaker2" accesskey="4">Search</a>:
- <input accesskey="f" class="small" id="q" name="q" size="20" type="text" />
+ <div id="search">
+ <%= form_tag(search_path, :method => 'get') do -%>
+ <label for="q">Search:</label>
+ <input accesskey="f" class="small" id="q" name="q" size="20" type="text" value="<%= params[:q] %>" />
<select name="at">
- <option selected="selected">Everywhere</option>
- <option disabled="disabled" style="text-align: center">&mdash;&mdash;&mdash;&mdash;</option>
- <option value="glsa">GLSAs</option>
- <option value="glsa-request">&nbsp;&nbsp;Requests</option>
- <option value="glsa-draft">&nbsp;&nbsp;Drafts</option>
- <option value="glsa-sent">&nbsp;&nbsp;Archive</option>
- <option disabled="disabled" style="text-align: center">&mdash;&mdash;&mdash;&mdash;</option>
- <option disabled="disabled">Vulnerability intelligence</option>
- <option value="cve">&nbsp;&nbsp;CVEs</option>
- <option value="secunia">&nbsp;&nbsp;Secunia Advisories</option>
+ <option value="everywhere" selected="selected">Everywhere</option>
+ <!--<optgroup label="Advisories">
+ <option value="glsa">All GLSAs</option>
+ <option value="glsa-requests">Requests</option>
+ <option value="glsa-drafts">Drafts</option>
+ <option value="glsa-archive">Archive</option>
+ </optgroup>
+ <optgroup label="Vulnerability Intelligence">
+ <option value="cve">CVEs</option>
+ <option value="cve-assigned">Assigned CVEs</option>
+ <option value="cve-new">New CVEs</option>
+ </optgroup>-->
</select>
- </form>
- </div>-->
+ <% end -%>
+ </div>
<ul>
<li><%= link_to "New…", new_glsa_path, :class => 'new' %></li>
<li style="margin-right: 2em;">&nbsp;</li>
diff --git a/app/views/search/_cve_row.html.erb b/app/views/search/_cve_row.html.erb
new file mode 100644
index 0000000..ba641cd
--- /dev/null
+++ b/app/views/search/_cve_row.html.erb
@@ -0,0 +1,6 @@
+<tr>
+ <td class="nowrap"><%= link_to_function cve.colorize(:cve_id).html_safe, "cvepopup('#{cve.cve_id}')" %></td>
+ <td><%= cve.state %></td>
+ <td><%= sanitize(cve.excerpts.summary, :tags => 'span', :attributes => 'class') %></td>
+ <td><%= cve.cvss %></td>
+</tr> \ No newline at end of file
diff --git a/app/views/search/_cves.html.erb b/app/views/search/_cves.html.erb
new file mode 100644
index 0000000..e3f66ab
--- /dev/null
+++ b/app/views/search/_cves.html.erb
@@ -0,0 +1,13 @@
+<div class="box">
+ <h2>CVEs</h2>
+
+ <table class="glsamaker-table">
+ <tr align="left">
+ <th>ID</th>
+ <th>State</th>
+ <th>Summary</th>
+ <th>CVSS Score</th>
+ </tr>
+ <%= render :partial => "cve_row", :collection => results, :as => :cve %>
+ </table>
+</div> \ No newline at end of file
diff --git a/app/views/search/_glsas.html.erb b/app/views/search/_glsas.html.erb
new file mode 100644
index 0000000..cfa4c59
--- /dev/null
+++ b/app/views/search/_glsas.html.erb
@@ -0,0 +1,14 @@
+<div class="box">
+ <h2>GLSAs</h2>
+
+ <table class="glsamaker-table">
+ <tr align="left">
+ <th>ID</th>
+ <th>State</th>
+ <th>Title</th>
+ <th>Last changed at/by</th>
+ <% if current_user.is_el_jefe? %><th>Admin</th><% end %>
+ </tr>
+ <%= render :partial => "/glsa/glsa_row", :collection => results, :as => :glsa, :locals => { :view => :archive } %>
+ </table>
+</div> \ No newline at end of file
diff --git a/app/views/search/results.html.erb b/app/views/search/results.html.erb
new file mode 100644
index 0000000..c3aa24c
--- /dev/null
+++ b/app/views/search/results.html.erb
@@ -0,0 +1,13 @@
+<h1>Search results for "<%= params[:q] %>"</h1>
+
+<%- if @results.include? 'Glsa' -%>
+<%= render :partial => "glsas", :locals => {:results => @results['Glsa']} %>
+<%- end -%>
+
+<%- if @results.include? 'Cve' -%>
+<%= render :partial => "cves", :locals => {:results => @results['Cve']} %>
+<%- end -%>
+
+<%- if @results.empty? -%>
+<%= image_tag 'icons/error.png' %> No results found. :(
+<%- end -%> \ No newline at end of file