Package Exports
- eslint-plugin-crypto
- eslint-plugin-crypto/types
Readme
Cryptographic security rules enforcing best practices and modern standards (Node.js crypto).
Description
This plugin enforces cryptographic best practices and modern security standards specifically for Node.js environments. It assists developers in avoiding weak algorithms and insecure implementations by flagging potential risks directly in the code. By integrating these checks, you can ensure that your application's data protection measures are robust and compliant with industry standards.
Philosophy
Interlace fosters strength through integration. Instead of stacking isolated rules, we interlace security directly into your workflow to create a resilient fabric of code. We believe tools should guide rather than gatekeep, providing educational feedback that strengthens the developer with every interaction.
Getting Started
- To check out the guide, visit eslint.interlace.tools. ๐
- ่ฆๆฅ็ไธญๆ ๆๅ, ่ฏท่ฎฟ้ฎ eslint.interlace.tools. ๐
- ๊ฐ์ด๋ ๋ฌธ์๋ eslint.interlace.tools์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐
- ใฌใคใใฏ eslint.interlace.toolsใงใ็ขบ่ชใใ ใใใ ๐
- Para ver la guรญa, visita eslint.interlace.tools. ๐
- ููุงุทูุงุน ุนูู ุงูุฏูููุ ูู ุจุฒูุงุฑุฉ eslint.interlace.tools. ๐
npm install eslint-plugin-crypto --save-dev๐ก What You Get
- 24 security rules covering cryptographic best practices
- CVE detection for CVE-2023-46809, CVE-2020-36732, CVE-2023-46233
- OWASP Top 10 coverage for cryptographic vulnerabilities
- LLM-optimized messages with CWE references and fix guidance
- Package support for crypto-hash, crypto-random-string, crypto-js
Features
- ๐ 24 Rules covering crypto best practices
- ๐ฏ CVE Detection (CVE-2023-46809, CVE-2020-36732, CVE-2023-46233)
- ๐ค AI-Optimized messages with CWE references
- โก Auto-Fix suggestions where safe
- ๐ฆ Package Support for crypto-hash, crypto-random-string, crypto-js
โ๏ธ Configuration Presets
| Preset | Description |
|---|---|
recommended |
Balanced security defaults for most projects |
strict |
Strict preset - all rules as errors |
cryptojs-migration |
For teams migrating from crypto-js |
nodejs-only |
Only Node.js crypto rules |
cve-focused |
Rules targeting specific CVEs |
๐ Supported Libraries
| Library | npm | Downloads | Detection |
|---|---|---|---|
crypto (Node.js) |
- | Weak Algo, Key Length, Randomness | |
crypto-js |
Legacy patterns, Weak PRNG |
Examples
โ Bad
// CVE-2023-46809: Marvin Attack
crypto.privateDecrypt({ key, padding: crypto.constants.RSA_PKCS1_PADDING }, buffer);
// CWE-338: Weak random
const token = Math.random().toString(36);
// CWE-327: ECB mode leaks patterns
crypto.createCipheriv('aes-256-ecb', key, iv);
// CWE-208: Timing attack
if (userToken === storedToken) { ... }โ Good
// Use OAEP padding
crypto.privateDecrypt({ key, padding: crypto.constants.RSA_PKCS1_OAEP_PADDING }, buffer);
// Secure random
const token = crypto.randomBytes(32).toString('hex');
// GCM provides authentication
crypto.createCipheriv('aes-256-gcm', key, iv);
// Constant-time comparison
if (crypto.timingSafeEqual(Buffer.from(userToken), Buffer.from(storedToken))) { ... }Peer Dependencies (Optional)
{
"crypto-hash": ">=3.0.0",
"crypto-random-string": ">=4.0.0",
"crypto-js": ">=4.0.0"
}AI-Optimized Messages
This plugin is optimized for ESLint's Model Context Protocol (MCP), enabling AI assistants like Cursor, GitHub Copilot, and Claude to:
- Understand the exact vulnerability type via CWE references
- Apply the correct fix using structured guidance
- Provide educational context to developers
// .cursor/mcp.json
{
"mcpServers": {
"eslint": {
"command": "npx",
"args": ["@eslint/mcp@latest"]
}
}
}By providing this structured context (CWE, OWASP, Fix), we enable AI tools to reason about the security flaw rather than hallucinating. This allows Copilot/Cursor to suggest the exact correct fix immediately.
Rules
Legend
| Icon | Description |
|---|---|
| ๐ผ | Recommended: Included in the recommended preset. |
| โ ๏ธ | Warns: Set towarn in recommended preset. |
| ๐ง | Auto-fixable: Automatically fixable by the --fix CLI option. |
| ๐ก | Suggestions: Providing code suggestions in IDE. |
| ๐ซ | Deprecated: This rule is deprecated. |
๐ Related ESLint Plugins
Part of the Interlace ESLint Ecosystem โ AI-native security plugins with LLM-optimized error messages:
| Plugin | Downloads | Description |
|---|---|---|
eslint-plugin-secure-coding |
General security rules & OWASP guidelines. | |
eslint-plugin-pg |
PostgreSQL security & best practices. | |
eslint-plugin-jwt |
JWT security & best practices. | |
eslint-plugin-browser-security |
Browser-specific security & XSS prevention. | |
eslint-plugin-vercel-ai-security |
Vercel AI SDK security rules. | |
eslint-plugin-express-security |
Express.js security hardening rules. | |
eslint-plugin-lambda-security |
AWS Lambda security best practices. | |
eslint-plugin-nestjs-security |
NestJS security rules & patterns. | |
eslint-plugin-import-next |
Next-gen import sorting & architecture. |
๐ License
MIT ยฉ Ofri Peretz
