eslint-plugin-browser-security 1.2.3 → 1.2.4
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/AGENTS.md +97 -0
- package/CHANGELOG.md +125 -0
- package/README.md +111 -89
- package/package.json +21 -5
- package/src/index.js +14 -1
- package/src/oxlint.d.ts +20 -0
- package/src/oxlint.js +21 -0
- package/src/rules/detect-mixed-content/index.js +3 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +3 -0
- package/src/rules/no-clickjacking/index.js +10 -5
- package/src/rules/no-client-side-auth-logic/index.js +4 -0
- package/src/rules/no-cookie-auth-tokens/index.js +4 -1
- package/src/rules/no-credentials-in-query-params/index.js +3 -0
- package/src/rules/no-disabled-certificate-validation/index.js +5 -2
- package/src/rules/no-dynamic-service-worker-url/index.js +4 -1
- package/src/rules/no-eval/index.js +34 -15
- package/src/rules/no-filereader-innerhtml/index.js +8 -5
- package/src/rules/no-http-urls/index.js +3 -0
- package/src/rules/no-innerhtml/index.js +58 -34
- package/src/rules/no-insecure-redirects/index.js +5 -2
- package/src/rules/no-insecure-websocket/index.js +3 -0
- package/src/rules/no-jwt-in-storage/index.js +7 -4
- package/src/rules/no-missing-cors-check/index.js +5 -2
- package/src/rules/no-missing-csrf-protection/index.js +3 -0
- package/src/rules/no-missing-security-headers/index.js +20 -17
- package/src/rules/no-password-in-url/index.js +3 -0
- package/src/rules/no-permissive-cors/index.js +4 -0
- package/src/rules/no-postmessage-innerhtml/index.js +8 -5
- package/src/rules/no-postmessage-wildcard-origin/index.js +4 -1
- package/src/rules/no-sensitive-cookie-js/index.js +4 -1
- package/src/rules/no-sensitive-data-in-analytics/index.js +3 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +5 -1
- package/src/rules/no-sensitive-indexeddb/index.js +4 -1
- package/src/rules/no-sensitive-localstorage/index.js +3 -0
- package/src/rules/no-sensitive-sessionstorage/index.js +4 -1
- package/src/rules/no-tracking-without-consent/index.js +3 -0
- package/src/rules/no-unencrypted-transmission/index.js +5 -2
- package/src/rules/no-unescaped-url-parameter/index.js +6 -2
- package/src/rules/no-unsafe-eval-csp/index.js +4 -1
- package/src/rules/no-unsafe-inline-csp/index.js +4 -1
- package/src/rules/no-unvalidated-deeplinks/index.js +3 -0
- package/src/rules/no-websocket-eval/index.js +6 -3
- package/src/rules/no-websocket-innerhtml/index.js +8 -5
- package/src/rules/no-worker-message-innerhtml/index.js +8 -5
- package/src/rules/require-blob-url-revocation/index.js +4 -1
- package/src/rules/require-cookie-secure-attrs/index.js +4 -1
- package/src/rules/require-csp-headers/index.js +3 -0
- package/src/rules/require-https-only/index.js +3 -0
- package/src/rules/require-mime-type-validation/index.js +3 -0
- package/src/rules/require-postmessage-origin-check/index.js +3 -0
- package/src/rules/require-url-validation/index.js +3 -0
- package/src/rules/require-websocket-wss/index.js +6 -2
package/AGENTS.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
npm 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
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
## [1.2.3] - 2026-02-08
|
|
2
|
+
|
|
3
|
+
## 1.2.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#141](https://github.com/ofri-peretz/eslint/pull/141) [`38ab670`](https://github.com/ofri-peretz/eslint/commit/38ab670a0221684f4fd3d5dc3c05ddec7458ca2b) Thanks [@ofri-peretz](https://github.com/ofri-peretz)! - fix: remove false `meta.fixable: 'code'` declarations from 21 rules that had no `fix()` function
|
|
8
|
+
|
|
9
|
+
Rules that declared `fixable: 'code'` in their ESLint meta without an actual `fix()` implementation would show the ⚡ auto-fix icon in editors and CI formatters but apply no change when `--fix` was run. This patch removes the misleading declaration from:
|
|
10
|
+
- `browser-security/no-clickjacking`
|
|
11
|
+
- `import-next/first`, `named`, `no-barrel-import`, `no-import-module-exports`, `no-namespace`
|
|
12
|
+
- `node-security/no-buffer-overread`, `no-unsafe-dynamic-require`, `no-zip-slip`
|
|
13
|
+
- `react-features/react-no-inline-functions`
|
|
14
|
+
- `reliability/no-jsdoc-terminator-in-example` (uses `suggest`, not auto-fix; corrected to `hasSuggestions: true` only)
|
|
15
|
+
- `secure-coding/no-directive-injection`, `no-electron-security-issues`, `no-graphql-injection`, `no-improper-sanitization`, `no-improper-type-validation`, `no-ldap-injection`, `no-unchecked-loop-condition`, `no-unlimited-resource-allocation`, `no-weak-password-recovery`, `no-xpath-injection`
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`736a5fe`](https://github.com/ofri-peretz/eslint/commit/736a5fed47e673f6157ea900b29fe2a54e4bc7df)]:
|
|
18
|
+
- @interlace/eslint-devkit@1.4.1
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
- align codecov component IDs with full package names ([2831b968](https://github.com/ofri-peretz/eslint/commit/2831b968))
|
|
23
|
+
- resolve all benchmark FN/FP across security rules ([45ffb791](https://github.com/ofri-peretz/eslint/commit/45ffb791))
|
|
24
|
+
|
|
25
|
+
### Documentation
|
|
26
|
+
|
|
27
|
+
- fix changelog header format across all packages ([c3a15082](https://github.com/ofri-peretz/eslint/commit/c3a15082))
|
|
28
|
+
|
|
29
|
+
### ❤️ Thank You
|
|
30
|
+
|
|
31
|
+
- Ofri Peretz
|
|
32
|
+
|
|
33
|
+
## [1.2.2] - 2026-02-06
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
- align codecov component names and update docs components ([0a59a86c](https://github.com/ofri-peretz/eslint/commit/0a59a86c))
|
|
38
|
+
|
|
39
|
+
### ❤️ Thank You
|
|
40
|
+
|
|
41
|
+
- Ofri Peretz
|
|
42
|
+
|
|
43
|
+
## [1.2.1] - 2026-02-02
|
|
44
|
+
|
|
45
|
+
This was a version bump only for eslint-plugin-browser-security to align it with other projects, there were no code changes.
|
|
46
|
+
|
|
47
|
+
# Changelog
|
|
48
|
+
|
|
49
|
+
All notable changes to `eslint-plugin-browser-security` will be documented in this file.
|
|
50
|
+
|
|
51
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
52
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
53
|
+
|
|
54
|
+
### Documentation
|
|
55
|
+
|
|
56
|
+
- 📘 Launched new documentation site: [eslint.interlace.tools](https://eslint.interlace.tools/)
|
|
57
|
+
|
|
58
|
+
## [1.0.0] - 2025-12-29
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
#### XSS Prevention Rules (2)
|
|
63
|
+
|
|
64
|
+
- `no-innerhtml` - Detect dangerous innerHTML/outerHTML assignments (CWE-79)
|
|
65
|
+
- `no-eval` - Detect eval(), new Function(), and string-based callbacks (CWE-95)
|
|
66
|
+
|
|
67
|
+
#### postMessage Security Rules (3)
|
|
68
|
+
|
|
69
|
+
- `require-postmessage-origin-check` - Require origin validation in message handlers (CWE-346)
|
|
70
|
+
- `no-postmessage-wildcard-origin` - Prevent wildcard targetOrigin in postMessage (CWE-346)
|
|
71
|
+
- `no-postmessage-innerhtml` - Prevent XSS via innerHTML in postMessage handlers (CWE-79)
|
|
72
|
+
|
|
73
|
+
#### Storage Security Rules (4)
|
|
74
|
+
|
|
75
|
+
- `no-sensitive-localstorage` - Prevent storing sensitive data in localStorage (CWE-922)
|
|
76
|
+
- `no-sensitive-sessionstorage` - Prevent storing sensitive data in sessionStorage (CWE-922)
|
|
77
|
+
- `no-sensitive-indexeddb` - Prevent storing sensitive data in IndexedDB (CWE-922)
|
|
78
|
+
- `no-jwt-in-storage` - Prevent storing JWT tokens in browser storage (CWE-922)
|
|
79
|
+
|
|
80
|
+
#### Cookie Security Rules (3)
|
|
81
|
+
|
|
82
|
+
- `no-sensitive-cookie-js` - Prevent storing sensitive data in cookies via JavaScript (CWE-1004)
|
|
83
|
+
- `no-cookie-auth-tokens` - Prevent auth tokens in JS-accessible cookies (CWE-1004)
|
|
84
|
+
- `require-cookie-secure-attrs` - Require Secure and SameSite cookie attributes (CWE-614)
|
|
85
|
+
|
|
86
|
+
#### WebSocket Security Rules (3)
|
|
87
|
+
|
|
88
|
+
- `require-websocket-wss` - Require secure WebSocket connections (wss://) (CWE-319)
|
|
89
|
+
- `no-websocket-innerhtml` - Prevent XSS via innerHTML in WebSocket handlers (CWE-79)
|
|
90
|
+
- `no-websocket-eval` - Prevent RCE via eval() in WebSocket handlers (CWE-95)
|
|
91
|
+
|
|
92
|
+
#### File API & Workers Security Rules (4)
|
|
93
|
+
|
|
94
|
+
- `no-filereader-innerhtml` - Prevent XSS via innerHTML with FileReader data (CWE-79)
|
|
95
|
+
- `require-blob-url-revocation` - Require revoking Blob URLs to prevent memory leaks (CWE-401)
|
|
96
|
+
- `no-dynamic-service-worker-url` - Prevent dynamic URLs in service worker registration (CWE-829)
|
|
97
|
+
- `no-worker-message-innerhtml` - Prevent XSS via innerHTML in Worker message handlers (CWE-79)
|
|
98
|
+
|
|
99
|
+
#### CSP Security Rules (2)
|
|
100
|
+
|
|
101
|
+
- `no-unsafe-inline-csp` - Disallow 'unsafe-inline' in CSP (CWE-79)
|
|
102
|
+
- `no-unsafe-eval-csp` - Disallow 'unsafe-eval' in CSP (CWE-95)
|
|
103
|
+
|
|
104
|
+
#### Presets (7)
|
|
105
|
+
|
|
106
|
+
- `recommended` - Balanced security defaults
|
|
107
|
+
- `strict` - All 21 rules as errors
|
|
108
|
+
- `xss` - XSS-focused rules only
|
|
109
|
+
- `storage` - Storage security rules only
|
|
110
|
+
- `postmessage` - postMessage security rules only
|
|
111
|
+
- `websocket` - WebSocket security rules only
|
|
112
|
+
- `cookies` - Cookie security rules only
|
|
113
|
+
|
|
114
|
+
#### Features
|
|
115
|
+
|
|
116
|
+
- LLM-optimized error messages with CWE references
|
|
117
|
+
- OWASP Top 10 2021 alignment
|
|
118
|
+
- TypeScript support with exported option types
|
|
119
|
+
- Comprehensive test coverage (297 tests, 97.73% line coverage)
|
|
120
|
+
- Auto-fix suggestions where safe
|
|
121
|
+
|
|
122
|
+
### Security
|
|
123
|
+
|
|
124
|
+
- Covers 8 CWEs: 79, 95, 319, 346, 401, 614, 829, 922, 1004
|
|
125
|
+
- Maps to OWASP Top 10 2021: A01, A02, A03
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://eslint.interlace.tools" target="blank"><img src="https://eslint.interlace.tools/eslint-interlace-logo-light.svg" alt="ESLint Interlace Logo" width="120" /></a>
|
|
2
|
+
<a href="https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security" target="blank"><img src="https://eslint.interlace.tools/eslint-interlace-logo-light.svg" alt="ESLint Interlace Logo" width="120" /></a>
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center">
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
<a href="https://www.npmjs.com/package/eslint-plugin-browser-security" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-browser-security.svg" alt="NPM Version" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/eslint-plugin-browser-security" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-browser-security.svg" alt="NPM Downloads" /></a>
|
|
12
12
|
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
|
|
13
|
-
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=browser-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=
|
|
13
|
+
<a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=browser-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=browser-security" alt="Codecov" /></a>
|
|
14
14
|
<a href="https://github.com/ofri-peretz/eslint" target="_blank"><img src="https://img.shields.io/badge/Since-Dec_2025-blue?logo=rocket&logoColor=white" alt="Since Dec 2025" /></a>
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
|
+
> ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
|
|
18
|
+
|
|
17
19
|
## Description
|
|
18
20
|
|
|
19
21
|
This plugin provides Browser-specific security rules to prevent XSS and other client-side attacks.
|
|
20
|
-
By using this plugin, you can proactively identify and mitigate security risks across your entire codebase.
|
|
21
22
|
|
|
22
23
|
## Philosophy
|
|
23
24
|
|
|
@@ -25,17 +26,47 @@ By using this plugin, you can proactively identify and mitigate security risks a
|
|
|
25
26
|
|
|
26
27
|
## Getting Started
|
|
27
28
|
|
|
28
|
-
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-browser-security), visit [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
29
|
-
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-browser-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
30
|
-
- [가이드](https://eslint.interlace.tools/docs/security/plugin-browser-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools)에서 확인하실 수 있습니다. 📚
|
|
31
|
-
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-browser-security)は [eslint.interlace.tools](https://eslint.interlace.tools)でご確認ください。 📚
|
|
32
|
-
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-browser-security), visita [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
33
|
-
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-browser-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools). 📚
|
|
29
|
+
- To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security). 📚
|
|
30
|
+
- 要查看中文 [指南](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security), 请访问 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security). 📚
|
|
31
|
+
- [가이드](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) 문서는 [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security)에서 확인하실 수 있습니다. 📚
|
|
32
|
+
- [ガイド](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security)は [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security)でご確認ください。 📚
|
|
33
|
+
- Para ver la [guía](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security), visita [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security). 📚
|
|
34
|
+
- للاطلاع على [الدليل](https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security)، قم بزيارة [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security). 📚
|
|
34
35
|
|
|
35
36
|
```bash
|
|
36
37
|
npm install eslint-plugin-browser-security --save-dev
|
|
37
38
|
```
|
|
38
39
|
|
|
40
|
+
## ⚙️ Configuration Presets
|
|
41
|
+
| Preset | Description |
|
|
42
|
+
| :------------ | :-------------------------------------------------- |
|
|
43
|
+
| `recommended` | Recommended security configuration |
|
|
44
|
+
| `strict` | Strict security configuration - all rules as errors |
|
|
45
|
+
|
|
46
|
+
## 🤖 LLM-Optimized Messages
|
|
47
|
+
All rules include structured remediation guidance designed for AI assistants:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
[browser-security/no-innerhtml] XSS vulnerability: Direct HTML assignment detected.
|
|
51
|
+
|
|
52
|
+
📋 CONTEXT:
|
|
53
|
+
• Pattern: element.innerHTML = unsanitizedInput
|
|
54
|
+
• Risk: Any script in unsanitizedInput will execute
|
|
55
|
+
|
|
56
|
+
🛠️ REMEDIATION:
|
|
57
|
+
Option A (Preferred): Use textContent for plain text
|
|
58
|
+
element.textContent = userInput;
|
|
59
|
+
|
|
60
|
+
Option B: Sanitize before insertion
|
|
61
|
+
element.innerHTML = DOMPurify.sanitize(userInput);
|
|
62
|
+
|
|
63
|
+
📚 References:
|
|
64
|
+
• CWE-79: https://cwe.mitre.org/data/definitions/79.html
|
|
65
|
+
• OWASP XSS Prevention: https://owasp.org/...
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
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.
|
|
69
|
+
|
|
39
70
|
## 💡 What You Get
|
|
40
71
|
- **21 security rules** targeting browser-specific vulnerabilities
|
|
41
72
|
- **XSS prevention** via DOM manipulation and dynamic content detection
|
|
@@ -91,35 +122,13 @@ window.addEventListener('message', (event) => {
|
|
|
91
122
|
});
|
|
92
123
|
```
|
|
93
124
|
|
|
94
|
-
##
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
100
|
-
## 🤖 LLM-Optimized Messages
|
|
101
|
-
All rules include structured remediation guidance designed for AI assistants:
|
|
102
|
-
|
|
103
|
-
```
|
|
104
|
-
[browser-security/no-innerhtml] XSS vulnerability: Direct HTML assignment detected.
|
|
105
|
-
|
|
106
|
-
📋 CONTEXT:
|
|
107
|
-
• Pattern: element.innerHTML = unsanitizedInput
|
|
108
|
-
• Risk: Any script in unsanitizedInput will execute
|
|
109
|
-
|
|
110
|
-
🛠️ REMEDIATION:
|
|
111
|
-
Option A (Preferred): Use textContent for plain text
|
|
112
|
-
element.textContent = userInput;
|
|
113
|
-
|
|
114
|
-
Option B: Sanitize before insertion
|
|
115
|
-
element.innerHTML = DOMPurify.sanitize(userInput);
|
|
116
|
-
|
|
117
|
-
📚 References:
|
|
118
|
-
• CWE-79: https://cwe.mitre.org/data/definitions/79.html
|
|
119
|
-
• OWASP XSS Prevention: https://owasp.org/...
|
|
120
|
-
```
|
|
125
|
+
## 📦 Compatibility
|
|
126
|
+
| Package | Version |
|
|
127
|
+
| :--- | :--- |
|
|
128
|
+
| ESLint | `^8.0.0 \|\| ^9.0.0 \|\| ^10.0.0` |
|
|
129
|
+
| Node.js | `>=18.0.0` |
|
|
121
130
|
|
|
122
|
-
|
|
131
|
+
See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) — current ecosystem share data, the 20% gate, and the forward-looking exception that covers v10.
|
|
123
132
|
|
|
124
133
|
## Rules
|
|
125
134
|
|
|
@@ -128,59 +137,63 @@ By providing this structured context (CWE, OWASP, Fix), we enable AI tools to **
|
|
|
128
137
|
| Icon | Description |
|
|
129
138
|
| :---: | :--- |
|
|
130
139
|
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
131
|
-
| ⚠️ | **Warns**: Set
|
|
140
|
+
| ⚠️ | **Warns**: Set to warn in recommended preset. |
|
|
132
141
|
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
133
142
|
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
134
143
|
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
135
|
-
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
|
141
|
-
|
|
|
142
|
-
| [
|
|
143
|
-
| [no-
|
|
144
|
-
| [no-
|
|
145
|
-
| [no-
|
|
146
|
-
| [no-
|
|
147
|
-
| [no-
|
|
148
|
-
| [no-
|
|
149
|
-
| [no-
|
|
150
|
-
| [no-
|
|
151
|
-
| [no-
|
|
152
|
-
| [no-
|
|
153
|
-
| [no-
|
|
154
|
-
| [no-
|
|
155
|
-
| [no-
|
|
156
|
-
| [no-
|
|
157
|
-
| [no-
|
|
158
|
-
| [no-
|
|
159
|
-
| [no-
|
|
160
|
-
| [no-
|
|
161
|
-
| [no-
|
|
162
|
-
| [no-
|
|
163
|
-
| [no-
|
|
164
|
-
| [no-sensitive-
|
|
165
|
-
| [no-sensitive-
|
|
166
|
-
| [no-
|
|
167
|
-
| [no-
|
|
168
|
-
| [no-
|
|
169
|
-
| [no-
|
|
170
|
-
| [no-
|
|
171
|
-
| [no-
|
|
172
|
-
| [no-
|
|
173
|
-
| [no-
|
|
174
|
-
| [no-
|
|
175
|
-
| [
|
|
176
|
-
| [
|
|
177
|
-
| [
|
|
178
|
-
| [
|
|
179
|
-
| [require-
|
|
180
|
-
| [require-
|
|
181
|
-
| [require-
|
|
182
|
-
| [require-
|
|
183
|
-
|
|
144
|
+
| 🟢 | **Type-unaware**: AST-only, runs in oxlint JS-plugin tier. |
|
|
145
|
+
| 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
|
|
146
|
+
| 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
|
|
147
|
+
|
|
148
|
+
<!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
|
|
149
|
+
| Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
150
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
|
|
151
|
+
| [detect-mixed-content](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/detect-mixed-content?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-311 | | | Detects HTTP URLs in code that should use HTTPS, preventing mixed content vulnerabilities. | 🟢 | | | | | |
|
|
152
|
+
| [no-allow-arbitrary-loads](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-allow-arbitrary-loads?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | Prevents disabling App Transport Security (ATS) by detecting allowArbitraryLoads: true in configuration. | 🟢 | | | | | |
|
|
153
|
+
| [no-clickjacking](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-clickjacking?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1021 | | | Detects clickjacking vulnerabilities and missing frame protections | 🟢 | | | | | |
|
|
154
|
+
| [no-client-side-auth-logic](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-client-side-auth-logic?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | | | | Prevent client-side authentication logic that can be bypassed. This rule is part of eslint-plugin-browser-s… | 🟢 | | | | | |
|
|
155
|
+
| [no-cookie-auth-tokens](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-cookie-auth-tokens?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1004 | A02:2021 | | Prevent storing authentication tokens in JavaScript-accessible cookies. | 🟢 | | | | | |
|
|
156
|
+
| [no-credentials-in-query-params](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-credentials-in-query-params?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-598 | | | CWE: [CWE-598](https://cwe.mitre.org/data/definitions/598.html) | 🟢 | | | | | |
|
|
157
|
+
| [no-disabled-certificate-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-disabled-certificate-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | CWE: [CWE-295](https://cwe.mitre.org/data/definitions/295.html) | 🟢 | | | | | |
|
|
158
|
+
| [no-dynamic-service-worker-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-dynamic-service-worker-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-829 | A08:2021 | | Prevent dynamic URLs in service worker registration. | 🟢 | | | | | |
|
|
159
|
+
| [no-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-eval?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-94 | | | Detects dangerous eval() and similar code execution patterns | 🟢 | 💼 | | | | |
|
|
160
|
+
| [no-filereader-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-filereader-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
161
|
+
| [no-http-urls](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-http-urls?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | | | | | |
|
|
162
|
+
| [no-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | | | Detects dangerous innerHTML/outerHTML assignments that can lead to Cross-Site Scripting (XSS) | 🟢 | 💼 | | | | |
|
|
163
|
+
| [no-insecure-redirects](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-redirects?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-601 | | | ESLint Rule: no-insecure-redirects | 🟢 | | | | | |
|
|
164
|
+
| [no-insecure-websocket](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-websocket?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | | | | | |
|
|
165
|
+
| [no-jwt-in-storage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-jwt-in-storage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-311 | A02:2021 | | This rule prevents storing JWT tokens in browser storage (localStorage/sessionStorage) | 🟢 | | | | | |
|
|
166
|
+
| [no-missing-cors-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-cors-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-346 | | | Detects missing CORS validation (wildcard CORS, missing origin check) that can allow unauthorized cross-ori… | 🟢 | | | | | |
|
|
167
|
+
| [no-missing-csrf-protection](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-csrf-protection?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-352 | | | Detects missing CSRF token validation in POST/PUT/DELETE requests | 🟢 | | | | | |
|
|
168
|
+
| [no-missing-security-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-security-headers?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | | | ESLint Rule: no-missing-security-headers | 🟢 | | | | | |
|
|
169
|
+
| [no-password-in-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-password-in-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-521 | | | This rule detects when URLs contain password-related query parameters or URL fragments | 🟢 | | | | | |
|
|
170
|
+
| [no-permissive-cors](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-permissive-cors?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-942 | | | CWE: [CWE-942](https://cwe.mitre.org/data/definitions/942.html) | 🟢 | | | | | |
|
|
171
|
+
| [no-postmessage-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
172
|
+
| [no-postmessage-wildcard-origin](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-wildcard-origin?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A01:2021 | | This rule prevents using \\"\\" as the targetOrigin parameter in postMessage() calls | 🟢 | | | | | |
|
|
173
|
+
| [no-sensitive-cookie-js](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-cookie-js?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | A02:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
174
|
+
| [no-sensitive-data-in-analytics](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-analytics?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | | | This rule detects when sensitive user data (email, SSN, credit card, password, phone, address) is passed to… | 🟢 | | | | | |
|
|
175
|
+
| [no-sensitive-data-in-cache](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-cache?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-200 | | | CWE: [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | 🟢 | | | | | |
|
|
176
|
+
| [no-sensitive-indexeddb](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-indexeddb?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in IndexedDB. | 🟢 | | | | | |
|
|
177
|
+
| [no-sensitive-localstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-localstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | | | Detects storage of sensitive data (tokens, passwords, PII) in localStorage | 🟢 | | | | | |
|
|
178
|
+
| [no-sensitive-sessionstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-sessionstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in sessionStorage. | 🟢 | | | | | |
|
|
179
|
+
| [no-tracking-without-consent](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-tracking-without-consent?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | | | CWE: [CWE-359](https://cwe.mitre.org/data/definitions/359.html) | 🟢 | | | | | |
|
|
180
|
+
| [no-unencrypted-transmission](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unencrypted-transmission?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols) | 🟢 | | | | | |
|
|
181
|
+
| [no-unescaped-url-parameter](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unescaped-url-parameter?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | | | Detects unescaped URL parameters that can lead to Cross-Site Scripting (XSS) or open redirect vulnerabilities | 🟢 | | | | | |
|
|
182
|
+
| [no-unsafe-eval-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-eval-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-95 | A03:2021 | | Disallow 'unsafe-eval' in Content Security Policy directives. | 🟢 | | | | | |
|
|
183
|
+
| [no-unsafe-inline-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-inline-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow 'unsafe-inline' in Content Security Policy directives. | 🟢 | | | | | |
|
|
184
|
+
| [no-unvalidated-deeplinks](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unvalidated-deeplinks?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-939 | | | This rule detects when deep link URLs are opened without validation in React Native or mobile web apps | 🟢 | | | | | |
|
|
185
|
+
| [no-websocket-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-eval?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
186
|
+
| [no-websocket-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
|
|
187
|
+
| [no-worker-message-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-worker-message-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow using innerHTML with Web Worker message data. | 🟢 | | | | | |
|
|
188
|
+
| [require-blob-url-revocation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-blob-url-revocation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-401 | A04:2021 | | Require revoking Blob URLs after use to prevent memory leaks. | 🟢 | | | | | |
|
|
189
|
+
| [require-cookie-secure-attrs](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-cookie-secure-attrs?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-614 | A05:2021 | | Require Secure and SameSite attributes on cookies. | 🟢 | | | | | |
|
|
190
|
+
| [require-csp-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-csp-headers?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1021 | | | CWE: [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | 🟢 | | | | | |
|
|
191
|
+
| [require-https-only](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-https-only?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | This rule detects HTTP (unencrypted) URLs in fetch() and axios requests | 🟢 | | | | | |
|
|
192
|
+
| [require-mime-type-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-mime-type-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-434 | | | CWE: [CWE-434](https://cwe.mitre.org/data/definitions/434.html) | 🟢 | | | | | |
|
|
193
|
+
| [require-postmessage-origin-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-postmessage-origin-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-346 | | | Detects postMessage event handlers without origin validation | 🟢 | | | | | |
|
|
194
|
+
| [require-url-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-url-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-601 | | | CWE: [CWE-601](https://cwe.mitre.org/data/definitions/601.html) | 🟢 | | | | | |
|
|
195
|
+
| [require-websocket-wss](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-websocket-wss?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A02:2021 | | This rule enforces the use of wss:// (WebSocket Secure) protocol instead of ws:// (unencrypted WebSocket) | 🟢 | | | | | |
|
|
196
|
+
<!-- AUTO-GENERATED:RULES_TABLE:END -->
|
|
184
197
|
## 🔗 Related ESLint Plugins
|
|
185
198
|
|
|
186
199
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
@@ -189,7 +202,7 @@ Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with L
|
|
|
189
202
|
| :--- | :---: | :--- |
|
|
190
203
|
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
191
204
|
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
192
|
-
| [`eslint-plugin-
|
|
205
|
+
| [`eslint-plugin-node-security`](https://www.npmjs.com/package/eslint-plugin-node-security) | [](https://www.npmjs.com/package/eslint-plugin-node-security) | Node.js core-module security (fs, child_process, vm, crypto, Buffer). |
|
|
193
206
|
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
194
207
|
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
|
|
195
208
|
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
|
|
@@ -199,10 +212,19 @@ Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with L
|
|
|
199
212
|
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening. |
|
|
200
213
|
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
201
214
|
|
|
215
|
+
<!-- INTERLACE:STAR_CTA:START -->
|
|
216
|
+
## ⭐ Support & follow
|
|
217
|
+
|
|
218
|
+
If this plugin caught a real bug for you, **[star the repo](https://github.com/ofri-peretz/eslint)** — stars are the signal that keeps the Interlace ESLint ecosystem maintained — and **[follow the writeups on Dev.to](https://dev.to/ofri-peretz)** for the benchmarks and security research behind these rules.
|
|
219
|
+
|
|
220
|
+
[](https://github.com/ofri-peretz/eslint)
|
|
221
|
+
|
|
222
|
+
<!-- INTERLACE:STAR_CTA:END -->
|
|
223
|
+
|
|
202
224
|
## 📄 License
|
|
203
225
|
|
|
204
226
|
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
205
227
|
|
|
206
228
|
<p align="center">
|
|
207
|
-
<a href="https://eslint.interlace.tools/docs/security/plugin-browser-security"><img src="https://eslint.interlace.tools/images/og-browser-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
229
|
+
<a href="https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security"><img src="https://eslint.interlace.tools/images/og-browser-security.png" alt="ESLint Interlace Plugin" width="100%" /></a>
|
|
208
230
|
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-browser-security",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Security-focused ESLint plugin for browser applications. Detects XSS vulnerabilities, postMessage abuse, localStorage/sessionStorage/IndexedDB token exposure, cookie security issues, WebSocket security, Blob URL leaks, Service Worker risks, and CSP misconfigurations.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
"./types": {
|
|
14
14
|
"types": "./src/types/index.d.ts",
|
|
15
15
|
"default": "./src/types/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./oxlint": {
|
|
18
|
+
"types": "./src/oxlint.d.ts",
|
|
19
|
+
"default": "./src/oxlint.js"
|
|
16
20
|
}
|
|
17
21
|
},
|
|
18
22
|
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
23
|
"license": "MIT",
|
|
20
|
-
"homepage": "https://
|
|
24
|
+
"homepage": "https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-browser-security",
|
|
21
25
|
"repository": {
|
|
22
26
|
"type": "git",
|
|
23
27
|
"url": "https://github.com/ofri-peretz/eslint",
|
|
@@ -74,11 +78,23 @@
|
|
|
74
78
|
},
|
|
75
79
|
"dependencies": {
|
|
76
80
|
"tslib": "^2.3.0",
|
|
77
|
-
"@interlace/eslint-devkit": "^1.
|
|
81
|
+
"@interlace/eslint-devkit": "^1.4.1"
|
|
82
|
+
},
|
|
83
|
+
"peerDependencies": {
|
|
84
|
+
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
78
85
|
},
|
|
79
|
-
"peerDependencies": {},
|
|
80
86
|
"devDependencies": {
|
|
81
87
|
"@typescript-eslint/parser": "^8.46.2",
|
|
82
88
|
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
89
|
+
},
|
|
90
|
+
"scripts": {
|
|
91
|
+
"build": "tsx ../../scripts/build-package.ts",
|
|
92
|
+
"test": "vitest run",
|
|
93
|
+
"test:coverage": "vitest run --coverage",
|
|
94
|
+
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
95
|
+
},
|
|
96
|
+
"funding": {
|
|
97
|
+
"type": "github",
|
|
98
|
+
"url": "https://github.com/ofri-peretz/eslint"
|
|
83
99
|
}
|
|
84
|
-
}
|
|
100
|
+
}
|