Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const generateDataFilesForAllRegions = () => {
console.log('Processing per region list updates...')
let p = Promise.resolve()
new lists('regions').forEach((region) => { // eslint-disable-line
p = p.then(generateDataFileFromURL.bind(null, region.url,
region.langs, region.uuid, `rs-${region.uuid}.dat`))
})
return p
}
let promises = []
lists.forEach((l) => {
console.log(`${l.url}...`)
const filterFn = getListFilterFunction(l.uuid)
promises.push(getListBufferFromURL(l.url, filterFn))
})
let p = Promise.all(promises)
p = p.then((listBuffers) => {
generateDataFileFromString(listBuffers, filename, 'default')
})
p = p.then(generateResourcesFile)
return p
}
const generateDataFilesForDefaultAdblock =
generateDataFilesForList.bind(null, new lists('default'), 'rs-ABPFilterParserData.dat') // eslint-disable-line
// For adblock-rust-ffi, included just as a char array via hexdump
const generateTestDataFile1 =
generateDataFileFromString.bind(null, 'ad-banner', 'ad-banner.dat', 'test-data')
// For adblock-rust-ffi, included just as a char array via hexdump
const generateTestDataFile2 =
generateDataFileFromString.bind(null, 'ad-banner$tag=abc', 'ad-banner-tag-abc.dat', 'test-data')
// For brave-core ./data/adblock-data/adblock-default/rs-ABPFilterParserData.dat
// For brave-core ./data/adblock-data/adblock-v3/rs-ABPFilterParserData.dat
const generateTestDataFile3 =
generateDataFileFromString.bind(null, 'adbanner\nad_banner', 'rs-default.dat', 'test-data')
// For brave-core ./data/adblock-data/adblock-v4/rs-ABPFilterParserData.dat
const generateTestDataFile4 =
generateDataFileFromString.bind(null, 'v4_specific_banner.png', 'rs-v4.dat', 'test-data')
// For brave-core ./brave/test/data/adblock-data/adblock-regional/
// 9852EFC4-99E4-4F2D-A915-9C3196C7A1DE/rs-9852EFC4-99E4-4F2D-A915-9C3196C7A1DE.dat
static parse(rawLists) {
return new Brave(new Engine(rawLists.split(/[\n\r]+/g)));
}
const generateDataFileFromString = (filterRuleData, outputDATFilename, outSubdir) => {
let rules
if (filterRuleData.constructor === Array) {
rules = filterRuleData.join('\n')
} else {
rules = filterRuleData
}
const client = new Engine(rules.split('\n'))
const arrayBuffer = client.serialize()
const outPath = getOutPath(outputDATFilename, outSubdir)
fs.writeFileSync(outPath, Buffer.from(arrayBuffer))
}
return new Promise((resolve, reject) => {
const jsonData = JSON.stringify(uBlockResources(
uBlockWebAccessibleResources,
uBlockRedirectEngine,
uBlockScriptlets
))
fs.writeFileSync(getOutPath('resources.json', 'default'), jsonData, 'utf8')
})
}