~ubuntu-branches/ubuntu/edgy/bugzilla/edgy

« back to all changes in this revision

Viewing changes to show_bug.cgi

  • Committer: Bazaar Package Importer
  • Author(s): Alexis Sukrieh
  • Date: 2005-10-03 16:51:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051003165101-38n0y5qofd68vole
Tags: 2.18.4-1
* New upstream minor release
  + Fixed a security issue: It was possible to bypass the "user
    visibility groups" restrictions if user-matching was turned on
    in "substring" mode.
  + Fixed a security issue: config.cgi exposed information to users who
    weren't logged in, even when "requirelogin" was turned on in Bugzilla.
  (closes: #331206)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bonsaitools/bin/perl -wT
 
1
#!/usr/bin/perl -wT
2
2
# -*- Mode: perl; indent-tabs-mode: nil -*-
3
3
#
4
4
# The contents of this file are subject to the Mozilla Public
20
20
#
21
21
# Contributor(s): Terry Weissman <terry@mozilla.org>
22
22
 
23
 
use diagnostics;
24
23
use strict;
25
24
 
26
 
use lib '/usr/share/bugzilla/lib';
 
25
use lib qw(.);
 
26
 
 
27
use Bugzilla;
 
28
use Bugzilla::Constants;
27
29
 
28
30
require "CGI.pl";
29
 
require "bug_form.pl";
30
 
 
31
 
ConnectToDatabase();
32
 
 
33
 
if ($::FORM{'GoAheadAndLogIn'}) {
34
 
    confirm_login();
 
31
 
 
32
use vars qw($template $vars $userid);
 
33
 
 
34
use Bugzilla::Bug;
 
35
 
 
36
my $cgi = Bugzilla->cgi;
 
37
 
 
38
if ($cgi->param('GoAheadAndLogIn')) {
 
39
    Bugzilla->login(LOGIN_REQUIRED);
35
40
} else {
36
 
    quietly_check_login();
37
 
}
38
 
 
39
 
######################################################################
40
 
# Begin Data/Security Validation
41
 
######################################################################
42
 
 
43
 
# Make sure the bug ID is a positive integer representing an existing
44
 
# bug that the user is authorized to access.
45
 
if (defined ($::FORM{'id'})) {
46
 
    ValidateBugID($::FORM{'id'});
47
 
}
48
 
 
49
 
######################################################################
50
 
# End Data/Security Validation
51
 
######################################################################
 
41
    Bugzilla->login();
 
42
}
 
43
 
 
44
# Editable, 'single' HTML bugs are treated slightly specially in a few places
 
45
my $single = !$cgi->param('format')
 
46
  && (!$cgi->param('ctype') || $cgi->param('ctype') eq 'html');
 
47
 
 
48
# If we don't have an ID, _AND_ we're only doing a single bug, then prompt
 
49
if (!$cgi->param('id') && $single) {
 
50
    print Bugzilla->cgi->header();
 
51
    $template->process("bug/choose.html.tmpl", $vars) ||
 
52
      ThrowTemplateError($template->error());
 
53
    exit;
 
54
}
 
55
 
 
56
my $format = GetFormat("bug/show", scalar $cgi->param('format'), 
 
57
                       scalar $cgi->param('ctype'));
52
58
 
53
59
GetVersionTable();
54
60
 
55
 
print "Content-type: text/html\n\n";
56
 
 
57
 
show_bug();
 
61
my @bugs = ();
 
62
 
 
63
if ($single) {
 
64
    my $id = $cgi->param('id');
 
65
    # Its a bit silly to do the validation twice - that functionality should
 
66
    # probably move into Bug.pm at some point
 
67
    ValidateBugID($id);
 
68
    push @bugs, new Bugzilla::Bug($id, $userid);
 
69
} else {
 
70
    foreach my $id ($cgi->param('id')) {
 
71
        my $bug = new Bugzilla::Bug($id, $userid);
 
72
        push @bugs, $bug;
 
73
    }
 
74
}
 
75
 
 
76
# Determine if Patch Viewer is installed, for Diff link
 
77
eval {
 
78
  require PatchReader;
 
79
  $vars->{'patchviewerinstalled'} = 1;
 
80
};
 
81
 
 
82
$vars->{'bugs'} = \@bugs;
 
83
 
 
84
# Next bug in list (if there is one)
 
85
my @bug_list;
 
86
if ($cgi->cookie("BUGLIST")) {
 
87
    @bug_list = split(/:/, $cgi->cookie("BUGLIST"));
 
88
}
 
89
 
 
90
$vars->{'bug_list'} = \@bug_list;
 
91
 
 
92
# Work out which fields we are displaying (currently XML only.)
 
93
# If no explicit list is defined, we show all fields. We then exclude any
 
94
# on the exclusion list. This is so you can say e.g. "Everything except 
 
95
# attachments" without listing almost all the fields.
 
96
my @fieldlist = (Bugzilla::Bug::fields(), 'group', 'long_desc', 'attachment');
 
97
my %displayfields;
 
98
 
 
99
if ($cgi->param("field")) {
 
100
    @fieldlist = $cgi->param("field");
 
101
}
 
102
 
 
103
unless (UserInGroup(Param("timetrackinggroup"))) {
 
104
    @fieldlist = grep($_ !~ /_time$/, @fieldlist);
 
105
}
 
106
 
 
107
foreach (@fieldlist) {
 
108
    $displayfields{$_} = 1;
 
109
}
 
110
 
 
111
foreach ($cgi->param("excludefield")) {
 
112
    $displayfields{$_} = undef;    
 
113
}
 
114
 
 
115
$vars->{'displayfields'} = \%displayfields;
 
116
 
 
117
print $cgi->header($format->{'ctype'});
 
118
 
 
119
$template->process("$format->{'template'}", $vars)
 
120
  || ThrowTemplateError($template->error());