
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@brave-intl/bat-usermodel
Advanced tools
BAT Ad User Model
This is a work in progress. Comments welcome, of course.
The usermodel contain an implementation of Naive Bayes and Logistic Regression. The Naive Bayes fit uses multinomial distribution with a stopword list. The Logistic Regression uses a feature vector and weights to return a probability value.
The resulting data files are all log probabilities with 5 significant digits.
The locales/
directory contains a directory for each locale dataset.
The default list (locales/default
) uses the standard english language stopword list.
Each dataset consists of the floowing files:
prior.js
The prior.js
file looks like this:
module.exports =
{ names: [ 'class1', ... ]
, priors: [ lp1, ... ]
}
consisting of a vector of class labels denoted by "names" and a vector of prior (log) class probabilities denoted by "priors." The priors are "document frequencies" aka the probability of a class in the corpus of documents.
The entries in the names
and priors
arrays correspond to pairs, e.g.,
module.exports =
{ names: [ 'red', blue', 'green' ]
, priors: ] -1.0988, -1.0981, -1.0987 ]
}
logPwGc.js
The logPwGc.js
file looks like this:
module.exports =
{ word1: [ lp1, ... ]
, word12
}
This is a set of vectors of multinomial log probabilities of porter-stemmed words given the class.
The class is implied by the ordering defined in prior.js
.
For example,
gien the priors.js
example above ("red", "blue", and "green"),
each array in logPwGc.js
will have three values,
with the first value corresponding to "red",
the second value corresponding to "blue",
and the third value corresponding to "green".
You probably want to run
mkdir -p locales/xx_YY
uglify --source .../prior.js --output locales/xx_YY/prior.js
uglify --source .../logPwGc.js --output locales/xx_YY/logPwGc.js
to minify the prior.js
and logPwGc.js
files for faster loading.
For s better understanding of the text analysis approach, take a look at the quanteda package.
adsRelevance.js
and notificationModel.js
This is a logistic regression model that contains feature names
, the weights
and the intercept
term.
adsRelevance.js
will be used for scoring relevance of Ads and notificationModel.js
is a placeholder model for introducing a logistic regression model for deciding whether to show or not a notification.
The class space is flat; however a separation character (hyphen, "-") joins the supercategory and subcategory, e.g., the "sports-rugby" class refers to a supercategory of "sports" with a subcategory of "rugby".
The current interface is synchronous.
minimumWordsToClassify
maximumWordsToClassify
A locales
directory contains one or more directories,
for each locale
.
At a minimum,
one directory, "default", must be present.
Each directory for a locale has two files:
prior.js
logPwGc.js
These are minified files whose module.exports
contains the objects described above.
For development purposes,
the files do not meed to be minified.
Further,
the corresponding JSON files may be present instead,
i.e.,
prior.json
logPwGc.json
To set a specific locale, use:
let locale = setLocaleSync('locale', 'directory')
The first argument indicates the particular locale to use, e.g., "en-US". The second argument indicates the pathname to the locales directory, and is usually omitted.
Some examples:
setLocaleSync('en')
setLocaleSync('en_US')
setLocaleSync('en_US.UTF-8')
Note that setLocaleSync
returns the actual locale being used,
e.g., if the locales directory contains "en" but not "en_US",
then setLocaleSync('en_US')
returns "en".
To determine what locales are available:
const locales = getLocalesSync()
To retrieve all locale information:
const localeInfo = getLocaleInfo()
// localeInfo.locale = 'default'
// localeInfo.locales = [ 'default', 'en' ]
// localeInfo.path = '/...bat-usermodel/locales'
The call to setLocaleSYnc
is optional;
however,
it mut be made before either of these two calls is made:
const prior = getPriorDataSync()
const matrix = getMatrixDataSync()
textBlobIntoWordVec
processWordsFromHTML
vectorIndexOfMax
deriveCategoryScores
NBWordVec
Future revisions may add asynchronous calls.
These are encoded as negative numbers. Future revisions may omit the minus-sign.
In release 0.2.x
and earlier,
each class corresponds to a category -- the class taxonomy is flat and fully defined by prior.js
.
In the current release 0.3.x
, the taxonomy remains flat;
however, a hyphen ("-") is used to join the supercategory and a subcategory into a single class.
Future revisions may use a taxonomy.js
file to key a category to its subcategories.
FAQs
BAT Ad Generation Engine
We found that @brave-intl/bat-usermodel demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.