Net::G...Lookup(3pm)

πŸ“¦ version 1.07, in ubuntu jammy

✨ NAME ✨

okay bestie, gather round πŸ’– this is Net::Google::SafeBrowsing2::Lookup β€” a Perl extension (a 3pm manual, so it lives in the User Contributed Perl Documentation zone) for the Google Safe Browsing v2 Lookup API. yes, that Google. the one that tells you a site is shady before you click it. iconic behavior honestly πŸ›‘οΈβœ¨


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste ready:

use Net::Google::SafeBrowsing2::Lookup;

my $gsb = Net::Google::SafeBrowsing2::Lookup->new(
      key     => "my key",
);

my %match = $gsb->lookup(url => 'http://www.gumblar.cn/');

if ($match{'http://www.gumblar.cn/'} eq 'malware') {
      print "http://www.gumblar.cn/ is flagged as a dangerous site\n";
}

my %matches = $gsb->lookup(urls => ['http://www.gumblar.cn/', 'http://flahupdate.co.cc']);
foreach my $url (keys %matches) {
  print $url, " is ", $matches{$url}, "\n";
}

like… you literally make an object, hand it a URL, and it tells you if that URL is giving malware πŸ¦ πŸ’€ no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

Net::Google::SafeBrowsing2::Lookup implements the Google Safe Browsing v2 Lookup API. the official API docs are chillin' at <http://code.google.com/apis/safebrowsing/lookup_guide.html> πŸ“–

bestie, real talk: if you need to check more than 10,000 URLs a day, this module is NOT the one. you need to use Net::Google::SafeBrowsing2 instead. periodt.

the source code is available on github at <https://github.com/juliensobrier/Net-Google-SafeBrowsing2> πŸ‘‘ go star it or whatever, it's the respectful thing to do.


πŸŽ€ CONSTRUCTOR πŸŽ€

new()

creates a Net::Google::SafeBrowsing2::Lookup object. your main character moment starts here:

my $gsb = Net::Google::SafeBrowsing2::Lookup->new(
      key     => "my key",
      debug   => 0,
);

Arguments

  • key β€” Required. your Google Safe Browsing API key πŸ”‘ no key, no vibes.
  • debug β€” Optional. set it to 1 to turn on debugging. it's 0 (disabled) by default.
    • > lowkey a warning: the debug output maybe quite large and can slow down significantly the update and lookup functions 😭 so maybe don't leave it on forever.
  • errors β€” Optional. set it to 1 to show errors to STDOUT. 0 (disabled by default).
  • version β€” Optional. Google Safe Browsing version. 3.0 by default πŸ‘‘
  • delay β€” Optional. delay, in seconds, between 2 requests to the Google server. see the "lookup" function for more details. 0 (no delay) by default. pls be nice to the server 🫢

πŸ’… PUBLIC FUNCTIONS πŸ’…

lookup()

looks up a list of URLs against the Google Safe Browsing v2 lists. the moment of truth:

my %match = $gsb->lookup(url => 'http://www.gumblar.cn');

returns a hash of "url" => "Google match". the possible values for "Google match" are:

  • "ok" β€” no match, we love a clean URL ✨
  • "malware" 🦠
  • "phishing" 🎣
  • "malware,phishing" β€” match both lists, double yikes πŸ’€
  • "error" πŸ™ˆ

Arguments

  • url β€” Optional. a single URL to lookup.
  • urls β€” Optional. list of URLs to lookup.
    • > okay so the Lookup API allows only 10,000 URL checks a day. if you need more, use the Net::Google::SafeBrowsing2 library, fr fr.
    • each request must contain 500 URLs at most. the lookup() method will split the list of URLs in blocks of 500 URLs if needed β€” it's got you, bestie 🫢
  • delay β€” Optional. if more than 500 URLs are checked, wait "delay" seconds between consecutive requests to avoid rate limiting by Google. respect the rate limit or get humbled, iykyk.

🌈 CHANGELOG 🌈

  • 0.2 Documentation update.

(short and sweet, we love a glow-up ✨)


πŸ‘€ SEE ALSO πŸ‘€

see Net::Google::SafeBrowsing2 for the implementation of Google Safe Browsing v2 API. that's the big sibling, go say hi 🫢


πŸ’– AUTHOR πŸ’–

Julien Sobrier, <jsobrier@zscaler.com> or <julien@sobrier.net> β€” the icon, the legend, the moment πŸ‘‘


Copyright (C) 2012 by Julien Sobrier

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. slay, legally speaking πŸ’…


and that's the whole page, bestie πŸ¦‹ this was Net::G...Lookup(3pm) from perl v5.32.0, dated 2021-01-07 β€” mwah, go be safe on the internet πŸ’–βœ¨

πŸ“¦ where this page comes from