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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +53 -46
  3. 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
  [![npm version](https://img.shields.io/npm/v/eslint-plugin-browser-security.svg)](https://www.npmjs.com/package/eslint-plugin-browser-security)
6
+ [![npm downloads](https://img.shields.io/npm/dm/eslint-plugin-browser-security.svg)](https://www.npmjs.com/package/eslint-plugin-browser-security)
6
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
8
  [![codecov](https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=browser_security)](https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=browser_security)
9
+ [![Dec 2025](https://img.shields.io/badge/Dec_2025-blue?logo=rocket&logoColor=white)](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
- ## 📋 Rules (21 total)
72
+ ## 🔐 Rules (21 total)
73
+
74
+ 💼 = Set in `recommended` | 🔧 = Auto-fixable | 💡 = Has suggestions
71
75
 
72
76
  ### XSS Prevention
73
77
 
74
- | Rule | Description | CVSS | CWE |
75
- | ---------------------------------------------- | --------------------------------------------------------------------------------- | ---- | ------ |
76
- | [`no-eval`](./docs/rules/no-eval.md) | Prevent code injection via `eval()`, `new Function()`, and string-based callbacks | 9.3 | CWE-95 |
77
- | [`no-innerhtml`](./docs/rules/no-innerhtml.md) | Prevent XSS via `innerHTML`, `outerHTML`, and `insertAdjacentHTML()` | 8.1 | CWE-79 |
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 | Description | CVSS | CWE |
82
- | -------------------------------------------------------------------------------------- | -------------------------------------------------- | ---- | ------- |
83
- | [`require-postmessage-origin-check`](./docs/rules/require-postmessage-origin-check.md) | Require origin validation in postMessage handlers | 9.3 | CWE-346 |
84
- | [`no-postmessage-wildcard-origin`](./docs/rules/no-postmessage-wildcard-origin.md) | Prevent wildcard targetOrigin in postMessage calls | 7.5 | CWE-346 |
85
- | [`no-postmessage-innerhtml`](./docs/rules/no-postmessage-innerhtml.md) | Prevent XSS via innerHTML in postMessage handlers | 8.8 | CWE-79 |
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 | Description | CVSS | CWE |
90
- | ---------------------------------------------------------------------------- | ------------------------------------------------ | ---- | ------- |
91
- | [`no-sensitive-localstorage`](./docs/rules/no-sensitive-localstorage.md) | Prevent storing sensitive data in localStorage | 7.5 | CWE-922 |
92
- | [`no-sensitive-sessionstorage`](./docs/rules/no-sensitive-sessionstorage.md) | Prevent storing sensitive data in sessionStorage | 7.5 | CWE-922 |
93
- | [`no-sensitive-indexeddb`](./docs/rules/no-sensitive-indexeddb.md) | Prevent storing sensitive data in IndexedDB | 7.5 | CWE-922 |
94
- | [`no-jwt-in-storage`](./docs/rules/no-jwt-in-storage.md) | Prevent storing JWT tokens in browser storage | 8.1 | CWE-922 |
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 | Description | CVSS | CWE |
99
- | ---------------------------------------------------------------------------- | -------------------------------------------------------- | ---- | -------- |
100
- | [`no-sensitive-cookie-js`](./docs/rules/no-sensitive-cookie-js.md) | Prevent storing sensitive data in cookies via JavaScript | 8.1 | CWE-1004 |
101
- | [`no-cookie-auth-tokens`](./docs/rules/no-cookie-auth-tokens.md) | Prevent auth tokens in JS-accessible cookies | 8.5 | CWE-1004 |
102
- | [`require-cookie-secure-attrs`](./docs/rules/require-cookie-secure-attrs.md) | Require Secure and SameSite cookie attributes | 6.5 | CWE-614 |
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 | Description | CVSS | CWE |
107
- | ------------------------------------------------------------------ | ----------------------------------------------- | ---- | ------- |
108
- | [`require-websocket-wss`](./docs/rules/require-websocket-wss.md) | Require secure WebSocket connections (wss://) | 7.5 | CWE-319 |
109
- | [`no-websocket-innerhtml`](./docs/rules/no-websocket-innerhtml.md) | Prevent XSS via innerHTML in WebSocket handlers | 8.1 | CWE-79 |
110
- | [`no-websocket-eval`](./docs/rules/no-websocket-eval.md) | Prevent RCE via eval() in WebSocket handlers | 9.8 | CWE-95 |
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 | Description | CVSS | CWE |
115
- | -------------------------------------------------------------------------------- | ---------------------------------------------------- | ---- | ------- |
116
- | [`no-filereader-innerhtml`](./docs/rules/no-filereader-innerhtml.md) | Prevent XSS via innerHTML with FileReader data | 8.1 | CWE-79 |
117
- | [`require-blob-url-revocation`](./docs/rules/require-blob-url-revocation.md) | Require revoking Blob URLs to prevent memory leaks | 5.3 | CWE-401 |
118
- | [`no-dynamic-service-worker-url`](./docs/rules/no-dynamic-service-worker-url.md) | Prevent dynamic URLs in service worker registration | 8.1 | CWE-829 |
119
- | [`no-worker-message-innerhtml`](./docs/rules/no-worker-message-innerhtml.md) | Prevent XSS via innerHTML in Worker message handlers | 7.5 | CWE-79 |
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 | Description | CVSS | CWE |
124
- | -------------------------------------------------------------- | ------------------------------- | ---- | ------ |
125
- | [`no-unsafe-inline-csp`](./docs/rules/no-unsafe-inline-csp.md) | Disallow 'unsafe-inline' in CSP | 7.5 | CWE-79 |
126
- | [`no-unsafe-eval-csp`](./docs/rules/no-unsafe-eval-csp.md) | Disallow 'unsafe-eval' in CSP | 8.1 | CWE-95 |
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 [Forge-JS ESLint Security Ecosystem](https://github.com/ofri-peretz/eslint):
202
-
203
- | Package | Focus |
204
- | --------------------------------------------------------------------- | --------------------------- |
205
- | [`eslint-plugin-secure-coding`](../eslint-plugin-secure-coding) | Universal security patterns |
206
- | [`eslint-plugin-crypto`](../eslint-plugin-crypto) | Cryptographic security |
207
- | [`eslint-plugin-jwt`](../eslint-plugin-jwt) | JWT handling security |
208
- | [`eslint-plugin-express-security`](../eslint-plugin-express-security) | Express.js security |
209
- | [`eslint-plugin-nestjs-security`](../eslint-plugin-nestjs-security) | NestJS security |
210
- | [`eslint-plugin-lambda-security`](../eslint-plugin-lambda-security) | AWS Lambda security |
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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-secure-coding.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-jwt.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-crypto.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-pg.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-express-security.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-nestjs-security.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-lambda-security.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-vercel-ai-security.svg)](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) | [![npm](https://img.shields.io/npm/dm/eslint-plugin-import-next.svg)](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.1",
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
+ }