Download reports from Bugzilla

-1

We habe a password protected Bugzilla instance and I would like to download a report in CSV form.

Using

wget $URL

or

curl $URL

I do not get any error, no authentication request. Bugzilla just delivers a 0 bytes file

The same happens with a browser. If I type the URL in I get the empty file. If I log in on any Bugzilla page before than the Bugilla will deliver the file.

Is there a way to authenticate from the command line, store the cookie and then fetch the report using the same cookies?

Matteo

Posted 2013-08-08T11:37:36.137

Reputation: 6 553

Just use the built-in Tabular reports to do this. This question would be best directed towards the Bugzilla community as it might require a modification to Bugzilla itself. Since Bugzilla is server software I doubt this is actually an on topic question. – Ramhound – 2013-08-08T11:52:16.240

I am using the tabular reports. But I access the URL I get no way to log in. Bugzilla is requesting authentication only for HTML pages but not for downloads. It just gives you an empty file. I wanted to know it there is a way to get them from the user side. I have no means to change anything on the server. – Matteo – 2013-08-08T12:12:05.497

If you don't have the means to change the server to resolve the problem then you are out of luck. – Ramhound – 2013-08-08T12:15:24.130

Why? I am now writing a small script with Perl and Mechanize: fetch a page, submit credentials, store cookie, access the table. I asked since what I am doing seems an overkill and maybe there is something I missed (that does not need scripting). I still don't get the down vote but whatever not a big issue – Matteo – 2013-08-08T12:19:09.387

Answers

0

Ok maybe there are better solutions but it can be done with a little Perl script

#!/usr/bin/perl

use strict;
use warnings;

use WWW::Mechanize;
use Readonly;

Readonly::Scalar my $base_url => 'https://example.org';
Readonly::Scalar my $url      => "$base_url/bugzilla/report.cgi?...&ctype=csv&format=table";

# just as an example: put them in a property file
Readonly::Scalar my $username => 'USERNAME';
Readonly::Scalar my $password => 'PASSWORD';

my $mech = WWW::Mechanize->new();

$mech->get("$url&GoAheadAndLogIn=1");

my %login = (
    "Bugzilla_login"=> $username,
    "Bugzilla_password"=> $password
);
$mech->set_fields(%login);
$mech->submit( 'GoAheadAndLogIn' );
$mech->get( $url );
$mech->save_content( 'name.csv' );

1;

Matteo

Posted 2013-08-08T11:37:36.137

Reputation: 6 553