This file is indexed.

/usr/share/perl5/Devscripts/Debbugs.pm is in devscripts 2.17.6+deb9u2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# This is Debbugs.pm from the Debian devscripts package
#
#   Copyright (C) 2008 Adam D. Barratt
#   select() is Copyright (C) 2007 Don Armstrong
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

package Devscripts::Debbugs;

=head1 OPTIONS

=item select [key:value  ...]

Uses the SOAP interface to output a list of bugs which match the given
selection requirements.

The following keys are allowed, and may be given multiple times.

=over 8

=item package

Binary package name.

=item source

Source package name.

=item maintainer

E-mail address of the maintainer.

=item submitter

E-mail address of the submitter.

=item severity

Bug severity.

=item status

Status of the bug.

=item tag

Tags applied to the bug. If I<users> is specified, may include
usertags in addition to the standard tags.

=item owner

Bug's owner.

=item correspondent

Address of someone who sent mail to the log.

=item affects

Bugs which affect this package.

=item bugs

List of bugs to search within.

=item users

Users to use when looking up usertags.

=item archive

Whether to search archived bugs or normal bugs; defaults to 0
(i.e. only search normal bugs). As a special case, if archive is
'both', both archived and unarchived bugs are returned.

=back

For example, to select the set of bugs submitted by
jrandomdeveloper@example.com and tagged wontfix, one would use

select("submitter:jrandomdeveloper@example.com", "tag:wontfix")

=cut

use strict;
use warnings;

my $soapurl='Debbugs/SOAP/1';
our $btsurl='http://bugs.debian.org/';
my @errors;

our $soap_timeout;
sub soap_timeout {
    my $timeout_arg = shift;
    if (defined $timeout_arg and $timeout_arg =~ m{^[1-9]\d*$}) {
        $soap_timeout = $timeout_arg;
    }
}

sub init_soap {
    my $soapproxyurl;
    if ($btsurl =~ m%^https?://(.*)/?$%) {
	$soapproxyurl = $btsurl . '/';
    } else {
	$soapproxyurl = 'http://' . $btsurl . '/';
    }
    $soapproxyurl =~ s%//$%/%;
    $soapproxyurl .= 'cgi-bin/soap.cgi';
    my %options;
    if ($soap_timeout) {
        $options{timeout} = $soap_timeout;
    }
    my $soap = SOAP::Lite->uri($soapurl)->proxy($soapproxyurl, %options);

    $soap->transport->env_proxy();
    $soap->on_fault(\&getSOAPError);

    return $soap;
}

my $soap_broken;
sub have_soap {
    return ($soap_broken ? 0 : 1) if defined $soap_broken;
    eval {
	require SOAP::Lite;
    };

    if ($@) {
	if ($@ =~ m%^Can't locate SOAP/%) {
	    $soap_broken="the libsoap-lite-perl package is not installed";
	} else {
	    $soap_broken="couldn't load SOAP::Lite: $@";
	}
    }
    else {
	$soap_broken = 0;
    }
    return ($soap_broken ? 0 : 1);
}

sub getSOAPError {
    my ($soap, $result) = @_;
    my $err;
    if (ref($result)) {
	$err = $result->faultstring;
    } else {
	$err = $soap->transport->status;
    }
    chomp $err;
    push @errors, $err;

    return new SOAP::SOM;
}

sub usertags {
    die "Couldn't run usertags: $soap_broken\n" unless have_soap();

    my @args = @_;

    my $soap = init_soap();
    my $usertags = $soap->get_usertag(@_);

    if (@errors or not defined $usertags) {
	my $error = join("\n", @errors);
	die "Error retrieving usertags from SOAP server: $error\n";
    }

    my $result = $usertags->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error retrieving usertags from SOAP server: $error\n";
    }

    return $result;
}

sub select {
    die "Couldn't run select: $soap_broken\n" unless have_soap();
    my @args = @_;
    my %valid_keys = (package => 'package',
                      pkg     => 'package',
                      src     => 'src',
                      source  => 'src',
                      maint   => 'maint',
                      maintainer => 'maint',
                      submitter => 'submitter',
                      from => 'submitter',
                      status    => 'status',
                      tag       => 'tag',
                      tags      => 'tag',
                      usertag   => 'tag',
                      usertags  => 'tag',
                      owner     => 'owner',
                      dist      => 'dist',
                      distribution => 'dist',
                      bugs       => 'bugs',
                      archive    => 'archive',
                      severity   => 'severity',
                      correspondent => 'correspondent',
                      affects       => 'affects',
    );
    my %users;
    my %search_parameters;
    my $soap = init_soap();
    for my $arg (@args) {
	my ($key,$value) = split /:/, $arg, 2;
	next unless $key;
	if (exists $valid_keys{$key}) {
	    if ($valid_keys{$key} eq 'archive') {
		$search_parameters{$valid_keys{$key}} = $value
		    if $value;
	    } else {
		push @{$search_parameters{$valid_keys{$key}}},
		    $value if $value;
	    }
	} elsif ($key =~/users?$/) {
	    $users{$value} = 1 if $value;
	} else {
	    warn "select(): Unrecognised key: $key\n";
	}
    }
    my %usertags;
    for my $user (keys %users) {
	my $ut = usertags($user);
	next unless defined $ut and $ut ne "";
	for my $tag (keys %{$ut}) {
	    push @{$usertags{$tag}},
	    @{$ut->{$tag}};
	}
    }
    my $bugs = $soap->get_bugs(%search_parameters,
	(keys %usertags)?(usertags=>\%usertags):()
    );

    if (@errors or not defined $bugs) {
	my $error = join("\n", @errors);
	die "Error while retrieving bugs from SOAP server: $error\n";
    }

    my $result = $bugs->result();
    if (@errors or not defined $result) {
	my $error = join( "\n", @errors );
	die "Error while retrieving bugs from SOAP server: $error\n";
    }

    return $result;
}

