Link Shield is a lightweight cybersecurity-focused npm package that detects suspicious and malicious URLs using heuristics, fuzzy matching, and threat intelligence patterns.
npm install link-shieldpaypa1.com, g00gle.net)
.exe, .apk, .scr)
javascript:, data:, file:)
.xyz, .tk, .ru)
.exe, .apk, .scr)
bash
npm install link-shield
`
or using yarn:
`bash
yarn add link-shield
`
---
โก Usage
`js
const { detectSuspiciousLink } = require("link-shield");
const result = detectSuspiciousLink("http://g00gle.com/login");
console.log(result);
`
$3
`json
{
"url": "http://g00gle.com/login",
"suspicious": true,
"riskScore": 60,
"reasons": [
"Domain contains numbers (possible typosquatting)",
"Lookalike domain detected: g00gle โ google",
"Suspicious keyword in domain"
]
}
`
---
โ๏ธ API
$3
url (string, required)* โ The URL to analyze
options (object, optional)*
threshold (number, default: 20)* โ Minimum score to mark as suspicious
Returns:
`ts
{
url: string;
suspicious: boolean;
riskScore: number; // 0โ100
reasons: string[];
}
`
---
๐ Cybersecurity Use Cases
* Email Security โ Filter malicious links in phishing campaigns
* Web Security โ Block suspicious redirects or downloads before execution
* Threat Intelligence โ Enrich suspicious indicators (IOCs) with scoring
* SOC Tools โ Automate link triage in incident response
* CI/CD Security โ Validate external links in codebases or docs
---
๐งช Testing
We use Jest for testing. Run tests with:
`bash
npm test
`
Example test case (test/detector.test.js):
`js
const { detectSuspiciousLink } = require("../src");
test("flags g00gle.com as suspicious", () => {
const result = detectSuspiciousLink("http://g00gle.com/login");
expect(result.suspicious).toBe(true);
expect(result.riskScore).toBeGreaterThan(20);
});
`
---
๐ฎ Roadmap
* [ ] CLI support (npx link-shield