eslint-plugin-browser-security 1.2.0 โ 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 +23 -0
- package/README.md +78 -58
- package/package.json +3 -3
- package/src/rules/no-missing-cors-check/index.js +0 -5
- package/src/rules/no-unescaped-url-parameter/index.js +0 -3
- package/AGENTS.md +0 -97
- package/CHANGELOG.md +0 -81
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
|
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
|
|
17
17
|
## Description
|
|
18
18
|
|
|
19
|
-
This plugin provides
|
|
19
|
+
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.
|
|
20
21
|
|
|
21
22
|
## Philosophy
|
|
22
23
|
|
|
@@ -24,19 +25,18 @@ This plugin provides a suite of browser-specific security rules designed to prev
|
|
|
24
25
|
|
|
25
26
|
## Getting Started
|
|
26
27
|
|
|
27
|
-
- To check out the [guide](https://eslint.interlace.tools/docs/browser-security), visit [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
28
|
-
- ่ฆๆฅ็ไธญๆ [ๆๅ](https://eslint.interlace.tools/docs/browser-security), ่ฏท่ฎฟ้ฎ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
29
|
-
- [๊ฐ์ด๋](https://eslint.interlace.tools/docs/browser-security) ๋ฌธ์๋ [eslint.interlace.tools](https://eslint.interlace.tools)์์ ํ์ธํ์ค ์ ์์ต๋๋ค. ๐
|
|
30
|
-
- [ใฌใคใ](https://eslint.interlace.tools/docs/browser-security)ใฏ [eslint.interlace.tools](https://eslint.interlace.tools)ใงใ็ขบ่ชใใ ใใใ ๐
|
|
31
|
-
- Para ver la [guรญa](https://eslint.interlace.tools/docs/browser-security), visita [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
32
|
-
- ููุงุทูุงุน ุนูู [ุงูุฏููู](https://eslint.interlace.tools/docs/browser-security)ุ ูู
ุจุฒูุงุฑุฉ [eslint.interlace.tools](https://eslint.interlace.tools). ๐
|
|
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). ๐
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
36
|
npm install eslint-plugin-browser-security --save-dev
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
## ๐ก What You Get
|
|
39
|
-
|
|
40
40
|
- **21 security rules** targeting browser-specific vulnerabilities
|
|
41
41
|
- **XSS prevention** via DOM manipulation and dynamic content detection
|
|
42
42
|
- **Storage security** preventing sensitive data exposure in localStorage/sessionStorage/IndexedDB
|
|
@@ -45,7 +45,6 @@ npm install eslint-plugin-browser-security --save-dev
|
|
|
45
45
|
- **OWASP Top 10 coverage** for browser security patterns
|
|
46
46
|
|
|
47
47
|
## ๐ฏ Why This Plugin?
|
|
48
|
-
|
|
49
48
|
Modern browser applications face unique security challenges across storage APIs, cross-origin communication, and dynamic content rendering. This plugin provides static analysis rules specifically designed for browser security patterns:
|
|
50
49
|
|
|
51
50
|
- **XSS Prevention**: Detects dangerous DOM manipulation patterns
|
|
@@ -55,7 +54,6 @@ Modern browser applications face unique security challenges across storage APIs,
|
|
|
55
54
|
- **LLM-Optimized**: All rules include AI-friendly remediation guidance
|
|
56
55
|
|
|
57
56
|
## ๐ Detection Examples
|
|
58
|
-
|
|
59
57
|
### โ Vulnerable Code
|
|
60
58
|
|
|
61
59
|
```javascript
|
|
@@ -94,14 +92,12 @@ window.addEventListener('message', (event) => {
|
|
|
94
92
|
```
|
|
95
93
|
|
|
96
94
|
## โ๏ธ Configuration Presets
|
|
97
|
-
|
|
98
95
|
| Preset | Description |
|
|
99
96
|
| :------------ | :-------------------------------------------------- |
|
|
100
97
|
| `recommended` | Recommended security configuration |
|
|
101
98
|
| `strict` | Strict security configuration - all rules as errors |
|
|
102
99
|
|
|
103
100
|
## ๐ค LLM-Optimized Messages
|
|
104
|
-
|
|
105
101
|
All rules include structured remediation guidance designed for AI assistants:
|
|
106
102
|
|
|
107
103
|
```
|
|
@@ -129,60 +125,84 @@ By providing this structured context (CWE, OWASP, Fix), we enable AI tools to **
|
|
|
129
125
|
|
|
130
126
|
**Legend**
|
|
131
127
|
|
|
132
|
-
| Icon | Description
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
138
|
-
|
|
|
139
|
-
|
|
140
|
-
| Rule
|
|
141
|
-
|
|
|
142
|
-
| [
|
|
143
|
-
| [no-
|
|
144
|
-
| [
|
|
145
|
-
| [no-
|
|
146
|
-
| [no-
|
|
147
|
-
| [no-
|
|
148
|
-
| [no-
|
|
149
|
-
| [no-
|
|
150
|
-
| [no-
|
|
151
|
-
| [no-
|
|
152
|
-
| [no-
|
|
153
|
-
| [
|
|
154
|
-
| [
|
|
155
|
-
| [no-websocket
|
|
156
|
-
| [no-
|
|
157
|
-
| [no-
|
|
158
|
-
| [
|
|
159
|
-
| [no-
|
|
160
|
-
| [no-
|
|
161
|
-
| [no-
|
|
162
|
-
| [no-
|
|
128
|
+
| Icon | Description |
|
|
129
|
+
| :---: | :--- |
|
|
130
|
+
| ๐ผ | **Recommended**: Included in the recommended preset. |
|
|
131
|
+
| โ ๏ธ | **Warns**: Set towarn in recommended preset. |
|
|
132
|
+
| ๐ง | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
133
|
+
| ๐ก | **Suggestions**: Providing code suggestions in IDE. |
|
|
134
|
+
| ๐ซ | **Deprecated**: This rule is deprecated. |
|
|
135
|
+
|
|
136
|
+
| Rule | CWE | OWASP | CVSS | Description | ๐ผ | โ ๏ธ | ๐ง | ๐ก | ๐ซ |
|
|
137
|
+
| :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
138
|
+
| [detect-mixed-content](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/detect-mixed-content) | | | | ESLint rule documentation for detect-mixed-content | | | | | |
|
|
139
|
+
| [no-allow-arbitrary-loads](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-allow-arbitrary-loads) | | | | ESLint rule documentation for no-allow-arbitrary-loads | | | | | |
|
|
140
|
+
| [no-clickjacking](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-clickjacking) | | | | ESLint rule documentation for no-clickjacking | | | | | |
|
|
141
|
+
| [no-client-side-auth-logic](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-client-side-auth-logic) | | | | ESLint rule documentation for no-client-side-auth-logic | | | | | |
|
|
142
|
+
| [no-cookie-auth-tokens](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-cookie-auth-tokens) | CWE-1004 | A02:2025 | 5.3 | ESLint rule documentation for no-cookie-auth-tokens | ๐ผ | | | ๐ก | |
|
|
143
|
+
| [no-credentials-in-query-params](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-credentials-in-query-params) | | | | ESLint rule documentation for no-credentials-in-query-params | | | | | |
|
|
144
|
+
| [no-disabled-certificate-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-disabled-certificate-validation) | | | | ESLint rule documentation for no-disabled-certificate-validation | | | | | |
|
|
145
|
+
| [no-dynamic-service-worker-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-dynamic-service-worker-url) | CWE-829 | A08:2025 | 7.5 | ESLint rule documentation for no-dynamic-service-worker-url | ๐ผ | | | ๐ก | |
|
|
146
|
+
| [no-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-eval) | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-eval | ๐ผ | | | ๐ก | ๐ซ |
|
|
147
|
+
| [no-filereader-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-filereader-innerhtml) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-filereader-innerhtml | ๐ผ | | | ๐ก | |
|
|
148
|
+
| [no-http-urls](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-http-urls) | | | | ESLint rule documentation for no-http-urls | | | | | |
|
|
149
|
+
| [no-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-innerhtml) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-innerhtml | ๐ผ | | | ๐ก | |
|
|
150
|
+
| [no-insecure-redirects](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-redirects) | | | | ESLint rule documentation for no-insecure-redirects | | | | | |
|
|
151
|
+
| [no-insecure-websocket](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-websocket) | | | | ESLint rule documentation for no-insecure-websocket | | | | | |
|
|
152
|
+
| [no-jwt-in-storage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-jwt-in-storage) | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-jwt-in-storage | ๐ผ | | | ๐ก | |
|
|
153
|
+
| [no-missing-cors-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-cors-check) | | | | ESLint rule documentation for no-missing-cors-check | | | | | |
|
|
154
|
+
| [no-missing-csrf-protection](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-csrf-protection) | | | | ESLint rule documentation for no-missing-csrf-protection | | | | | |
|
|
155
|
+
| [no-missing-security-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-security-headers) | | | | ESLint rule documentation for no-missing-security-headers | | | | | |
|
|
156
|
+
| [no-password-in-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-password-in-url) | | | | ESLint rule documentation for no-password-in-url | | | | | |
|
|
157
|
+
| [no-permissive-cors](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-permissive-cors) | | | | ESLint rule documentation for no-permissive-cors | | | | | |
|
|
158
|
+
| [no-postmessage-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-innerhtml) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-postmessage-innerhtml | ๐ผ | | | | |
|
|
159
|
+
| [no-postmessage-wildcard-origin](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-wildcard-origin) | CWE-346 | A01:2025 | 8.8 | ESLint rule documentation for no-postmessage-wildcard-origin | ๐ผ | | | | |
|
|
160
|
+
| [no-sensitive-cookie-js](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-cookie-js) | CWE-1004 | A02:2025 | 5.3 | ESLint rule documentation for no-sensitive-cookie-js | ๐ผ | | | ๐ก | |
|
|
161
|
+
| [no-sensitive-data-in-analytics](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-analytics) | | | | ESLint rule documentation for no-sensitive-data-in-analytics | | | | | |
|
|
162
|
+
| [no-sensitive-data-in-cache](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-cache) | | | | ESLint rule documentation for no-sensitive-data-in-cache | | | | | |
|
|
163
|
+
| [no-sensitive-indexeddb](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-indexeddb) | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-indexeddb | ๐ผ | | | ๐ก | |
|
|
164
|
+
| [no-sensitive-localstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-localstorage) | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-localstorage | ๐ผ | | | ๐ก | |
|
|
165
|
+
| [no-sensitive-sessionstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-sessionstorage) | CWE-922 | A02:2025 | 7.5 | ESLint rule documentation for no-sensitive-sessionstorage | ๐ผ | | | ๐ก | |
|
|
166
|
+
| [no-tracking-without-consent](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-tracking-without-consent) | | | | ESLint rule documentation for no-tracking-without-consent | | | | | |
|
|
167
|
+
| [no-unencrypted-transmission](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unencrypted-transmission) | | | | ESLint rule documentation for no-unencrypted-transmission | | | | | |
|
|
168
|
+
| [no-unescaped-url-parameter](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unescaped-url-parameter) | | | | ESLint rule documentation for no-unescaped-url-parameter | | | | | |
|
|
169
|
+
| [no-unsafe-eval-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-eval-csp) | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-unsafe-eval-csp | ๐ผ | | | ๐ก | |
|
|
170
|
+
| [no-unsafe-inline-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-inline-csp) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-unsafe-inline-csp | ๐ผ | | | ๐ก | |
|
|
171
|
+
| [no-unvalidated-deeplinks](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unvalidated-deeplinks) | | | | ESLint rule documentation for no-unvalidated-deeplinks | | | | | |
|
|
172
|
+
| [no-websocket-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-eval) | CWE-95 | A03:2025 | 9.8 | ESLint rule documentation for no-websocket-eval | ๐ผ | | | ๐ก | |
|
|
173
|
+
| [no-websocket-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-innerhtml) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-websocket-innerhtml | ๐ผ | | | ๐ก | |
|
|
174
|
+
| [no-worker-message-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-worker-message-innerhtml) | CWE-79 | A03:2025 | 6.1 | ESLint rule documentation for no-worker-message-innerhtml | ๐ผ | | | | |
|
|
175
|
+
| [require-blob-url-revocation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-blob-url-revocation) | CWE-401 | A04:2025 | 5.3 | ESLint rule documentation for require-blob-url-revocation | ๐ผ | โ ๏ธ | | ๐ก | |
|
|
176
|
+
| [require-cookie-secure-attrs](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-cookie-secure-attrs) | CWE-614 | A05:2025 | 5.3 | ESLint rule documentation for require-cookie-secure-attrs | ๐ผ | | | | ๐ซ |
|
|
177
|
+
| [require-csp-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-csp-headers) | | | | ESLint rule documentation for require-csp-headers | | | | | |
|
|
178
|
+
| [require-https-only](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-https-only) | | | | ESLint rule documentation for require-https-only | | | | | |
|
|
179
|
+
| [require-mime-type-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-mime-type-validation) | | | | ESLint rule documentation for require-mime-type-validation | | | | | |
|
|
180
|
+
| [require-postmessage-origin-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-postmessage-origin-check) | CWE-346 | A01:2025 | 8.8 | ESLint rule documentation for require-postmessage-origin-check | ๐ผ | | | | |
|
|
181
|
+
| [require-url-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-url-validation) | | | | ESLint rule documentation for require-url-validation | | | | | |
|
|
182
|
+
| [require-websocket-wss](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-websocket-wss) | CWE-319 | A02:2025 | 7.5 | ESLint rule documentation for require-websocket-wss | ๐ผ | | | ๐ก | ๐ซ |
|
|
163
183
|
|
|
164
184
|
## ๐ Related ESLint Plugins
|
|
165
185
|
|
|
166
186
|
Part of the **Interlace ESLint Ecosystem** โ AI-native security plugins with LLM-optimized error messages:
|
|
167
187
|
|
|
168
|
-
| Plugin
|
|
169
|
-
|
|
|
170
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding)
|
|
171
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg)
|
|
172
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto)
|
|
173
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt)
|
|
174
|
-
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
175
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security)
|
|
176
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security)
|
|
177
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security)
|
|
178
|
-
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security)
|
|
179
|
-
| [`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.
|
|
180
|
-
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next)
|
|
188
|
+
| Plugin | Downloads | Description |
|
|
189
|
+
| :--- | :---: | :--- |
|
|
190
|
+
| [`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
|
+
| [`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-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
193
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
194
|
+
| [`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
|
+
| [`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. |
|
|
196
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
|
|
197
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
|
|
198
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB security best practices. |
|
|
199
|
+
| [`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
|
+
| [`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. |
|
|
181
201
|
|
|
182
202
|
## ๐ License
|
|
183
203
|
|
|
184
204
|
MIT ยฉ [Ofri Peretz](https://github.com/ofri-peretz)
|
|
185
205
|
|
|
186
206
|
<p align="center">
|
|
187
|
-
<a href="https://eslint.interlace.tools/docs/browser-security"><img src="https://eslint.interlace.tools/images/og-browser-security.png" alt="ESLint Interlace Plugin" width="
|
|
188
|
-
</p>
|
|
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>
|
|
208
|
+
</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.1",
|
|
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",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"author": "Ofri Peretz <ofriperetzdev@gmail.com>",
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"homepage": "https://github.com/ofri-peretz/eslint/
|
|
20
|
+
"homepage": "https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-browser-security#readme",
|
|
21
21
|
"repository": {
|
|
22
22
|
"type": "git",
|
|
23
|
-
"url": "
|
|
23
|
+
"url": "https://github.com/ofri-peretz/eslint",
|
|
24
24
|
"directory": "packages/eslint-plugin-browser-security"
|
|
25
25
|
},
|
|
26
26
|
"bugs": {
|
|
@@ -191,7 +191,6 @@ exports.noMissingCorsCheck = (0, eslint_devkit_2.createRule)({
|
|
|
191
191
|
suggest: [
|
|
192
192
|
{
|
|
193
193
|
messageId: 'useOriginValidation',
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
195
194
|
fix: (_fixer) => null,
|
|
196
195
|
},
|
|
197
196
|
],
|
|
@@ -214,7 +213,6 @@ exports.noMissingCorsCheck = (0, eslint_devkit_2.createRule)({
|
|
|
214
213
|
suggest: [
|
|
215
214
|
{
|
|
216
215
|
messageId: 'useOriginValidation',
|
|
217
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
218
216
|
fix: (_fixer) => null,
|
|
219
217
|
},
|
|
220
218
|
],
|
|
@@ -282,7 +280,6 @@ exports.noMissingCorsCheck = (0, eslint_devkit_2.createRule)({
|
|
|
282
280
|
suggest: [
|
|
283
281
|
{
|
|
284
282
|
messageId: 'useOriginValidation',
|
|
285
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
286
283
|
fix: (_fixer) => null,
|
|
287
284
|
},
|
|
288
285
|
],
|
|
@@ -324,7 +321,6 @@ exports.noMissingCorsCheck = (0, eslint_devkit_2.createRule)({
|
|
|
324
321
|
suggest: [
|
|
325
322
|
{
|
|
326
323
|
messageId: 'useOriginValidation',
|
|
327
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
328
324
|
fix: (_fixer) => null,
|
|
329
325
|
},
|
|
330
326
|
],
|
|
@@ -384,7 +380,6 @@ exports.noMissingCorsCheck = (0, eslint_devkit_2.createRule)({
|
|
|
384
380
|
suggest: [
|
|
385
381
|
{
|
|
386
382
|
messageId: 'useOriginValidation',
|
|
387
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
388
383
|
fix: (_fixer) => null,
|
|
389
384
|
},
|
|
390
385
|
],
|
|
@@ -205,12 +205,10 @@ exports.noUnescapedUrlParameter = (0, eslint_devkit_2.createRule)({
|
|
|
205
205
|
suggest: [
|
|
206
206
|
{
|
|
207
207
|
messageId: 'useEncodeURIComponent',
|
|
208
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
209
208
|
fix: (_fixer) => null,
|
|
210
209
|
},
|
|
211
210
|
{
|
|
212
211
|
messageId: 'useURLSearchParams',
|
|
213
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
214
212
|
fix: (_fixer) => null,
|
|
215
213
|
},
|
|
216
214
|
],
|
|
@@ -257,7 +255,6 @@ exports.noUnescapedUrlParameter = (0, eslint_devkit_2.createRule)({
|
|
|
257
255
|
suggest: [
|
|
258
256
|
{
|
|
259
257
|
messageId: 'useEncodeURIComponent',
|
|
260
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
261
258
|
fix: (_fixer) => null,
|
|
262
259
|
},
|
|
263
260
|
],
|
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
|