sub status {
    die "Couldn't run status: $soap_broken\n" unless have_soap();
    my @args = @_;

    my $soap = init_soap();

    my $result = {};
    while (my @slice = splice(@args, 0, 500)) {
	my $bugs = $soap->get_status(@slice);

	if (@errors or not defined $bugs) {
	    my $error = join("\n", @errors);
	    die "Error while retrieving bug statuses from SOAP server: $error\n";
	}

	my $tmp = $bugs->result();

	if (@errors or not defined $tmp) {
	    my $error = join("\n", @errors);
	    die "Error while retrieving bug statuses from SOAP server: $error\n";
	}

	%$result = (%$result, %$tmp);
    }

    return $result;
}

sub versions {
    die "Couldn't run versions: $soap_broken\n" unless have_soap();

    my @args = @_;
    my %valid_keys = (package => 'package',
                      pkg     => 'package',
                      src => 'source',
                      source => 'source',
                      time => 'time',
                      binary => 'no_source_arch',
                      notsource => 'no_source_arch',
                      archs => 'return_archs',
                      displayarch => 'return_archs',
    );

    my %search_parameters;
    my @archs = ();
    my @dists = ();

    for my $arg (@args) {
	my ($key,$value) = split /:/, $arg, 2;
	$value ||= "1";
	if ($key =~ /^arch(itecture)?$/) {
	    push @archs, $value;
	} elsif ($key =~ /^dist(ribution)?$/) {
	    push @dists, $value;
	} elsif (exists $valid_keys{$key}) {
	    $search_parameters{$valid_keys{$key}} = $value;
	}
    }

    $search_parameters{arch} = \@archs if @archs;
    $search_parameters{dist} = \@dists if @dists;

    my $soap = init_soap();

    my $versions = $soap->get_versions(%search_parameters);

    if (@errors or not defined $versions) {
	my $error = join("\n", @errors);
	die "Error while retrieving package versions from SOAP server: $error\n";
    }

    my $result = $versions->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error while retrieivng package versions from SOAP server: $error";
    }

    return $result;
}

sub versions_with_arch {
    die "Couldn't run versions_with_arch: $soap_broken\n" unless have_soap();
    my @args = @_;

    my $versions = versions(@args, 'displayarch:1');

    if (not defined $versions) {
	die "Error while retrieivng package versions from SOAP server: $@";
    }

    return $versions;
}

sub newest_bugs {
    die "Couldn't run newest_bugs: $soap_broken\n" unless have_soap();
    my $count = shift || '';

    return if $count !~ /^\d+$/;

    my $soap = init_soap();

    my $bugs = $soap->newest_bugs($count);

    if (@errors or not defined $bugs) {
	my $error = join("\n", @errors);
	die "Error while retrieving newest bug list from SOAP server: $error";
    }

    my $result = $bugs->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error while retrieving newest bug list from SOAP server: $error";
    }

    return $result;
}

# debbugs currently ignores the $msg_num parameter
# but eventually it might not, so we support passing it

sub bug_log {
    die "Couldn't run bug_log: $soap_broken\n" unless have_soap();

    my $bug = shift || '';
    my $message = shift;

    return if $bug !~ /^\d+$/;

    my $soap = init_soap();

    my $log = $soap->get_bug_log($bug, $message);

    if (@errors or not defined $log) {
	my $error = join("\n", @errors);
	die "Error while retrieving bug log from SOAP server: $error\n";
    }

    my $result = $log->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error while retrieving bug log from SOAP server: $error\n";
    }

    return $result;
}

sub binary_to_source {
    die "Couldn't run binary_to_source: $soap_broken\n"
	unless have_soap();

    my $soap = init_soap();

    my $binpkg = shift;
    my $binver = shift;
    my $arch = shift;

    return if not defined $binpkg or not defined $binver;

    my $mapping = $soap->binary_to_source($binpkg, $binver, $arch);

    if (@errors or not defined $mapping) {
	my $error = join("\n", @errors);
	die "Error while retrieving binary to source mapping from SOAP server: $error\n";
    }

    my $result = $mapping->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error while retrieving binary to source mapping from SOAP server: $error\n";
    }

    return $result;
}

sub source_to_binary {
    die "Couldn't run source_to_binary: $soap_broken\n"
	unless have_soap();

    my $soap = init_soap();

    my $srcpkg = shift;
    my $srcver = shift;

    return if not defined $srcpkg or not defined $srcver;

    my $mapping = $soap->source_to_binary($srcpkg, $srcver);

    if (@errors or not defined $mapping) {
	my $error = join("\n", @errors);
	die "Error while retrieving source to binary mapping from SOAP server: $error\n";
    }

    my $result = $mapping->result();

    if (@errors or not defined $result) {
	my $error = join("\n", @errors);
	die "Error while retrieving source to binary mapping from SOAP server: $error\n";
    }

    return $result;
}

1;

__END__