eslint-plugin-browser-security 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -11
- package/package.json +4 -3
- package/src/index.js +62 -0
- package/src/rules/detect-mixed-content/index.d.ts +12 -0
- package/src/rules/detect-mixed-content/index.js +45 -0
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +12 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +48 -0
- package/src/rules/no-clickjacking/index.d.ts +36 -0
- package/src/rules/no-clickjacking/index.js +401 -0
- package/src/rules/no-client-side-auth-logic/index.d.ts +12 -0
- package/src/rules/no-client-side-auth-logic/index.js +74 -0
- package/src/rules/no-cookie-auth-tokens/index.d.ts +3 -1
- package/src/rules/no-credentials-in-query-params/index.d.ts +12 -0
- package/src/rules/no-credentials-in-query-params/index.js +62 -0
- package/src/rules/no-disabled-certificate-validation/index.d.ts +12 -0
- package/src/rules/no-disabled-certificate-validation/index.js +66 -0
- package/src/rules/no-dynamic-service-worker-url/index.d.ts +3 -1
- package/src/rules/no-eval/index.d.ts +3 -1
- package/src/rules/no-filereader-innerhtml/index.d.ts +3 -1
- package/src/rules/no-http-urls/index.d.ts +17 -0
- package/src/rules/no-http-urls/index.js +119 -0
- package/src/rules/no-innerhtml/index.d.ts +3 -1
- package/src/rules/no-insecure-redirects/index.d.ts +26 -0
- package/src/rules/no-insecure-redirects/index.js +221 -0
- package/src/rules/no-insecure-websocket/index.d.ts +12 -0
- package/src/rules/no-insecure-websocket/index.js +66 -0
- package/src/rules/no-jwt-in-storage/index.d.ts +3 -1
- package/src/rules/no-missing-cors-check/index.d.ts +28 -0
- package/src/rules/no-missing-cors-check/index.js +404 -0
- package/src/rules/no-missing-csrf-protection/index.d.ts +30 -0
- package/src/rules/no-missing-csrf-protection/index.js +185 -0
- package/src/rules/no-missing-security-headers/index.d.ts +26 -0
- package/src/rules/no-missing-security-headers/index.js +223 -0
- package/src/rules/no-password-in-url/index.d.ts +12 -0
- package/src/rules/no-password-in-url/index.js +55 -0
- package/src/rules/no-permissive-cors/index.d.ts +12 -0
- package/src/rules/no-permissive-cors/index.js +74 -0
- package/src/rules/no-postmessage-innerhtml/index.d.ts +3 -1
- package/src/rules/no-postmessage-wildcard-origin/index.d.ts +3 -1
- package/src/rules/no-sensitive-cookie-js/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-analytics/index.js +66 -0
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +53 -0
- package/src/rules/no-sensitive-indexeddb/index.d.ts +3 -1
- package/src/rules/no-sensitive-localstorage/index.d.ts +3 -1
- package/src/rules/no-sensitive-sessionstorage/index.d.ts +3 -1
- package/src/rules/no-tracking-without-consent/index.d.ts +12 -0
- package/src/rules/no-tracking-without-consent/index.js +72 -0
- package/src/rules/no-unencrypted-transmission/index.d.ts +30 -0
- package/src/rules/no-unencrypted-transmission/index.js +241 -0
- package/src/rules/no-unescaped-url-parameter/index.d.ts +28 -0
- package/src/rules/no-unescaped-url-parameter/index.js +360 -0
- package/src/rules/no-unsafe-eval-csp/index.d.ts +3 -1
- package/src/rules/no-unsafe-inline-csp/index.d.ts +3 -1
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +12 -0
- package/src/rules/no-unvalidated-deeplinks/index.js +67 -0
- package/src/rules/no-websocket-eval/index.d.ts +3 -1
- package/src/rules/no-websocket-innerhtml/index.d.ts +3 -1
- package/src/rules/no-worker-message-innerhtml/index.d.ts +3 -1
- package/src/rules/require-blob-url-revocation/index.d.ts +3 -1
- package/src/rules/require-cookie-secure-attrs/index.d.ts +3 -1
- package/src/rules/require-csp-headers/index.d.ts +12 -0
- package/src/rules/require-csp-headers/index.js +69 -0
- package/src/rules/require-https-only/index.d.ts +12 -0
- package/src/rules/require-https-only/index.js +67 -0
- package/src/rules/require-mime-type-validation/index.d.ts +12 -0
- package/src/rules/require-mime-type-validation/index.js +71 -0
- package/src/rules/require-postmessage-origin-check/index.d.ts +3 -1
- package/src/rules/require-url-validation/index.d.ts +12 -0
- package/src/rules/require-url-validation/index.js +77 -0
- package/src/rules/require-websocket-wss/index.d.ts +3 -1
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -165,17 +165,19 @@ By providing this structured context (CWE, OWASP, Fix), we enable AI tools to **
|
|
|
165
165
|
|
|
166
166
|
Part of the **Interlace ESLint Ecosystem** — AI-native security plugins with LLM-optimized error messages:
|
|
167
167
|
|
|
168
|
-
| Plugin | Downloads | Description
|
|
169
|
-
| :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
170
|
-
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines.
|
|
171
|
-
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices.
|
|
172
|
-
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules.
|
|
173
|
-
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices.
|
|
174
|
-
| [`eslint-plugin-
|
|
175
|
-
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules.
|
|
176
|
-
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices.
|
|
177
|
-
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns.
|
|
178
|
-
| [`eslint-plugin-
|
|
168
|
+
| Plugin | Downloads | Description |
|
|
169
|
+
| :--------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------ |
|
|
170
|
+
| [`eslint-plugin-secure-coding`](https://www.npmjs.com/package/eslint-plugin-secure-coding) | [](https://www.npmjs.com/package/eslint-plugin-secure-coding) | General security rules & OWASP guidelines. |
|
|
171
|
+
| [`eslint-plugin-pg`](https://www.npmjs.com/package/eslint-plugin-pg) | [](https://www.npmjs.com/package/eslint-plugin-pg) | PostgreSQL security & best practices. |
|
|
172
|
+
| [`eslint-plugin-crypto`](https://www.npmjs.com/package/eslint-plugin-crypto) | [](https://www.npmjs.com/package/eslint-plugin-crypto) | NodeJS Cryptography security rules. |
|
|
173
|
+
| [`eslint-plugin-jwt`](https://www.npmjs.com/package/eslint-plugin-jwt) | [](https://www.npmjs.com/package/eslint-plugin-jwt) | JWT security & best practices. |
|
|
174
|
+
| [`eslint-plugin-browser-security`](https://www.npmjs.com/package/eslint-plugin-browser-security) | [](https://www.npmjs.com/package/eslint-plugin-browser-security) | Browser-specific security & XSS prevention. |
|
|
175
|
+
| [`eslint-plugin-express-security`](https://www.npmjs.com/package/eslint-plugin-express-security) | [](https://www.npmjs.com/package/eslint-plugin-express-security) | Express.js security hardening rules. |
|
|
176
|
+
| [`eslint-plugin-lambda-security`](https://www.npmjs.com/package/eslint-plugin-lambda-security) | [](https://www.npmjs.com/package/eslint-plugin-lambda-security) | AWS Lambda security best practices. |
|
|
177
|
+
| [`eslint-plugin-nestjs-security`](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | [](https://www.npmjs.com/package/eslint-plugin-nestjs-security) | NestJS security rules & patterns. |
|
|
178
|
+
| [`eslint-plugin-mongodb-security`](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | [](https://www.npmjs.com/package/eslint-plugin-mongodb-security) | MongoDB security best practices. |
|
|
179
|
+
| [`eslint-plugin-vercel-ai-security`](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | [](https://www.npmjs.com/package/eslint-plugin-vercel-ai-security) | Vercel AI SDK security hardening. |
|
|
180
|
+
| [`eslint-plugin-import-next`](https://www.npmjs.com/package/eslint-plugin-import-next) | [](https://www.npmjs.com/package/eslint-plugin-import-next) | Next-gen import sorting & architecture. |
|
|
179
181
|
|
|
180
182
|
## 📄 License
|
|
181
183
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-browser-security",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Security-focused ESLint plugin for browser applications. Detects XSS vulnerabilities, postMessage abuse, localStorage/sessionStorage/IndexedDB token exposure, cookie security issues, WebSocket security, Blob URL leaks, Service Worker risks, and CSP misconfigurations.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"eslint",
|
|
42
42
|
"eslint-plugin",
|
|
43
43
|
"eslintplugin",
|
|
44
|
+
"interlace-security",
|
|
44
45
|
"browser",
|
|
45
46
|
"browser-security",
|
|
46
47
|
"web-security",
|
|
@@ -72,8 +73,8 @@
|
|
|
72
73
|
"node": ">=18.0.0"
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
|
-
"
|
|
76
|
-
"
|
|
76
|
+
"tslib": "^2.3.0",
|
|
77
|
+
"@interlace/eslint-devkit": "^1.2.1"
|
|
77
78
|
},
|
|
78
79
|
"peerDependencies": {},
|
|
79
80
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -35,6 +35,32 @@ const no_worker_message_innerhtml_1 = require("./rules/no-worker-message-innerht
|
|
|
35
35
|
// CSP Security
|
|
36
36
|
const no_unsafe_inline_csp_1 = require("./rules/no-unsafe-inline-csp");
|
|
37
37
|
const no_unsafe_eval_csp_1 = require("./rules/no-unsafe-eval-csp");
|
|
38
|
+
// Migrated rules from secure-coding
|
|
39
|
+
const detect_mixed_content_1 = require("./rules/detect-mixed-content");
|
|
40
|
+
const no_allow_arbitrary_loads_1 = require("./rules/no-allow-arbitrary-loads");
|
|
41
|
+
const no_clickjacking_1 = require("./rules/no-clickjacking");
|
|
42
|
+
const no_credentials_in_query_params_1 = require("./rules/no-credentials-in-query-params");
|
|
43
|
+
const no_http_urls_1 = require("./rules/no-http-urls");
|
|
44
|
+
const no_insecure_redirects_1 = require("./rules/no-insecure-redirects");
|
|
45
|
+
const no_insecure_websocket_1 = require("./rules/no-insecure-websocket");
|
|
46
|
+
const no_missing_cors_check_1 = require("./rules/no-missing-cors-check");
|
|
47
|
+
const no_missing_csrf_protection_1 = require("./rules/no-missing-csrf-protection");
|
|
48
|
+
const no_missing_security_headers_1 = require("./rules/no-missing-security-headers");
|
|
49
|
+
const no_password_in_url_1 = require("./rules/no-password-in-url");
|
|
50
|
+
const no_permissive_cors_1 = require("./rules/no-permissive-cors");
|
|
51
|
+
const no_sensitive_data_in_analytics_1 = require("./rules/no-sensitive-data-in-analytics");
|
|
52
|
+
const no_sensitive_data_in_cache_1 = require("./rules/no-sensitive-data-in-cache");
|
|
53
|
+
const no_tracking_without_consent_1 = require("./rules/no-tracking-without-consent");
|
|
54
|
+
const no_unencrypted_transmission_1 = require("./rules/no-unencrypted-transmission");
|
|
55
|
+
const no_unescaped_url_parameter_1 = require("./rules/no-unescaped-url-parameter");
|
|
56
|
+
const no_unvalidated_deeplinks_1 = require("./rules/no-unvalidated-deeplinks");
|
|
57
|
+
const require_csp_headers_1 = require("./rules/require-csp-headers");
|
|
58
|
+
const require_https_only_1 = require("./rules/require-https-only");
|
|
59
|
+
const require_url_validation_1 = require("./rules/require-url-validation");
|
|
60
|
+
const require_mime_type_validation_1 = require("./rules/require-mime-type-validation");
|
|
61
|
+
const no_disabled_certificate_validation_1 = require("./rules/no-disabled-certificate-validation");
|
|
62
|
+
// Migrated from secure-coding (browser-specific auth)
|
|
63
|
+
const no_client_side_auth_logic_1 = require("./rules/no-client-side-auth-logic");
|
|
38
64
|
/**
|
|
39
65
|
* Collection of all browser security ESLint rules
|
|
40
66
|
*/
|
|
@@ -68,6 +94,32 @@ exports.rules = {
|
|
|
68
94
|
// CSP Security
|
|
69
95
|
'no-unsafe-inline-csp': no_unsafe_inline_csp_1.noUnsafeInlineCsp,
|
|
70
96
|
'no-unsafe-eval-csp': no_unsafe_eval_csp_1.noUnsafeEvalCsp,
|
|
97
|
+
// Migrated rules
|
|
98
|
+
'detect-mixed-content': detect_mixed_content_1.detectMixedContent,
|
|
99
|
+
'no-allow-arbitrary-loads': no_allow_arbitrary_loads_1.noAllowArbitraryLoads,
|
|
100
|
+
'no-clickjacking': no_clickjacking_1.noClickjacking,
|
|
101
|
+
'no-credentials-in-query-params': no_credentials_in_query_params_1.noCredentialsInQueryParams,
|
|
102
|
+
'no-http-urls': no_http_urls_1.noHttpUrls,
|
|
103
|
+
'no-insecure-redirects': no_insecure_redirects_1.noInsecureRedirects,
|
|
104
|
+
'no-insecure-websocket': no_insecure_websocket_1.noInsecureWebsocket,
|
|
105
|
+
'no-missing-cors-check': no_missing_cors_check_1.noMissingCorsCheck,
|
|
106
|
+
'no-missing-csrf-protection': no_missing_csrf_protection_1.noMissingCsrfProtection,
|
|
107
|
+
'no-missing-security-headers': no_missing_security_headers_1.noMissingSecurityHeaders,
|
|
108
|
+
'no-password-in-url': no_password_in_url_1.noPasswordInUrl,
|
|
109
|
+
'no-permissive-cors': no_permissive_cors_1.noPermissiveCors,
|
|
110
|
+
'no-sensitive-data-in-analytics': no_sensitive_data_in_analytics_1.noSensitiveDataInAnalytics,
|
|
111
|
+
'no-sensitive-data-in-cache': no_sensitive_data_in_cache_1.noSensitiveDataInCache,
|
|
112
|
+
'no-tracking-without-consent': no_tracking_without_consent_1.noTrackingWithoutConsent,
|
|
113
|
+
'no-unencrypted-transmission': no_unencrypted_transmission_1.noUnencryptedTransmission,
|
|
114
|
+
'no-unescaped-url-parameter': no_unescaped_url_parameter_1.noUnescapedUrlParameter,
|
|
115
|
+
'no-unvalidated-deeplinks': no_unvalidated_deeplinks_1.noUnvalidatedDeeplinks,
|
|
116
|
+
'require-csp-headers': require_csp_headers_1.requireCspHeaders,
|
|
117
|
+
'require-https-only': require_https_only_1.requireHttpsOnly,
|
|
118
|
+
'require-url-validation': require_url_validation_1.requireUrlValidation,
|
|
119
|
+
'require-mime-type-validation': require_mime_type_validation_1.requireMimeTypeValidation,
|
|
120
|
+
'no-disabled-certificate-validation': no_disabled_certificate_validation_1.noDisabledCertificateValidation,
|
|
121
|
+
// Migrated from secure-coding
|
|
122
|
+
'no-client-side-auth-logic': no_client_side_auth_logic_1.noClientSideAuthLogic,
|
|
71
123
|
};
|
|
72
124
|
/**
|
|
73
125
|
* ESLint Plugin object
|
|
@@ -112,6 +164,16 @@ const recommendedRules = {
|
|
|
112
164
|
// Medium - CSP Security
|
|
113
165
|
'browser-security/no-unsafe-inline-csp': 'error',
|
|
114
166
|
'browser-security/no-unsafe-eval-csp': 'error',
|
|
167
|
+
// Migrated Rules
|
|
168
|
+
'browser-security/detect-mixed-content': 'error',
|
|
169
|
+
'browser-security/no-allow-arbitrary-loads': 'error',
|
|
170
|
+
'browser-security/no-clickjacking': 'error',
|
|
171
|
+
'browser-security/no-credentials-in-query-params': 'error',
|
|
172
|
+
'browser-security/no-http-urls': 'error',
|
|
173
|
+
'browser-security/require-https-only': 'error',
|
|
174
|
+
'browser-security/no-insecure-websocket': 'error',
|
|
175
|
+
'browser-security/no-unvalidated-deeplinks': 'error',
|
|
176
|
+
'browser-security/no-client-side-auth-logic': 'error',
|
|
115
177
|
};
|
|
116
178
|
/**
|
|
117
179
|
* Preset configurations for browser security rules
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const detectMixedContent: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.detectMixedContent = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Detect HTTP resources in HTTPS pages
|
|
11
|
+
* @see https://owasp.org/www-project-mobile-top-10/
|
|
12
|
+
* @see https://cwe.mitre.org/data/definitions/311.html
|
|
13
|
+
*/
|
|
14
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
|
+
exports.detectMixedContent = (0, eslint_devkit_1.createRule)({
|
|
16
|
+
name: 'detect-mixed-content',
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Detect HTTP resources in HTTPS pages',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
24
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
25
|
+
issueName: 'violation Detected',
|
|
26
|
+
cwe: 'CWE-311',
|
|
27
|
+
description: 'Detect HTTP resources in HTTPS pages detected - Literal containing http:// in HTTPS context',
|
|
28
|
+
severity: 'MEDIUM',
|
|
29
|
+
fix: 'Review and apply secure practices',
|
|
30
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/311.html',
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
schema: [],
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [],
|
|
36
|
+
create(context) {
|
|
37
|
+
return {
|
|
38
|
+
Literal(node) {
|
|
39
|
+
if (typeof node.value === 'string' && node.value.startsWith('http://')) {
|
|
40
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
export interface Options {
|
|
7
|
+
}
|
|
8
|
+
type RuleOptions = [Options?];
|
|
9
|
+
export declare const noAllowArbitraryLoads: import("@typescript-eslint/utils/ts-eslint").RuleModule<"violationDetected", RuleOptions, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
10
|
+
name: string;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
4
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
5
|
+
* MIT license that can be found in the LICENSE file.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.noAllowArbitraryLoads = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Prevent configuration allowing insecure loads
|
|
11
|
+
* @see https://owasp.org/www-project-mobile-top-10/
|
|
12
|
+
* @see https://cwe.mitre.org/data/definitions/749.html
|
|
13
|
+
*/
|
|
14
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
|
+
exports.noAllowArbitraryLoads = (0, eslint_devkit_1.createRule)({
|
|
16
|
+
name: 'no-allow-arbitrary-loads',
|
|
17
|
+
meta: {
|
|
18
|
+
type: 'problem',
|
|
19
|
+
docs: {
|
|
20
|
+
description: 'Prevent configuration allowing insecure loads',
|
|
21
|
+
},
|
|
22
|
+
messages: {
|
|
23
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
24
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
25
|
+
issueName: 'violation Detected',
|
|
26
|
+
cwe: 'CWE-295',
|
|
27
|
+
description: 'Prevent configuration allowing insecure loads detected - allowArbitraryLoads: true',
|
|
28
|
+
severity: 'HIGH',
|
|
29
|
+
fix: 'Review and apply secure practices',
|
|
30
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/295.html',
|
|
31
|
+
})
|
|
32
|
+
},
|
|
33
|
+
schema: [],
|
|
34
|
+
},
|
|
35
|
+
defaultOptions: [],
|
|
36
|
+
create(context) {
|
|
37
|
+
return {
|
|
38
|
+
Property(node) {
|
|
39
|
+
if (node.key.type === 'Identifier' &&
|
|
40
|
+
node.key.name === 'allowArbitraryLoads' &&
|
|
41
|
+
node.value.type === 'Literal' &&
|
|
42
|
+
node.value.value === true) {
|
|
43
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Ofri Peretz
|
|
3
|
+
* Licensed under the MIT License. Use of this source code is governed by the
|
|
4
|
+
* MIT license that can be found in the LICENSE file.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* ESLint Rule: no-clickjacking
|
|
8
|
+
* Detects clickjacking vulnerabilities (CWE-1021)
|
|
9
|
+
*
|
|
10
|
+
* Clickjacking tricks users into clicking on invisible or disguised elements
|
|
11
|
+
* by overlaying them with transparent frames. This rule detects missing
|
|
12
|
+
* protections against clickjacking attacks.
|
|
13
|
+
*
|
|
14
|
+
* False Positive Reduction:
|
|
15
|
+
* This rule uses security utilities to reduce false positives by detecting:
|
|
16
|
+
* - Safe iframe usage patterns
|
|
17
|
+
* - Trusted frame sources
|
|
18
|
+
* - JSDoc annotations (@trusted-frame, @safe-iframe)
|
|
19
|
+
* - Frame-busting protections
|
|
20
|
+
*/
|
|
21
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
22
|
+
import { type SecurityRuleOptions } from '@interlace/eslint-devkit';
|
|
23
|
+
type MessageIds = 'clickjackingVulnerability' | 'missingFrameBusting' | 'unsafeIframeUsage' | 'missingXFrameOptions' | 'missingCspFrameAncestors' | 'transparentFrameOverlay' | 'frameManipulation' | 'implementFrameBusting' | 'useXFrameOptions' | 'setCspFrameAncestors' | 'strategyFrameProtection' | 'strategyContentSecurity' | 'strategyUserInteraction';
|
|
24
|
+
export interface Options extends SecurityRuleOptions {
|
|
25
|
+
/** Trusted iframe sources */
|
|
26
|
+
trustedSources?: string[];
|
|
27
|
+
/** Require frame-busting code */
|
|
28
|
+
requireFrameBusting?: boolean;
|
|
29
|
+
/** Detect transparent overlays */
|
|
30
|
+
detectTransparentOverlays?: boolean;
|
|
31
|
+
}
|
|
32
|
+
type RuleOptions = [Options?];
|
|
33
|
+
export declare const noClickjacking: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
34
|
+
name: string;
|
|
35
|
+
};
|
|
36
|
+
export {};
|