summaryrefslogtreecommitdiff
blob: 986f71da71b8863d1cae0bcef8d1d1bb4f638178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# ===GLSAMaker v2
#  Copyright (C) 2009 Alex Legler <a3li@gentoo.org>
#  Copyright (C) 2009 Pierre-Yves Rofes <py@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
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# For more information, see the LICENSE file.

# Tools controller
class ToolsController < ApplicationController
  def buginfo
#    bug = Bugzilla::Bug.load_from_id(params[:id])
    
    str = "<dev-ruby/rails-2.2.2: XSS (CVE 2009-5607)"
    
    respond_to do |format|
      format.html { }
      format.ajax { render :text => "text to render...", :status => 1 }
    end
  end
  
  def ajaxbugs
    bug_ids = Bugzilla::Bug.str2bugIDs(params[:bugs])
    
    @bugs = []
    bug_ids.each do |bug_id|
      begin
        @bugs << Bugzilla::Bug.load_from_id(bug_id.to_i)
      rescue Exception => e
        @bugs << "Ignoring #{CGI.escapeHTML(bug_id)} (#{CGI.escapeHTML(e.message)})"
      end
    end
    
    render :layout => false
  end
  
  def ajaxdescr
    bug_ids = Bugzilla::Bug.str2bugIDs(params[:bugs])
    
    @bugs = []
    bug_ids.each do |bug_id|
      begin
        @bugs << Bugzilla::Bug.load_from_id(bug_id.to_i)
      rescue Exception => e
      end
    end  
    
    if @bugs.length == 1
      @text = @bugs[0].summary
      render :layout => false
      return
    end
    
    # Process 2 or more bugs
    @atoms = []
    @bugs.each do |bug|
      matchdata = /([\w-]+)\/([\w-]+)(-([\w.]+))?/.match(bug.summary)
      
      unless matchdata.nil?
        category = matchdata[1]
        package = matchdata[2].gsub(/-+?$/, '')
        
        @atoms << "#{category}/#{package}"
      end
    end
    
    @atoms.uniq!
    
    if @atoms.length > 0
      @text = @atoms.join(', ') + ": Multiple vulnerabilities"
      render :layout => false
      return
    end

    render :text => "(no suggestion available)", :layout => false
  end

  def background
    render :layout => false
  end
end