eslint-plugin-browser-security 1.0.1 → 1.0.3
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 +21 -0
- package/README.md +53 -46
- package/package.json +3 -12
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/README.md
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
> 🔐 Security-focused ESLint plugin for browser applications. Detects XSS vulnerabilities, postMessage abuse, storage API token exposure, cookie security issues, WebSocket vulnerabilities, and more.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
6
|
+
[](https://www.npmjs.com/package/eslint-plugin-browser-security)
|
|
6
7
|
[](https://opensource.org/licenses/MIT)
|
|
7
8
|
[](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=browser_security)
|
|
9
|
+
[](https://github.com/ofri-peretz/eslint)
|
|
8
10
|
|
|
9
11
|
## 💡 What You Get
|
|
10
12
|
|
|
@@ -67,63 +69,65 @@ import browserSecurity from 'eslint-plugin-browser-security';
|
|
|
67
69
|
export default [browserSecurity.configs.recommended];
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
##
|
|
72
|
+
## 🔐 Rules (21 total)
|
|
73
|
+
|
|
74
|
+
💼 = Set in `recommended` | 🔧 = Auto-fixable | 💡 = Has suggestions
|
|
71
75
|
|
|
72
76
|
### XSS Prevention
|
|
73
77
|
|
|
74
|
-
| Rule
|
|
75
|
-
|
|
|
76
|
-
| [
|
|
77
|
-
| [
|
|
78
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
79
|
+
| -------------------------------------------- | ------ | -------- | ----------------------------------------------------- | --- | --- | --- |
|
|
80
|
+
| [no-eval](./docs/rules/no-eval.md) | CWE-95 | A03:2021 | Prevent code injection via `eval()`, `new Function()` | 💼 | | 💡 |
|
|
81
|
+
| [no-innerhtml](./docs/rules/no-innerhtml.md) | CWE-79 | A03:2021 | Prevent XSS via `innerHTML`, `outerHTML` | 💼 | | 💡 |
|
|
78
82
|
|
|
79
83
|
### postMessage Security
|
|
80
84
|
|
|
81
|
-
| Rule
|
|
82
|
-
|
|
|
83
|
-
| [
|
|
84
|
-
| [
|
|
85
|
-
| [
|
|
85
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
86
|
+
| ------------------------------------------------------------------------------------ | ------- | -------- | ------------------------------------------------- | --- | --- | --- |
|
|
87
|
+
| [require-postmessage-origin-check](./docs/rules/require-postmessage-origin-check.md) | CWE-346 | A01:2021 | Require origin validation in postMessage handlers | 💼 | | 💡 |
|
|
88
|
+
| [no-postmessage-wildcard-origin](./docs/rules/no-postmessage-wildcard-origin.md) | CWE-346 | A01:2021 | Prevent wildcard targetOrigin in postMessage | 💼 | | 💡 |
|
|
89
|
+
| [no-postmessage-innerhtml](./docs/rules/no-postmessage-innerhtml.md) | CWE-79 | A03:2021 | Prevent XSS via innerHTML in postMessage handlers | 💼 | | 💡 |
|
|
86
90
|
|
|
87
91
|
### Storage Security
|
|
88
92
|
|
|
89
|
-
| Rule
|
|
90
|
-
|
|
|
91
|
-
| [
|
|
92
|
-
| [
|
|
93
|
-
| [
|
|
94
|
-
| [
|
|
93
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
94
|
+
| -------------------------------------------------------------------------- | ------- | -------- | ---------------------------------------- | --- | --- | --- |
|
|
95
|
+
| [no-sensitive-localstorage](./docs/rules/no-sensitive-localstorage.md) | CWE-922 | A02:2021 | Prevent sensitive data in localStorage | 💼 | | 💡 |
|
|
96
|
+
| [no-sensitive-sessionstorage](./docs/rules/no-sensitive-sessionstorage.md) | CWE-922 | A02:2021 | Prevent sensitive data in sessionStorage | 💼 | | 💡 |
|
|
97
|
+
| [no-sensitive-indexeddb](./docs/rules/no-sensitive-indexeddb.md) | CWE-922 | A02:2021 | Prevent sensitive data in IndexedDB | 💼 | | 💡 |
|
|
98
|
+
| [no-jwt-in-storage](./docs/rules/no-jwt-in-storage.md) | CWE-922 | A02:2021 | Prevent JWT tokens in browser storage | 💼 | | 💡 |
|
|
95
99
|
|
|
96
100
|
### Cookie Security
|
|
97
101
|
|
|
98
|
-
| Rule
|
|
99
|
-
|
|
|
100
|
-
| [
|
|
101
|
-
| [
|
|
102
|
-
| [
|
|
102
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
103
|
+
| -------------------------------------------------------------------------- | -------- | -------- | -------------------------------------------- | --- | --- | --- |
|
|
104
|
+
| [no-sensitive-cookie-js](./docs/rules/no-sensitive-cookie-js.md) | CWE-1004 | A02:2021 | Prevent sensitive data in cookies via JS | 💼 | | 💡 |
|
|
105
|
+
| [no-cookie-auth-tokens](./docs/rules/no-cookie-auth-tokens.md) | CWE-1004 | A02:2021 | Prevent auth tokens in JS-accessible cookies | 💼 | | 💡 |
|
|
106
|
+
| [require-cookie-secure-attrs](./docs/rules/require-cookie-secure-attrs.md) | CWE-614 | A05:2021 | Require Secure and SameSite attributes | 💼 | | 💡 |
|
|
103
107
|
|
|
104
108
|
### WebSocket Security
|
|
105
109
|
|
|
106
|
-
| Rule
|
|
107
|
-
|
|
|
108
|
-
| [
|
|
109
|
-
| [
|
|
110
|
-
| [
|
|
110
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
111
|
+
| ---------------------------------------------------------------- | ------- | -------- | --------------------------------- | --- | --- | --- |
|
|
112
|
+
| [require-websocket-wss](./docs/rules/require-websocket-wss.md) | CWE-319 | A02:2021 | Require secure WebSocket (wss://) | 💼 | | 💡 |
|
|
113
|
+
| [no-websocket-innerhtml](./docs/rules/no-websocket-innerhtml.md) | CWE-79 | A03:2021 | Prevent XSS in WebSocket handlers | 💼 | | 💡 |
|
|
114
|
+
| [no-websocket-eval](./docs/rules/no-websocket-eval.md) | CWE-95 | A03:2021 | Prevent RCE in WebSocket handlers | 💼 | | 💡 |
|
|
111
115
|
|
|
112
116
|
### File API & Workers Security
|
|
113
117
|
|
|
114
|
-
| Rule
|
|
115
|
-
|
|
|
116
|
-
| [
|
|
117
|
-
| [
|
|
118
|
-
| [
|
|
119
|
-
| [
|
|
118
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
119
|
+
| ------------------------------------------------------------------------------ | ------- | -------- | ----------------------------------- | --- | --- | --- |
|
|
120
|
+
| [no-filereader-innerhtml](./docs/rules/no-filereader-innerhtml.md) | CWE-79 | A03:2021 | Prevent XSS with FileReader data | 💼 | | 💡 |
|
|
121
|
+
| [require-blob-url-revocation](./docs/rules/require-blob-url-revocation.md) | CWE-401 | A04:2021 | Require revoking Blob URLs | 💼 | | 💡 |
|
|
122
|
+
| [no-dynamic-service-worker-url](./docs/rules/no-dynamic-service-worker-url.md) | CWE-829 | A08:2021 | Prevent dynamic service worker URLs | 💼 | | 💡 |
|
|
123
|
+
| [no-worker-message-innerhtml](./docs/rules/no-worker-message-innerhtml.md) | CWE-79 | A03:2021 | Prevent XSS in Worker handlers | 💼 | | 💡 |
|
|
120
124
|
|
|
121
125
|
### CSP Security
|
|
122
126
|
|
|
123
|
-
| Rule
|
|
124
|
-
|
|
|
125
|
-
| [
|
|
126
|
-
| [
|
|
127
|
+
| Rule | CWE | OWASP | Description | 💼 | 🔧 | 💡 |
|
|
128
|
+
| ------------------------------------------------------------ | ------ | -------- | ------------------------------- | --- | --- | --- |
|
|
129
|
+
| [no-unsafe-inline-csp](./docs/rules/no-unsafe-inline-csp.md) | CWE-79 | A03:2021 | Disallow 'unsafe-inline' in CSP | 💼 | | 💡 |
|
|
130
|
+
| [no-unsafe-eval-csp](./docs/rules/no-unsafe-eval-csp.md) | CWE-95 | A03:2021 | Disallow 'unsafe-eval' in CSP | 💼 | | 💡 |
|
|
127
131
|
|
|
128
132
|
## 🔍 Detection Examples
|
|
129
133
|
|
|
@@ -198,16 +202,19 @@ All rules include structured remediation guidance designed for AI assistants:
|
|
|
198
202
|
|
|
199
203
|
## 🔗 Related Packages
|
|
200
204
|
|
|
201
|
-
Part of the
|
|
202
|
-
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
| [`eslint-plugin-secure-coding`](
|
|
206
|
-
| [`eslint-plugin-
|
|
207
|
-
| [`eslint-plugin-
|
|
208
|
-
| [`eslint-plugin-
|
|
209
|
-
| [`eslint-plugin-
|
|
210
|
-
| [`eslint-plugin-
|
|
205
|
+
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
206
|
+
|
|
207
|
+
| Plugin | Downloads | Description | Rules |
|
|
208
|
+
| ---------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------ | :---: |
|
|
209
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://npmjs.com/package/eslint-plugin-secure-coding) | Universal security (OWASP Top 10 Web + Mobile) | 89 |
|
|
210
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://npmjs.com/package/eslint-plugin-jwt) | JWT security (algorithm confusion, weak secrets, claims) | 13 |
|
|
211
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://npmjs.com/package/eslint-plugin-crypto) | Cryptographic best practices (weak algorithms, key handling) | 24 |
|
|
212
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://npmjs.com/package/eslint-plugin-pg) | PostgreSQL/node-postgres security | 13 |
|
|
213
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://npmjs.com/package/eslint-plugin-express-security) | Express.js security (CORS, cookies, CSRF, helmet) | 8 |
|
|
214
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security (guards, validation pipes, throttler) | 5 |
|
|
215
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda/Middy security (API Gateway, CORS, secrets) | 5 |
|
|
216
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security (OWASP LLM + Agentic Top 10) | 19 |
|
|
217
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://npmjs.com/package/eslint-plugin-import-next) | High-performance import linting | 12 |
|
|
211
218
|
|
|
212
219
|
## 📄 License
|
|
213
220
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-browser-security",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
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",
|
|
@@ -73,20 +73,11 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@interlace/eslint-devkit": "^1.2.1",
|
|
76
|
-
"vitest": "^4.0.6",
|
|
77
|
-
"@nx/vite": "^22.0.3",
|
|
78
76
|
"tslib": "^2.8.1"
|
|
79
77
|
},
|
|
80
78
|
"peerDependencies": {},
|
|
81
|
-
"scripts": {
|
|
82
|
-
"test": "vitest run",
|
|
83
|
-
"test:watch": "vitest watch",
|
|
84
|
-
"test:coverage": "vitest run --coverage"
|
|
85
|
-
},
|
|
86
79
|
"devDependencies": {
|
|
87
80
|
"@typescript-eslint/parser": "^8.46.2",
|
|
88
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
89
|
-
"@vitest/coverage-v8": "^4.0.6",
|
|
90
|
-
"vitest": "^4.0.6"
|
|
81
|
+
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
91
82
|
}
|
|
92
|
-
}
|
|
83
|
+
}
|