~ubuntu-branches/ubuntu/hardy/bugzilla/hardy-security

« back to all changes in this revision

Viewing changes to describecomponents.cgi

  • Committer: Bazaar Package Importer
  • Author(s): Rémi Perrot
  • Date: 2004-04-02 01:13:32 UTC
  • Revision ID: james.westby@ubuntu.com-20040402011332-hxrg0n2szimd7d25
Tags: upstream-2.16.5
Import upstream version 2.16.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bonsaitools/bin/perl -wT
 
2
# -*- Mode: perl; indent-tabs-mode: nil -*-
 
3
#
 
4
# The contents of this file are subject to the Mozilla Public
 
5
# License Version 1.1 (the "License"); you may not use this file
 
6
# except in compliance with the License. You may obtain a copy of
 
7
# the License at http://www.mozilla.org/MPL/
 
8
#
 
9
# Software distributed under the License is distributed on an "AS
 
10
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 
11
# implied. See the License for the specific language governing
 
12
# rights and limitations under the License.
 
13
#
 
14
# The Original Code is the Bugzilla Bug Tracking System.
 
15
#
 
16
# The Initial Developer of the Original Code is Netscape Communications
 
17
# Corporation. Portions created by Netscape are
 
18
# Copyright (C) 1998 Netscape Communications Corporation. All
 
19
# Rights Reserved.
 
20
#
 
21
# Contributor(s): Terry Weissman <terry@mozilla.org>
 
22
#                 Bradley Baetz <bbaetz@student.usyd.edu.au>
 
23
 
 
24
use vars qw(
 
25
  %FORM
 
26
  $userid
 
27
);
 
28
 
 
29
use diagnostics;
 
30
use strict;
 
31
 
 
32
use lib qw(.);
 
33
 
 
34
require "CGI.pl";
 
35
 
 
36
ConnectToDatabase();
 
37
quietly_check_login();
 
38
 
 
39
GetVersionTable();
 
40
 
 
41
if (!defined $::FORM{'product'}) {
 
42
    # Reference to a subset of %::proddesc, which the user is allowed to see
 
43
    my %products;
 
44
 
 
45
    if (Param("usebuggroups")) {
 
46
        # OK, now only add products the user can see
 
47
        confirm_login() unless $::userid;
 
48
        foreach my $p (@::legal_product) {
 
49
            if (!GroupExists($p) || UserInGroup($p)) {
 
50
                $products{$p} = $::proddesc{$p};
 
51
            }
 
52
        }
 
53
    }
 
54
    else {
 
55
          %products = %::proddesc;
 
56
    }
 
57
 
 
58
    my $prodsize = scalar(keys %products);
 
59
    if ($prodsize == 0) {
 
60
        DisplayError("Either no products have been defined ".
 
61
                     "or you have not been given access to any.\n");
 
62
        exit;
 
63
    }
 
64
    elsif ($prodsize > 1) {
 
65
        $::vars->{'proddesc'} = \%products;
 
66
        $::vars->{'target'} = "describecomponents.cgi";
 
67
        $::vars->{'title'} = "Bugzilla component description";
 
68
        $::vars->{'h2'} = 
 
69
          "Please specify the product whose components you want described.";
 
70
 
 
71
        print "Content-type: text/html\n\n";
 
72
        $::template->process("global/choose-product.html.tmpl", $::vars)
 
73
          || ThrowTemplateError($::template->error());
 
74
        exit;
 
75
    }
 
76
 
 
77
    $::FORM{'product'} = (keys %products)[0];
 
78
}
 
79
 
 
80
my $product = $::FORM{'product'};
 
81
 
 
82
# Make sure the user specified a valid product name.  Note that
 
83
# if the user specifies a valid product name but is not authorized
 
84
# to access that product, they will receive a different error message
 
85
# which could enable people guessing product names to determine
 
86
# whether or not certain products exist in Bugzilla, even if they
 
87
# cannot get any other information about that product.
 
88
grep($product eq $_ , @::legal_product)
 
89
  || DisplayError("The product name is invalid.")
 
90
  && exit;
 
91
 
 
92
# Make sure the user is authorized to access this product.
 
93
if (Param("usebuggroups") && GroupExists($product)) {
 
94
    confirm_login() unless $::userid;
 
95
    UserInGroup($product)
 
96
      || DisplayError("You are not authorized to access that product.")
 
97
        && exit;
 
98
}
 
99
 
 
100
######################################################################
 
101
# End Data/Security Validation
 
102
######################################################################
 
103
 
 
104
my @components;
 
105
SendSQL("SELECT value, initialowner, initialqacontact, description FROM " .
 
106
        "components WHERE program = " . SqlQuote($product) . " ORDER BY " .
 
107
        "value");
 
108
while (MoreSQLData()) {
 
109
    my ($name, $initialowner, $initialqacontact, $description) =
 
110
      FetchSQLData();
 
111
 
 
112
    my %component;
 
113
 
 
114
    $component{'name'} = $name;
 
115
    $component{'initialowner'} = $initialowner ?
 
116
      DBID_to_name($initialowner) : '';
 
117
    $component{'initialqacontact'} = $initialqacontact ?
 
118
      DBID_to_name($initialqacontact) : '';
 
119
    $component{'description'} = $description;
 
120
 
 
121
    push @components, \%component;
 
122
}
 
123
 
 
124
$::vars->{'product'} = $product;
 
125
$::vars->{'components'} = \@components;
 
126
 
 
127
print "Content-type: text/html\n\n";
 
128
$::template->process("reports/components.html.tmpl", $::vars)
 
129
  || ThrowTemplateError($::template->error());
 
130