CC: | bug-Net-Google-SafeBrowsing3 [...] rt.cpan.org |
Subject: | Re: SafeBrowsing3.pm bug |
Date: | Sat, 19 Mar 2016 22:01:56 -0700 |
To: | Jesper Knudsen <jkn [...] swerts-knudsen.dk> |
From: | Julien Sobrier <julien [...] sobrier.net> |
Jesper,
I finally has some time to look at it. I made a slightly different change:
https://github.com/juliensobrier/Net-Google-SafeBrowsing3/commit/fde8db8cfcb76014b0967fd7c86cb70d752172f5
I have a uploaded a new version to CPAN.
Thank you for your contribution
Julien Sobrier
On Mon, Nov 30, 2015 at 4:55 AM, Jesper Knudsen <jkn@swerts-knudsen.dk>
wrote:
Show quoted text
> Hi Julien,
>
>
>
> I am a happy user of your perl contribution for GSB. I have found a bug
> that you might want to update the package with. If you have any kind of
> unpublished updates, then I am keen to test for you. I have a quite large
> URL DB that I intended to take through this…
>
>
>
> Rgds,
>
> Jesper
>
>
>
> In the function parse_full_hashes within SafeBrowsing3.pm, Google uses \r
> (oxOA) rather than \n after “m” - goog-malware-shavar:32:2:m
>
>
>
> This means the parsing needs to alter slightly:
>
>
>
> * if ($data =~ /^[a-z-]+:\d+:\d+(:m)?/gi) {*
>
> * } else {*
>
> * return ();*
>
> * }*
>
> * $data =~ s/^([a-z-]+)://;*
>
> * my $list = $1;*
>
> * $self->debug("List: ", $list, "\n");*
>
>
>
> * $data =~ s/^(\d+)://;*
>
> * my $length = $1;*
>
> * $self->debug("Full hash length: ", $length, "\n");*
>
>
>
> * $data =~ s/^(\d+)//;*
>
> * my $num = $1;*
>
>
>
> * $self->debug("Number of full hashes returned: ", $num, "\n");*
>
>
>
> * my $metadata = 0;*
>
> * if ($data =~ s/:m//) {*
>
> * $metadata = 1;*
>
> * }*
>
>
>
> * # get rid of newline chars*
>
> * $data =~ s/[\r\n]//;*
>
>
>
> Same goes for the metadata portion
>
>
>
> * if ($metadata) {*
>
> * my $count = 0;*
>
> * while ($data =~ s/(\d+)//) {*
>
> * my $meta_length = $1;*
>
>
>
> * # get rid of newline chars*
>
> * $data =~ s/[\r\n]//;*
>
>
>
> * my $info = substr($data, 0, $meta_length, '');*
>
>
>
> * $self->debug("Metadata: ",$self->hex_to_ascii($info),"
> ($meta_length)\n");*
>
> * my $extra = MalwarePatternType->decode($info);*
>
>
>
> * # update the type*
>
> * my $hash = $local_hashes[$count];*
>
> * $hash->{type} = $extra->{pattern_type};*
>
> * $local_hashes[$count] = $hash;*
>
>
>
> * $count++;*
>
> * }*
>
> * }*
>
>
>
>
>