Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/client9/gsb4u
Google Safe Browsing batch server, client
https://github.com/client9/gsb4u
Last synced: about 1 month ago
JSON representation
Google Safe Browsing batch server, client
- Host: GitHub
- URL: https://github.com/client9/gsb4u
- Owner: client9
- License: mit
- Created: 2011-10-29T19:47:36.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2011-12-04T23:25:07.000Z (almost 13 years ago)
- Last Synced: 2024-05-08T17:15:11.669Z (6 months ago)
- Language: PHP
- Homepage:
- Size: 115 KB
- Stars: 15
- Watchers: 5
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
This implements a toolkit for implementing the
[Google Safe Browsing API v2](http://code.google.com/apis/safebrowsing/)The lib directory contains the pieces you'll need to assemble to match
your enivroment:lib/GSB_Client.php The client to test if a URL is blacklisted
lib/GSB_Exception.php An empty class to namespace our exceptions
lib/GSB_Logger.php A really simple logger. Ideally you'd subclass to modify for your environment
lib/GSB_Request.php All network (http) calls are here
lib/GSB_Storage.php Every database query is here, wrapper up in a function
lib/GSB_Updater.php Updates the local GSB database
lib/GSB_URL.php URL cannonicalizationbin-sample shows how this might be done. You'll want to rewrite these for match your environment:
bin-sample/intro.php common code for both lookup and updater
bin-sample/lookup.php CLI to test a URL
bin-sample/update.php code to update the local GSB database
bin-sample/cron.sh shows how update might be run periodiciallyThe URL lookup and the local database update shares common code:
$api = 'YOUR-API-KEY-HERE';
$gsblists = array('goog-malware-shavar', 'googpub-phish-shavar');// make a PDO object, 2nd line is just good practice
$dbh = new PDO('mysql:host=127.0.0.1;dbname=gsb', 'root');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);// create the pieces. Subclass, over-ride for your environment
$storage = new GSB_StoreDB($dbh);
$network = new GSB_Request($api);
$logger = new GSB_Logger(5);To make URL checker:
// make the client with the pieces, and test
$client = new GSB_Client($storage, $network, $logger);
$client->lookup('A URL');To make a database updater:
$x = new GSB_Updater($storage, $network, $logger);
$x->downloadData($gsblists, FALSE);
$storage->fullhash_delete_old();