aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Amoss <ackle@gentoo.org>2017-04-18 18:48:21 -0400
committerSean Amoss <ackle@gentoo.org>2017-04-18 18:48:21 -0400
commit4d5b41d09e73f981c89a1156531353d5a403447e (patch)
treec6079ac46b19d2b83281d98204af69e7cdec8083
parentGenerate migration to add slot support (diff)
downloadglsamaker-4d5b41d09e73f981c89a1156531353d5a403447e.tar.gz
glsamaker-4d5b41d09e73f981c89a1156531353d5a403447e.tar.bz2
glsamaker-4d5b41d09e73f981c89a1156531353d5a403447e.zip
Add slot support to GLSAMaker2.1.2
-rw-r--r--app/controllers/glsa_controller.rb6
-rw-r--r--app/views/glsa/_glsa.xml.builder12
-rw-r--r--app/views/glsa/_package.html.erb1
-rw-r--r--app/views/glsa/_show_package_row.txt.erb14
-rw-r--r--app/views/glsa/edit.html.erb3
-rw-r--r--app/views/glsa/show.html.erb4
-rw-r--r--db/schema.rb250
-rw-r--r--test/fixtures/packages.yml4
8 files changed, 159 insertions, 135 deletions
diff --git a/app/controllers/glsa_controller.rb b/app/controllers/glsa_controller.rb
index d6408ab..b7a98fa 100644
--- a/app/controllers/glsa_controller.rb
+++ b/app/controllers/glsa_controller.rb
@@ -246,7 +246,7 @@ class GlsaController < ApplicationController
next if package[:atom].strip == ''
begin
- revision.packages.create!(package.permit([:atom, :comp, :version, :arch, :automatic, :my_type]))
+ revision.packages.create!(package.permit([:atom, :comp, :version, :arch, :automatic, :my_type, :slot]))
rescue ActiveRecord::RecordInvalid => e
flash[:error] = "Errors occurred while saving a package: #{e.record.errors.full_messages.join ', '}"
set_up_editing
@@ -467,8 +467,8 @@ class GlsaController < ApplicationController
protected
def set_up_editing
# Packages
- @rev.vulnerable_packages.build(:comp => "<", :arch => "*") if @rev.vulnerable_packages.length == 0
- @rev.unaffected_packages.build(:comp => ">=", :arch => "*") if @rev.unaffected_packages.length == 0
+ @rev.vulnerable_packages.build(:comp => "<", :slot => "*", :arch => "*") if @rev.vulnerable_packages.length == 0
+ @rev.unaffected_packages.build(:comp => ">=", :slot => "*", :arch => "*") if @rev.unaffected_packages.length == 0
# References
if params.has_key? :glsa and params[:glsa].has_key? :reference
diff --git a/app/views/glsa/_glsa.xml.builder b/app/views/glsa/_glsa.xml.builder
index 2213f65..0fe529d 100644
--- a/app/views/glsa/_glsa.xml.builder
+++ b/app/views/glsa/_glsa.xml.builder
@@ -19,10 +19,18 @@ xml.glsa :id => glsa.glsa_id do
xml.package({:name => package, :auto => (atoms['unaffected'] || []).select {|a| !a.automatic}.length == 0 ? 'yes' : 'no',
:arch => (atoms['vulnerable'].nil? || atoms['vulnerable'].length == 0) ? '*' : atoms['vulnerable'].first.arch}) do
(atoms['unaffected'] || []).each do |a|
- xml.unaffected({:range => a.xml_comp}, a.version)
+ if a.slot != '*'
+ xml.unaffected({:range => a.xml_comp, :slot => a.slot}, a.version)
+ else
+ xml.unaffected({:range => a.xml_comp}, a.version)
+ end
end
(atoms['vulnerable'] || []).each do |a|
- xml.vulnerable({:range => a.xml_comp}, a.version)
+ if a.slot != '*'
+ xml.vulnerable({:range => a.xml_comp, :slot => a.slot}, a.version)
+ else
+ xml.vulnerable({:range => a.xml_comp}, a.version)
+ end
end
end
end
diff --git a/app/views/glsa/_package.html.erb b/app/views/glsa/_package.html.erb
index 73203d9..5e3d115 100644
--- a/app/views/glsa/_package.html.erb
+++ b/app/views/glsa/_package.html.erb
@@ -4,6 +4,7 @@
<td><%= pf.text_field :atom, :class => :nice, :index => nil %></td>
<td class="odd"><%= pf.select :comp, comps, {}, :index => nil %></td>
<td class="odd"><%= pf.text_field :version, :class => :nice, :size => 10, :index => nil %></td>
+ <td class="odd"><%= pf.text_field :slot, :class => :nice, :size => 5, :index => nil %></td>
<td><%= pf.text_field :arch, :class => :nice, :size => 7, :index => nil %></td>
<td class="odd"><%= pf.select :automatic, [["yes", true], ["no", false]], {}, :index => nil %></td>
<td><%= link_to_function(
diff --git a/app/views/glsa/_show_package_row.txt.erb b/app/views/glsa/_show_package_row.txt.erb
index be33882..31d3186 100644
--- a/app/views/glsa/_show_package_row.txt.erb
+++ b/app/views/glsa/_show_package_row.txt.erb
@@ -16,7 +16,12 @@ print_vulnerable = (unaffected_versions.size == 0 ? true : false)
while vulnerable_versions.size > 0 or unaffected_versions.size > 0
v = (vulnerable_versions.shift if vulnerable_versions.size > 0) || nil
- line = (v ? "#{v.comp} #{v.version}" : "").center(20)
+ print_slot = (v.slot != '*' ? true : false)
+ if print_slot
+ line = (v ? "#{v.comp} #{v.version}:#{v.slot}" : "").center(20)
+ else
+ line = (v ? "#{v.comp} #{v.version}" : "").center(20)
+ end
if v and v.arch != '*'
@arches[@packages_count] ||= []
@@ -28,7 +33,12 @@ while vulnerable_versions.size > 0 or unaffected_versions.size > 0
print_vulnerable = false
else
v = (unaffected_versions.shift if unaffected_versions.size > 0) || nil
- line += (v ? "#{v.comp} #{v.version} #{v.automatic ? "" : (@print_noauto = true && "*")}" : "").rjust(22)
+ print_slot = (v.slot != '*' ? true : false)
+ if print_slot
+ line += (v ? "#{v.comp} #{v.version}:#{v.slot} #{v.automatic ? "" : (@print_noauto = true && "*")}" : "").rjust(22)
+ else
+ line += (v ? "#{v.comp} #{v.version} #{v.automatic ? "" : (@print_noauto = true && "*")}" : "").rjust(22)
+ end
end
versions << line
end
diff --git a/app/views/glsa/edit.html.erb b/app/views/glsa/edit.html.erb
index 882f503..000d1be 100644
--- a/app/views/glsa/edit.html.erb
+++ b/app/views/glsa/edit.html.erb
@@ -75,6 +75,7 @@
<tr>
<th><%= image_tag 'icons/atom.png' %> Atom</th>
<th class="odd" colspan="2">Version</th>
+ <th title="* or slot">Slot</th>
<th title="* or space-separated list of arches"><%= image_tag 'icons/arch.png' %> Arch</th>
<th class="odd"><%= image_tag 'icons/auto.png' %> Auto</th>
</tr>
@@ -173,4 +174,4 @@
GLSAMaker.editing.templates.observeClick($('impact'));
GLSAMaker.editing.templates.observeClick($('workaround'));
GLSAMaker.editing.templates.observeClick($('resolution'));
-</script> \ No newline at end of file
+</script>
diff --git a/app/views/glsa/show.html.erb b/app/views/glsa/show.html.erb
index a0965f9..1da1a94 100644
--- a/app/views/glsa/show.html.erb
+++ b/app/views/glsa/show.html.erb
@@ -90,7 +90,7 @@
<td>
<ul>
<% @rev.packages.each do |pkg| ; next unless pkg.my_type == "unaffected" %>
- <li><%= pkg.comp %><strong><%= pkg.atom %></strong>-<%= pkg.version %> on <%= pkg.arch %> (auto: <%= pkg.automatic %>)</li>
+ <li><%= pkg.comp %><strong><%= pkg.atom %></strong>-<%= pkg.version %>:<%= pkg.slot %> on <%= pkg.arch %> (auto: <%= pkg.automatic %>)</li>
<% end %>
</ul>
</td>
@@ -100,7 +100,7 @@
<td>
<ul>
<% @rev.packages.each do |pkg| ; next unless pkg.my_type == "vulnerable" %>
- <li><%= pkg.comp %><strong><%= pkg.atom %></strong>-<%= pkg.version %> on <%= pkg.arch %> (auto: <%= pkg.automatic %>)</li>
+ <li><%= pkg.comp %><strong><%= pkg.atom %></strong>-<%= pkg.version %>:<%= pkg.slot %> on <%= pkg.arch %> (auto: <%= pkg.automatic %>)</li>
<% end %>
</ul>
</td>
diff --git a/db/schema.rb b/db/schema.rb
index d6ab809..f32d7a4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -1,3 +1,4 @@
+# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
@@ -8,212 +9,213 @@
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
-# It's strongly recommended to check this file into your version control system.
+# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20110829174909) do
+ActiveRecord::Schema.define(version: 20170418102638) do
- create_table "bugs", :force => true do |t|
- t.integer "bug_id"
- t.text "title"
- t.integer "revision_id"
+ create_table "bugs", force: :cascade do |t|
+ t.integer "bug_id", limit: 4
+ t.text "title", limit: 65535
+ t.integer "revision_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
- t.string "whiteboard"
- t.string "arches"
+ t.string "whiteboard", limit: 255
+ t.string "arches", limit: 255
end
- add_index "bugs", ["bug_id"], :name => "index_bugs_on_bug_id"
- add_index "bugs", ["revision_id"], :name => "index_bugs_on_revision_id"
+ add_index "bugs", ["bug_id"], name: "index_bugs_on_bug_id", using: :btree
+ add_index "bugs", ["revision_id"], name: "index_bugs_on_revision_id", using: :btree
- create_table "comments", :force => true do |t|
- t.integer "user_id"
- t.integer "glsa_id"
- t.text "text"
- t.string "rating"
- t.boolean "read", :default => false
+ create_table "comments", force: :cascade do |t|
+ t.integer "user_id", limit: 4
+ t.integer "glsa_id", limit: 4
+ t.text "text", limit: 65535
+ t.string "rating", limit: 255
+ t.boolean "read", limit: 1, default: false
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "comments", ["glsa_id"], :name => "index_comments_on_glsa_id"
- add_index "comments", ["user_id"], :name => "comments_users_userid"
+ add_index "comments", ["glsa_id"], name: "index_comments_on_glsa_id", using: :btree
+ add_index "comments", ["user_id"], name: "comments_users_userid", using: :btree
- create_table "cpes", :force => true do |t|
- t.string "cpe"
+ create_table "cpes", force: :cascade do |t|
+ t.string "cpe", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cpes", ["cpe"], :name => "index_cpes_on_cpe", :unique => true
+ add_index "cpes", ["cpe"], name: "index_cpes_on_cpe", unique: true, using: :btree
- create_table "cpes_cves", :id => false, :force => true do |t|
- t.integer "cpe_id"
- t.integer "cve_id"
+ create_table "cpes_cves", id: false, force: :cascade do |t|
+ t.integer "cpe_id", limit: 4
+ t.integer "cve_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cpes_cves", ["cpe_id"], :name => "cpes_cves_cpe_id"
- add_index "cpes_cves", ["cve_id", "cpe_id"], :name => "index_cpes_cves_on_cve_id_and_cpe_id"
+ add_index "cpes_cves", ["cpe_id"], name: "cpes_cves_cpe_id", using: :btree
+ add_index "cpes_cves", ["cve_id", "cpe_id"], name: "index_cpes_cves_on_cve_id_and_cpe_id", using: :btree
- create_table "cve_assignments", :force => true do |t|
- t.integer "cve_id"
- t.integer "bug"
+ create_table "cve_assignments", force: :cascade do |t|
+ t.integer "cve_id", limit: 4
+ t.integer "bug", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cve_assignments", ["bug"], :name => "index_cve_assignments_on_bug"
- add_index "cve_assignments", ["cve_id"], :name => "index_cve_assignments_on_cve_id"
+ add_index "cve_assignments", ["bug"], name: "index_cve_assignments_on_bug", using: :btree
+ add_index "cve_assignments", ["cve_id"], name: "index_cve_assignments_on_cve_id", using: :btree
- create_table "cve_changes", :force => true do |t|
- t.integer "cve_id"
- t.integer "user_id"
- t.string "action"
- t.string "object"
+ create_table "cve_changes", force: :cascade do |t|
+ t.integer "cve_id", limit: 4
+ t.integer "user_id", limit: 4
+ t.string "action", limit: 255
+ t.string "object", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cve_changes", ["cve_id"], :name => "cve_changes_cve_id"
- add_index "cve_changes", ["user_id"], :name => "cve_changes_user_id"
+ add_index "cve_changes", ["cve_id"], name: "cve_changes_cve_id", using: :btree
+ add_index "cve_changes", ["user_id"], name: "cve_changes_user_id", using: :btree
- create_table "cve_comments", :force => true do |t|
- t.integer "cve_id"
- t.integer "user_id"
- t.boolean "confidential", :default => false
- t.text "comment"
+ create_table "cve_comments", force: :cascade do |t|
+ t.integer "cve_id", limit: 4
+ t.integer "user_id", limit: 4
+ t.boolean "confidential", limit: 1, default: false
+ t.text "comment", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cve_comments", ["cve_id"], :name => "index_cve_comments_on_cve_id"
- add_index "cve_comments", ["user_id"], :name => "cve_comments_user_id"
+ add_index "cve_comments", ["cve_id"], name: "index_cve_comments_on_cve_id", using: :btree
+ add_index "cve_comments", ["user_id"], name: "cve_comments_user_id", using: :btree
- create_table "cve_references", :force => true do |t|
- t.string "source"
- t.text "title"
- t.text "uri"
- t.integer "cve_id"
+ create_table "cve_references", force: :cascade do |t|
+ t.string "source", limit: 255
+ t.text "title", limit: 65535
+ t.text "uri", limit: 65535
+ t.integer "cve_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cve_references", ["cve_id"], :name => "index_cve_references_on_cve_id"
+ add_index "cve_references", ["cve_id"], name: "index_cve_references_on_cve_id", using: :btree
- create_table "cves", :force => true do |t|
- t.string "cve_id"
- t.text "summary"
- t.string "cvss"
- t.string "state"
+ create_table "cves", force: :cascade do |t|
+ t.string "cve_id", limit: 255
+ t.text "summary", limit: 65535
+ t.string "cvss", limit: 255
+ t.string "state", limit: 255
t.datetime "published_at"
t.datetime "last_changed_at"
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "cves", ["cve_id"], :name => "index_cves_on_cve_id", :unique => true
+ add_index "cves", ["cve_id"], name: "index_cves_on_cve_id", unique: true, using: :btree
- create_table "glsas", :force => true do |t|
- t.string "glsa_id"
- t.integer "requester"
- t.integer "submitter"
- t.integer "bugreadymaker"
- t.string "status"
- t.boolean "restricted", :default => false
+ create_table "glsas", force: :cascade do |t|
+ t.string "glsa_id", limit: 255
+ t.integer "requester", limit: 4
+ t.integer "submitter", limit: 4
+ t.integer "bugreadymaker", limit: 4
+ t.string "status", limit: 255
+ t.boolean "restricted", limit: 1, default: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "first_released_at"
end
- add_index "glsas", ["bugreadymaker"], :name => "glsas_users_bugreadymakers"
- add_index "glsas", ["glsa_id"], :name => "index_glsas_on_glsa_id", :unique => true
- add_index "glsas", ["requester"], :name => "glsas_users_requesters"
- add_index "glsas", ["status"], :name => "index_glsas_on_status"
- add_index "glsas", ["submitter"], :name => "glsas_users_submitters"
+ add_index "glsas", ["bugreadymaker"], name: "glsas_users_bugreadymakers", using: :btree
+ add_index "glsas", ["glsa_id"], name: "index_glsas_on_glsa_id", unique: true, using: :btree
+ add_index "glsas", ["requester"], name: "glsas_users_requesters", using: :btree
+ add_index "glsas", ["status"], name: "index_glsas_on_status", using: :btree
+ add_index "glsas", ["submitter"], name: "glsas_users_submitters", using: :btree
- create_table "packages", :force => true do |t|
- t.integer "revision_id"
- t.string "my_type"
- t.string "atom"
- t.string "version"
- t.string "comp"
- t.string "arch"
- t.boolean "automatic", :default => true
+ create_table "packages", force: :cascade do |t|
+ t.integer "revision_id", limit: 4
+ t.string "my_type", limit: 255
+ t.string "atom", limit: 255
+ t.string "version", limit: 255
+ t.string "comp", limit: 255
+ t.string "arch", limit: 255
+ t.boolean "automatic", limit: 1, default: true
t.datetime "created_at"
t.datetime "updated_at"
+ t.string "slot", limit: 255
end
- add_index "packages", ["revision_id"], :name => "index_packages_on_revision_id"
+ add_index "packages", ["revision_id"], name: "index_packages_on_revision_id", using: :btree
- create_table "references", :force => true do |t|
- t.integer "revision_id"
- t.text "title"
- t.text "url"
- t.string "type"
+ create_table "references", force: :cascade do |t|
+ t.integer "revision_id", limit: 4
+ t.text "title", limit: 65535
+ t.text "url", limit: 65535
+ t.string "type", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "references", ["revision_id"], :name => "index_references_on_revision_id"
+ add_index "references", ["revision_id"], name: "index_references_on_revision_id", using: :btree
- create_table "revisions", :force => true do |t|
- t.integer "glsa_id"
- t.integer "revid"
- t.string "title"
- t.string "access", :default => "remote"
- t.string "product"
- t.string "category"
- t.string "severity", :default => "normal"
- t.text "synopsis"
- t.text "background"
- t.text "description"
- t.text "impact"
- t.text "workaround"
- t.text "resolution"
+ create_table "revisions", force: :cascade do |t|
+ t.integer "glsa_id", limit: 4
+ t.integer "revid", limit: 4
+ t.string "title", limit: 255
+ t.string "access", limit: 255, default: "remote"
+ t.string "product", limit: 255
+ t.string "category", limit: 255
+ t.string "severity", limit: 255, default: "normal"
+ t.text "synopsis", limit: 65535
+ t.text "background", limit: 65535
+ t.text "description", limit: 65535
+ t.text "impact", limit: 65535
+ t.text "workaround", limit: 65535
+ t.text "resolution", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "user_id"
- t.boolean "is_release", :default => false
- t.integer "release_revision"
+ t.integer "user_id", limit: 4
+ t.boolean "is_release", limit: 1, default: false
+ t.integer "release_revision", limit: 4
end
- add_index "revisions", ["glsa_id"], :name => "index_revisions_on_glsa_id"
- add_index "revisions", ["revid"], :name => "index_revisions_on_revid"
- add_index "revisions", ["title"], :name => "index_revisions_on_title"
- add_index "revisions", ["user_id"], :name => "revisions_user_userid"
+ add_index "revisions", ["glsa_id"], name: "index_revisions_on_glsa_id", using: :btree
+ add_index "revisions", ["revid"], name: "index_revisions_on_revid", using: :btree
+ add_index "revisions", ["title"], name: "index_revisions_on_title", using: :btree
+ add_index "revisions", ["user_id"], name: "revisions_user_userid", using: :btree
- create_table "sessions", :force => true do |t|
- t.string "session_id", :null => false
- t.text "data"
+ create_table "sessions", force: :cascade do |t|
+ t.string "session_id", limit: 255, null: false
+ t.text "data", limit: 65535
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
- add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
+ add_index "sessions", ["session_id"], name: "index_sessions_on_session_id", using: :btree
+ add_index "sessions", ["updated_at"], name: "index_sessions_on_updated_at", using: :btree
- create_table "templates", :force => true do |t|
- t.string "name"
- t.text "text"
- t.string "target"
- t.boolean "enabled", :default => true
+ create_table "templates", force: :cascade do |t|
+ t.string "name", limit: 255
+ t.text "text", limit: 65535
+ t.string "target", limit: 255
+ t.boolean "enabled", limit: 1, default: true
t.datetime "created_at"
t.datetime "updated_at"
end
- create_table "users", :force => true do |t|
- t.string "login"
- t.string "name"
- t.string "email"
- t.boolean "disabled", :default => false
- t.boolean "jefe", :default => false
- t.text "preferences"
- t.integer "access"
+ create_table "users", force: :cascade do |t|
+ t.string "login", limit: 255
+ t.string "name", limit: 255
+ t.string "email", limit: 255
+ t.boolean "disabled", limit: 1, default: false
+ t.boolean "jefe", limit: 1, default: false
+ t.text "preferences", limit: 65535
+ t.integer "access", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "users", ["login"], :name => "index_users_on_login", :unique => true
+ add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree
end
diff --git a/test/fixtures/packages.yml b/test/fixtures/packages.yml
index 1cdd41d..a1b44ba 100644
--- a/test/fixtures/packages.yml
+++ b/test/fixtures/packages.yml
@@ -3,6 +3,7 @@ package_one:
atom: dev-lang/ruby
version: 1.8.7_p334
comp: '<'
+ slot: '1.8'
arch: '*'
automatic: 1
revision_id: 1
@@ -13,5 +14,6 @@ package_two:
version: 1.8.7_p334
comp: '>='
arch: '*'
+ slot: '1.8'
automatic: 1
- revision_id: 1 \ No newline at end of file
+ revision_id: 1