Skip Menu |

This queue is for tickets about the Net-Google-SafeBrowsing2 CPAN distribution.

Report information
The Basics
Id: 89585
Status: new
Priority: 0/
Queue: Net-Google-SafeBrowsing2

People
Owner: JSOBRIER [...] cpan.org
Requestors: HSW [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Support custom API urls.
Hi! Russian search engine Yandex (http://en.wikipedia.org/wiki/Yandex) maintains its own SafeBrowsing database with other API urls: http://api.yandex.ru/safebrowsing/doc/quickstart/tasks/integration_difftypes.xml Getting API key: http://safe.yandex.ru/keys/ (Yandex login required). Patch allow override api urls. Sample code: =========== use Net::Google::SafeBrowsing2; use Net::Google::SafeBrowsing2::Sqlite; my $storage = Net::Google::SafeBrowsing2::Sqlite->new(file => 'sb-yandex-v2.db'); my $gsb = Net::Google::SafeBrowsing2->new( key => 'my key', storage => $storage, version => 2.3, urls => { downloads => 'http://sba.yandex.net/downloads', gethash => 'http://sba.yandex.net/gethash', list => 'http://sba.yandex.net/list', newkey => 'https://sba.yandex.net/newkey', }, ); $gsb->update(); my $match = $gsb->lookup(url => 'http://www.gumblar.cn/'); $storage->close(); ===========
Subject: SafeBrowsing2.pm.patch
--- SafeBrowsing2.pm 2013-10-17 14:37:54.748639850 +0400 +++ SafeBrowsing2.pm 2013-10-17 15:02:28.650429290 +0400 @@ -152,6 +152,12 @@ debug => 0, mac => 0, list => MALWARE, + urls => { + downloads => 'https://safebrowsing.clients.google.com/safebrowsing/downloads', + gethash => 'https://safebrowsing.clients.google.com/safebrowsing/gethash', + list => 'https://safebrowsing.clients.google.com/safebrowsing/list', + newkey => 'https://sb-ssl.google.com/safebrowsing/newkey', + }, ); Arguments @@ -174,6 +180,10 @@ Optional. Set to 1 to enable Message Authentication Code (MAC). 0 (disabled) by default. +=item urls + +Optional. API urls. + =item debug Optional. Set to 1 to enable debugging. 0 (disabled) by default. @@ -208,6 +218,12 @@ last_error => '', mac => 0, perf => 0, + urls => { + downloads => 'https://safebrowsing.clients.google.com/safebrowsing/downloads', + gethash => 'https://safebrowsing.clients.google.com/safebrowsing/gethash', + list => 'https://safebrowsing.clients.google.com/safebrowsing/list', + newkey => 'https://sb-ssl.google.com/safebrowsing/newkey', + }, %args, }; @@ -318,7 +334,7 @@ my $ua = $self->ua; - my $url = "https://safebrowsing.clients.google.com/safebrowsing/downloads?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; + my $url = $self->{urls}{downloads} . "?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; $url .= "&wrkey=$wrapped_key" if ($mac); my $body = ''; @@ -607,7 +623,7 @@ sub get_lists { my ($self, %args) = @_; - my $url = "https://safebrowsing.clients.google.com/safebrowsing/list?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; + my $url = $self->{urls}{list} . "?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; my $res = $self->ua->get($url); @@ -917,7 +933,7 @@ my $client_key = ''; my $wrapped_key = ''; - my $url = "https://sb-ssl.google.com/safebrowsing/newkey?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; + my $url = $self->{urls}{newkey} . "?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; my $res = $self->ua->get($url); @@ -1600,7 +1616,7 @@ } } - my $url = "https://safebrowsing.clients.google.com/safebrowsing/gethash?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; + my $url = $self->{urls}{gethash} . "?client=api&apikey=" . $self->{key} . "&appver=$VERSION&pver=" . $self->{version}; my $prefix_list = join('', @$prefixes); my $header = "$size:" . scalar @$prefixes * $size;