Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
ad-block
Advanced tools
Readme
Native node module, and C++ library for Adblock Plus filter parsing for lists like EasyList.
It uses a bloom filter and Rabin-Karp algorithm to be super fast.
npm install --save ad-block
const {AdBlockClient, FilterOptions} = require('ad-block')
const client = new AdBlockClient()
client.parse('/public/ad/*$domain=slashdot.org')
client.parse('/public/ad3/*$script')
var b1 = client.matches('http://www.brianbondy.com/public/ad/some-ad', FilterOptions.script, 'slashdot.org')
var b2 = client.matches('http://www.brianbondy.com/public/ad/some-ad', FilterOptions.script, 'digg.com')
console.log('public/ad/* should match b1. Actual: ', b1)
console.log('public/ad/* should not match b2. Actual: ', b2)
#include "ad_block_client.h"
#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iostream>
#include <string>
using namespace std;
string getFileContents(const char *filename)
{
ifstream in(filename, ios::in);
if (in) {
ostringstream contents;
contents << in.rdbuf();
in.close();
return(contents.str());
}
throw(errno);
}
void writeFile(const char *filename, const char *buffer, int length)
{
ofstream outFile(filename, ios::out | ios::binary);
if (outFile) {
outFile.write(buffer, length);
outFile.close();
return;
}
throw(errno);
}
int main(int argc, char**argv) {
std::string &&easyListTxt = getFileContents("./test/data/easylist.txt");
const char *urlsToCheck[] = {
// ||pagead2.googlesyndication.com^$~object-subrequest
"http://pagead2.googlesyndication.com/pagead/show_ads.js",
// Should be blocked by: ||googlesyndication.com/safeframe/$third-party
"http://tpc.googlesyndication.com/safeframe/1-0-2/html/container.html",
// Should be blocked by: ||googletagservices.com/tag/js/gpt_$third-party
"http://www.googletagservices.com/tag/js/gpt_mobile.js",
// Shouldn't be blocked
"http://www.brianbondy.com"
};
// This is the site who's URLs are being checked, not the domain of the URL being checked.
const char *currentPageDomain = "slashdot.org";
// Parse easylist
AdBlockClient client;
client.parse(easyListTxt.c_str());
// Do the checks
std::for_each(urlsToCheck, urlsToCheck + sizeof(urlsToCheck) / sizeof(urlsToCheck[0]), [&client, currentPageDomain](std::string const &urlToCheck) {
if (client.matches(urlToCheck.c_str(), FONoFilterOption, currentPageDomain)) {
cout << urlToCheck << ": You should block this URL!" << endl;
} else {
cout << urlToCheck << ": You should NOT block this URL!" << endl;
}
});
int size;
// This buffer is allocate on the heap, you must call delete[] when you're done using it.
char *buffer = client.serialize(size);
writeFile("./ABPFilterParserData.dat", buffer, size);
AdBlockClient client2;
// Deserialize uses the buffer directly for subsequent matches, do not free until all matches are done.
client2.deserialize(buffer);
// Prints the same as client.matches would
std::for_each(urlsToCheck, urlsToCheck + sizeof(urlsToCheck) / sizeof(urlsToCheck[0]), [&client2, currentPageDomain](std::string const &urlToCheck) {
if (client2.matches(urlToCheck.c_str(), FONoFilterOption, currentPageDomain)) {
cout << urlToCheck << ": You should block this URL!" << endl;
} else {
cout << urlToCheck << ": You should NOT block this URL!" << endl;
}
});
delete[] buffer;
return 0;
}
node scripts/check.js --host www.cnet.com --location https://s0.2mdn.net/instream/html5/ima3.js
node scripts/check.js --host www.cnet.com --location "https://slashdot.org?t=1&ad_box_=2" --discover
node scripts/check.js --uuid 03F91310-9244-40FA-BCF6-DA31B832F34D --host slashdot.org --location https://s.yimg.jp/images/ds/ult/toppage/rapidjp-1.0.0.js
node scripts/check.js --dat ./out/SafeBrowsingData.dat --host excellentmovies.net --location https://excellentmovies.net
node scripts/check.js --host www.cnet.com --list ./test/data/sitelist.txt
node scripts/check.js --host www.cnet.com --list ./test/data/sitelist.txt --discover
Clone the git repository from GitHub:
git clone --recursive https://github.com/brave/ad-block
Open the working directory:
cd ad-block
Install the Node (v5+) dependencies:
npm install
make
make sample
make test
make clean
FAQs
Ad block engine used in the Brave browser for ABP filter syntax based lists like EasyList.
The npm package ad-block receives a total of 72 weekly downloads. As such, ad-block popularity was classified as not popular.
We found that ad-block demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.