Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A simple spamfilter with autotraining
npm i --save antibot
const spamfilter = require("antibot");
const instance = spamfilter.create(["spam"], {
onFiltered: (spam) =>
spam.split(" ").flatMap((word) => [`_${word}_`, `-${word}-`]),
skipOnFilteredOnInit: true,
});
const isSpam = instance.test("SPAM filter"); // true
const isSpamToo = instance.test("_FILTER_"); // true, because it trained from onFiltered call
const instance = instance.create();
Creates a new Spamfilter
instance
instance.test(content);
Returns true
if spam detected, otherwise false
.
By default will split words and lowercase them, banning those too. You might want to override the tactic with onFiltered
second parameter of the .create
method:
const instance = spamfilter.create(["spam"], {
onFiltered: (spam) =>
spam.split(" ").flatMap((word) => [`_${word}_`, `-${word}-`]),
skipOnFilteredOnInit: true,
});
onFiltered
- function that predicts the new banned words derived from detected content
skipOnFilteredOnInit
- the words passed in .create()
method will not be transformed through onFiltered
and leave intact
onDetection
- overrides detection behavior
const filter = spamfilter.create(["123"], {
onDetection: (text, dict) => Object.keys(dict).length === text.length,
});
filter.test("3"); // true
const tree = instance.explain();
Explains the reason of detection as a tree, e.g.
{
spam: {
filter: {},
test: {},
},
filter: {
word: {},
},
};
const spamfilter = require("antibot");
class CustomPlugin extends spamfilter.Plugin {
beforeFiltered(content: string) {
// ... preprocessing returning string
return content;
}
afterFiltered(contents: string[]) {
// ... postprocessing returning string array
return contents;
}
}
const filter = spamfilter.create(...);
filter.inject(new CustomPlugin())
beforeFiltered
fires before main intermediate processing as asserted in Spamfilter
params onFiltered
afterFiltered
fires after main intermediate processing as asserted in Spamfilter
params onFiltered
onDetection
of params takes precedence over onDetection
of plugin(s)
const LevenshteinPlugin = require("antibot/plugins/LevenshteinPlugin");
const filter = spamfilter.create(["abcd"]);
filter.inject(new LevenshteinPlugin({ sensitivity: 1 }));
filter.test("abced");
const NilsimsaPlugin = require("antibot/plugins/NilsimsaPlugin");
const expected = true;
const filter = spamfilter.create(["1234 abcde"], {
onFiltered: (exact) => [exact],
});
filter.inject(new NilsimsaPlugin({ from: 128, to: 128 }));
filter.test("1234 abcde");
npm test
FAQs
A simple auto-training spamfilter
The npm package antibot receives a total of 0 weekly downloads. As such, antibot popularity was classified as not popular.
We found that antibot 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.