eslint-plugin-browser-security 1.1.0 → 1.2.0
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/README.md +94 -133
- package/package.json +4 -3
- package/src/index.js +62 -0
- package/src/rules/detect-mixed-content/index.d.ts +12 -0
- package/src/rules/detect-mixed-content/index.js +45 -0
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +12 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +48 -0
- package/src/rules/no-clickjacking/index.d.ts +36 -0
- package/src/rules/no-clickjacking/index.js +401 -0
- package/src/rules/no-client-side-auth-logic/index.d.ts +12 -0
- package/src/rules/no-client-side-auth-logic/index.js +74 -0
- package/src/rules/no-cookie-auth-tokens/index.d.ts +3 -1
- package/src/rules/no-credentials-in-query-params/index.d.ts +12 -0
- package/src/rules/no-credentials-in-query-params/index.js +62 -0
- package/src/rules/no-disabled-certificate-validation/index.d.ts +12 -0
- package/src/rules/no-disabled-certificate-validation/index.js +66 -0
- package/src/rules/no-dynamic-service-worker-url/index.d.ts +3 -1
- package/src/rules/no-eval/index.d.ts +3 -1
- package/src/rules/no-filereader-innerhtml/index.d.ts +3 -1
- package/src/rules/no-http-urls/index.d.ts +17 -0
- package/src/rules/no-http-urls/index.js +119 -0
- package/src/rules/no-innerhtml/index.d.ts +3 -1
- package/src/rules/no-insecure-redirects/index.d.ts +26 -0
- package/src/rules/no-insecure-redirects/index.js +221 -0
- package/src/rules/no-insecure-websocket/index.d.ts +12 -0
- package/src/rules/no-insecure-websocket/index.js +66 -0
- package/src/rules/no-jwt-in-storage/index.d.ts +3 -1
- package/src/rules/no-missing-cors-check/index.d.ts +28 -0
- package/src/rules/no-missing-cors-check/index.js +404 -0
- package/src/rules/no-missing-csrf-protection/index.d.ts +30 -0
- package/src/rules/no-missing-csrf-protection/index.js +185 -0
- package/src/rules/no-missing-security-headers/index.d.ts +26 -0
- package/src/rules/no-missing-security-headers/index.js +223 -0
- package/src/rules/no-password-in-url/index.d.ts +12 -0
- package/src/rules/no-password-in-url/index.js +55 -0
- package/src/rules/no-permissive-cors/index.d.ts +12 -0
- package/src/rules/no-permissive-cors/index.js +74 -0
- package/src/rules/no-postmessage-innerhtml/index.d.ts +3 -1
- package/src/rules/no-postmessage-wildcard-origin/index.d.ts +3 -1
- package/src/rules/no-sensitive-cookie-js/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-analytics/index.js +66 -0
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +53 -0
- package/src/rules/no-sensitive-indexeddb/index.d.ts +3 -1
- package/src/rules/no-sensitive-localstorage/index.d.ts +3 -1
- package/src/rules/no-sensitive-sessionstorage/index.d.ts +3 -1
- package/src/rules/no-tracking-without-consent/index.d.ts +12 -0
- package/src/rules/no-tracking-without-consent/index.js +72 -0
- package/src/rules/no-unencrypted-transmission/index.d.ts +30 -0
- package/src/rules/no-unencrypted-transmission/index.js +241 -0
- package/src/rules/no-unescaped-url-parameter/index.d.ts +28 -0
- package/src/rules/no-unescaped-url-parameter/index.js +360 -0
- package/src/rules/no-unsafe-eval-csp/index.d.ts +3 -1
- package/src/rules/no-unsafe-inline-csp/index.d.ts +3 -1
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +12 -0
- package/src/rules/no-unvalidated-deeplinks/index.js +67 -0
- package/src/rules/no-websocket-eval/index.d.ts +3 -1
- package/src/rules/no-websocket-innerhtml/index.d.ts +3 -1
- package/src/rules/no-worker-message-innerhtml/index.d.ts +3 -1
- package/src/rules/require-blob-url-revocation/index.d.ts +3 -1
- package/src/rules/require-cookie-secure-attrs/index.d.ts +3 -1
- package/src/rules/require-csp-headers/index.d.ts +12 -0
- package/src/rules/require-csp-headers/index.js +69 -0
- package/src/rules/require-https-only/index.d.ts +12 -0
- package/src/rules/require-https-only/index.js +67 -0
- package/src/rules/require-mime-type-validation/index.d.ts +12 -0
- package/src/rules/require-mime-type-validation/index.js +71 -0
- package/src/rules/require-postmessage-origin-check/index.d.ts +3 -1
- package/src/rules/require-url-validation/index.d.ts +12 -0
- package/src/rules/require-url-validation/index.js +77 -0
- package/src/rules/require-websocket-wss/index.d.ts +3 -1
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,18 +1,39 @@
|
|
|
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>
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
</
|
|
5
|
+
<p align="center">
|
|
6
|
+
Browser-specific security rules to prevent XSS and other client-side attacks.
|
|
7
|
+
</p>
|
|
6
8
|
|
|
7
|
-
>
|
|
8
|
-
>
|
|
9
|
-
|
|
9
|
+
<p align="center">
|
|
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
|
+
<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
|
+
<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=browser-security" alt="Codecov" /></a>
|
|
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
|
+
</p>
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
## Description
|
|
18
|
+
|
|
19
|
+
This plugin provides a suite of browser-specific security rules designed to prevent Cross-Site Scripting (XSS) and other client-side vulnerabilities. It scans your code for dangerous patterns, such as unsafe DOM manipulation and insecure storage practices, offering real-time feedback to developers. Using this plugin ensures that your frontend applications adhere to modern security standards and protect user data effectively.
|
|
20
|
+
|
|
21
|
+
## Philosophy
|
|
22
|
+
|
|
23
|
+
**Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
|
|
24
|
+
|
|
25
|
+
## Getting Started
|
|
26
|
+
|
|
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). 📚
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm install eslint-plugin-browser-security --save-dev
|
|
36
|
+
```
|
|
16
37
|
|
|
17
38
|
## 💡 What You Get
|
|
18
39
|
|
|
@@ -33,108 +54,6 @@ Modern browser applications face unique security challenges across storage APIs,
|
|
|
33
54
|
- **Cookie Security**: Identifies insecure cookie handling in JavaScript
|
|
34
55
|
- **LLM-Optimized**: All rules include AI-friendly remediation guidance
|
|
35
56
|
|
|
36
|
-
## 📦 Installation
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npm install eslint-plugin-browser-security --save-dev
|
|
40
|
-
# or
|
|
41
|
-
pnpm add -D eslint-plugin-browser-security
|
|
42
|
-
# or
|
|
43
|
-
yarn add -D eslint-plugin-browser-security
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## 🚀 Quick Start
|
|
47
|
-
|
|
48
|
-
### Flat Config (ESLint 9+)
|
|
49
|
-
|
|
50
|
-
```javascript
|
|
51
|
-
// eslint.config.js
|
|
52
|
-
import browserSecurity from 'eslint-plugin-browser-security';
|
|
53
|
-
|
|
54
|
-
export default [
|
|
55
|
-
{
|
|
56
|
-
plugins: {
|
|
57
|
-
'browser-security': browserSecurity,
|
|
58
|
-
},
|
|
59
|
-
rules: {
|
|
60
|
-
'browser-security/no-eval': 'error',
|
|
61
|
-
'browser-security/no-innerhtml': 'error',
|
|
62
|
-
'browser-security/no-sensitive-localstorage': 'error',
|
|
63
|
-
'browser-security/require-postmessage-origin-check': 'error',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
];
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### Using Recommended Config
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
// eslint.config.js
|
|
73
|
-
import browserSecurity from 'eslint-plugin-browser-security';
|
|
74
|
-
|
|
75
|
-
export default [browserSecurity.configs.recommended];
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## 🔐 Rules (21 total)
|
|
79
|
-
|
|
80
|
-
💼 = Set in `recommended` | 🔧 = Auto-fixable | 💡 = Has suggestions
|
|
81
|
-
|
|
82
|
-
### XSS Prevention
|
|
83
|
-
|
|
84
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
85
|
-
| :------------------------------------------- | :----: | :------: | :--: | :---------------------------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
86
|
-
| [no-eval](./docs/rules/no-eval.md) | CWE-95 | A03:2021 | | Prevent code injection via `eval()`, `new Function()` | 💼 | | | 💡 | |
|
|
87
|
-
| [no-innerhtml](./docs/rules/no-innerhtml.md) | CWE-79 | A03:2021 | | Prevent XSS via `innerHTML`, `outerHTML` | 💼 | | | 💡 | |
|
|
88
|
-
|
|
89
|
-
### postMessage Security
|
|
90
|
-
|
|
91
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
92
|
-
| :----------------------------------------------------------------------------------- | :-----: | :------: | :--: | :------------------------------------------------ | :-: | :-: | :-: | :-: | :-: |
|
|
93
|
-
| [require-postmessage-origin-check](./docs/rules/require-postmessage-origin-check.md) | CWE-346 | A01:2021 | | Require origin validation in postMessage handlers | 💼 | | | 💡 | |
|
|
94
|
-
| [no-postmessage-wildcard-origin](./docs/rules/no-postmessage-wildcard-origin.md) | CWE-346 | A01:2021 | | Prevent wildcard targetOrigin in postMessage | 💼 | | | 💡 | |
|
|
95
|
-
| [no-postmessage-innerhtml](./docs/rules/no-postmessage-innerhtml.md) | CWE-79 | A03:2021 | | Prevent XSS via innerHTML in postMessage handlers | 💼 | | | 💡 | |
|
|
96
|
-
|
|
97
|
-
### Storage Security
|
|
98
|
-
|
|
99
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
100
|
-
| :------------------------------------------------------------------------- | :-----: | :------: | :--: | :--------------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
101
|
-
| [no-sensitive-localstorage](./docs/rules/no-sensitive-localstorage.md) | CWE-922 | A02:2021 | | Prevent sensitive data in localStorage | 💼 | | | 💡 | |
|
|
102
|
-
| [no-sensitive-sessionstorage](./docs/rules/no-sensitive-sessionstorage.md) | CWE-922 | A02:2021 | | Prevent sensitive data in sessionStorage | 💼 | | | 💡 | |
|
|
103
|
-
| [no-sensitive-indexeddb](./docs/rules/no-sensitive-indexeddb.md) | CWE-922 | A02:2021 | | Prevent sensitive data in IndexedDB | 💼 | | | 💡 | |
|
|
104
|
-
| [no-jwt-in-storage](./docs/rules/no-jwt-in-storage.md) | CWE-922 | A02:2021 | | Prevent JWT tokens in browser storage | 💼 | | | 💡 | |
|
|
105
|
-
|
|
106
|
-
### Cookie Security
|
|
107
|
-
|
|
108
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
109
|
-
| :------------------------------------------------------------------------- | :------: | :------: | :--: | :------------------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
110
|
-
| [no-sensitive-cookie-js](./docs/rules/no-sensitive-cookie-js.md) | CWE-1004 | A02:2021 | | Prevent sensitive data in cookies via JS | 💼 | | | 💡 | |
|
|
111
|
-
| [no-cookie-auth-tokens](./docs/rules/no-cookie-auth-tokens.md) | CWE-1004 | A02:2021 | | Prevent auth tokens in JS-accessible cookies | 💼 | | | 💡 | |
|
|
112
|
-
| [require-cookie-secure-attrs](./docs/rules/require-cookie-secure-attrs.md) | CWE-614 | A05:2021 | | Require Secure and SameSite attributes | 💼 | | | 💡 | |
|
|
113
|
-
|
|
114
|
-
### WebSocket Security
|
|
115
|
-
|
|
116
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
117
|
-
| :--------------------------------------------------------------- | :-----: | :------: | :--: | :-------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
118
|
-
| [require-websocket-wss](./docs/rules/require-websocket-wss.md) | CWE-319 | A02:2021 | | Require secure WebSocket (wss://) | 💼 | | | 💡 | |
|
|
119
|
-
| [no-websocket-innerhtml](./docs/rules/no-websocket-innerhtml.md) | CWE-79 | A03:2021 | | Prevent XSS in WebSocket handlers | 💼 | | | 💡 | |
|
|
120
|
-
| [no-websocket-eval](./docs/rules/no-websocket-eval.md) | CWE-95 | A03:2021 | | Prevent RCE in WebSocket handlers | 💼 | | | 💡 | |
|
|
121
|
-
|
|
122
|
-
### File API & Workers Security
|
|
123
|
-
|
|
124
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
125
|
-
| :----------------------------------------------------------------------------- | :-----: | :------: | :--: | :---------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
126
|
-
| [no-filereader-innerhtml](./docs/rules/no-filereader-innerhtml.md) | CWE-79 | A03:2021 | | Prevent XSS with FileReader data | 💼 | | | 💡 | |
|
|
127
|
-
| [require-blob-url-revocation](./docs/rules/require-blob-url-revocation.md) | CWE-401 | A04:2021 | | Require revoking Blob URLs | 💼 | | | 💡 | |
|
|
128
|
-
| [no-dynamic-service-worker-url](./docs/rules/no-dynamic-service-worker-url.md) | CWE-829 | A08:2021 | | Prevent dynamic service worker URLs | 💼 | | | 💡 | |
|
|
129
|
-
| [no-worker-message-innerhtml](./docs/rules/no-worker-message-innerhtml.md) | CWE-79 | A03:2021 | | Prevent XSS in Worker handlers | 💼 | | | 💡 | |
|
|
130
|
-
|
|
131
|
-
### CSP Security
|
|
132
|
-
|
|
133
|
-
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
134
|
-
| :----------------------------------------------------------- | :----: | :------: | :--: | :------------------------------ | :-: | :-: | :-: | :-: | :-: |
|
|
135
|
-
| [no-unsafe-inline-csp](./docs/rules/no-unsafe-inline-csp.md) | CWE-79 | A03:2021 | | Disallow 'unsafe-inline' in CSP | 💼 | | | 💡 | |
|
|
136
|
-
| [no-unsafe-eval-csp](./docs/rules/no-unsafe-eval-csp.md) | CWE-95 | A03:2021 | | Disallow 'unsafe-eval' in CSP | 💼 | | | 💡 | |
|
|
137
|
-
|
|
138
57
|
## 🔍 Detection Examples
|
|
139
58
|
|
|
140
59
|
### ❌ Vulnerable Code
|
|
@@ -174,14 +93,12 @@ window.addEventListener('message', (event) => {
|
|
|
174
93
|
});
|
|
175
94
|
```
|
|
176
95
|
|
|
177
|
-
##
|
|
96
|
+
## ⚙️ Configuration Presets
|
|
178
97
|
|
|
179
|
-
|
|
|
180
|
-
|
|
|
181
|
-
| `
|
|
182
|
-
| `
|
|
183
|
-
| `no-sensitive-localstorage` | | A02: Cryptographic Failures | | | | | | | |
|
|
184
|
-
| `require-postmessage-origin-check` | | A01: Broken Access Control | | | | | | | |
|
|
98
|
+
| Preset | Description |
|
|
99
|
+
| :------------ | :-------------------------------------------------- |
|
|
100
|
+
| `recommended` | Recommended security configuration |
|
|
101
|
+
| `strict` | Strict security configuration - all rules as errors |
|
|
185
102
|
|
|
186
103
|
## 🤖 LLM-Optimized Messages
|
|
187
104
|
|
|
@@ -206,22 +123,66 @@ All rules include structured remediation guidance designed for AI assistants:
|
|
|
206
123
|
• OWASP XSS Prevention: https://owasp.org/...
|
|
207
124
|
```
|
|
208
125
|
|
|
209
|
-
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
## Rules
|
|
129
|
+
|
|
130
|
+
**Legend**
|
|
131
|
+
|
|
132
|
+
| Icon | Description |
|
|
133
|
+
| :--: | :----------------------------------------------------------------- |
|
|
134
|
+
| 💼 | **Recommended**: Included in the recommended preset. |
|
|
135
|
+
| ⚠️ | **Warns**: Set towarn in recommended preset. |
|
|
136
|
+
| 🔧 | **Auto-fixable**: Automatically fixable by the `--fix` CLI option. |
|
|
137
|
+
| 💡 | **Suggestions**: Providing code suggestions in IDE. |
|
|
138
|
+
| 🚫 | **Deprecated**: This rule is deprecated. |
|
|
139
|
+
|
|
140
|
+
| Rule | CWE | OWASP | CVSS | Description | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
|
|
141
|
+
| :------------------------------------------------------------------------------------------------------------------------------ | :------: | :------: | :--: | :----------------------------------------------------------------------------------- | :-: | :-: | :-: | :-: | :-: |
|
|
142
|
+
| [no-eval](https://eslint.interlace.tools/docs/browser-security/rules/no-eval) | CWE-95 | A03:2025 | 9.8 | [no-eval](./docs/rules/no-eval.md) | 💼 | | | 💡 | 🚫 |
|
|
143
|
+
| [no-innerhtml](https://eslint.interlace.tools/docs/browser-security/rules/no-innerhtml) | CWE-79 | A03:2025 | 6.1 | [no-innerhtml](./docs/rules/no-innerhtml.md) | 💼 | | | 💡 | |
|
|
144
|
+
| [require-postmessage-origin-check](https://eslint.interlace.tools/docs/browser-security/rules/require-postmessage-origin-check) | CWE-346 | A01:2025 | 8.8 | [require-postmessage-origin-check](./docs/rules/require-postmessage-origin-check.md) | 💼 | | | | |
|
|
145
|
+
| [no-postmessage-wildcard-origin](https://eslint.interlace.tools/docs/browser-security/rules/no-postmessage-wildcard-origin) | CWE-346 | A01:2025 | 8.8 | [no-postmessage-wildcard-origin](./docs/rules/no-postmessage-wildcard-origin.md) | 💼 | | | | |
|
|
146
|
+
| [no-postmessage-innerhtml](https://eslint.interlace.tools/docs/browser-security/rules/no-postmessage-innerhtml) | CWE-79 | A03:2025 | 6.1 | [no-postmessage-innerhtml](./docs/rules/no-postmessage-innerhtml.md) | 💼 | | | | |
|
|
147
|
+
| [no-sensitive-localstorage](https://eslint.interlace.tools/docs/browser-security/rules/no-sensitive-localstorage) | CWE-922 | A02:2025 | 7.5 | [no-sensitive-localstorage](./docs/rules/no-sensitive-localstorage.md) | 💼 | | | 💡 | |
|
|
148
|
+
| [no-sensitive-sessionstorage](https://eslint.interlace.tools/docs/browser-security/rules/no-sensitive-sessionstorage) | CWE-922 | A02:2025 | 7.5 | [no-sensitive-sessionstorage](./docs/rules/no-sensitive-sessionstorage.md) | 💼 | | | 💡 | |
|
|
149
|
+
| [no-sensitive-indexeddb](https://eslint.interlace.tools/docs/browser-security/rules/no-sensitive-indexeddb) | CWE-922 | A02:2025 | 7.5 | [no-sensitive-indexeddb](./docs/rules/no-sensitive-indexeddb.md) | 💼 | | | 💡 | |
|
|
150
|
+
| [no-jwt-in-storage](https://eslint.interlace.tools/docs/browser-security/rules/no-jwt-in-storage) | CWE-922 | A02:2025 | 7.5 | [no-jwt-in-storage](./docs/rules/no-jwt-in-storage.md) | 💼 | | | 💡 | |
|
|
151
|
+
| [no-sensitive-cookie-js](https://eslint.interlace.tools/docs/browser-security/rules/no-sensitive-cookie-js) | CWE-1004 | A02:2025 | 5.3 | [no-sensitive-cookie-js](./docs/rules/no-sensitive-cookie-js.md) | 💼 | | | 💡 | |
|
|
152
|
+
| [no-cookie-auth-tokens](https://eslint.interlace.tools/docs/browser-security/rules/no-cookie-auth-tokens) | CWE-1004 | A02:2025 | 5.3 | [no-cookie-auth-tokens](./docs/rules/no-cookie-auth-tokens.md) | 💼 | | | 💡 | |
|
|
153
|
+
| [require-cookie-secure-attrs](https://eslint.interlace.tools/docs/browser-security/rules/require-cookie-secure-attrs) | CWE-614 | A05:2025 | 5.3 | [require-cookie-secure-attrs](./docs/rules/require-cookie-secure-attrs.md) | 💼 | | | | 🚫 |
|
|
154
|
+
| [require-websocket-wss](https://eslint.interlace.tools/docs/browser-security/rules/require-websocket-wss) | CWE-319 | A02:2025 | 7.5 | [require-websocket-wss](./docs/rules/require-websocket-wss.md) | 💼 | | | 💡 | 🚫 |
|
|
155
|
+
| [no-websocket-innerhtml](https://eslint.interlace.tools/docs/browser-security/rules/no-websocket-innerhtml) | CWE-79 | A03:2025 | 6.1 | [no-websocket-innerhtml](./docs/rules/no-websocket-innerhtml.md) | 💼 | | | 💡 | |
|
|
156
|
+
| [no-websocket-eval](https://eslint.interlace.tools/docs/browser-security/rules/no-websocket-eval) | CWE-95 | A03:2025 | 9.8 | [no-websocket-eval](./docs/rules/no-websocket-eval.md) | 💼 | | | 💡 | |
|
|
157
|
+
| [no-filereader-innerhtml](https://eslint.interlace.tools/docs/browser-security/rules/no-filereader-innerhtml) | CWE-79 | A03:2025 | 6.1 | [no-filereader-innerhtml](./docs/rules/no-filereader-innerhtml.md) | 💼 | | | 💡 | |
|
|
158
|
+
| [require-blob-url-revocation](https://eslint.interlace.tools/docs/browser-security/rules/require-blob-url-revocation) | CWE-401 | A04:2025 | 5.3 | [require-blob-url-revocation](./docs/rules/require-blob-url-revocation.md) | 💼 | ⚠️ | | 💡 | |
|
|
159
|
+
| [no-dynamic-service-worker-url](https://eslint.interlace.tools/docs/browser-security/rules/no-dynamic-service-worker-url) | CWE-829 | A08:2025 | 7.5 | [no-dynamic-service-worker-url](./docs/rules/no-dynamic-service-worker-url.md) | 💼 | | | 💡 | |
|
|
160
|
+
| [no-worker-message-innerhtml](https://eslint.interlace.tools/docs/browser-security/rules/no-worker-message-innerhtml) | CWE-79 | A03:2025 | 6.1 | [no-worker-message-innerhtml](./docs/rules/no-worker-message-innerhtml.md) | 💼 | | | | |
|
|
161
|
+
| [no-unsafe-inline-csp](https://eslint.interlace.tools/docs/browser-security/rules/no-unsafe-inline-csp) | CWE-79 | A03:2025 | 6.1 | [no-unsafe-inline-csp](./docs/rules/no-unsafe-inline-csp.md) | 💼 | | | 💡 | |
|
|
162
|
+
| [no-unsafe-eval-csp](https://eslint.interlace.tools/docs/browser-security/rules/no-unsafe-eval-csp) | CWE-95 | A03:2025 | 9.8 | [no-unsafe-eval-csp](./docs/rules/no-unsafe-eval-csp.md) | 💼 | | | 💡 | |
|
|
163
|
+
|
|
164
|
+
## 🔗 Related ESLint Plugins
|
|
210
165
|
|
|
211
166
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
212
167
|
|
|
213
|
-
| Plugin |
|
|
214
|
-
| :--------------------------------------------------------------------------------------------------- |
|
|
215
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) |
|
|
216
|
-
| [`eslint-plugin-
|
|
217
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) |
|
|
218
|
-
| [`eslint-plugin-
|
|
219
|
-
| [`eslint-plugin-
|
|
220
|
-
| [`eslint-plugin-
|
|
221
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) |
|
|
222
|
-
| [`eslint-plugin-
|
|
223
|
-
| [`eslint-plugin-
|
|
168
|
+
| Plugin | Downloads | Description |
|
|
169
|
+
| :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------ |
|
|
170
|
+
| [`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. |
|
|
171
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
172
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
173
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
174
|
+
| [`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. |
|
|
175
|
+
| [`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. |
|
|
176
|
+
| [`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. |
|
|
177
|
+
| [`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. |
|
|
178
|
+
| [`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. |
|
|
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) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
224
181
|
|
|
225
182
|
## 📄 License
|
|
226
183
|
|
|
227
184
|
MIT © [Ofri Peretz](https://github.com/ofri-peretz)
|
|
185
|
+
|
|
186
|
+
<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="300" /></a>
|
|
188
|
+
</p>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-browser-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"eslint",
|
|
42
42
|
"eslint-plugin",
|
|
43
43
|
"eslintplugin",
|
|
44
|
+
"interlace-security",
|
|
44
45
|
"browser",
|
|
45
46
|
"browser-security",
|
|
46
47
|
"web-security",
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
"node": ">=18.0.0"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
76
|
+
"tslib": "^2.3.0",
|
|
77
|
+
"@interlace/eslint-devkit": "^1.2.1"
|
|
77
78
|
},
|
|
78
79
|
"peerDependencies": {},
|
|
79
80
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,32 @@ const no_worker_message_innerhtml_1 = require("./rules/no-worker-message-innerht
|
|
|
35
35
|
// CSP Security
|
|
36
36
|
const no_unsafe_inline_csp_1 = require("./rules/no-unsafe-inline-csp");
|
|
37
37
|
const no_unsafe_eval_csp_1 = require("./rules/no-unsafe-eval-csp");
|
|
38
|
+
// Migrated rules from secure-coding
|
|
39
|
+
const detect_mixed_content_1 = require("./rules/detect-mixed-content");
|
|
40
|
+
const no_allow_arbitrary_loads_1 = require("./rules/no-allow-arbitrary-loads");
|
|
41
|
+
const no_clickjacking_1 = require("./rules/no-clickjacking");
|
|
42
|
+
const no_credentials_in_query_params_1 = require("./rules/no-credentials-in-query-params");
|
|
43
|
+
const no_http_urls_1 = require("./rules/no-http-urls");
|
|
44
|
+
const no_insecure_redirects_1 = require("./rules/no-insecure-redirects");
|
|
45
|
+
const no_insecure_websocket_1 = require("./rules/no-insecure-websocket");
|
|
46
|
+
const no_missing_cors_check_1 = require("./rules/no-missing-cors-check");
|
|
47
|
+
const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection");
|
|
48
|
+
const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
|
|
49
|
+
const no_password_in_url_1 = require("./rules/no-password-in-url");
|
|
50
|
+
const no_permissive_cors_1 = require("./rules/no-permissive-cors");
|
|
51
|
+
const no_sensitive_data_in_analytics_1 = require("./rules/no-sensitive-data-in-analytics");
|
|
52
|
+
const no_sensitive_data_in_cache_1 = require("./rules/no-sensitive-data-in-cache");
|
|
53
|
+
const no_tracking_without_consent_1 = require("./rules/no-tracking-without-consent");
|
|
54
|
+
const no_unencrypted_transmission_1 = require("./rules/no-unencrypted-transmission");
|
|
55
|
+
const no_unescaped_url_parameter_1 = require("./rules/no-unescaped-url-parameter");
|
|
56
|
+
const no_unvalidated_deeplinks_1 = require("./rules/no-unvalidated-deeplinks");
|
|
57
|
+
const require_csp_headers_1 = require("./rules/require-csp-headers");
|
|
58
|
+
const require_https_only_1 = require("./rules/require-https-only");
|
|
59
|
+
const require_url_validation_1 = require("./rules/require-url-validation");
|
|
60
|
+
const require_mime_type_validation_1 = require("./rules/require-mime-type-validation");
|
|
61
|
+
const no_disabled_certificate_validation_1 = require("./rules/no-disabled-certificate-validation");
|
|
62
|
+
// Migrated from secure-coding (browser-specific auth)
|
|
63
|
+
const no_client_side_auth_logic_1 = require("./rules/no-client-side-auth-logic");
|
|
38
64
|
/**
|
|
39
65
|
* Collection of all browser security ESLint rules
|
|
40
66
|
*/
|
|
@@ -68,6 +94,32 @@ exports.rules = {
|
|
|
68
94
|
// CSP Security
|
|
69
95
|
'no-unsafe-inline-csp': no_unsafe_inline_csp_1.noUnsafeInlineCsp,
|
|
70
96
|
'no-unsafe-eval-csp': no_unsafe_eval_csp_1.noUnsafeEvalCsp,
|
|
97
|
+
// Migrated rules
|
|
98
|
+
'detect-mixed-content': detect_mixed_content_1.detectMixedContent,
|
|
99
|
+
'no-allow-arbitrary-loads': no_allow_arbitrary_loads_1.noAllowArbitraryLoads,
|
|
100
|
+
'no-clickjacking': no_clickjacking_1.noClickjacking,
|
|
101
|
+
'no-credentials-in-query-params': no_credentials_in_query_params_1.noCredentialsInQueryParams,
|
|
102
|
+
'no-http-urls': no_http_urls_1.noHttpUrls,
|
|
103
|
+
'no-insecure-redirects': no_insecure_redirects_1.noInsecureRedirects,
|
|
104
|
+
'no-insecure-websocket': no_insecure_websocket_1.noInsecureWebsocket,
|
|
105
|
+
'no-missing-cors-check': no_missing_cors_check_1.noMissingCorsCheck,
|
|
106
|
+
'no-missing-csrf-protection': no_missing_csrf_protection_1.noMissingCsrfProtection,
|
|
107
|
+
'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
|
|
108
|
+
'no-password-in-url': no_password_in_url_1.noPasswordInUrl,
|
|
109
|
+
'no-permissive-cors': no_permissive_cors_1.noPermissiveCors,
|
|
110
|
+
'no-sensitive-data-in-analytics': no_sensitive_data_in_analytics_1.noSensitiveDataInAnalytics,
|
|
111
|
+
'no-sensitive-data-in-cache': no_sensitive_data_in_cache_1.noSensitiveDataInCache,
|
|
112
|
+
'no-tracking-without-consent': no_tracking_without_consent_1.noTrackingWithoutConsent,
|
|
113
|
+
'no-unencrypted-transmission': no_unencrypted_transmission_1.noUnencryptedTransmission,
|
|
114
|
+
'no-unescaped-url-parameter': no_unescaped_url_parameter_1.noUnescapedUrlParameter,
|
|
115
|
+
'no-unvalidated-deeplinks': no_unvalidated_deeplinks_1.noUnvalidatedDeeplinks,
|
|
116
|
+
'require-csp-headers': require_csp_headers_1.requireCspHeaders,
|
|
117
|
+
'require-https-only': require_https_only_1.requireHttpsOnly,
|
|
118
|
+
'require-url-validation': require_url_validation_1.requireUrlValidation,
|
|
119
|
+
'require-mime-type-validation': require_mime_type_validation_1.requireMimeTypeValidation,
|
|
120
|
+
'no-disabled-certificate-validation': no_disabled_certificate_validation_1.noDisabledCertificateValidation,
|
|
121
|
+
// Migrated from secure-coding
|
|
122
|
+
'no-client-side-auth-logic': no_client_side_auth_logic_1.noClientSideAuthLogic,
|
|
71
123
|
};
|
|
72
124
|
/**
|
|
73
125
|
* ESLint Plugin object
|
|
@@ -112,6 +164,16 @@ const recommendedRules = {
|
|
|
112
164
|
// Medium - CSP Security
|
|
113
165
|
'browser-security/no-unsafe-inline-csp': 'error',
|
|
114
166
|
'browser-security/no-unsafe-eval-csp': 'error',
|
|
167
|
+
// Migrated Rules
|
|
168
|
+
'browser-security/detect-mixed-content': 'error',
|
|
169
|
+
'browser-security/no-allow-arbitrary-loads': 'error',
|
|
170
|
+
'browser-security/no-clickjacking': 'error',
|
|
171
|
+
'browser-security/no-credentials-in-query-params': 'error',
|
|
172
|
+
'browser-security/no-http-urls': 'error',
|
|
173
|
+
'browser-security/require-https-only': 'error',
|
|
174
|
+
'browser-security/no-insecure-websocket': 'error',
|
|
175
|
+
'browser-security/no-unvalidated-deeplinks': 'error',
|
|
176
|
+
'browser-security/no-client-side-auth-logic': 'error',
|
|
115
177
|
};
|
|
116
178
|
/**
|
|
117
179
|
* Preset configurations for browser security rules
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const detectMixedContent: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.detectMixedContent = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Detect HTTP resources in HTTPS pages
|
|
11
|
+
* @see https://owasp.org/www-project-mobile-top-10/
|
|
12
|
+
* @see https://cwe.mitre.org/data/definitions/311.html
|
|
13
|
+
*/
|
|
14
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
|
+
exports.detectMixedContent = (0, eslint_devkit_1.createRule)({
|
|
16
|
+
name: 'detect-mixed-content',
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Detect HTTP resources in HTTPS pages',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
24
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
25
|
+
issueName: 'violation Detected',
|
|
26
|
+
cwe: 'CWE-311',
|
|
27
|
+
description: 'Detect HTTP resources in HTTPS pages detected - Literal containing http:// in HTTPS context',
|
|
28
|
+
severity: 'MEDIUM',
|
|
29
|
+
fix: 'Review and apply secure practices',
|
|
30
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/311.html',
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
schema: [],
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [],
|
|
36
|
+
create(context) {
|
|
37
|
+
return {
|
|
38
|
+
Literal(node) {
|
|
39
|
+
if (typeof node.value === 'string' && node.value.startsWith('http://')) {
|
|
40
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const noAllowArbitraryLoads: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.noAllowArbitraryLoads = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Prevent configuration allowing insecure loads
|
|
11
|
+
* @see https://owasp.org/www-project-mobile-top-10/
|
|
12
|
+
* @see https://cwe.mitre.org/data/definitions/749.html
|
|
13
|
+
*/
|
|
14
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
|
+
exports.noAllowArbitraryLoads = (0, eslint_devkit_1.createRule)({
|
|
16
|
+
name: 'no-allow-arbitrary-loads',
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Prevent configuration allowing insecure loads',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
24
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
25
|
+
issueName: 'violation Detected',
|
|
26
|
+
cwe: 'CWE-295',
|
|
27
|
+
description: 'Prevent configuration allowing insecure loads detected - allowArbitraryLoads: true',
|
|
28
|
+
severity: 'HIGH',
|
|
29
|
+
fix: 'Review and apply secure practices',
|
|
30
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/295.html',
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
schema: [],
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [],
|
|
36
|
+
create(context) {
|
|
37
|
+
return {
|
|
38
|
+
Property(node) {
|
|
39
|
+
if (node.key.type === 'Identifier' &&
|
|
40
|
+
node.key.name === 'allowArbitraryLoads' &&
|
|
41
|
+
node.value.type === 'Literal' &&
|
|
42
|
+
node.value.value === true) {
|
|
43
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* ESLint Rule: no-clickjacking
|
|
8
|
+
* Detects clickjacking vulnerabilities (CWE-1021)
|
|
9
|
+
*
|
|
10
|
+
* Clickjacking tricks users into clicking on invisible or disguised elements
|
|
11
|
+
* by overlaying them with transparent frames. This rule detects missing
|
|
12
|
+
* protections against clickjacking attacks.
|
|
13
|
+
*
|
|
14
|
+
* False Positive Reduction:
|
|
15
|
+
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
+
* - Safe iframe usage patterns
|
|
17
|
+
* - Trusted frame sources
|
|
18
|
+
* - JSDoc annotations (@trusted-frame, @safe-iframe)
|
|
19
|
+
* - Frame-busting protections
|
|
20
|
+
*/
|
|
21
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
+
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
+
type MessageIds = 'clickjackingVulnerability' | 'missingFrameBusting' | 'unsafeIframeUsage' | 'missingXFrameOptions' | 'missingCspFrameAncestors' | 'transparentFrameOverlay' | 'frameManipulation' | 'implementFrameBusting' | 'useXFrameOptions' | 'setCspFrameAncestors' | 'strategyFrameProtection' | 'strategyContentSecurity' | 'strategyUserInteraction';
|
|
24
|
+
export interface Options extends SecurityRuleOptions {
|
|
25
|
+
/** Trusted iframe sources */
|
|
26
|
+
trustedSources?: string[];
|
|
27
|
+
/** Require frame-busting code */
|
|
28
|
+
requireFrameBusting?: boolean;
|
|
29
|
+
/** Detect transparent overlays */
|
|
30
|
+
detectTransparentOverlays?: boolean;
|
|
31
|
+
}
|
|
32
|
+
type RuleOptions = [Options?];
|
|
33
|
+
export declare const noClickjacking: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
export {};
|