eslint-plugin-browser-security 1.3.0 → 1.3.2

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 CHANGED
@@ -18,6 +18,7 @@
18
18
  <a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
19
19
  <a href="https://app.codecov.io/gh/ofri-peretz/eslint/components?components%5B0%5D=eslint-plugin-browser-security" target="_blank"><img src="https://codecov.io/gh/ofri-peretz/eslint/graph/badge.svg?component=eslint-plugin-browser-security" alt="Codecov" /></a>
20
20
  <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>
21
+ <a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
21
22
  </p>
22
23
 
23
24
  > ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
@@ -155,50 +156,51 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md)
155
156
  | Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
156
157
  | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
157
158
  | [detect-mixed-content](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/detect-mixed-content?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-311 | | | Detects HTTP URLs in code that should use HTTPS, preventing mixed content vulnerabilities. | 🟢 | | | | | |
158
- | [no-allow-arbitrary-loads](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-allow-arbitrary-loads?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | Prevents disabling App Transport Security (ATS) by detecting allowArbitraryLoads: true in configuration. | 🟢 | | | | | |
159
- | [no-clickjacking](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-clickjacking?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1021 | | | Detects clickjacking vulnerabilities and missing frame protections | 🟢 | | | | | |
160
- | [no-client-side-auth-logic](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-client-side-auth-logic?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | | | | Prevent client-side authentication logic that can be bypassed. This rule is part of eslint-plugin-browser-s… | 🟢 | | | | | |
161
- | [no-cookie-auth-tokens](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-cookie-auth-tokens?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1004 | A02:2021 | | Prevent storing authentication tokens in JavaScript-accessible cookies. | 🟢 | | | | | |
162
- | [no-credentials-in-query-params](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-credentials-in-query-params?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-598 | | | CWE: [CWE-598](https://cwe.mitre.org/data/definitions/598.html) | 🟢 | | | | | |
163
- | [no-disabled-certificate-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-disabled-certificate-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | CWE: [CWE-295](https://cwe.mitre.org/data/definitions/295.html) | 🟢 | | | | | |
164
- | [no-dynamic-service-worker-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-dynamic-service-worker-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-829 | A08:2021 | | Prevent dynamic URLs in service worker registration. | 🟢 | | | | | |
159
+ | [no-allow-arbitrary-loads](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-allow-arbitrary-loads?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | Prevents disabling App Transport Security (ATS) by detecting allowArbitraryLoads: true in configuration. | 🟢 | 💼 | | | | |
160
+ | [no-clickjacking](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-clickjacking?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1021 | | | Detects clickjacking vulnerabilities and missing frame protections | 🟢 | 💼 | | | | |
161
+ | [no-client-side-auth-logic](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-client-side-auth-logic?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | | | | Prevent client-side authentication logic that can be bypassed. This rule is part of eslint-plugin-browser-s… | 🟢 | 💼 | | | | |
162
+ | [no-cookie-auth-tokens](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-cookie-auth-tokens?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1004 | A02:2021 | | Prevent storing authentication tokens in JavaScript-accessible cookies. | 🟢 | 💼 | | | | |
163
+ | [no-credentials-in-query-params](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-credentials-in-query-params?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-598 | | | CWE: [CWE-598](https://cwe.mitre.org/data/definitions/598.html) | 🟢 | 💼 | | | | |
164
+ | [no-disabled-certificate-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-disabled-certificate-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-295 | | | CWE: [CWE-295](https://cwe.mitre.org/data/definitions/295.html) | 🟢 | 💼 | | | | |
165
+ | [no-dynamic-service-worker-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-dynamic-service-worker-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-829 | A08:2021 | | Prevent dynamic URLs in service worker registration. | 🟢 | 💼 | | | | |
165
166
  | [no-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-eval?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-94 | | | Detects dangerous eval() and similar code execution patterns | 🟢 | 💼 | | | | |
166
- | [no-filereader-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-filereader-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
167
- | [no-http-urls](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-http-urls?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | | | | | |
167
+ | [no-filereader-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-filereader-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
168
+ | [no-http-urls](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-http-urls?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | 💼 | | | | |
169
+ | [no-incomplete-url-sanitization](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-incomplete-url-sanitization?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-020 | A01:2021 | | Disallow URL substring tests and partial scheme denylists as security decisions | 🟢 | 💼 | | | | |
168
170
  | [no-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | | | Detects dangerous innerHTML/outerHTML assignments that can lead to Cross-Site Scripting (XSS) | 🟢 | 💼 | | | | |
169
- | [no-insecure-redirects](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-redirects?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-601 | | | ESLint Rule: no-insecure-redirects | 🟢 | | | | | |
170
- | [no-insecure-websocket](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-websocket?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | | | | | |
171
- | [no-jwt-in-storage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-jwt-in-storage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-311 | A02:2021 | | This rule prevents storing JWT tokens in browser storage (localStorage/sessionStorage) | 🟢 | | | | | |
171
+ | [no-insecure-redirects](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-redirects?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-601 | | | ESLint Rule: no-insecure-redirects | 🟢 | 💼 | | | | |
172
+ | [no-insecure-websocket](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-insecure-websocket?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | CWE: [CWE-319](https://cwe.mitre.org/data/definitions/319.html) | 🟢 | 💼 | | | | |
173
+ | [no-jwt-in-storage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-jwt-in-storage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-311 | A02:2021 | | This rule prevents storing JWT tokens in browser storage (localStorage/sessionStorage) | 🟢 | 💼 | | | | |
172
174
  | [no-missing-cors-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-cors-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-346 | | | Detects missing CORS validation (wildcard CORS, missing origin check) that can allow unauthorized cross-ori… | 🟢 | | | | | |
173
175
  | [no-missing-csrf-protection](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-csrf-protection?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-352 | | | Detects missing CSRF token validation in POST/PUT/DELETE requests | 🟢 | | | | | |
174
176
  | [no-missing-security-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-missing-security-headers?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | | | ESLint Rule: no-missing-security-headers | 🟢 | | | | | |
175
177
  | [no-password-in-url](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-password-in-url?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-521 | | | This rule detects when URLs contain password-related query parameters or URL fragments | 🟢 | | | | | |
176
178
  | [no-permissive-cors](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-permissive-cors?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-942 | | | CWE: [CWE-942](https://cwe.mitre.org/data/definitions/942.html) | 🟢 | | | | | |
177
- | [no-postmessage-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
178
- | [no-postmessage-wildcard-origin](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-wildcard-origin?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A01:2021 | | This rule prevents using \\"\\" as the targetOrigin parameter in postMessage() calls | 🟢 | | | | | |
179
- | [no-sensitive-cookie-js](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-cookie-js?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | A02:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
179
+ | [no-postmessage-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
180
+ | [no-postmessage-wildcard-origin](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-postmessage-wildcard-origin?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-693 | A01:2021 | | This rule prevents using \\"\\" as the targetOrigin parameter in postMessage() calls | 🟢 | 💼 | | | | |
181
+ | [no-sensitive-cookie-js](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-cookie-js?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | A02:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
180
182
  | [no-sensitive-data-in-analytics](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-analytics?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | | | This rule detects when sensitive user data (email, SSN, credit card, password, phone, address) is passed to… | 🟢 | | | | | |
181
183
  | [no-sensitive-data-in-cache](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-data-in-cache?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-200 | | | CWE: [CWE-200](https://cwe.mitre.org/data/definitions/200.html) | 🟢 | | | | | |
182
- | [no-sensitive-indexeddb](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-indexeddb?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in IndexedDB. | 🟢 | | | | | |
183
- | [no-sensitive-localstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-localstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | | | Detects storage of sensitive data (tokens, passwords, PII) in localStorage | 🟢 | | | | | |
184
- | [no-sensitive-sessionstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-sessionstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in sessionStorage. | 🟢 | | | | | |
184
+ | [no-sensitive-indexeddb](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-indexeddb?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in IndexedDB. | 🟢 | 💼 | | | | |
185
+ | [no-sensitive-localstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-localstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | | | Detects storage of sensitive data (tokens, passwords, PII) in localStorage | 🟢 | 💼 | | | | |
186
+ | [no-sensitive-sessionstorage](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-sensitive-sessionstorage?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-922 | A02:2021 | | Prevent storing sensitive data in sessionStorage. | 🟢 | 💼 | | | | |
185
187
  | [no-tracking-without-consent](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-tracking-without-consent?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-359 | | | CWE: [CWE-359](https://cwe.mitre.org/data/definitions/359.html) | 🟢 | | | | | |
186
188
  | [no-unencrypted-transmission](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unencrypted-transmission?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols) | 🟢 | | | | | |
187
189
  | [no-unescaped-url-parameter](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unescaped-url-parameter?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | | | Detects unescaped URL parameters that can lead to Cross-Site Scripting (XSS) or open redirect vulnerabilities | 🟢 | | | | | |
188
- | [no-unsafe-eval-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-eval-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-95 | A03:2021 | | Disallow 'unsafe-eval' in Content Security Policy directives. | 🟢 | | | | | |
189
- | [no-unsafe-inline-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-inline-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow 'unsafe-inline' in Content Security Policy directives. | 🟢 | | | | | |
190
- | [no-unvalidated-deeplinks](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unvalidated-deeplinks?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-939 | | | This rule detects when deep link URLs are opened without validation in React Native or mobile web apps | 🟢 | | | | | |
191
- | [no-websocket-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-eval?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
192
- | [no-websocket-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | | | | | |
193
- | [no-worker-message-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-worker-message-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow using innerHTML with Web Worker message data. | 🟢 | | | | | |
194
- | [require-blob-url-revocation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-blob-url-revocation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-401 | A04:2021 | | Require revoking Blob URLs after use to prevent memory leaks. | 🟢 | | | | | |
195
- | [require-cookie-secure-attrs](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-cookie-secure-attrs?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-614 | A05:2021 | | Require Secure and SameSite attributes on cookies. | 🟢 | | | | | |
190
+ | [no-unsafe-eval-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-eval-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-95 | A03:2021 | | Disallow 'unsafe-eval' in Content Security Policy directives. | 🟢 | 💼 | | | | |
191
+ | [no-unsafe-inline-csp](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unsafe-inline-csp?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow 'unsafe-inline' in Content Security Policy directives. | 🟢 | 💼 | | | | |
192
+ | [no-unvalidated-deeplinks](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-unvalidated-deeplinks?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-939 | | | This rule detects when deep link URLs are opened without validation in React Native or mobile web apps | 🟢 | 💼 | | | | |
193
+ | [no-websocket-eval](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-eval?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
194
+ | [no-websocket-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-websocket-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A03:2021 | | The rule provides LLM-optimized error messages (Compact 2-line format) with actionable security guidance: | 🟢 | 💼 | | | | |
195
+ | [no-worker-message-innerhtml](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/no-worker-message-innerhtml?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-79 | A03:2021 | | Disallow using innerHTML with Web Worker message data. | 🟢 | 💼 | | | | |
196
+ | [require-blob-url-revocation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-blob-url-revocation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-401 | A04:2021 | | Require revoking Blob URLs after use to prevent memory leaks. | 🟢 | | ⚠️ | | | |
197
+ | [require-cookie-secure-attrs](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-cookie-secure-attrs?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-614 | A05:2021 | | Require Secure and SameSite attributes on cookies. | 🟢 | 💼 | | | | |
196
198
  | [require-csp-headers](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-csp-headers?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-1021 | | | CWE: [CWE-1021](https://cwe.mitre.org/data/definitions/1021.html) | 🟢 | | | | | |
197
- | [require-https-only](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-https-only?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | This rule detects HTTP (unencrypted) URLs in fetch() and axios requests | 🟢 | | | | | |
199
+ | [require-https-only](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-https-only?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | | | This rule detects HTTP (unencrypted) URLs in fetch() and axios requests | 🟢 | 💼 | | | | |
198
200
  | [require-mime-type-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-mime-type-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-434 | | | CWE: [CWE-434](https://cwe.mitre.org/data/definitions/434.html) | 🟢 | | | | | |
199
- | [require-postmessage-origin-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-postmessage-origin-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-346 | | | Detects postMessage event handlers without origin validation | 🟢 | | | | | |
201
+ | [require-postmessage-origin-check](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-postmessage-origin-check?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-346 | | | Detects postMessage event handlers without origin validation | 🟢 | 💼 | | | | |
200
202
  | [require-url-validation](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-url-validation?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-601 | | | CWE: [CWE-601](https://cwe.mitre.org/data/definitions/601.html) | 🟢 | | | | | |
201
- | [require-websocket-wss](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-websocket-wss?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A02:2021 | | This rule enforces the use of wss:// (WebSocket Secure) protocol instead of ws:// (unencrypted WebSocket) | 🟢 | | | | | |
203
+ | [require-websocket-wss](https://eslint.interlace.tools/docs/security/plugin-browser-security/rules/require-websocket-wss?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-browser-security) | CWE-319 | A02:2021 | | This rule enforces the use of wss:// (WebSocket Secure) protocol instead of ws:// (unencrypted WebSocket) | 🟢 | 💼 | | | | |
202
204
  <!-- AUTO-GENERATED:RULES_TABLE:END -->
203
205
  ## 🔗 Related ESLint Plugins
204
206
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "eslint-plugin-browser-security",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "ESLint plugin for browser security — detects DOM XSS, postMessage abuse, tokens in localStorage, insecure cookies, clickjacking, mixed content, and CSP gaps.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
7
7
  "types": "./src/index.d.ts",
8
8
  "exports": {
9
+ "./package.json": "./package.json",
9
10
  ".": {
10
11
  "types": "./src/index.d.ts",
11
12
  "default": "./src/index.js"
@@ -73,7 +74,7 @@
73
74
  "node": ">=18.0.0"
74
75
  },
75
76
  "dependencies": {
76
- "@interlace/eslint-devkit": "^1.11.0"
77
+ "@interlace/eslint-devkit": "^1.15.0"
77
78
  },
78
79
  "peerDependencies": {
79
80
  "eslint": "^8.40.0 || ^9.0.0 || ^10.0.0"
package/src/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;exports.rules={get"no-innerhtml"(){return require("./rules/no-innerhtml").noInnerhtml},get"no-eval"(){return require("./rules/no-eval").noEval},get"require-postmessage-origin-check"(){return require("./rules/require-postmessage-origin-check").requirePostmessageOriginCheck},get"no-postmessage-wildcard-origin"(){return require("./rules/no-postmessage-wildcard-origin").noPostmessageWildcardOrigin},get"no-postmessage-innerhtml"(){return require("./rules/no-postmessage-innerhtml").noPostmessageInnerhtml},get"no-sensitive-localstorage"(){return require("./rules/no-sensitive-localstorage").noSensitiveLocalstorage},get"no-jwt-in-storage"(){return require("./rules/no-jwt-in-storage").noJwtInStorage},get"no-sensitive-sessionstorage"(){return require("./rules/no-sensitive-sessionstorage").noSensitiveSessionstorage},get"no-sensitive-indexeddb"(){return require("./rules/no-sensitive-indexeddb").noSensitiveIndexeddb},get"no-sensitive-cookie-js"(){return require("./rules/no-sensitive-cookie-js").noSensitiveCookieJs},get"no-cookie-auth-tokens"(){return require("./rules/no-cookie-auth-tokens").noCookieAuthTokens},get"require-cookie-secure-attrs"(){return require("./rules/require-cookie-secure-attrs").requireCookieSecureAttrs},get"require-websocket-wss"(){return require("./rules/require-websocket-wss").requireWebsocketWss},get"no-websocket-innerhtml"(){return require("./rules/no-websocket-innerhtml").noWebsocketInnerhtml},get"no-websocket-eval"(){return require("./rules/no-websocket-eval").noWebsocketEval},get"no-filereader-innerhtml"(){return require("./rules/no-filereader-innerhtml").noFilereaderInnerhtml},get"require-blob-url-revocation"(){return require("./rules/require-blob-url-revocation").requireBlobUrlRevocation},get"no-dynamic-service-worker-url"(){return require("./rules/no-dynamic-service-worker-url").noDynamicServiceWorkerUrl},get"no-worker-message-innerhtml"(){return require("./rules/no-worker-message-innerhtml").noWorkerMessageInnerhtml},get"no-unsafe-inline-csp"(){return require("./rules/no-unsafe-inline-csp").noUnsafeInlineCsp},get"no-unsafe-eval-csp"(){return require("./rules/no-unsafe-eval-csp").noUnsafeEvalCsp},get"detect-mixed-content"(){return require("./rules/detect-mixed-content").detectMixedContent},get"no-allow-arbitrary-loads"(){return require("./rules/no-allow-arbitrary-loads").noAllowArbitraryLoads},get"no-clickjacking"(){return require("./rules/no-clickjacking").noClickjacking},get"no-credentials-in-query-params"(){return require("./rules/no-credentials-in-query-params").noCredentialsInQueryParams},get"no-http-urls"(){return require("./rules/no-http-urls").noHttpUrls},get"no-insecure-redirects"(){return require("./rules/no-insecure-redirects").noInsecureRedirects},get"no-insecure-websocket"(){return require("./rules/no-insecure-websocket").noInsecureWebsocket},get"no-missing-cors-check"(){return require("./rules/no-missing-cors-check").noMissingCorsCheck},get"no-missing-csrf-protection"(){return require("./rules/no-missing-csrf-protection").noMissingCsrfProtection},get"no-missing-security-headers"(){return require("./rules/no-missing-security-headers").noMissingSecurityHeaders},get"no-password-in-url"(){return require("./rules/no-password-in-url").noPasswordInUrl},get"no-permissive-cors"(){return require("./rules/no-permissive-cors").noPermissiveCors},get"no-sensitive-data-in-analytics"(){return require("./rules/no-sensitive-data-in-analytics").noSensitiveDataInAnalytics},get"no-sensitive-data-in-cache"(){return require("./rules/no-sensitive-data-in-cache").noSensitiveDataInCache},get"no-tracking-without-consent"(){return require("./rules/no-tracking-without-consent").noTrackingWithoutConsent},get"no-unencrypted-transmission"(){return require("./rules/no-unencrypted-transmission").noUnencryptedTransmission},get"no-unescaped-url-parameter"(){return require("./rules/no-unescaped-url-parameter").noUnescapedUrlParameter},get"no-unvalidated-deeplinks"(){return require("./rules/no-unvalidated-deeplinks").noUnvalidatedDeeplinks},get"require-csp-headers"(){return require("./rules/require-csp-headers").requireCspHeaders},get"require-https-only"(){return require("./rules/require-https-only").requireHttpsOnly},get"require-url-validation"(){return require("./rules/require-url-validation").requireUrlValidation},get"require-mime-type-validation"(){return require("./rules/require-mime-type-validation").requireMimeTypeValidation},get"no-disabled-certificate-validation"(){return require("./rules/no-disabled-certificate-validation").noDisabledCertificateValidation},get"no-client-side-auth-logic"(){return require("./rules/no-client-side-auth-logic").noClientSideAuthLogic}};exports.plugin={meta:{name:"eslint-plugin-browser-security",version:"1.3.0"},rules:exports.rules};const recommendedRules={"browser-security/no-innerhtml":"error","browser-security/no-eval":"error","browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error","browser-security/no-postmessage-innerhtml":"error","browser-security/no-sensitive-localstorage":"error","browser-security/no-jwt-in-storage":"error","browser-security/no-sensitive-sessionstorage":"error","browser-security/no-sensitive-indexeddb":"error","browser-security/no-sensitive-cookie-js":"error","browser-security/no-cookie-auth-tokens":"error","browser-security/require-cookie-secure-attrs":"error","browser-security/require-websocket-wss":"error","browser-security/no-websocket-innerhtml":"error","browser-security/no-websocket-eval":"error","browser-security/no-filereader-innerhtml":"error","browser-security/require-blob-url-revocation":"warn","browser-security/no-dynamic-service-worker-url":"error","browser-security/no-worker-message-innerhtml":"error","browser-security/no-unsafe-inline-csp":"error","browser-security/no-unsafe-eval-csp":"error","browser-security/detect-mixed-content":"error","browser-security/no-allow-arbitrary-loads":"error","browser-security/no-clickjacking":"error","browser-security/no-credentials-in-query-params":"error","browser-security/no-http-urls":"error","browser-security/no-insecure-redirects":"error","browser-security/require-https-only":"error","browser-security/no-insecure-websocket":"error","browser-security/no-unvalidated-deeplinks":"error","browser-security/no-client-side-auth-logic":"error"};exports.configs={flagship:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-postmessage-wildcard-origin":"error"}},recommended:{plugins:{"browser-security":exports.plugin},rules:recommendedRules},strict:{plugins:{"browser-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`browser-security/${ruleName}`,"error"]))},xss:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-innerhtml":"error","browser-security/no-eval":"error"}},storage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-localstorage":"error"}},postmessage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error"}},websocket:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-websocket-wss":"error"}},cookies:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-cookie-js":"error"}}};exports.default=exports.plugin;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.rules={get"no-innerhtml"(){return require("./rules/no-innerhtml").noInnerhtml},get"no-eval"(){return require("./rules/no-eval").noEval},get"require-postmessage-origin-check"(){return require("./rules/require-postmessage-origin-check").requirePostmessageOriginCheck},get"no-postmessage-wildcard-origin"(){return require("./rules/no-postmessage-wildcard-origin").noPostmessageWildcardOrigin},get"no-postmessage-innerhtml"(){return require("./rules/no-postmessage-innerhtml").noPostmessageInnerhtml},get"no-sensitive-localstorage"(){return require("./rules/no-sensitive-localstorage").noSensitiveLocalstorage},get"no-jwt-in-storage"(){return require("./rules/no-jwt-in-storage").noJwtInStorage},get"no-sensitive-sessionstorage"(){return require("./rules/no-sensitive-sessionstorage").noSensitiveSessionstorage},get"no-sensitive-indexeddb"(){return require("./rules/no-sensitive-indexeddb").noSensitiveIndexeddb},get"no-sensitive-cookie-js"(){return require("./rules/no-sensitive-cookie-js").noSensitiveCookieJs},get"no-cookie-auth-tokens"(){return require("./rules/no-cookie-auth-tokens").noCookieAuthTokens},get"require-cookie-secure-attrs"(){return require("./rules/require-cookie-secure-attrs").requireCookieSecureAttrs},get"require-websocket-wss"(){return require("./rules/require-websocket-wss").requireWebsocketWss},get"no-websocket-innerhtml"(){return require("./rules/no-websocket-innerhtml").noWebsocketInnerhtml},get"no-websocket-eval"(){return require("./rules/no-websocket-eval").noWebsocketEval},get"no-filereader-innerhtml"(){return require("./rules/no-filereader-innerhtml").noFilereaderInnerhtml},get"require-blob-url-revocation"(){return require("./rules/require-blob-url-revocation").requireBlobUrlRevocation},get"no-dynamic-service-worker-url"(){return require("./rules/no-dynamic-service-worker-url").noDynamicServiceWorkerUrl},get"no-worker-message-innerhtml"(){return require("./rules/no-worker-message-innerhtml").noWorkerMessageInnerhtml},get"no-unsafe-inline-csp"(){return require("./rules/no-unsafe-inline-csp").noUnsafeInlineCsp},get"no-unsafe-eval-csp"(){return require("./rules/no-unsafe-eval-csp").noUnsafeEvalCsp},get"detect-mixed-content"(){return require("./rules/detect-mixed-content").detectMixedContent},get"no-allow-arbitrary-loads"(){return require("./rules/no-allow-arbitrary-loads").noAllowArbitraryLoads},get"no-clickjacking"(){return require("./rules/no-clickjacking").noClickjacking},get"no-credentials-in-query-params"(){return require("./rules/no-credentials-in-query-params").noCredentialsInQueryParams},get"no-http-urls"(){return require("./rules/no-http-urls").noHttpUrls},get"no-incomplete-url-sanitization"(){return require("./rules/no-incomplete-url-sanitization").noIncompleteUrlSanitization},get"no-insecure-redirects"(){return require("./rules/no-insecure-redirects").noInsecureRedirects},get"no-insecure-websocket"(){return require("./rules/no-insecure-websocket").noInsecureWebsocket},get"no-missing-cors-check"(){return require("./rules/no-missing-cors-check").noMissingCorsCheck},get"no-missing-csrf-protection"(){return require("./rules/no-missing-csrf-protection").noMissingCsrfProtection},get"no-missing-security-headers"(){return require("./rules/no-missing-security-headers").noMissingSecurityHeaders},get"no-password-in-url"(){return require("./rules/no-password-in-url").noPasswordInUrl},get"no-permissive-cors"(){return require("./rules/no-permissive-cors").noPermissiveCors},get"no-sensitive-data-in-analytics"(){return require("./rules/no-sensitive-data-in-analytics").noSensitiveDataInAnalytics},get"no-sensitive-data-in-cache"(){return require("./rules/no-sensitive-data-in-cache").noSensitiveDataInCache},get"no-tracking-without-consent"(){return require("./rules/no-tracking-without-consent").noTrackingWithoutConsent},get"no-unencrypted-transmission"(){return require("./rules/no-unencrypted-transmission").noUnencryptedTransmission},get"no-unescaped-url-parameter"(){return require("./rules/no-unescaped-url-parameter").noUnescapedUrlParameter},get"no-unvalidated-deeplinks"(){return require("./rules/no-unvalidated-deeplinks").noUnvalidatedDeeplinks},get"require-csp-headers"(){return require("./rules/require-csp-headers").requireCspHeaders},get"require-https-only"(){return require("./rules/require-https-only").requireHttpsOnly},get"require-url-validation"(){return require("./rules/require-url-validation").requireUrlValidation},get"require-mime-type-validation"(){return require("./rules/require-mime-type-validation").requireMimeTypeValidation},get"no-disabled-certificate-validation"(){return require("./rules/no-disabled-certificate-validation").noDisabledCertificateValidation},get"no-client-side-auth-logic"(){return require("./rules/no-client-side-auth-logic").noClientSideAuthLogic}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-browser-security",exports.rules);exports.plugin={meta:{name:"eslint-plugin-browser-security",version:"1.3.2"},rules:exports.rules};const recommendedRules={"browser-security/no-innerhtml":"error","browser-security/no-eval":"error","browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error","browser-security/no-postmessage-innerhtml":"error","browser-security/no-sensitive-localstorage":"error","browser-security/no-jwt-in-storage":"error","browser-security/no-sensitive-sessionstorage":"error","browser-security/no-sensitive-indexeddb":"error","browser-security/no-sensitive-cookie-js":"error","browser-security/no-cookie-auth-tokens":"error","browser-security/require-cookie-secure-attrs":"error","browser-security/require-websocket-wss":"error","browser-security/no-websocket-innerhtml":"error","browser-security/no-websocket-eval":"error","browser-security/no-filereader-innerhtml":"error","browser-security/require-blob-url-revocation":"warn","browser-security/no-dynamic-service-worker-url":"error","browser-security/no-worker-message-innerhtml":"error","browser-security/no-unsafe-inline-csp":"error","browser-security/no-unsafe-eval-csp":"error","browser-security/no-allow-arbitrary-loads":"error","browser-security/no-clickjacking":"error","browser-security/no-credentials-in-query-params":"error","browser-security/no-http-urls":"error","browser-security/no-incomplete-url-sanitization":"error","browser-security/no-insecure-redirects":"error","browser-security/no-disabled-certificate-validation":"error","browser-security/require-https-only":"error","browser-security/no-insecure-websocket":"error","browser-security/no-unvalidated-deeplinks":"error","browser-security/no-client-side-auth-logic":"error"};exports.configs={flagship:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-postmessage-wildcard-origin":"error"}},recommended:{plugins:{"browser-security":exports.plugin},rules:recommendedRules},strict:{plugins:{"browser-security":exports.plugin},rules:Object.fromEntries(Object.keys(exports.rules).map(ruleName=>[`browser-security/${ruleName}`,"error"]))},xss:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-innerhtml":"error","browser-security/no-eval":"error"}},storage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-localstorage":"error"}},postmessage:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-postmessage-origin-check":"error","browser-security/no-postmessage-wildcard-origin":"error"}},websocket:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/require-websocket-wss":"error"}},cookies:{plugins:{"browser-security":exports.plugin},rules:{"browser-security/no-sensitive-cookie-js":"error"}}};exports.default=exports.plugin;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.detectMixedContent=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.detectMixedContent=(0,eslint_devkit_1.createRule)({name:"detect-mixed-content",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/detect-mixed-content.md",description:"Detect HTTP resources in HTTPS pages",cwe:"CWE-311",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-311",description:"Detect HTTP resources in HTTPS pages detected - Literal containing http:// in HTTPS context",severity:"MEDIUM",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/311.html"})},schema:[]},defaultOptions:[],create(context){return{Literal(node){if(typeof node.value==="string"&&node.value.startsWith("http://")){context.report({node,messageId:"violationDetected"})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.detectMixedContent=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const namespace_uris_1=require("../../utils/namespace-uris");exports.detectMixedContent=(0,eslint_devkit_1.createRule)({name:"detect-mixed-content",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/detect-mixed-content.md",description:"Detect HTTP resources in HTTPS pages",cwe:"CWE-311",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-311",description:"Detect HTTP resources in HTTPS pages detected - Literal containing http:// in HTTPS context",severity:"MEDIUM",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/311.html"})},schema:[]},defaultOptions:[],create(context){return{Literal(node){if(typeof node.value!=="string"||!node.value.startsWith("http://")){return}const parent=node.parent;const declaredAs=parent?.type==="JSXAttribute"&&parent.name.type==="JSXIdentifier"?parent.name.name:void 0;if((0,namespace_uris_1.isXmlNamespaceUri)(node.value,declaredAs)){return}if((0,namespace_uris_1.isTrustworthyLocalUrl)(node.value)){return}if((0,namespace_uris_1.isDiscardedUrlBase)(node)){return}context.report({node,messageId:"violationDetected"})}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClickjacking=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const eslint_devkit_3=require("@interlace/eslint-devkit");const FRAME_REFS=new Set(["top","self","parent","window"]);function isFrameRef(node){if(node.type==="Identifier")return FRAME_REFS.has(node.name);if(node.type==="MemberExpression"&&node.object.type==="Identifier"&&node.object.name==="window"){return node.property.type==="Identifier"&&FRAME_REFS.has(node.property.name)}return false}function isFrameBustingTest(test){return test.type==="BinaryExpression"&&["!=","!==","==","==="].includes(test.operator)&&isFrameRef(test.left)&&isFrameRef(test.right)}const FUNCTION_TYPES=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]);function runsOnlyInsideGuard(fn,guard,sourceCode){const parent=fn.parent;if(parent?.type==="CallExpression"&&parent.arguments.includes(fn)){return true}if(parent?.type==="CallExpression"&&parent.callee===fn)return true;const declarator=fn.type==="FunctionDeclaration"?fn:parent?.type==="VariableDeclarator"?parent:void 0;if(declarator===void 0)return false;return sourceCode.getDeclaredVariables(declarator).every(variable=>variable.references.every(ref=>ref.identifier.range[0]>=guard.range[0]&&ref.identifier.range[1]<=guard.range[1]))}function insideFrameBustingGuard(node,sourceCode){const crossed=[];let current=node.parent;while(current){if(FUNCTION_TYPES.has(current.type))crossed.push(current);if(current.type==="IfStatement"&&isFrameBustingTest(current.test)){const guard=current;return crossed.every(fn=>runsOnlyInsideGuard(fn,guard,sourceCode))}current=current.parent}return false}exports.noClickjacking=(0,eslint_devkit_1.createRule)({name:"no-clickjacking",meta:{type:"problem",deprecated:true,replacedBy:["@see eslint-plugin-express-security/require-helmet"],docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-clickjacking.md",description:"Detects clickjacking vulnerabilities and missing frame protections",cwe:"CWE-1021"},messages:{clickjackingVulnerability:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Clickjacking Vulnerability",cwe:"CWE-1021",description:"Clickjacking protection missing",severity:"{{severity}}",fix:"{{safeAlternative}}",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing Frame Busting",cwe:"CWE-1021",description:"No frame-busting code to prevent clickjacking",severity:"HIGH",fix:"Add frame-busting JavaScript to prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),unsafeIframeUsage:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Unsafe iframe Usage",cwe:"CWE-1021",description:"iframe may enable clickjacking attacks",severity:"MEDIUM",fix:"Add X-Frame-Options or CSP frame-ancestors protection",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing X-Frame-Options",cwe:"CWE-1021",description:"X-Frame-Options header not set",severity:"HIGH",fix:"Set X-Frame-Options: DENY or SAMEORIGIN",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),missingCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing CSP frame-ancestors",cwe:"CWE-1021",description:"CSP frame-ancestors directive not configured",severity:"HIGH",fix:"Add frame-ancestors to Content-Security-Policy",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),transparentFrameOverlay:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Transparent Frame Overlay",cwe:"CWE-1021",description:"Transparent elements may hide clickjacking attacks",severity:"MEDIUM",fix:"Use frame-busting or CSP protections",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),frameManipulation:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Frame Manipulation",cwe:"CWE-1021",description:"Code attempts to manipulate parent frames",severity:"LOW",fix:"Implement proper frame communication or prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),implementFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Implement Frame Busting",description:"Add JavaScript to prevent framing",severity:"LOW",fix:"if (top != self) top.location = location;",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),useXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use X-Frame-Options",description:"Set X-Frame-Options HTTP header",severity:"LOW",fix:"X-Frame-Options: DENY",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),setCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Set CSP frame-ancestors",description:"Configure CSP frame-ancestors directive",severity:"LOW",fix:"frame-ancestors 'self' https://trusted.com",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),strategyFrameProtection:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Frame Protection Strategy",description:"Implement multiple layers of frame protection",severity:"LOW",fix:"Use X-Frame-Options, CSP, and frame-busting together",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),strategyContentSecurity:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Content Security Strategy",description:"Use CSP for comprehensive frame control",severity:"LOW",fix:"Implement strict CSP with frame-ancestors",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),strategyUserInteraction:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"User Interaction Strategy",description:"Protect user interactions from framing attacks",severity:"LOW",fix:"Validate user intent for sensitive actions",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"})},schema:[{type:"object",properties:{trustedSources:{type:"array",items:{type:"string"},default:["self","same-origin"],description:"Frame-ancestor sources treated as safe"},requireFrameBusting:{type:"boolean",default:true,description:"Require frame-busting code in addition to headers"},detectTransparentOverlays:{type:"boolean",default:true,description:"Report transparent overlays positioned over clickable elements"},trustedSanitizers:{type:"array",items:{type:"string"},default:[],description:"Additional function names to consider as frame protectors"},trustedAnnotations:{type:"array",items:{type:"string"},default:[],description:"Additional JSDoc annotations to consider as safe markers"},strictMode:{type:"boolean",default:false,description:"Disable all false positive detection (strict mode)"}},additionalProperties:false}]},defaultOptions:[{trustedSources:["self","same-origin"],requireFrameBusting:true,detectTransparentOverlays:true,trustedSanitizers:[],trustedAnnotations:[],strictMode:false}],create(context){const options=context.options[0]||{};const{trustedSources=["self","same-origin"],requireFrameBusting=true,detectTransparentOverlays=true,trustedSanitizers=[],trustedAnnotations=[],strictMode=false}=options;const sourceCode=context.sourceCode;const filename=context.filename;const safetyChecker=(0,eslint_devkit_3.createSafetyChecker)({trustedSanitizers,trustedAnnotations,trustedOrmPatterns:[],strictMode});let hasFrameBusting=false;const isTrustedSource=source=>{return trustedSources.some(trusted=>source.includes(trusted)||trusted==="self"&&(source==="self"||source.startsWith("/"))||trusted==="same-origin"&&source==="same-origin")};const isFrameBustingCode=node=>{const test=node.test;const testText=sourceCode.getText(test).toLowerCase();return testText.includes("top != self")||testText.includes("top !== self")||testText.includes("window.top !== window.self")||testText.includes("parent != self")||testText.includes("top.location")||testText.includes("self.location")};const hasTransparentStyles=styleText=>{const styles=styleText.toLowerCase();return styles.includes("opacity: 0")||styles.includes("opacity:0")||styles.includes("visibility: hidden")||styles.includes("display: none")||styles.includes("z-index: -1")||styles.includes("position: absolute")&&styles.includes("top: 0")&&styles.includes("left: 0")};return{IfStatement(node){if(isFrameBustingCode(node)){hasFrameBusting=true}},JSXElement(node){if(node.openingElement.name.type==="JSXIdentifier"&&node.openingElement.name.name==="iframe"){const attributes=node.openingElement.attributes;let hasSrc=false;let srcValue="";for(const attr of attributes){if(attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="src"&&attr.value){hasSrc=true;if(attr.value.type==="Literal"&&typeof attr.value.value==="string"){srcValue=attr.value.value}}}if(hasSrc&&srcValue&&!isTrustedSource(srcValue)){if(safetyChecker.isSafe(node,context)){return}context.report({node:node.openingElement,messageId:"unsafeIframeUsage",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},MemberExpression(node){if(node.object.type==="Identifier"&&(node.object.name==="top"||node.object.name==="window")){if(node.property.type==="Identifier"&&(node.property.name==="location"||node.property.name==="top")){let current=node;let isFrameManipulation=false;while(current){if(current.type==="AssignmentExpression"&&current.left===node){isFrameManipulation=true;break}if(current.type==="BinaryExpression"&&(current.left===node||current.right===node)){const operator=current.operator;if(operator==="!="||operator==="!=="||operator==="=="||operator==="==="){break}isFrameManipulation=true;break}current=current.parent}if(isFrameManipulation){if(safetyChecker.isSafe(node,context)){return}if(insideFrameBustingGuard(node,sourceCode)){return}context.report({node,messageId:"frameManipulation",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}}},Literal(node){if(typeof node.value==="string"&&detectTransparentOverlays){const text=node.value.toLowerCase();if((text.includes("style=")||text.includes("css"))&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},TemplateLiteral(node){if(detectTransparentOverlays){const text=sourceCode.getText(node).toLowerCase();if(text.includes("style")&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},"Program:exit"(){if(requireFrameBusting&&!hasFrameBusting){const isEntryPoint=/\.(html|htm)$/.test(filename)||/(index|app|main|page)\.(tsx|jsx)$/i.test(filename)||/pages?\/.*\.(tsx|jsx)$/i.test(filename)||/layout\.(tsx|jsx)$/i.test(filename);if(!isEntryPoint){return}const fileContent=sourceCode.getText();const hasUIElements=fileContent.includes("<button")||fileContent.includes("<form")||fileContent.includes("<input")||fileContent.includes("onClick")&&fileContent.includes("<");if(hasUIElements){context.report({node:context.sourceCode.ast,messageId:"missingFrameBusting",data:{filePath:filename,line:"1"}})}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClickjacking=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const eslint_devkit_3=require("@interlace/eslint-devkit");const FRAME_REFS=new Set(["top","self","parent","window"]);function isFrameRef(node){if(node.type==="Identifier")return FRAME_REFS.has(node.name);if(node.type==="MemberExpression"&&node.object.type==="Identifier"&&node.object.name==="window"){return node.property.type==="Identifier"&&FRAME_REFS.has(node.property.name)}return false}function isFrameBustingTest(test){return test.type==="BinaryExpression"&&["!=","!==","==","==="].includes(test.operator)&&isFrameRef(test.left)&&isFrameRef(test.right)}const DECLARATION=/(?:^|[^a-z-])([a-z-]+)\s*:\s*([^;{}"'`\n]*)/g;function cssDeclarations(text){const declarations=[];for(const match of text.toLowerCase().matchAll(DECLARATION)){const value=match[2].trim().replace(/\s*!important$/,"").replace(/,$/,"").trim();declarations.push([match[1],value])}return declarations}function hasDeclaration(declarations,property,matches){return declarations.some(([prop,value])=>prop===property&&matches(value))}const FUNCTION_TYPES=new Set(["FunctionDeclaration","FunctionExpression","ArrowFunctionExpression"]);function runsOnlyInsideGuard(fn,guard,sourceCode){const parent=fn.parent;if(parent?.type==="CallExpression"&&parent.arguments.includes(fn)){return true}if(parent?.type==="CallExpression"&&parent.callee===fn)return true;const declarator=fn.type==="FunctionDeclaration"?fn:parent?.type==="VariableDeclarator"?parent:void 0;if(declarator===void 0)return false;return sourceCode.getDeclaredVariables(declarator).every(variable=>variable.references.every(ref=>ref.identifier.range[0]>=guard.range[0]&&ref.identifier.range[1]<=guard.range[1]))}function insideFrameBustingGuard(node,sourceCode){const crossed=[];let current=node.parent;while(current){if(FUNCTION_TYPES.has(current.type))crossed.push(current);if(current.type==="IfStatement"&&isFrameBustingTest(current.test)){const guard=current;return crossed.every(fn=>runsOnlyInsideGuard(fn,guard,sourceCode))}current=current.parent}return false}exports.noClickjacking=(0,eslint_devkit_1.createRule)({name:"no-clickjacking",meta:{type:"problem",deprecated:true,replacedBy:["@see eslint-plugin-express-security/require-helmet"],docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-clickjacking.md",description:"Detects clickjacking vulnerabilities and missing frame protections",cwe:"CWE-1021"},messages:{clickjackingVulnerability:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Clickjacking Vulnerability",cwe:"CWE-1021",description:"Clickjacking protection missing",severity:"{{severity}}",fix:"{{safeAlternative}}",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing Frame Busting",cwe:"CWE-1021",description:"No frame-busting code to prevent clickjacking",severity:"HIGH",fix:"Add frame-busting JavaScript to prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),unsafeIframeUsage:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Unsafe iframe Usage",cwe:"CWE-1021",description:"iframe may enable clickjacking attacks",severity:"MEDIUM",fix:"Add X-Frame-Options or CSP frame-ancestors protection",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),missingXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing X-Frame-Options",cwe:"CWE-1021",description:"X-Frame-Options header not set",severity:"HIGH",fix:"Set X-Frame-Options: DENY or SAMEORIGIN",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),missingCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Missing CSP frame-ancestors",cwe:"CWE-1021",description:"CSP frame-ancestors directive not configured",severity:"HIGH",fix:"Add frame-ancestors to Content-Security-Policy",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),transparentFrameOverlay:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Transparent Frame Overlay",cwe:"CWE-1021",description:"Transparent elements may hide clickjacking attacks",severity:"MEDIUM",fix:"Use frame-busting or CSP protections",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),frameManipulation:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Frame Manipulation",cwe:"CWE-1021",description:"Code attempts to manipulate parent frames",severity:"LOW",fix:"Implement proper frame communication or prevent framing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),implementFrameBusting:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Implement Frame Busting",description:"Add JavaScript to prevent framing",severity:"LOW",fix:"if (top != self) top.location = location;",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),useXFrameOptions:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use X-Frame-Options",description:"Set X-Frame-Options HTTP header",severity:"LOW",fix:"X-Frame-Options: DENY",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options"}),setCspFrameAncestors:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Set CSP frame-ancestors",description:"Configure CSP frame-ancestors directive",severity:"LOW",fix:"frame-ancestors 'self' https://trusted.com",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors"}),strategyFrameProtection:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Frame Protection Strategy",description:"Implement multiple layers of frame protection",severity:"LOW",fix:"Use X-Frame-Options, CSP, and frame-busting together",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"}),strategyContentSecurity:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"Content Security Strategy",description:"Use CSP for comprehensive frame control",severity:"LOW",fix:"Implement strict CSP with frame-ancestors",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),strategyUserInteraction:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.STRATEGY,issueName:"User Interaction Strategy",description:"Protect user interactions from framing attacks",severity:"LOW",fix:"Validate user intent for sensitive actions",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/Clickjacking_Defense_Cheat_Sheet.html"})},schema:[{type:"object",properties:{trustedSources:{type:"array",items:{type:"string"},default:["self","same-origin"],description:"Frame-ancestor sources treated as safe"},requireFrameBusting:{type:"boolean",default:true,description:"Require frame-busting code in addition to headers"},detectTransparentOverlays:{type:"boolean",default:true,description:"Report transparent overlays positioned over clickable elements"},trustedSanitizers:{type:"array",items:{type:"string"},default:[],description:"Additional function names to consider as frame protectors"},trustedAnnotations:{type:"array",items:{type:"string"},default:[],description:"Additional JSDoc annotations to consider as safe markers"},strictMode:{type:"boolean",default:false,description:"Disable all false positive detection (strict mode)"}},additionalProperties:false}]},defaultOptions:[{trustedSources:["self","same-origin"],requireFrameBusting:true,detectTransparentOverlays:true,trustedSanitizers:[],trustedAnnotations:[],strictMode:false}],create(context){const options=context.options[0]||{};const{trustedSources=["self","same-origin"],requireFrameBusting=true,detectTransparentOverlays=true,trustedSanitizers=[],trustedAnnotations=[],strictMode=false}=options;const sourceCode=context.sourceCode;const filename=context.filename;const safetyChecker=(0,eslint_devkit_3.createSafetyChecker)({trustedSanitizers,trustedAnnotations,trustedOrmPatterns:[],strictMode});let hasFrameBusting=false;const isTrustedSource=source=>{return trustedSources.some(trusted=>source.includes(trusted)||trusted==="self"&&(source==="self"||source.startsWith("/"))||trusted==="same-origin"&&source==="same-origin")};const isFrameBustingCode=node=>{const test=node.test;const testText=sourceCode.getText(test).toLowerCase();return testText.includes("top != self")||testText.includes("top !== self")||testText.includes("window.top !== window.self")||testText.includes("parent != self")||testText.includes("top.location")||testText.includes("self.location")};const hasTransparentStyles=styleText=>{const declarations=cssDeclarations(styleText);return hasDeclaration(declarations,"opacity",v=>/^0(?:\.0+)?%?$/.test(v))||hasDeclaration(declarations,"visibility",v=>v==="hidden")||hasDeclaration(declarations,"z-index",v=>/^-\d+$/.test(v))||hasDeclaration(declarations,"position",v=>v==="absolute")&&hasDeclaration(declarations,"top",v=>/^0(?:\.0+)?(?:px|%)?$/.test(v))&&hasDeclaration(declarations,"left",v=>/^0(?:\.0+)?(?:px|%)?$/.test(v))};return{IfStatement(node){if(isFrameBustingCode(node)){hasFrameBusting=true}},JSXElement(node){if(node.openingElement.name.type==="JSXIdentifier"&&node.openingElement.name.name==="iframe"){const attributes=node.openingElement.attributes;let hasSrc=false;let srcValue="";for(const attr of attributes){if(attr.type==="JSXAttribute"&&attr.name.type==="JSXIdentifier"&&attr.name.name==="src"&&attr.value){hasSrc=true;if(attr.value.type==="Literal"&&typeof attr.value.value==="string"){srcValue=attr.value.value}}}if(hasSrc&&srcValue&&!isTrustedSource(srcValue)){if(safetyChecker.isSafe(node,context)){return}context.report({node:node.openingElement,messageId:"unsafeIframeUsage",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},MemberExpression(node){if(node.object.type==="Identifier"&&(node.object.name==="top"||node.object.name==="window")){if(node.property.type==="Identifier"&&(node.property.name==="location"||node.property.name==="top")){let current=node;let isFrameManipulation=false;while(current){if(current.type==="AssignmentExpression"&&current.left===node){isFrameManipulation=true;break}if(current.type==="BinaryExpression"&&(current.left===node||current.right===node)){const operator=current.operator;if(operator==="!="||operator==="!=="||operator==="=="||operator==="==="){break}isFrameManipulation=true;break}current=current.parent}if(isFrameManipulation){if(safetyChecker.isSafe(node,context)){return}if(insideFrameBustingGuard(node,sourceCode)){return}context.report({node,messageId:"frameManipulation",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}}},Literal(node){if(typeof node.value==="string"&&detectTransparentOverlays){const text=node.value.toLowerCase();if((text.includes("style=")||text.includes("css"))&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},TemplateLiteral(node){if(detectTransparentOverlays){const text=sourceCode.getText(node).toLowerCase();if(text.includes("style")&&hasTransparentStyles(text)){if(safetyChecker.isSafe(node,context)){return}context.report({node,messageId:"transparentFrameOverlay",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}}},"Program:exit"(){if(requireFrameBusting&&!hasFrameBusting){const isEntryPoint=/\.(html|htm)$/.test(filename)||/(index|app|main|page)\.(tsx|jsx)$/i.test(filename)||/pages?\/.*\.(tsx|jsx)$/i.test(filename)||/layout\.(tsx|jsx)$/i.test(filename);if(!isEntryPoint){return}const fileContent=sourceCode.getText();const hasUIElements=fileContent.includes("<button")||fileContent.includes("<form")||fileContent.includes("<input")||fileContent.includes("onClick")&&fileContent.includes("<");if(hasUIElements){context.report({node:context.sourceCode.ast,messageId:"missingFrameBusting",data:{filePath:filename,line:"1"}})}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClientSideAuthLogic=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noClientSideAuthLogic=(0,eslint_devkit_1.createRule)({name:"no-client-side-auth-logic",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-client-side-auth-logic.md",description:"Prevent authentication logic in client code",cwe:"CWE-602",cvss:6.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Client-Side Auth Logic",cwe:"CWE-602",description:"Authentication logic in client code - easily bypassed",severity:"CRITICAL",fix:"Move authentication checks to the server",documentationLink:"https://cwe.mitre.org/data/definitions/602.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}const authKeywords=["admin","authenticated","authorized","isAdmin","isAuthenticated","role"];return{IfStatement(node){if(node.test.type==="CallExpression"&&node.test.callee.type==="MemberExpression"&&node.test.callee.object.type==="Identifier"&&node.test.callee.object.name==="localStorage"&&node.test.callee.property.type==="Identifier"&&node.test.callee.property.name==="getItem"){const keyArg=node.test.arguments[0];if(keyArg&&keyArg.type==="Literal"){const key=String(keyArg.value).toLowerCase();if(authKeywords.some(kw=>key.includes(kw))){report(node)}}}if(node.test.type==="BinaryExpression"){const checkMember=expr=>{if(expr.type==="MemberExpression"&&expr.property.type==="Identifier"&&["password","secret","token"].includes(expr.property.name)){return true}return false};if(checkMember(node.test.left)||checkMember(node.test.right)){report(node)}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noClientSideAuthLogic=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");function isFlagComparand(node){if(node.type==="Literal"){return typeof node.value==="boolean"||node.value===null}return node.type==="Identifier"&&node.name==="undefined"}exports.noClientSideAuthLogic=(0,eslint_devkit_1.createRule)({name:"no-client-side-auth-logic",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-client-side-auth-logic.md",description:"Prevent authentication logic in client code",cwe:"CWE-602",cvss:6.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Client-Side Auth Logic",cwe:"CWE-602",description:"Authentication logic in client code - easily bypassed",severity:"CRITICAL",fix:"Move authentication checks to the server",documentationLink:"https://cwe.mitre.org/data/definitions/602.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}const authKeywords=["admin","authenticated","authorized","isAdmin","isAuthenticated","role"];return{IfStatement(node){if(node.test.type==="CallExpression"&&node.test.callee.type==="MemberExpression"&&node.test.callee.object.type==="Identifier"&&node.test.callee.object.name==="localStorage"&&node.test.callee.property.type==="Identifier"&&node.test.callee.property.name==="getItem"){const keyArg=node.test.arguments[0];if(keyArg&&keyArg.type==="Literal"){const key=String(keyArg.value).toLowerCase();if(authKeywords.some(kw=>key.includes(kw))){report(node)}}}if(node.test.type==="BinaryExpression"){const checkMember=expr=>{if(expr.type==="MemberExpression"&&expr.property.type==="Identifier"&&["password","secret","token"].includes(expr.property.name)){return true}return false};const left=node.test.left;const right=node.test.right;const leftIsCredential=checkMember(left);if(leftIsCredential||checkMember(right)){const comparand=leftIsCredential?right:left;if(!isFlagComparand(comparand)){report(node)}}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noCredentialsInQueryParams=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noCredentialsInQueryParams=(0,eslint_devkit_1.createRule)({name:"no-credentials-in-query-params",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-credentials-in-query-params.md",description:"Disallow credentials in URL query parameters",cwe:"CWE-798",cvss:9.8},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Credentials in Query Parameters",cwe:"CWE-798",description:"Credentials detected in URL query parameters - this is a security risk",severity:"CRITICAL",fix:"Use secure methods: POST body, headers (Authorization), or secure cookies",documentationLink:"https://cwe.mitre.org/data/definitions/798.html"})},schema:[]},defaultOptions:[],create(context){const sourceCode=context.sourceCode;const sensitiveParams=["password=","token=","apikey=","secret=","auth="];function report(node){context.report({node,messageId:"violationDetected"})}return{Literal(node){if(typeof node.value==="string"){const url=node.value.toLowerCase();if(sensitiveParams.some(param=>url.includes("?"+param)||url.includes("&"+param))){report(node)}}},TemplateLiteral(node){const text=sourceCode.getText(node).toLowerCase();if(sensitiveParams.some(param=>text.includes(param))){report(node)}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noCredentialsInQueryParams=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noCredentialsInQueryParams=(0,eslint_devkit_1.createRule)({name:"no-credentials-in-query-params",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-credentials-in-query-params.md",description:"Disallow credentials in URL query parameters",cwe:"CWE-798",cvss:9.8},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Credentials in Query Parameters",cwe:"CWE-798",description:"Credentials detected in URL query parameters - this is a security risk",severity:"CRITICAL",fix:"Use secure methods: POST body, headers (Authorization), or secure cookies",documentationLink:"https://cwe.mitre.org/data/definitions/798.html"})},schema:[]},defaultOptions:[],create(context){const sensitiveParams=["password=","token=","apikey=","secret=","auth="];const OUT_OF_BAND_FLOWS=/\/(reset|reset-password|forgot|verify|verify-email|confirm|activate|unsubscribe|magic-?link)\b/;function hasReportableCredential(url){const present=sensitiveParams.filter(param=>url.includes("?"+param)||url.includes("&"+param));return present.some(param=>!(param==="token="&&OUT_OF_BAND_FLOWS.test(url)))}function report(node){context.report({node,messageId:"violationDetected"})}return{Literal(node){if(typeof node.value==="string"){const url=node.value.toLowerCase();if(hasReportableCredential(url)){report(node)}}},TemplateLiteral(node){const INTERPOLATION="";const text=node.quasis.map(q=>q.value.raw).join(INTERPOLATION).toLowerCase();if(hasReportableCredential(text)){report(node)}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noDisabledCertificateValidation=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noDisabledCertificateValidation=(0,eslint_devkit_1.createRule)({name:"no-disabled-certificate-validation",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-disabled-certificate-validation.md",description:"Prevent disabled SSL/TLS certificate validation",cwe:"CWE-295",cvss:9.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Disabled Certificate Validation",cwe:"CWE-295",description:"SSL/TLS certificate validation is disabled - man-in-the-middle attack possible",severity:"CRITICAL",fix:"Remove rejectUnauthorized: false or verify: false, fix certificate issues properly",documentationLink:"https://cwe.mitre.org/data/definitions/295.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}const dangerousProperties=new Set(["rejectUnauthorized","strictSSL","verify"]);return{Property(node){if(node.key.type==="Identifier"&&dangerousProperties.has(node.key.name)&&node.value.type==="Literal"&&node.value.value===false){report(node)}},AssignmentExpression(node){if(node.left.type==="MemberExpression"&&node.left.object.type==="MemberExpression"&&node.left.object.object.type==="Identifier"&&node.left.object.object.name==="process"&&node.left.object.property.type==="Identifier"&&node.left.object.property.name==="env"&&node.left.property.type==="Identifier"&&node.left.property.name==="NODE_TLS_REJECT_UNAUTHORIZED"){if(node.right.type==="Literal"&&node.right.value==="0"){report(node)}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noDisabledCertificateValidation=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const NON_ERROR_UNARY="void";function isDefinitelyNotError(node){if(node.type==="Literal")return true;if(node.type==="Identifier")return node.name==="undefined";if(node.type==="UnaryExpression")return node.operator===NON_ERROR_UNARY;return false}exports.noDisabledCertificateValidation=(0,eslint_devkit_1.createRule)({name:"no-disabled-certificate-validation",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-disabled-certificate-validation.md",description:"Prevent disabled SSL/TLS certificate validation",cwe:"CWE-295",cvss:9.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Disabled Certificate Validation",cwe:"CWE-295",description:"SSL/TLS certificate validation is disabled - man-in-the-middle attack possible",severity:"CRITICAL",fix:"Remove rejectUnauthorized: false or verify: false, fix certificate issues properly",documentationLink:"https://cwe.mitre.org/data/definitions/295.html"}),noopHostnameVerification:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Hostname verification stubbed out",cwe:"CWE-295",description:"checkServerIdentity can never return an Error, so a certificate validly issued for ANY domain is accepted for this host \u2014 the exact MITM that hostname verification prevents.",severity:"CRITICAL",fix:"Delete the override, or delegate: const err = tls.checkServerIdentity(host, cert); if (err) return err;",documentationLink:"https://cwe.mitre.org/data/definitions/295.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}const dangerousProperties=new Set(["rejectUnauthorized","strictSSL","verify"]);const identityChecks=[];return{Property(node){if(node.key.type==="Identifier"&&dangerousProperties.has(node.key.name)&&node.value.type==="Literal"&&node.value.value===false){report(node)}if(node.key.type!=="Identifier"||node.key.name!=="checkServerIdentity"){return}const implementation=node.value;if(implementation.type!=="FunctionExpression"&&implementation.type!=="ArrowFunctionExpression"){return}if(implementation.type==="ArrowFunctionExpression"&&implementation.body.type!=="BlockStatement"){if(isDefinitelyNotError(implementation.body)){context.report({node,messageId:"noopHostnameVerification"})}return}identityChecks.push({property:node,canReportMismatch:false})},"Property:exit"(node){const open=identityChecks[identityChecks.length-1];if(open===void 0||open.property!==node)return;identityChecks.pop();if(!open.canReportMismatch){context.report({node,messageId:"noopHostnameVerification"})}},ReturnStatement(node){const open=identityChecks[identityChecks.length-1];if(open===void 0)return;if(node.argument!==null&&!isDefinitelyNotError(node.argument)){open.canReportMismatch=true}},ThrowStatement(){const open=identityChecks[identityChecks.length-1];if(open!==void 0){open.canReportMismatch=true}},AssignmentExpression(node){if(node.left.type==="MemberExpression"&&node.left.object.type==="MemberExpression"&&node.left.object.object.type==="Identifier"&&node.left.object.object.name==="process"&&node.left.object.property.type==="Identifier"&&node.left.object.property.name==="env"&&node.left.property.type==="Identifier"&&node.left.property.name==="NODE_TLS_REJECT_UNAUTHORIZED"){if(node.right.type==="Literal"&&node.right.value==="0"){report(node)}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DANGEROUS_FUNCTIONS=new Set(["eval","execScript"]);const DANGEROUS_METHODS_WITH_STRING_ARG=new Set(["setTimeout","setInterval","setImmediate"]);exports.noEval=(0,eslint_devkit_2.createRule)({name:"no-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-eval.md",description:"Disallow eval(), Function(), and other code execution patterns",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{dangerousEval:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Code Injection via {{function}}",cwe:"CWE-95",description:"Using {{function}} with dynamic input can execute arbitrary code. This is a critical security vulnerability.",severity:"CRITICAL",fix:"Use safe alternatives like JSON.parse() for data, or refactor to avoid dynamic code execution.",documentationLink:"https://owasp.org/www-community/attacks/Code_Injection"}),useSafeAlternative:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use Safe Alternative",description:"Replace with a safe alternative",severity:"LOW",fix:"Use JSON.parse() for JSON, or define functions statically.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},allowFunctionConstructor:{type:"boolean",default:false,description:"Allow `new Function(...)` while still reporting `eval()`"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,allowFunctionConstructor:false}],create(context,[options={}]){const{allowInTests=false,allowFunctionConstructor=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{CallExpression(node){const callee=node.callee;if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(callee.type==="Identifier"){if(DANGEROUS_FUNCTIONS.has(callee.name)){context.report({node,messageId:"dangerousEval",data:{function:callee.name},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]});return}if(DANGEROUS_METHODS_WITH_STRING_ARG.has(callee.name)){const firstArg=node.arguments[0];if(firstArg&&firstArg.type==="Literal"&&typeof firstArg.value==="string"){context.report({node,messageId:"dangerousEval",data:{function:`${callee.name} with string`},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}if(callee.type==="MemberExpression"){let propertyName=null;if(!callee.computed&&callee.property.type==="Identifier"&&DANGEROUS_FUNCTIONS.has(callee.property.name)){propertyName=callee.property.name}else if(callee.computed&&callee.property.type==="Literal"&&typeof callee.property.value==="string"&&DANGEROUS_FUNCTIONS.has(callee.property.value)){propertyName=callee.property.value}if(propertyName){context.report({node,messageId:"dangerousEval",data:{function:propertyName},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}},NewExpression(node){if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(allowFunctionConstructor){return}const callee=node.callee;if(callee.type==="Identifier"&&callee.name==="Function"){context.report({node,messageId:"dangerousEval",data:{function:"Function constructor"},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noEval=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DANGEROUS_FUNCTIONS=new Set(["eval","execScript"]);const DANGEROUS_METHODS_WITH_STRING_ARG=new Set(["setTimeout","setInterval","setImmediate"]);function hasStaticPayload(node){return node.arguments.every(arg=>arg.type==="Literal"&&typeof arg.value==="string")}exports.noEval=(0,eslint_devkit_2.createRule)({name:"no-eval",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-eval.md",description:"Disallow eval(), Function(), and other code execution patterns",cwe:"CWE-95",cvss:9.8},hasSuggestions:true,messages:{dangerousEval:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Code Injection via {{function}}",cwe:"CWE-95",description:"Using {{function}} with dynamic input can execute arbitrary code. This is a critical security vulnerability.",severity:"CRITICAL",fix:"Use safe alternatives like JSON.parse() for data, or refactor to avoid dynamic code execution.",documentationLink:"https://owasp.org/www-community/attacks/Code_Injection"}),useSafeAlternative:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use Safe Alternative",description:"Replace with a safe alternative",severity:"LOW",fix:"Use JSON.parse() for JSON, or define functions statically.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval!"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},allowFunctionConstructor:{type:"boolean",default:false,description:"Allow `new Function(...)` while still reporting `eval()`"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,allowFunctionConstructor:false}],create(context,[options={}]){const{allowInTests=false,allowFunctionConstructor=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);function ownsPayload(node){if(node.arguments.some(arg=>payloadSource(arg)!==void 0)){return true}return hasStaticPayload(node)}return{CallExpression(node){const callee=node.callee;if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(callee.type==="Identifier"){if(DANGEROUS_FUNCTIONS.has(callee.name)){if(callee.name==="eval"&&!ownsPayload(node)){return}context.report({node,messageId:"dangerousEval",data:{function:callee.name},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]});return}if(DANGEROUS_METHODS_WITH_STRING_ARG.has(callee.name)){const firstArg=node.arguments[0];if(firstArg&&firstArg.type==="Literal"&&typeof firstArg.value==="string"){context.report({node,messageId:"dangerousEval",data:{function:`${callee.name} with string`},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}if(callee.type==="MemberExpression"){let propertyName=null;if(!callee.computed&&callee.property.type==="Identifier"&&DANGEROUS_FUNCTIONS.has(callee.property.name)){propertyName=callee.property.name}else if(callee.computed&&callee.property.type==="Literal"&&typeof callee.property.value==="string"&&DANGEROUS_FUNCTIONS.has(callee.property.value)){propertyName=callee.property.value}if(propertyName){context.report({node,messageId:"dangerousEval",data:{function:propertyName},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}},NewExpression(node){if(node.arguments.some(arg=>payloadSource(arg)==="websocket"))return;if(allowFunctionConstructor){return}if(!ownsPayload(node)){return}const callee=node.callee;if(callee.type==="Identifier"&&callee.name==="Function"){context.report({node,messageId:"dangerousEval",data:{function:"Function constructor"},suggest:[{messageId:"useSafeAlternative",fix:()=>null}]})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHttpUrls=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noHttpUrls=(0,eslint_devkit_1.createRule)({name:"no-http-urls",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-http-urls.md",description:"Disallow hardcoded HTTP URLs (require HTTPS)",cwe:"CWE-319",cvss:7.5},messages:{insecureHttp:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Insecure HTTP URL",cwe:"CWE-319",owasp:"A02:2021",cvss:7.5,description:'Hardcoded HTTP URL detected: "{{url}}"',severity:"HIGH",compliance:["SOC2","PCI-DSS","HIPAA"],fix:'Use HTTPS instead: const url = "https://..."',documentationLink:"https://cwe.mitre.org/data/definitions/319.html"}),insecureHttpWithException:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Insecure HTTP URL",cwe:"CWE-319",owasp:"A02:2021",cvss:5.3,description:'HTTP URL detected: "{{url}}"',severity:"MEDIUM",fix:"Use HTTPS or add to allowedHosts config",documentationLink:"https://cwe.mitre.org/data/definitions/319.html"})},schema:[{type:"object",properties:{allowedHosts:{type:"array",items:{type:"string"},description:"List of hostnames allowed to use HTTP (e.g., localhost, 127.0.0.1)"},allowedPorts:{type:"array",items:{type:"number"},description:"List of ports allowed for HTTP (e.g., 3000, 8080 for development)"}},additionalProperties:false}]},defaultOptions:[{allowedHosts:["localhost","127.0.0.1"],allowedPorts:[]}],create(context){const[options={}]=context.options;const allowedHosts=options.allowedHosts??["localhost","127.0.0.1"];const allowedPorts=options.allowedPorts??[];function isAllowedException(url){try{const parsedUrl=new URL(url);if(allowedHosts.includes(parsedUrl.hostname)){return true}if(parsedUrl.port&&allowedPorts.includes(parseInt(parsedUrl.port,10))){return true}return false}catch{return allowedHosts.some(host=>url.includes(host))}}function checkStringValue(node,value){const httpPattern=/^http:\/\//i;if(httpPattern.test(value)&&!isAllowedException(value)){context.report({node,messageId:allowedHosts.length>0||allowedPorts.length>0?"insecureHttpWithException":"insecureHttp",data:{url:value}})}}return{Literal(node){if(typeof node.value==="string"){checkStringValue(node,node.value)}},TemplateElement(node){if(node.value.cooked){checkStringValue(node,node.value.cooked)}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noHttpUrls=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const namespace_uris_1=require("../../utils/namespace-uris");exports.noHttpUrls=(0,eslint_devkit_1.createRule)({name:"no-http-urls",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-http-urls.md",description:"Disallow hardcoded HTTP URLs (require HTTPS)",cwe:"CWE-319",cvss:7.5},messages:{insecureHttp:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Insecure HTTP URL",cwe:"CWE-319",owasp:"A02:2021",cvss:7.5,description:'Hardcoded HTTP URL detected: "{{url}}"',severity:"HIGH",compliance:["SOC2","PCI-DSS","HIPAA"],fix:'Use HTTPS instead: const url = "https://..."',documentationLink:"https://cwe.mitre.org/data/definitions/319.html"}),insecureHttpWithException:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.WARNING,issueName:"Insecure HTTP URL",cwe:"CWE-319",owasp:"A02:2021",cvss:5.3,description:'HTTP URL detected: "{{url}}"',severity:"MEDIUM",fix:"Use HTTPS or add to allowedHosts config",documentationLink:"https://cwe.mitre.org/data/definitions/319.html"})},schema:[{type:"object",properties:{allowedHosts:{type:"array",items:{type:"string"},description:"List of hostnames allowed to use HTTP (e.g., localhost, 127.0.0.1)"},allowedPorts:{type:"array",items:{type:"number"},description:"List of ports allowed for HTTP (e.g., 3000, 8080 for development)"}},additionalProperties:false}]},defaultOptions:[{allowedHosts:["localhost","127.0.0.1"],allowedPorts:[]}],create(context){const[options={}]=context.options;const allowedHosts=options.allowedHosts??["localhost","127.0.0.1"];const allowedPorts=options.allowedPorts??[];function isAllowedException(url){try{const parsedUrl=new URL(url);if(allowedHosts.includes(parsedUrl.hostname)){return true}if(parsedUrl.port&&allowedPorts.includes(parseInt(parsedUrl.port,10))){return true}return false}catch{return allowedHosts.some(host=>url.includes(host))}}function declarationName(node){const parent=node.parent;if(parent.type==="JSXAttribute"){const name=parent.name;return name.type==="JSXIdentifier"?name.name:`${name.namespace.name}:${name.name.name}`}if(parent.type==="Property"&&parent.value===node&&!parent.computed){if(parent.key.type==="Identifier")return parent.key.name;if(parent.key.type==="Literal"&&typeof parent.key.value==="string"){return parent.key.value}}return void 0}function hasInterpolatedAuthority(node,cooked){const rest=/^http:\/\/(.*)$/is.exec(cooked)?.[1];if(rest===void 0)return false;const authority=rest.split(/[/?#]/)[0];if(authority!=="")return false;return!node.tail}function checkStringValue(node,value){const httpPattern=/^http:\/\//i;if((0,namespace_uris_1.isXmlNamespaceUri)(value,declarationName(node))){return}if((0,namespace_uris_1.isTrustworthyLocalUrl)(value)){return}if((0,namespace_uris_1.isDiscardedUrlBase)(node)){return}if(httpPattern.test(value)&&!isAllowedException(value)){context.report({node,messageId:allowedHosts.length>0||allowedPorts.length>0?"insecureHttpWithException":"insecureHttp",data:{url:value}})}}return{Literal(node){if(typeof node.value==="string"){checkStringValue(node,node.value)}},TemplateElement(node){const cooked=node.value.cooked;if(cooked&&!hasInterpolatedAuthority(node,cooked)){checkStringValue(node,cooked)}}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noIncompleteUrlSanitization=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const url_taint_1=require("../../utils/url-taint");const HOST_TLDS=new Set(["com","net","org","io","dev","co","app","ai","edu","gov","mil","info","biz","me","us","uk","ca","de","fr","jp","cn","au","eu","xyz","cloud","tv","online","site","store","link","tech","local"]);function isHostLikeLiteral(raw){let value=raw.trim().toLowerCase();value=value.replace(/^https?:/,"");value=value.replace(/^\/\//,"");value=value.replace(/^\./,"");const withoutPort=value.replace(/:\d{1,5}$/,"");if(/[/?#@\s:]/.test(withoutPort))return false;const labels=withoutPort.split(".");if(labels.length<2)return false;if(!labels.every(label=>/^[a-z0-9-]+$/.test(label)))return false;return HOST_TLDS.has(labels[labels.length-1])}const PASSTHROUGH_METHODS=new Set(["trim","trimStart","trimEnd","toLowerCase","toUpperCase","toString","normalize","valueOf"]);const URL_ISH_NAME=/url|uri|href|host|origin|domain|referr?er|endpoint|link/i;function receiverName(node){if(node.type==="Identifier"){return node.name}if(node.type==="MemberExpression"){return!node.computed&&node.property.type==="Identifier"?node.property.name:null}if(node.type!=="CallExpression"){return null}const callee=node.callee;if(callee.type==="MemberExpression"&&!callee.computed&&callee.property.type==="Identifier"&&PASSTHROUGH_METHODS.has(callee.property.name)){return receiverName(callee.object)}if(callee.type==="Identifier"&&callee.name==="String"&&node.arguments.length>0){return receiverName(node.arguments[0])}return null}function isUrlBearingReceiver(node,sourceCode){const name=receiverName(node);if(name!==null&&URL_ISH_NAME.test(name))return true;return(0,url_taint_1.isAttackerSteerableUrl)(node,sourceCode)}function literalNumber(node){if(node.type==="Literal"&&typeof node.value==="number"){return node.value}if(node.type==="UnaryExpression"&&node.operator==="-"&&node.argument.type==="Literal"&&typeof node.argument.value==="number"){return-node.argument.value}return null}const FLIPPED={">":"<","<":">",">=":"<=","<=":">="};function isContainmentComparison(call){const parent=call.parent;if(parent.type!=="BinaryExpression")return false;const callIsLeft=parent.left===call;const bound=literalNumber(callIsLeft?parent.right:parent.left);if(bound===null)return false;const operator=callIsLeft?parent.operator:FLIPPED[parent.operator]??parent.operator;if((operator==="!=="||operator==="!=")&&bound===-1)return true;if(operator===">"&&bound===-1)return true;return operator===">="&&bound===0}function isGuardPosition(node){const parent=node.parent;switch(parent.type){case"IfStatement":case"WhileStatement":case"DoWhileStatement":case"LogicalExpression":case"ReturnStatement":case"VariableDeclarator":case"ArrowFunctionExpression":return true;case"ConditionalExpression":case"ForStatement":return parent.test===node;case"UnaryExpression":return parent.operator==="!";default:return false}}const SCRIPTABLE_SCHEMES=["javascript:","data:","vbscript:"];function schemeOf(text){const value=text.trim().toLowerCase();return SCRIPTABLE_SCHEMES.find(scheme=>value.startsWith(scheme))??null}function schemeOfPattern(pattern){const value=pattern.toLowerCase().replace(/\\/g,"");return SCRIPTABLE_SCHEMES.find(scheme=>value.includes(scheme))??null}const NEEDLE_METHODS=new Set(["startsWith","endsWith","includes","indexOf","lastIndexOf","search","match"]);function enclosingScopeNode(node){let current=node;while(current.type!=="FunctionDeclaration"&&current.type!=="FunctionExpression"&&current.type!=="ArrowFunctionExpression"&&current.type!=="Program"){current=current.parent}return current}exports.noIncompleteUrlSanitization=(0,eslint_devkit_1.createRule)({name:"no-incomplete-url-sanitization",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-incomplete-url-sanitization.md",description:"Disallow URL substring tests and partial scheme denylists as security decisions",cwe:"CWE-020",cvss:7.5},messages:{substringHostCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"URL substring check used as a host allowlist",cwe:"CWE-020",description:'A substring test cannot decide the host of a URL \u2014 "https://evil.io/?r=trusted.com" and "https://trusted.com.evil.io/" both contain the string.',severity:"HIGH",fix:"Parse the URL and compare the host: const { hostname } = new URL(url); hostname === 'trusted.com' || hostname.endsWith('.trusted.com')",documentationLink:"https://cwe.mitre.org/data/definitions/20.html"}),incompleteSchemeDenylist:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Incomplete URL scheme denylist",cwe:"CWE-020",description:'Only "javascript:" is denied, so "data:text/html;base64,\u2026" still reaches the sink and still executes script.',severity:"HIGH",fix:"Allowlist instead of denylist: ['http:', 'https:'].includes(new URL(raw, location.origin).protocol)",documentationLink:"https://cwe.mitre.org/data/definitions/20.html"})},schema:[]},defaultOptions:[],create(context){const sourceCode=context.sourceCode;const schemeTests=new Map;function collectSchemeTest(at,needle){if(!isGuardPosition(at))return;if(needle.type!=="Literal")return;const scheme=typeof needle.value==="string"?schemeOf(needle.value):"regex"in needle?schemeOfPattern(needle.regex.pattern):null;if(scheme===null)return;const scope=enclosingScopeNode(at);let entry=schemeTests.get(scope);if(entry===void 0){entry={tested:new Set,firstJavascript:null};schemeTests.set(scope,entry)}entry.tested.add(scheme);if(scheme==="javascript:"&&entry.firstJavascript===null){entry.firstJavascript=at}}function checkSubstringHostCheck(node,method,receiver){if(method!=="includes"&&method!=="indexOf"&&method!=="lastIndexOf"){return}const needle=node.arguments[0];if(node.arguments.length!==1||needle.type!=="Literal"||typeof needle.value!=="string"||!isHostLikeLiteral(needle.value)){return}if(method==="includes"){if(!isGuardPosition(node))return;if(!isUrlBearingReceiver(receiver,sourceCode))return;context.report({node,messageId:"substringHostCheck"});return}if(!isContainmentComparison(node))return;const decision=node.parent;if(!isGuardPosition(decision))return;if(!isUrlBearingReceiver(receiver,sourceCode))return;context.report({node:decision,messageId:"substringHostCheck"})}return{CallExpression(node){const callee=node.callee;if(callee.type!=="MemberExpression"||callee.computed||callee.property.type!=="Identifier"){return}const method=callee.property.name;if(node.arguments.length>0){checkSubstringHostCheck(node,method,callee.object)}if(NEEDLE_METHODS.has(method)&&node.arguments.length>0){const at=method==="indexOf"||method==="lastIndexOf"?node.parent:node;collectSchemeTest(at,node.arguments[0])}if(method==="test"&&callee.object.type==="Literal"){collectSchemeTest(node,callee.object)}},BinaryExpression(node){if(node.operator!=="==="&&node.operator!=="!==")return;const literal=node.left.type==="Literal"?node.left:node.right;collectSchemeTest(node,literal)},"Program:exit"(){for(const entry of schemeTests.values()){if(entry.firstJavascript===null)continue;if(entry.tested.has("data:"))continue;context.report({node:entry.firstJavascript,messageId:"incompleteSchemeDenylist"})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const DEFAULT_SANITIZERS=["DOMPurify.sanitize","sanitize","sanitizeHtml","xss","purify"];function isSanitized(node,sourceCode,sanitizers){const text=sourceCode.getText(node);return sanitizers.some(s=>text.includes(s))}function isLiteralString(node){if(node.type==="Literal"&&typeof node.value==="string"){return true}if(node.type==="TemplateLiteral"&&node.expressions.length===0){return true}return false}exports.noInnerhtml=(0,eslint_devkit_2.createRule)({name:"no-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-innerhtml.md",description:"Disallow dangerous innerHTML/outerHTML assignments that can lead to XSS",cwe:"CWE-79",cvss:6.1,confidence:"medium"},hasSuggestions:true,messages:{dangerousInnerHTML:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Cross-Site Scripting (XSS) via innerHTML",cwe:"CWE-79",description:"Assigning to {{property}} with {{source}} can execute malicious scripts. This is a critical XSS vulnerability.",severity:"CRITICAL",fix:"Use textContent for text, or sanitize with DOMPurify.sanitize() before assignment.",documentationLink:"https://owasp.org/www-community/attacks/xss/"}),useSanitizer:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use HTML Sanitizer",description:"Sanitize HTML before assignment",severity:"LOW",fix:"element.innerHTML = DOMPurify.sanitize(userInput);",documentationLink:"https://www.npmjs.com/package/dompurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedSanitizers:{type:"array",items:{type:"string"},default:DEFAULT_SANITIZERS},allowLiteralStrings:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedSanitizers:DEFAULT_SANITIZERS,allowLiteralStrings:true}],create(context,[options={}]){const{allowInTests=false,trustedSanitizers=DEFAULT_SANITIZERS,allowLiteralStrings=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;const dangerousProperties=new Set(["innerHTML","outerHTML"]);const dangerousSinkMethods=new Set(["insertAdjacentHTML","write","writeln"]);function reportSink(reportNode,sinkName,taintedNode){if(payloadSource(taintedNode)!==void 0)return;if(allowLiteralStrings&&isLiteralString(taintedNode))return;if(isSanitized(taintedNode,sourceCode,trustedSanitizers))return;let source="dynamic content";if(taintedNode.type==="Identifier"){source=`variable "${taintedNode.name}"`}else if(taintedNode.type==="TemplateLiteral"){source="template literal with expressions"}else if(taintedNode.type==="CallExpression"){source="function call result"}context.report({node:reportNode,messageId:"dangerousInnerHTML",data:{property:sinkName,source},suggest:[{messageId:"useSanitizer",fix:()=>null}]})}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type!=="MemberExpression"){return}const property=node.left.property;if(property.type!=="Identifier"){return}if(!dangerousProperties.has(property.name)){return}reportSink(node,property.name,node.right)},CallExpression(node){if(node.callee.type!=="MemberExpression")return;const property=node.callee.property;if(property.type!=="Identifier")return;if(!dangerousSinkMethods.has(property.name))return;const tainted=node.arguments[node.arguments.length-1];if(!tainted)return;reportSink(node,property.name,tainted)}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInnerhtml=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const resolve_binding_1=require("../../utils/resolve-binding");const DEFAULT_SANITIZERS=["DOMPurify.sanitize","sanitize","sanitizeHtml","xss","purify"];function isSanitized(node,sourceCode,sanitizers){const text=sourceCode.getText(node);return sanitizers.some(s=>text.includes(s))}function isLiteralString(node){if(node.type==="Literal"&&typeof node.value==="string"){return true}if(node.type==="TemplateLiteral"&&node.expressions.length===0){return true}return false}function isConstantArgumentList(args){return args.length>0&&args.every(arg=>isLiteralString(arg))}function isConstantTemplateInvocation(node,sourceCode){if(node.type!=="CallExpression")return false;if(node.arguments.length>0)return false;const callee=node.callee;if(callee.type==="CallExpression"){return isConstantArgumentList(callee.arguments)}if(callee.type!=="Identifier")return false;const init=(0,resolve_binding_1.resolveInitializer)(callee,sourceCode);if(init===void 0||init.type!=="CallExpression")return false;return isConstantArgumentList(init.arguments)}exports.noInnerhtml=(0,eslint_devkit_2.createRule)({name:"no-innerhtml",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-innerhtml.md",description:"Disallow dangerous innerHTML/outerHTML assignments that can lead to XSS",cwe:"CWE-79",cvss:6.1,confidence:"medium"},hasSuggestions:true,messages:{dangerousInnerHTML:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Cross-Site Scripting (XSS) via {{property}}",cwe:"CWE-79",description:"Assigning to {{property}} with {{source}} can execute malicious scripts. This is a critical XSS vulnerability.",severity:"CRITICAL",fix:"Sanitize with DOMPurify.sanitize() before it reaches {{property}}; where the value is plain text, set textContent instead.",documentationLink:"https://owasp.org/www-community/attacks/xss/"}),useSanitizer:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.INFO,issueName:"Use HTML Sanitizer",description:"Sanitize HTML before assignment",severity:"LOW",fix:"Wrap the value: DOMPurify.sanitize(userInput).",documentationLink:"https://www.npmjs.com/package/dompurify"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedSanitizers:{type:"array",items:{type:"string"},default:DEFAULT_SANITIZERS},allowLiteralStrings:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedSanitizers:DEFAULT_SANITIZERS,allowLiteralStrings:true}],create(context,[options={}]){const{allowInTests=false,trustedSanitizers=DEFAULT_SANITIZERS,allowLiteralStrings=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;const dangerousProperties=new Set(["innerHTML","outerHTML","srcdoc"]);const dangerousSinkMethods=new Set(["insertAdjacentHTML","write","writeln"]);function isDocumentReceiver(object){if(object.type==="Identifier"){return object.name==="document"||/^(?:.*[a-z])?[Dd]oc(?:ument)?$/.test(object.name)}if(object.type==="MemberExpression"&&object.property.type==="Identifier"){return/^(?:content|owner)?[Dd]ocument$/.test(object.property.name)}return false}function reportSink(reportNode,sinkName,taintedNode){if(payloadSource(taintedNode)!==void 0)return;if(allowLiteralStrings&&(isLiteralString(taintedNode)||isConstantTemplateInvocation(taintedNode,sourceCode))){return}if(isSanitized(taintedNode,sourceCode,trustedSanitizers))return;let source="dynamic content";if(taintedNode.type==="Identifier"){source=`variable "${taintedNode.name}"`}else if(taintedNode.type==="TemplateLiteral"){source="template literal with expressions"}else if(taintedNode.type==="CallExpression"){source="function call result"}context.report({node:reportNode,messageId:"dangerousInnerHTML",data:{property:sinkName,source},suggest:[{messageId:"useSanitizer",fix:()=>null}]})}const payloadSource=(0,eslint_devkit_1.createPayloadResolver)(context.sourceCode);return{AssignmentExpression(node){if(node.left.type!=="MemberExpression"){return}const property=node.left.property;if(property.type!=="Identifier"){return}if(!dangerousProperties.has(property.name)){return}reportSink(node,property.name,node.right)},CallExpression(node){if(node.callee.type!=="MemberExpression")return;const property=node.callee.property;if(property.type!=="Identifier")return;if(!dangerousSinkMethods.has(property.name))return;if((property.name==="write"||property.name==="writeln")&&!isDocumentReceiver(node.callee.object)){return}const tainted=node.arguments[node.arguments.length-1];if(!tainted)return;reportSink(node,property.name,tainted)}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInsecureRedirects=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");function resolveVariableInit(ident,sourceCode){const name=ident.name;let current=ident.parent;while(current){const parent=current.parent;if(!parent)break;if(parent.type==="BlockStatement"||parent.type==="Program"){const body=parent.type==="BlockStatement"?parent.body:parent.body;const idx=body.indexOf(current);for(let i=idx-1;i>=0&&i>=idx-10;i--){const stmt=body[i];if(stmt.type==="VariableDeclaration"){for(const decl of stmt.declarations){if(decl.id.type==="Identifier"&&decl.id.name===name&&decl.init){return sourceCode.getText(decl.init)}}}}}current=parent}return null}function isRedirectValidated(node,sourceCode){const callText=sourceCode.getText(node);const userInputPattern=/\b(req\.(query|body|params)|window\.location|document\.location)\b/;let hasUserInput=userInputPattern.test(callText);if(!hasUserInput&&node.arguments.length>0){const arg=node.arguments[0];if(arg.type==="Identifier"){const resolved=resolveVariableInit(arg,sourceCode);if(resolved&&userInputPattern.test(resolved)){hasUserInput=true}}}if(!hasUserInput){return true}const program=sourceCode.ast;const nodeStart=node.loc?.start;const nodeEnd=node.loc?.end;if(!nodeStart||!nodeEnd||!program){return false}const validationPatterns=[/\b(validateUrl|validateRedirect|isValidUrl|isSafeUrl)\s*\(/,/\b(whitelist|allowedDomains|permittedUrls|ALLOWED_\w+)\s*\./,/\b(url\.hostname|url\.host)\s*===/,/\b\w+\.(includes|has)\s*\(/,/\bstartsWith\s*\(\s*['"]/,/\bendsWith\s*\(\s*['"]/,/\bindexOf\s*\(\s*['"]/,/\bmatch\s*\(\s*\//];let current=node;let depth=0;const maxDepth=20;while(current&&depth<maxDepth){const parent=current.parent;if(!parent)break;if(parent.type==="BlockStatement"||parent.type==="Program"){const body=parent.body;const currentIndex=body.indexOf(current);for(let i=currentIndex-1;i>=0&&i>=currentIndex-5;i--){const stmt=body[i];const stmtText=sourceCode.getText(stmt);if(validationPatterns.some(pattern=>pattern.test(stmtText))){return true}}}if(parent.type==="IfStatement"&&parent.test){const testText=sourceCode.getText(parent.test);if(validationPatterns.some(pattern=>pattern.test(testText))){return true}}current=parent;depth++}return false}exports.noInsecureRedirects=(0,eslint_devkit_2.createRule)({name:"no-insecure-redirects",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-insecure-redirects.md",description:"Detects open redirect vulnerabilities",cwe:"CWE-601",cvss:7.5},hasSuggestions:true,messages:{insecureRedirect:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Open redirect",cwe:"CWE-601",description:"Unvalidated redirect detected - user-controlled URL",severity:"HIGH",fix:"Whitelist allowed domains or validate redirect target",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),whitelistDomains:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Whitelist Domains",description:"Whitelist allowed redirect domains",severity:"LOW",fix:"if (allowedDomains.includes(url.hostname)) redirect(url)",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),validateRedirect:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Validate Redirect",description:"Validate redirect URL before use",severity:"LOW",fix:"validateRedirectUrl(userInput) before redirect",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),useRelativeUrl:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Relative URL",description:"Use relative URLs for internal redirects",severity:"LOW",fix:'redirect("/internal/path") instead of absolute URLs',documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"})},schema:[{type:"object",properties:{ignoreInTests:{type:"boolean",default:true},allowedDomains:{type:"array",items:{type:"string"},default:[],description:"Redirect target domains treated as safe"}},additionalProperties:false}]},defaultOptions:[{ignoreInTests:true,allowedDomains:[]}],create(context,[options={}]){const{ignoreInTests=true}=options||{};const filename=context.filename;const isTestFile=ignoreInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;function checkCallExpression(node){if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"){const methodName=node.callee.property.name;if(["redirect","replace","assign"].includes(methodName)){if(!isRedirectValidated(node,sourceCode)){context.report({node,messageId:"insecureRedirect",suggest:[{messageId:"whitelistDomains",fix:()=>null},{messageId:"validateRedirect",fix:()=>null},{messageId:"useRelativeUrl",fix:()=>null}]})}}}}function checkAssignmentExpression(node){if(node.left.type==="MemberExpression"&&node.left.object.type==="MemberExpression"&&node.left.object.object.type==="Identifier"&&node.left.object.object.name==="window"&&node.left.object.property.type==="Identifier"&&node.left.object.property.name==="location"&&node.left.property.type==="Identifier"&&["href","replace","assign"].includes(node.left.property.name)){const rightText=sourceCode.getText(node.right);const userInputPattern=/\b(req\.(query|body|params)|window\.location|document\.location)\b/;if(userInputPattern.test(rightText)){context.report({node,messageId:"insecureRedirect",suggest:[{messageId:"whitelistDomains",fix:()=>null},{messageId:"validateRedirect",fix:()=>null},{messageId:"useRelativeUrl",fix:()=>null}]})}}}return{CallExpression:checkCallExpression,AssignmentExpression:checkAssignmentExpression}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noInsecureRedirects=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const url_taint_1=require("../../utils/url-taint");const regexp_anchoring_1=require("../../utils/regexp-anchoring");function isNavigationSink(node){const callee=node.callee;if(callee.type!=="MemberExpression"||callee.computed||callee.property.type!=="Identifier"){return false}const method=callee.property.name;if(method==="redirect"){return true}return(method==="assign"||method==="replace")&&(0,url_taint_1.isLocationObject)(callee.object)}function isRedirectValidated(node,sourceCode){const target=node.arguments[0];const hasUserInput=target!==void 0&&(0,url_taint_1.isAttackerSteerableUrl)(target,sourceCode);if(!hasUserInput){return true}if(target.type==="ConditionalExpression"&&(0,regexp_anchoring_1.isAnchoredHostGuard)(target.test,sourceCode)){return true}const program=sourceCode.ast;const nodeStart=node.loc?.start;const nodeEnd=node.loc?.end;if(!nodeStart||!nodeEnd||!program){return false}const validationPatterns=[/\b(validateUrl|validateRedirect|isValidUrl|isSafeUrl)\s*\(/,/\b(whitelist|allowedDomains|permittedUrls|ALLOWED_\w+)\s*\./,/\b(url\.hostname|url\.host)\s*===/,/\b\w+\.(includes|has)\s*\(/,/\bstartsWith\s*\(\s*['"]/,/\bendsWith\s*\(\s*['"]/,/\bindexOf\s*\(\s*['"]/,/\bmatch\s*\(\s*\//];let current=node;let depth=0;const maxDepth=20;while(current&&depth<maxDepth){const parent=current.parent;if(!parent)break;if(parent.type==="BlockStatement"||parent.type==="Program"){const body=parent.body;const currentIndex=body.indexOf(current);for(let i=currentIndex-1;i>=0&&i>=currentIndex-5;i--){const stmt=body[i];const stmtText=sourceCode.getText(stmt);if(validationPatterns.some(pattern=>pattern.test(stmtText))){return true}}}if(parent.type==="IfStatement"&&parent.test){if((0,regexp_anchoring_1.isAnchoredHostGuard)(parent.test,sourceCode)){return true}const testText=sourceCode.getText(parent.test);if(validationPatterns.some(pattern=>pattern.test(testText))){return true}}current=parent;depth++}return false}exports.noInsecureRedirects=(0,eslint_devkit_2.createRule)({name:"no-insecure-redirects",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-insecure-redirects.md",description:"Detects open redirect vulnerabilities",cwe:"CWE-601",cvss:7.5},hasSuggestions:true,messages:{insecureRedirect:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Open redirect",cwe:"CWE-601",description:"Unvalidated redirect detected - user-controlled URL",severity:"HIGH",fix:"Whitelist allowed domains or validate redirect target",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),whitelistDomains:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Whitelist Domains",description:"Whitelist allowed redirect domains",severity:"LOW",fix:"if (allowedDomains.includes(url.hostname)) redirect(url)",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),validateRedirect:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Validate Redirect",description:"Validate redirect URL before use",severity:"LOW",fix:"validateRedirectUrl(userInput) before redirect",documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"}),useRelativeUrl:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Relative URL",description:"Use relative URLs for internal redirects",severity:"LOW",fix:'redirect("/internal/path") instead of absolute URLs',documentationLink:"https://owasp.org/www-community/vulnerabilities/Unvalidated_Redirects_and_Forwards"})},schema:[{type:"object",properties:{ignoreInTests:{type:"boolean",default:true},allowedDomains:{type:"array",items:{type:"string"},default:[],description:"Redirect target domains treated as safe"}},additionalProperties:false}]},defaultOptions:[{ignoreInTests:true,allowedDomains:[]}],create(context,[options={}]){const{ignoreInTests=true}=options||{};const filename=context.filename;const isTestFile=ignoreInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;function checkCallExpression(node){if(!isNavigationSink(node)){return}if(!isRedirectValidated(node,sourceCode)){context.report({node,messageId:"insecureRedirect",suggest:[{messageId:"whitelistDomains",fix:()=>null},{messageId:"validateRedirect",fix:()=>null},{messageId:"useRelativeUrl",fix:()=>null}]})}}function checkAssignmentExpression(node){if(node.left.type==="MemberExpression"&&node.left.object.type==="MemberExpression"&&node.left.object.object.type==="Identifier"&&node.left.object.object.name==="window"&&node.left.object.property.type==="Identifier"&&node.left.object.property.name==="location"&&node.left.property.type==="Identifier"&&["href","replace","assign"].includes(node.left.property.name)){if((0,url_taint_1.isAttackerSteerableUrl)(node.right,sourceCode)){context.report({node,messageId:"insecureRedirect",suggest:[{messageId:"whitelistDomains",fix:()=>null},{messageId:"validateRedirect",fix:()=>null},{messageId:"useRelativeUrl",fix:()=>null}]})}}}return{CallExpression:checkCallExpression,AssignmentExpression:checkAssignmentExpression}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSensitiveLocalstorage=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const DEFAULT_SENSITIVE_PATTERNS=["token","jwt","access_token","accessToken","refresh_token","refreshToken","id_token","idToken","auth","password","passwd","secret","api_key","apiKey","private_key","privateKey","session","sessionId","credential","bearer"];function isSensitiveKey(key,patterns){const lowerKey=key.toLowerCase();return patterns.some(pattern=>lowerKey.includes(pattern.toLowerCase()))}exports.noSensitiveLocalstorage=(0,eslint_devkit_1.createRule)({name:"no-sensitive-localstorage",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-sensitive-localstorage.md",description:"Disallow storing sensitive data like tokens and passwords in localStorage",cwe:"CWE-922",cvss:7.5},hasSuggestions:true,messages:{sensitiveLocalStorage:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Sensitive Data in localStorage",cwe:"CWE-922",description:'Storing "{{key}}" in {{storage}} is dangerous. localStorage is vulnerable to XSS attacks - any script on the page can access it.',severity:"HIGH",fix:"Use httpOnly cookies for tokens, or encrypt data before storage.",documentationLink:"https://owasp.org/www-community/vulnerabilities/Insecure_Storage"}),useHttpOnlyCookie:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use HttpOnly Cookie",description:"Store authentication tokens in httpOnly cookies instead",severity:"LOW",fix:"Set tokens via Set-Cookie header with httpOnly and secure flags.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#security"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},sensitivePatterns:{type:"array",items:{type:"string"},default:DEFAULT_SENSITIVE_PATTERNS},checkSessionStorage:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,sensitivePatterns:DEFAULT_SENSITIVE_PATTERNS,checkSessionStorage:true}],create(context,[options={}]){const{allowInTests=false,sensitivePatterns=DEFAULT_SENSITIVE_PATTERNS,checkSessionStorage=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const storageObjects=["localStorage"];if(checkSessionStorage){storageObjects.push("sessionStorage")}return{CallExpression(node){const callee=node.callee;if(callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&storageObjects.includes(callee.object.name)&&callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&callee.property.name==="setItem"){const keyArg=node.arguments[0];if(!keyArg){return}let keyValue=null;if(keyArg.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof keyArg.value==="string"){keyValue=keyArg.value}else if(keyArg.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){keyValue=keyArg.name}if(keyValue&&isSensitiveKey(keyValue,sensitivePatterns)){context.report({node,messageId:"sensitiveLocalStorage",data:{key:keyValue,storage:callee.object.name},suggest:[{messageId:"useHttpOnlyCookie",fix:()=>null}]})}}},AssignmentExpression(node){if(node.left.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression){return}const obj=node.left.object;if(obj.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||!storageObjects.includes(obj.name)){return}let keyValue=null;if(node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof node.left.property.value==="string"){keyValue=node.left.property.value}else if(node.left.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier){keyValue=node.left.property.name}if(keyValue&&isSensitiveKey(keyValue,sensitivePatterns)){context.report({node,messageId:"sensitiveLocalStorage",data:{key:keyValue,storage:obj.name},suggest:[{messageId:"useHttpOnlyCookie",fix:()=>null}]})}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noSensitiveLocalstorage=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const resolve_binding_1=require("../../utils/resolve-binding");const DEFAULT_SENSITIVE_PATTERNS=["token","jwt","access_token","accessToken","refresh_token","refreshToken","id_token","idToken","auth","password","passwd","secret","api_key","apiKey","private_key","privateKey","session","sessionId","credential","bearer"];function isSensitiveKey(key,patterns){const lowerKey=key.toLowerCase();return patterns.some(pattern=>lowerKey.includes(pattern.toLowerCase()))}exports.noSensitiveLocalstorage=(0,eslint_devkit_1.createRule)({name:"no-sensitive-localstorage",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-sensitive-localstorage.md",description:"Disallow storing sensitive data like tokens and passwords in localStorage",cwe:"CWE-922",cvss:7.5},hasSuggestions:true,messages:{sensitiveLocalStorage:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Sensitive Data in localStorage",cwe:"CWE-922",description:'Storing "{{key}}" in {{storage}} is dangerous. localStorage is vulnerable to XSS attacks - any script on the page can access it.',severity:"HIGH",fix:"Use httpOnly cookies for tokens, or encrypt data before storage.",documentationLink:"https://owasp.org/www-community/vulnerabilities/Insecure_Storage"}),useHttpOnlyCookie:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use HttpOnly Cookie",description:"Store authentication tokens in httpOnly cookies instead",severity:"LOW",fix:"Set tokens via Set-Cookie header with httpOnly and secure flags.",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#security"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},sensitivePatterns:{type:"array",items:{type:"string"},default:DEFAULT_SENSITIVE_PATTERNS},checkSessionStorage:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,sensitivePatterns:DEFAULT_SENSITIVE_PATTERNS,checkSessionStorage:true}],create(context,[options={}]){const{allowInTests=false,sensitivePatterns=DEFAULT_SENSITIVE_PATTERNS,checkSessionStorage=true}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const storageObjects=["localStorage"];if(checkSessionStorage){storageObjects.push("sessionStorage")}return{CallExpression(node){const callee=node.callee;if(callee.type===eslint_devkit_1.AST_NODE_TYPES.MemberExpression&&callee.object.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&storageObjects.includes(callee.object.name)&&callee.property.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&callee.property.name==="setItem"){const keyArg=node.arguments[0];if(!keyArg){return}const keyValue=(0,resolve_binding_1.resolveStringKey)(keyArg,context.sourceCode);if(keyValue&&isSensitiveKey(keyValue,sensitivePatterns)){context.report({node,messageId:"sensitiveLocalStorage",data:{key:keyValue,storage:callee.object.name},suggest:[{messageId:"useHttpOnlyCookie",fix:()=>null}]})}}},AssignmentExpression(node){if(node.left.type!==eslint_devkit_1.AST_NODE_TYPES.MemberExpression){return}const obj=node.left.object;if(obj.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||!storageObjects.includes(obj.name)){return}const keyValue=node.left.computed?(0,resolve_binding_1.resolveStringKey)(node.left.property,context.sourceCode):node.left.property.name;if(keyValue&&isSensitiveKey(keyValue,sensitivePatterns)){context.report({node,messageId:"sensitiveLocalStorage",data:{key:keyValue,storage:obj.name},suggest:[{messageId:"useHttpOnlyCookie",fix:()=>null}]})}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeInlineCsp=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noUnsafeInlineCsp=(0,eslint_devkit_1.createRule)({name:"no-unsafe-inline-csp",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unsafe-inline-csp.md",description:"Disallow 'unsafe-inline' in Content Security Policy",cwe:"CWE-79",cvss:7.5},hasSuggestions:true,messages:{unsafeInline:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"CSP 'unsafe-inline' Detected",cwe:"CWE-79",owasp:"A03:2021",cvss:7.5,description:"'unsafe-inline' in CSP allows inline scripts/styles to execute, defeating XSS protection.",severity:"HIGH",fix:"Use nonces or hashes instead: script-src 'nonce-abc123' or script-src 'sha256-...'",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),useNonceOrHash:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Nonce or Hash",description:"Replace unsafe-inline with nonces or hashes",severity:"LOW",fix:"script-src 'self' 'nonce-randomValue'; (generate nonce per-request)",documentationLink:"https://content-security-policy.com/nonce/"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}const UNSAFE_INLINE_PATTERN=/'unsafe-inline'/gi;function checkForUnsafeInline(node,value){if(UNSAFE_INLINE_PATTERN.test(value)){context.report({node,messageId:"unsafeInline",suggest:[{messageId:"useNonceOrHash",fix:()=>null}]})}}return{Literal(node){if(typeof node.value==="string"){checkForUnsafeInline(node,node.value)}},TemplateLiteral(node){const value=node.quasis.map(q=>q.value.raw).join("");checkForUnsafeInline(node,value)}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnsafeInlineCsp=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noUnsafeInlineCsp=(0,eslint_devkit_1.createRule)({name:"no-unsafe-inline-csp",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unsafe-inline-csp.md",description:"Disallow 'unsafe-inline' in Content Security Policy",cwe:"CWE-79",cvss:7.5},hasSuggestions:true,messages:{unsafeInline:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"CSP 'unsafe-inline' Detected",cwe:"CWE-79",owasp:"A03:2021",cvss:7.5,description:"'unsafe-inline' in CSP allows inline scripts/styles to execute, defeating XSS protection.",severity:"HIGH",fix:"Use nonces or hashes instead: script-src 'nonce-abc123' or script-src 'sha256-...'",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP"}),useNonceOrHash:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Use Nonce or Hash",description:"Replace unsafe-inline with nonces or hashes",severity:"LOW",fix:"script-src 'self' 'nonce-randomValue'; (generate nonce per-request)",documentationLink:"https://content-security-policy.com/nonce/"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:true}},additionalProperties:false}]},defaultOptions:[{allowInTests:true}],create(context,[options={}]){const{allowInTests=true}=options;const filename=context.filename;const isTestFile=/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(allowInTests&&isTestFile){return{}}const UNSAFE_INLINE_PATTERN=/'unsafe-inline'/i;const CSP_DIRECTIVES=/\b(?:default|script|style|img|connect|font|frame|media|object|worker|child|manifest|prefetch|base|form)-(?:src|uri|action)(?:-elem|-attr)?\b/i;const isCspName=name=>/^content-security-policy(-report-only)?$/i.test(name)||/^contentsecuritypolicy(reportonly)?$/i.test(name)||name.toLowerCase()==="csp";function atCspSink(node){const parent=node.parent;if(parent.type===eslint_devkit_1.AST_NODE_TYPES.CallExpression&&parent.arguments[1]===node){const first=parent.arguments[0];return first.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof first.value==="string"&&isCspName(first.value)}if(parent.type===eslint_devkit_1.AST_NODE_TYPES.Property&&parent.value===node&&!parent.computed){if(parent.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier)return isCspName(parent.key.name);if(parent.key.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof parent.key.value==="string"){return isCspName(parent.key.value)}return false}if(parent.type===eslint_devkit_1.AST_NODE_TYPES.JSXExpressionContainer||parent.type===eslint_devkit_1.AST_NODE_TYPES.JSXAttribute){const attribute=parent.type===eslint_devkit_1.AST_NODE_TYPES.JSXAttribute?parent:parent.parent;if(attribute?.type!==eslint_devkit_1.AST_NODE_TYPES.JSXAttribute||attribute.name.type!==eslint_devkit_1.AST_NODE_TYPES.JSXIdentifier||attribute.name.name!=="content"){return false}const element=attribute.parent;return element.attributes.some(other=>other.type===eslint_devkit_1.AST_NODE_TYPES.JSXAttribute&&other.name.type===eslint_devkit_1.AST_NODE_TYPES.JSXIdentifier&&/^http-?equiv$/i.test(other.name.name)&&other.value?.type===eslint_devkit_1.AST_NODE_TYPES.Literal&&typeof other.value.value==="string"&&isCspName(other.value.value))}return false}function checkForUnsafeInline(node,value){if(!UNSAFE_INLINE_PATTERN.test(value))return;if(!CSP_DIRECTIVES.test(value)&&!atCspSink(node))return;context.report({node,messageId:"unsafeInline",suggest:[{messageId:"useNonceOrHash",fix:()=>null}]})}return{Literal(node){if(typeof node.value==="string"){checkForUnsafeInline(node,node.value)}},TemplateLiteral(node){const value=node.quasis.map(q=>q.value.raw).join("");checkForUnsafeInline(node,value)}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnvalidatedDeeplinks=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.noUnvalidatedDeeplinks=(0,eslint_devkit_1.createRule)({name:"no-unvalidated-deeplinks",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unvalidated-deeplinks.md",description:"Require validation of deep link URLs",cwe:"CWE-939",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Unvalidated Deeplink",cwe:"CWE-939",description:"Deep link URL used without validation - potential open redirect",severity:"HIGH",fix:"Validate deep link URLs against a whitelist before navigation",documentationLink:"https://cwe.mitre.org/data/definitions/939.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}return{CallExpression(node){if(node.callee.type==="MemberExpression"&&node.callee.object.type==="Identifier"&&node.callee.object.name==="Linking"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="openURL"){const urlArg=node.arguments[0];if(urlArg&&urlArg.type==="Identifier"){report(node)}if(urlArg&&urlArg.type==="MemberExpression"){report(node)}}if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="navigate"){const urlArg=node.arguments[0];if(urlArg&&urlArg.type==="Identifier"){report(node)}}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noUnvalidatedDeeplinks=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const url_taint_1=require("../../utils/url-taint");exports.noUnvalidatedDeeplinks=(0,eslint_devkit_1.createRule)({name:"no-unvalidated-deeplinks",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/no-unvalidated-deeplinks.md",description:"Require validation of deep link URLs",cwe:"CWE-939",cvss:7.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Unvalidated Deeplink",cwe:"CWE-939",description:"Deep link URL used without validation - potential open redirect",severity:"HIGH",fix:"Validate deep link URLs against a whitelist before navigation",documentationLink:"https://cwe.mitre.org/data/definitions/939.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}return{CallExpression(node){if(node.callee.type==="MemberExpression"&&node.callee.object.type==="Identifier"&&node.callee.object.name==="Linking"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="openURL"){const urlArg=node.arguments[0];if(urlArg&&urlArg.type==="Identifier"){report(node)}if(urlArg&&urlArg.type==="MemberExpression"){report(node)}}if(node.callee.type==="MemberExpression"&&node.callee.property.type==="Identifier"&&node.callee.property.name==="navigate"){const urlArg=node.arguments[0];if(urlArg&&(0,url_taint_1.isAttackerSteerableUrl)(urlArg,context.sourceCode)){report(node)}}}}}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requirePostmessageOriginCheck=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");function hasOriginCheck(node,sourceCode){const text=sourceCode.getText(node);const originPatterns=[/event\.origin\s*[!=]==?\s*/,/e\.origin\s*[!=]==?\s*/,/\.origin\s*[!=]==?\s*/,/origin\s*[!=]==?\s*/,/checkOrigin/i,/validateOrigin/i,/isAllowedOrigin/i,/trustedOrigins/i,/allowedOrigins/i];return originPatterns.some(pattern=>pattern.test(text))}exports.requirePostmessageOriginCheck=(0,eslint_devkit_1.createRule)({name:"require-postmessage-origin-check",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/require-postmessage-origin-check.md",description:"Require origin validation in postMessage event listeners",cwe:"CWE-346",cvss:7.5},hasSuggestions:true,messages:{missingOriginCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing postMessage Origin Validation",cwe:"CWE-346",description:"postMessage listener lacks origin check. Malicious sites can send messages that will be processed.",severity:"HIGH",fix:"Add origin validation: if (event.origin !== 'https://trusted-domain.com') return;",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#security_concerns"}),addOriginCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Add Origin Check",description:"Validate event.origin before processing message",severity:"LOW",fix:"if (event.origin !== 'https://expected-origin.com') return;",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedOrigins:{type:"array",items:{type:"string"},default:[],description:"Origins accepted without an explicit check"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedOrigins:[]}],create(context,[options={}]){const{allowInTests=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;return{CallExpression(node){const callee=node.callee;let isMessageListener=false;if(callee.type==="MemberExpression"&&callee.property.type==="Identifier"&&callee.property.name==="addEventListener"){const eventArg=node.arguments[0];if(eventArg&&eventArg.type==="Literal"&&eventArg.value==="message"){isMessageListener=true}}if(callee.type==="Identifier"&&callee.name==="addEventListener"){const eventArg=node.arguments[0];if(eventArg&&eventArg.type==="Literal"&&eventArg.value==="message"){isMessageListener=true}}if(!isMessageListener){return}const handlerArg=node.arguments[1];if(!handlerArg){return}if(handlerArg.type==="FunctionExpression"||handlerArg.type==="ArrowFunctionExpression"){if(!hasOriginCheck(handlerArg,sourceCode)){context.report({node:handlerArg,messageId:"missingOriginCheck",suggest:[{messageId:"addOriginCheck",fix:()=>null}]})}}if(handlerArg.type==="Identifier"){}}}}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requirePostmessageOriginCheck=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const regexp_anchoring_1=require("../../utils/regexp-anchoring");const NON_WINDOW_RECEIVERS=new Set(["WebSocket","EventSource","Worker","SharedWorker","BroadcastChannel","MessagePort","MessageChannel"]);function receiverKey(node){if(node.type==="Identifier")return node.name;if(node.type==="MemberExpression"&&!node.computed&&node.property.type==="Identifier"){if(node.object.type==="ThisExpression"){return`this.${node.property.name}`}if(node.object.type==="Identifier"){return`${node.object.name}.${node.property.name}`}}return void 0}function annotatedTypeName(annotation){const type=annotation?.typeAnnotation;if(type?.type==="TSTypeReference"&&type.typeName.type==="Identifier"){return type.typeName.name}return void 0}function hasOriginCheck(node,sourceCode){const text=sourceCode.getText(node);const originPatterns=[/event\.origin\s*[!=]==?\s*/,/e\.origin\s*[!=]==?\s*/,/\.origin\s*[!=]==?\s*/,/origin\s*[!=]==?\s*/,/checkOrigin/i,/validateOrigin/i,/isAllowedOrigin/i,/trustedOrigins/i,/allowedOrigins/i];return originPatterns.some(pattern=>pattern.test(text))}exports.requirePostmessageOriginCheck=(0,eslint_devkit_1.createRule)({name:"require-postmessage-origin-check",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-browser-security/docs/rules/require-postmessage-origin-check.md",description:"Require origin validation in postMessage event listeners",cwe:"CWE-346",cvss:7.5},hasSuggestions:true,messages:{missingOriginCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Missing postMessage Origin Validation",cwe:"CWE-346",description:"postMessage listener lacks origin check. Malicious sites can send messages that will be processed.",severity:"HIGH",fix:"Add origin validation: if (event.origin !== 'https://trusted-domain.com') return;",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage#security_concerns"}),addOriginCheck:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.INFO,issueName:"Add Origin Check",description:"Validate event.origin before processing message",severity:"LOW",fix:"if (event.origin !== 'https://expected-origin.com') return;",documentationLink:"https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage"})},schema:[{type:"object",properties:{allowInTests:{type:"boolean",default:false},trustedOrigins:{type:"array",items:{type:"string"},default:[],description:"Origins accepted without an explicit check"}},additionalProperties:false}]},defaultOptions:[{allowInTests:false,trustedOrigins:[]}],create(context,[options={}]){const{allowInTests=false}=options;const filename=context.filename;const isTestFile=allowInTests&&/\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);if(isTestFile){return{}}const sourceCode=context.sourceCode;const unverified=[];const nonWindowReceivers=new Set;function rememberIfNonWindow(key,typeName){if(key===void 0||typeName===void 0)return;if(NON_WINDOW_RECEIVERS.has(typeName))nonWindowReceivers.add(key)}const anchoredOriginTests=[];function isOriginRead(node){return node.type==="MemberExpression"&&!node.computed&&node.property.type==="Identifier"&&node.property.name==="origin"}return{PropertyDefinition(node){if(node.key.type!=="Identifier")return;rememberIfNonWindow(`this.${node.key.name}`,annotatedTypeName(node.typeAnnotation))},VariableDeclarator(node){if(node.id.type!=="Identifier")return;rememberIfNonWindow(node.id.name,annotatedTypeName(node.id.typeAnnotation))},NewExpression(node){if(node.callee.type!=="Identifier")return;const typeName=node.callee.name;const parent=node.parent;if(parent?.type==="VariableDeclarator"&&parent.init===node){rememberIfNonWindow(receiverKey(parent.id),typeName);return}if(parent?.type==="AssignmentExpression"&&parent.right===node){rememberIfNonWindow(receiverKey(parent.left),typeName)}},CallExpression(node){const callee=node.callee;if(node.arguments.length===1&&isOriginRead(node.arguments[0])&&(0,regexp_anchoring_1.isAnchoredRegexpTest)(node,sourceCode)){anchoredOriginTests.push([node.range[0],node.range[1]])}let isMessageListener=false;let receiver;if(callee.type==="MemberExpression"&&callee.property.type==="Identifier"&&callee.property.name==="addEventListener"){const eventArg=node.arguments[0];if(eventArg&&eventArg.type==="Literal"&&eventArg.value==="message"){isMessageListener=true;receiver=receiverKey(callee.object);if(callee.object.type==="NewExpression"&&callee.object.callee.type==="Identifier"&&NON_WINDOW_RECEIVERS.has(callee.object.callee.name)){return}}}if(callee.type==="Identifier"&&callee.name==="addEventListener"){const eventArg=node.arguments[0];if(eventArg&&eventArg.type==="Literal"&&eventArg.value==="message"){isMessageListener=true}}if(!isMessageListener){return}const handlerArg=node.arguments[1];if(!handlerArg){return}if(handlerArg.type==="FunctionExpression"||handlerArg.type==="ArrowFunctionExpression"){if(!hasOriginCheck(handlerArg,sourceCode)){unverified.push({handler:handlerArg,receiver})}}if(handlerArg.type==="Identifier"){}},"Program:exit"(){for(const{handler,receiver}of unverified){if(receiver!==void 0&&nonWindowReceivers.has(receiver)){continue}const guarded=anchoredOriginTests.some(([start,end])=>start>=handler.range[0]&&end<=handler.range[1]);if(guarded)continue;context.report({node:handler,messageId:"missingOriginCheck",suggest:[{messageId:"addOriginCheck",fix:()=>null}]})}}}}});
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isXmlNamespaceUri=isXmlNamespaceUri;exports.isDiscardedUrlBase=isDiscardedUrlBase;exports.isTrustworthyLocalUrl=isTrustworthyLocalUrl;const eslint_devkit_1=require("@interlace/eslint-devkit");const NAMESPACE_AUTHORITY_HOSTS=new Set(["www.w3.org","schemas.xmlsoap.org","schemas.openid.net","schemas.microsoft.com","schemas.android.com","purl.org","ns.adobe.com","sodipodi.sourceforge.net","www.inkscape.org","xml.apache.org","xmlns.com","docbook.org","java.sun.com","www.opengis.net","iptc.org"]);function isNamespaceDeclarationName(name){return name==="xmlns"||name.startsWith("xmlns:")||name.startsWith("xmlnsX")}function isXmlNamespaceUri(value,declaredAs){if(declaredAs!==void 0&&isNamespaceDeclarationName(declaredAs)){return true}let host;try{host=new URL(value).hostname}catch{return false}return NAMESPACE_AUTHORITY_HOSTS.has(host)}const ORIGIN_INDEPENDENT_URL_PARTS=new Set(["pathname","search","searchParams","hash"]);function isDiscardedUrlBase(node){const parent=node.parent;if(parent?.type!==eslint_devkit_1.AST_NODE_TYPES.NewExpression||parent.callee.type!==eslint_devkit_1.AST_NODE_TYPES.Identifier||parent.callee.name!=="URL"||parent.arguments[1]!==node){return false}const declarator=parent.parent;if(declarator?.type!==eslint_devkit_1.AST_NODE_TYPES.VariableDeclarator||declarator.init!==parent||declarator.id.type!==eslint_devkit_1.AST_NODE_TYPES.ObjectPattern){return false}return declarator.id.properties.every(property=>property.type===eslint_devkit_1.AST_NODE_TYPES.Property&&!property.computed&&property.key.type===eslint_devkit_1.AST_NODE_TYPES.Identifier&&ORIGIN_INDEPENDENT_URL_PARTS.has(property.key.name))}const TRUSTWORTHY_LOCAL_HOSTS=new Set(["localhost","127.0.0.1","::1","[::1]","0.0.0.0"]);function isTrustworthyLocalUrl(value){let host;try{host=new URL(value).hostname}catch{return false}return TRUSTWORTHY_LOCAL_HOSTS.has(host)||host.endsWith(".localhost")}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isAnchoredHostPattern=isAnchoredHostPattern;exports.isAnchoredRegexpTest=isAnchoredRegexpTest;exports.isAnchoredHostGuard=isAnchoredHostGuard;const resolve_binding_1=require("./resolve-binding");function isAnchoredHostPattern(pattern){if(!pattern.startsWith("^"))return false;if(!pattern.endsWith("$"))return false;if(pattern.endsWith("\\$"))return false;let escaped=false;let inClass=false;for(const character of pattern){if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(inClass){if(character==="]")inClass=false;continue}if(character==="["){inClass=true;continue}if(character===".")return false}return true}function resolveRegexpPattern(node,sourceCode){if(node.type==="Literal"){return"regex"in node?node.regex.pattern:null}if(node.type!=="Identifier")return null;const init=(0,resolve_binding_1.resolveInitializer)(node,sourceCode);if(init===void 0||init.type!=="Literal")return null;return"regex"in init?init.regex.pattern:null}function isAnchoredRegexpTest(node,sourceCode){if(node.type!=="CallExpression")return false;const callee=node.callee;if(callee.type!=="MemberExpression"||callee.computed||callee.property.type!=="Identifier"||callee.property.name!=="test"){return false}const pattern=resolveRegexpPattern(callee.object,sourceCode);return pattern!==null&&isAnchoredHostPattern(pattern)}function resolveFunctionBody(identifier,sourceCode){for(let scope=sourceCode.getScope(identifier);scope!==null;scope=scope.upper){const variable=scope.variables.find(v=>v.name===identifier.name);if(variable===void 0)continue;if(variable.defs.length!==1)return void 0;if(variable.defs[0].type==="FunctionName"){return variable.defs[0].node.body??void 0}const init=(0,resolve_binding_1.resolveInitializer)(identifier,sourceCode);if(init===void 0)return void 0;return init.type==="FunctionExpression"||init.type==="ArrowFunctionExpression"?init.body:void 0}return void 0}function isAnchoredHostGuard(node,sourceCode){if(isAnchoredRegexpTest(node,sourceCode))return true;if(node.type!=="CallExpression"||node.callee.type!=="Identifier"){return false}const body=resolveFunctionBody(node.callee,sourceCode);if(body===void 0)return false;if(body.type!=="BlockStatement"){return isAnchoredRegexpTest(body,sourceCode)}return body.body.some(statement=>statement.type==="ReturnStatement"&&statement.argument!==null&&isAnchoredRegexpTest(statement.argument,sourceCode))}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveInitializer=resolveInitializer;exports.resolveStringKey=resolveStringKey;function resolveInitializer(identifier,sourceCode){for(let scope=sourceCode.getScope(identifier);scope!==null;scope=scope.upper){const variable=scope.variables.find(v=>v.name===identifier.name);if(variable===void 0)continue;if(variable.defs.length!==1)return void 0;const def=variable.defs[0];if(def.type!=="Variable")return void 0;if(variable.references.filter(ref=>ref.isWrite()).length>1){return void 0}return def.node.init??void 0}return void 0}function resolveStringKey(node,sourceCode){if(node.type==="Literal"&&typeof node.value==="string"){return node.value}if(node.type!=="Identifier"){return null}const init=resolveInitializer(node,sourceCode);if(init!==void 0&&init.type==="Literal"&&typeof init.value==="string"){return init.value}return node.name}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isLocationObject=isLocationObject;exports.isAttackerSteerableUrl=isAttackerSteerableUrl;const resolve_binding_1=require("./resolve-binding");const STEERABLE_LOCATION_PROPS=new Set(["href","search","hash","pathname"]);const LOCATION_HOLDERS=new Set(["window","document","self","top","parent","globalThis"]);const REQUEST_INPUT_PROPS=new Set(["query","body","params"]);function isLocationObject(node){if(node.type==="Identifier"){return node.name==="location"}return node.type==="MemberExpression"&&!node.computed&&node.property.type==="Identifier"&&node.property.name==="location"&&node.object.type==="Identifier"&&LOCATION_HOLDERS.has(node.object.name)}function isRequestInput(node){let current=node;let sawInputProp=false;while(current.type==="MemberExpression"){if(!current.computed&&current.property.type==="Identifier"&&REQUEST_INPUT_PROPS.has(current.property.name)){sawInputProp=true}current=current.object}return sawInputProp&&current.type==="Identifier"&&(current.name==="req"||current.name==="request")}const STEERABILITY_PRESERVING_METHODS=new Set(["slice","substring","substr","trim","trimStart","trimEnd","toString","toLowerCase","toUpperCase","normalize","valueOf"]);const STEERABILITY_PRESERVING_FUNCTIONS=new Set(["decodeURI","decodeURIComponent","unescape","String"]);function isSteerableMember(node){if(node.computed||node.property.type!=="Identifier"){return isRequestInput(node)}const property=node.property.name;if(STEERABLE_LOCATION_PROPS.has(property)&&isLocationObject(node.object)){return true}if((property==="URL"||property==="referrer")&&node.object.type==="Identifier"&&node.object.name==="document"){return true}return isRequestInput(node)}function isAttackerSteerableUrl(node,sourceCode,seen=new Set){switch(node.type){case"MemberExpression":return isSteerableMember(node);case"Identifier":{if(seen.has(node.name))return false;seen.add(node.name);const init=(0,resolve_binding_1.resolveInitializer)(node,sourceCode);return init!==void 0&&isAttackerSteerableUrl(init,sourceCode,seen)}case"BinaryExpression":return node.operator==="+"&&isAttackerSteerableUrl(node.left,sourceCode,seen);case"TemplateLiteral":return node.quasis[0].value.cooked===""&&node.expressions.length>0&&isAttackerSteerableUrl(node.expressions[0],sourceCode,seen);case"CallExpression":{const callee=node.callee;if(callee.type==="MemberExpression"&&!callee.computed&&callee.property.type==="Identifier"&&STEERABILITY_PRESERVING_METHODS.has(callee.property.name)){return isAttackerSteerableUrl(callee.object,sourceCode,seen)}if(callee.type==="Identifier"&&STEERABILITY_PRESERVING_FUNCTIONS.has(callee.name)&&node.arguments.length>0){return isAttackerSteerableUrl(node.arguments[0],sourceCode,seen)}return false}case"ConditionalExpression":return isAttackerSteerableUrl(node.consequent,sourceCode,seen)||isAttackerSteerableUrl(node.alternate,sourceCode,seen);case"LogicalExpression":return isAttackerSteerableUrl(node.left,sourceCode,seen)||isAttackerSteerableUrl(node.right,sourceCode,seen);default:return false}}