eslint-plugin-browser-security 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -0
- package/README.md +78 -56
- package/package.json +6 -5
- package/src/index.js +62 -0
- package/src/rules/detect-mixed-content/index.d.ts +12 -0
- package/src/rules/detect-mixed-content/index.js +45 -0
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +12 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +48 -0
- package/src/rules/no-clickjacking/index.d.ts +36 -0
- package/src/rules/no-clickjacking/index.js +401 -0
- package/src/rules/no-client-side-auth-logic/index.d.ts +12 -0
- package/src/rules/no-client-side-auth-logic/index.js +74 -0
- package/src/rules/no-cookie-auth-tokens/index.d.ts +3 -1
- package/src/rules/no-credentials-in-query-params/index.d.ts +12 -0
- package/src/rules/no-credentials-in-query-params/index.js +62 -0
- package/src/rules/no-disabled-certificate-validation/index.d.ts +12 -0
- package/src/rules/no-disabled-certificate-validation/index.js +66 -0
- package/src/rules/no-dynamic-service-worker-url/index.d.ts +3 -1
- package/src/rules/no-eval/index.d.ts +3 -1
- package/src/rules/no-filereader-innerhtml/index.d.ts +3 -1
- package/src/rules/no-http-urls/index.d.ts +17 -0
- package/src/rules/no-http-urls/index.js +119 -0
- package/src/rules/no-innerhtml/index.d.ts +3 -1
- package/src/rules/no-insecure-redirects/index.d.ts +26 -0
- package/src/rules/no-insecure-redirects/index.js +221 -0
- package/src/rules/no-insecure-websocket/index.d.ts +12 -0
- package/src/rules/no-insecure-websocket/index.js +66 -0
- package/src/rules/no-jwt-in-storage/index.d.ts +3 -1
- package/src/rules/no-missing-cors-check/index.d.ts +28 -0
- package/src/rules/no-missing-cors-check/index.js +399 -0
- package/src/rules/no-missing-csrf-protection/index.d.ts +30 -0
- package/src/rules/no-missing-csrf-protection/index.js +185 -0
- package/src/rules/no-missing-security-headers/index.d.ts +26 -0
- package/src/rules/no-missing-security-headers/index.js +223 -0
- package/src/rules/no-password-in-url/index.d.ts +12 -0
- package/src/rules/no-password-in-url/index.js +55 -0
- package/src/rules/no-permissive-cors/index.d.ts +12 -0
- package/src/rules/no-permissive-cors/index.js +74 -0
- package/src/rules/no-postmessage-innerhtml/index.d.ts +3 -1
- package/src/rules/no-postmessage-wildcard-origin/index.d.ts +3 -1
- package/src/rules/no-sensitive-cookie-js/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-analytics/index.js +66 -0
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +53 -0
- package/src/rules/no-sensitive-indexeddb/index.d.ts +3 -1
- package/src/rules/no-sensitive-localstorage/index.d.ts +3 -1
- package/src/rules/no-sensitive-sessionstorage/index.d.ts +3 -1
- package/src/rules/no-tracking-without-consent/index.d.ts +12 -0
- package/src/rules/no-tracking-without-consent/index.js +72 -0
- package/src/rules/no-unencrypted-transmission/index.d.ts +30 -0
- package/src/rules/no-unencrypted-transmission/index.js +241 -0
- package/src/rules/no-unescaped-url-parameter/index.d.ts +28 -0
- package/src/rules/no-unescaped-url-parameter/index.js +357 -0
- package/src/rules/no-unsafe-eval-csp/index.d.ts +3 -1
- package/src/rules/no-unsafe-inline-csp/index.d.ts +3 -1
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +12 -0
- package/src/rules/no-unvalidated-deeplinks/index.js +67 -0
- package/src/rules/no-websocket-eval/index.d.ts +3 -1
- package/src/rules/no-websocket-innerhtml/index.d.ts +3 -1
- package/src/rules/no-worker-message-innerhtml/index.d.ts +3 -1
- package/src/rules/require-blob-url-revocation/index.d.ts +3 -1
- package/src/rules/require-cookie-secure-attrs/index.d.ts +3 -1
- package/src/rules/require-csp-headers/index.d.ts +12 -0
- package/src/rules/require-csp-headers/index.js +69 -0
- package/src/rules/require-https-only/index.d.ts +12 -0
- package/src/rules/require-https-only/index.js +67 -0
- package/src/rules/require-mime-type-validation/index.d.ts +12 -0
- package/src/rules/require-mime-type-validation/index.js +71 -0
- package/src/rules/require-postmessage-origin-check/index.d.ts +3 -1
- package/src/rules/require-url-validation/index.d.ts +12 -0
- package/src/rules/require-url-validation/index.js +77 -0
- package/src/rules/require-websocket-wss/index.d.ts +3 -1
- package/AGENTS.md +0 -97
- package/CHANGELOG.md +0 -81
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const requireMimeTypeValidation: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.requireMimeTypeValidation = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Require MIME type validation for uploads
|
|
11
|
+
*/
|
|
12
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
|
+
exports.requireMimeTypeValidation = (0, eslint_devkit_1.createRule)({
|
|
14
|
+
name: 'require-mime-type-validation',
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Require MIME type validation for file uploads',
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
22
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
23
|
+
issueName: 'Missing MIME Validation',
|
|
24
|
+
cwe: 'CWE-434',
|
|
25
|
+
description: 'File upload without MIME type validation - unrestricted upload vulnerability',
|
|
26
|
+
severity: 'HIGH',
|
|
27
|
+
fix: 'Add fileFilter option to validate MIME types',
|
|
28
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/434.html',
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
schema: [],
|
|
32
|
+
},
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
create(context) {
|
|
35
|
+
function report(node) {
|
|
36
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
CallExpression(node) {
|
|
40
|
+
// Detect multer().single() or multer().array() without fileFilter
|
|
41
|
+
if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.MemberExpression &&
|
|
42
|
+
node.callee.property.type === eslint_devkit_1.AST_NODE_TYPES.Identifier &&
|
|
43
|
+
['single', 'array', 'fields'].includes(node.callee.property.name)) {
|
|
44
|
+
// Check if parent has fileFilter configuration
|
|
45
|
+
const calleeObj = node.callee.object;
|
|
46
|
+
if (calleeObj.type === eslint_devkit_1.AST_NODE_TYPES.CallExpression) {
|
|
47
|
+
const multerArgs = calleeObj.arguments[0];
|
|
48
|
+
if (multerArgs && multerArgs.type === eslint_devkit_1.AST_NODE_TYPES.ObjectExpression) {
|
|
49
|
+
const hasFileFilter = multerArgs.properties.some((p) => p.type === eslint_devkit_1.AST_NODE_TYPES.Property && p.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && (p.key.name === 'fileFilter' || p.key.name === 'limits'));
|
|
50
|
+
if (!hasFileFilter) {
|
|
51
|
+
report(node);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (!multerArgs) {
|
|
55
|
+
// No config at all = no validation
|
|
56
|
+
report(node);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// Detect upload() calls directly
|
|
61
|
+
if (node.callee.type === eslint_devkit_1.AST_NODE_TYPES.Identifier && node.callee.name === 'upload') {
|
|
62
|
+
// Check if there's validation in arguments
|
|
63
|
+
if (node.arguments.length === 0 ||
|
|
64
|
+
(node.arguments[0]?.type === eslint_devkit_1.AST_NODE_TYPES.Identifier)) {
|
|
65
|
+
report(node);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
trustedOrigins?: string[];
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const requirePostmessageOriginCheck: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const requirePostmessageOriginCheck: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const requireUrlValidation: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.requireUrlValidation = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Enforce URL validation before navigation
|
|
11
|
+
*/
|
|
12
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
|
+
exports.requireUrlValidation = (0, eslint_devkit_1.createRule)({
|
|
14
|
+
name: 'require-url-validation',
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Enforce URL validation before navigation',
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
22
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
23
|
+
issueName: 'URL Validation Required',
|
|
24
|
+
cwe: 'CWE-601',
|
|
25
|
+
description: 'Unvalidated URL used for navigation - this is a security risk',
|
|
26
|
+
severity: 'HIGH',
|
|
27
|
+
fix: 'Validate URLs before using them for navigation',
|
|
28
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/601.html',
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
schema: [],
|
|
32
|
+
},
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
create(context) {
|
|
35
|
+
function report(node) {
|
|
36
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
AssignmentExpression(node) {
|
|
40
|
+
// Detect window.location assignment from user input
|
|
41
|
+
if (node.left.type === 'MemberExpression' &&
|
|
42
|
+
node.left.object.type === 'Identifier' &&
|
|
43
|
+
node.left.object.name === 'window' &&
|
|
44
|
+
node.left.property.type === 'Identifier' &&
|
|
45
|
+
node.left.property.name === 'location') {
|
|
46
|
+
// Flag if right side is a variable (not a literal URL)
|
|
47
|
+
if (node.right.type === 'Identifier') {
|
|
48
|
+
report(node);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Detect location.href assignment
|
|
52
|
+
if (node.left.type === 'MemberExpression' &&
|
|
53
|
+
node.left.object.type === 'Identifier' &&
|
|
54
|
+
node.left.object.name === 'location' &&
|
|
55
|
+
node.left.property.type === 'Identifier' &&
|
|
56
|
+
node.left.property.name === 'href') {
|
|
57
|
+
if (node.right.type === 'Identifier') {
|
|
58
|
+
report(node);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
CallExpression(node) {
|
|
63
|
+
// Detect window.open with variable URL
|
|
64
|
+
if (node.callee.type === 'MemberExpression' &&
|
|
65
|
+
node.callee.object.type === 'Identifier' &&
|
|
66
|
+
node.callee.object.name === 'window' &&
|
|
67
|
+
node.callee.property.type === 'Identifier' &&
|
|
68
|
+
node.callee.property.name === 'open') {
|
|
69
|
+
const urlArg = node.arguments[0];
|
|
70
|
+
if (urlArg && urlArg.type === 'Identifier') {
|
|
71
|
+
report(node);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
});
|
|
@@ -20,5 +20,7 @@ export interface Options {
|
|
|
20
20
|
allowLocalhost?: boolean;
|
|
21
21
|
}
|
|
22
22
|
type RuleOptions = [Options?];
|
|
23
|
-
export declare const requireWebsocketWss: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener
|
|
23
|
+
export declare const requireWebsocketWss: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
24
26
|
export {};
|
package/AGENTS.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# AGENTS.md
|
|
2
|
-
|
|
3
|
-
> Context for AI coding agents working on eslint-plugin-browser-security
|
|
4
|
-
|
|
5
|
-
## Setup Commands
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
# Install dependencies (from monorepo root)
|
|
9
|
-
pnpm install
|
|
10
|
-
|
|
11
|
-
# Build this package
|
|
12
|
-
nx build eslint-plugin-browser-security
|
|
13
|
-
|
|
14
|
-
# Run tests
|
|
15
|
-
nx test eslint-plugin-browser-security
|
|
16
|
-
|
|
17
|
-
# Run tests with coverage
|
|
18
|
-
nx test eslint-plugin-browser-security --coverage
|
|
19
|
-
|
|
20
|
-
# Lint this package
|
|
21
|
-
nx lint eslint-plugin-browser-security
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Code Style
|
|
25
|
-
|
|
26
|
-
- TypeScript strict mode with `@interlace/eslint-devkit` types
|
|
27
|
-
- Use `AST_NODE_TYPES` constants, never string literals for node types
|
|
28
|
-
- Use `formatLLMMessage()` for all rule error messages
|
|
29
|
-
- Include CWE, CVSS, OWASP in every security message
|
|
30
|
-
- Use `c8 ignore` comments with documented reasons for untestable code
|
|
31
|
-
- Single-pass AST traversal patterns (O(n) complexity)
|
|
32
|
-
|
|
33
|
-
## Testing Instructions
|
|
34
|
-
|
|
35
|
-
- Tests use `@typescript-eslint/rule-tester` with Vitest
|
|
36
|
-
- Each rule has `index.ts` (implementation) and `*.test.ts` (tests) in same directory
|
|
37
|
-
- Run specific rule test: `nx test eslint-plugin-browser-security --testPathPattern="no-innerhtml"`
|
|
38
|
-
- Coverage target: ≥90% lines, ≥95% functions
|
|
39
|
-
- All tests must pass before committing
|
|
40
|
-
|
|
41
|
-
## Project Structure
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
src/
|
|
45
|
-
├── index.ts # Plugin entry, exports rules and 7 configs
|
|
46
|
-
└── rules/ # 21 rule directories
|
|
47
|
-
└── [rule-name]/
|
|
48
|
-
├── index.ts # Rule implementation
|
|
49
|
-
└── *.test.ts # Rule tests
|
|
50
|
-
docs/rules/ # Markdown documentation per rule
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
## Plugin Purpose
|
|
54
|
-
|
|
55
|
-
Security-focused ESLint plugin with **21 rules** for browser application security. Covers XSS prevention, postMessage abuse, storage security, cookie security, WebSocket vulnerabilities, File API, Workers, and CSP.
|
|
56
|
-
|
|
57
|
-
## Rule Categories
|
|
58
|
-
|
|
59
|
-
| Category | Rules | CWEs |
|
|
60
|
-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------ |
|
|
61
|
-
| XSS Prevention | `no-innerhtml`, `no-eval` | 79, 95 |
|
|
62
|
-
| postMessage | `require-postmessage-origin-check`, `no-postmessage-wildcard-origin`, `no-postmessage-innerhtml` | 79, 346 |
|
|
63
|
-
| Storage | `no-sensitive-localstorage`, `no-sensitive-sessionstorage`, `no-sensitive-indexeddb`, `no-jwt-in-storage` | 922 |
|
|
64
|
-
| Cookies | `no-sensitive-cookie-js`, `no-cookie-auth-tokens`, `require-cookie-secure-attrs` | 614, 1004 |
|
|
65
|
-
| WebSocket | `require-websocket-wss`, `no-websocket-innerhtml`, `no-websocket-eval` | 79, 95, 319 |
|
|
66
|
-
| File API & Workers | `no-filereader-innerhtml`, `require-blob-url-revocation`, `no-dynamic-service-worker-url`, `no-worker-message-innerhtml` | 79, 401, 829 |
|
|
67
|
-
| CSP | `no-unsafe-inline-csp`, `no-unsafe-eval-csp` | 79, 95 |
|
|
68
|
-
|
|
69
|
-
## Common Fix Patterns
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
// XSS - innerHTML
|
|
73
|
-
// BAD: element.innerHTML = userInput
|
|
74
|
-
// GOOD: element.textContent = userInput
|
|
75
|
-
// GOOD: element.innerHTML = DOMPurify.sanitize(userInput)
|
|
76
|
-
|
|
77
|
-
// postMessage origin check
|
|
78
|
-
// BAD: window.addEventListener('message', (e) => process(e.data))
|
|
79
|
-
// GOOD: window.addEventListener('message', (e) => {
|
|
80
|
-
// if (e.origin !== 'https://trusted.com') return;
|
|
81
|
-
// process(e.data);
|
|
82
|
-
// })
|
|
83
|
-
|
|
84
|
-
// Storage - JWT
|
|
85
|
-
// BAD: localStorage.setItem('token', jwt)
|
|
86
|
-
// GOOD: Use HttpOnly cookies set by server
|
|
87
|
-
|
|
88
|
-
// WebSocket
|
|
89
|
-
// BAD: new WebSocket('ws://example.com')
|
|
90
|
-
// GOOD: new WebSocket('wss://example.com')
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## Security Considerations
|
|
94
|
-
|
|
95
|
-
- All rules map to OWASP Top 10 2021 categories
|
|
96
|
-
- CWE coverage: 79, 95, 319, 346, 401, 614, 829, 922, 1004
|
|
97
|
-
- Every rule message includes remediation guidance for both humans and LLMs
|
package/CHANGELOG.md
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to `eslint-plugin-browser-security` will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
### Documentation
|
|
11
|
-
|
|
12
|
-
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
13
|
-
|
|
14
|
-
## [1.0.0] - 2025-12-29
|
|
15
|
-
|
|
16
|
-
### Added
|
|
17
|
-
|
|
18
|
-
#### XSS Prevention Rules (2)
|
|
19
|
-
|
|
20
|
-
- `no-innerhtml` - Detect dangerous innerHTML/outerHTML assignments (CWE-79)
|
|
21
|
-
- `no-eval` - Detect eval(), new Function(), and string-based callbacks (CWE-95)
|
|
22
|
-
|
|
23
|
-
#### postMessage Security Rules (3)
|
|
24
|
-
|
|
25
|
-
- `require-postmessage-origin-check` - Require origin validation in message handlers (CWE-346)
|
|
26
|
-
- `no-postmessage-wildcard-origin` - Prevent wildcard targetOrigin in postMessage (CWE-346)
|
|
27
|
-
- `no-postmessage-innerhtml` - Prevent XSS via innerHTML in postMessage handlers (CWE-79)
|
|
28
|
-
|
|
29
|
-
#### Storage Security Rules (4)
|
|
30
|
-
|
|
31
|
-
- `no-sensitive-localstorage` - Prevent storing sensitive data in localStorage (CWE-922)
|
|
32
|
-
- `no-sensitive-sessionstorage` - Prevent storing sensitive data in sessionStorage (CWE-922)
|
|
33
|
-
- `no-sensitive-indexeddb` - Prevent storing sensitive data in IndexedDB (CWE-922)
|
|
34
|
-
- `no-jwt-in-storage` - Prevent storing JWT tokens in browser storage (CWE-922)
|
|
35
|
-
|
|
36
|
-
#### Cookie Security Rules (3)
|
|
37
|
-
|
|
38
|
-
- `no-sensitive-cookie-js` - Prevent storing sensitive data in cookies via JavaScript (CWE-1004)
|
|
39
|
-
- `no-cookie-auth-tokens` - Prevent auth tokens in JS-accessible cookies (CWE-1004)
|
|
40
|
-
- `require-cookie-secure-attrs` - Require Secure and SameSite cookie attributes (CWE-614)
|
|
41
|
-
|
|
42
|
-
#### WebSocket Security Rules (3)
|
|
43
|
-
|
|
44
|
-
- `require-websocket-wss` - Require secure WebSocket connections (wss://) (CWE-319)
|
|
45
|
-
- `no-websocket-innerhtml` - Prevent XSS via innerHTML in WebSocket handlers (CWE-79)
|
|
46
|
-
- `no-websocket-eval` - Prevent RCE via eval() in WebSocket handlers (CWE-95)
|
|
47
|
-
|
|
48
|
-
#### File API & Workers Security Rules (4)
|
|
49
|
-
|
|
50
|
-
- `no-filereader-innerhtml` - Prevent XSS via innerHTML with FileReader data (CWE-79)
|
|
51
|
-
- `require-blob-url-revocation` - Require revoking Blob URLs to prevent memory leaks (CWE-401)
|
|
52
|
-
- `no-dynamic-service-worker-url` - Prevent dynamic URLs in service worker registration (CWE-829)
|
|
53
|
-
- `no-worker-message-innerhtml` - Prevent XSS via innerHTML in Worker message handlers (CWE-79)
|
|
54
|
-
|
|
55
|
-
#### CSP Security Rules (2)
|
|
56
|
-
|
|
57
|
-
- `no-unsafe-inline-csp` - Disallow 'unsafe-inline' in CSP (CWE-79)
|
|
58
|
-
- `no-unsafe-eval-csp` - Disallow 'unsafe-eval' in CSP (CWE-95)
|
|
59
|
-
|
|
60
|
-
#### Presets (7)
|
|
61
|
-
|
|
62
|
-
- `recommended` - Balanced security defaults
|
|
63
|
-
- `strict` - All 21 rules as errors
|
|
64
|
-
- `xss` - XSS-focused rules only
|
|
65
|
-
- `storage` - Storage security rules only
|
|
66
|
-
- `postmessage` - postMessage security rules only
|
|
67
|
-
- `websocket` - WebSocket security rules only
|
|
68
|
-
- `cookies` - Cookie security rules only
|
|
69
|
-
|
|
70
|
-
#### Features
|
|
71
|
-
|
|
72
|
-
- LLM-optimized error messages with CWE references
|
|
73
|
-
- OWASP Top 10 2021 alignment
|
|
74
|
-
- TypeScript support with exported option types
|
|
75
|
-
- Comprehensive test coverage (297 tests, 97.73% line coverage)
|
|
76
|
-
- Auto-fix suggestions where safe
|
|
77
|
-
|
|
78
|
-
### Security
|
|
79
|
-
|
|
80
|
-
- Covers 8 CWEs: 79, 95, 319, 346, 401, 614, 829, 922, 1004
|
|
81
|
-
- Maps to OWASP Top 10 2021: A01, A02, A03
|