eslint-plugin-browser-security 1.2.9 → 1.2.10
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/package.json +5 -22
- package/src/index.d.ts +17 -64
- package/src/index.js +1 -76
- package/src/oxlint.d.ts +17 -20
- package/src/oxlint.js +0 -18
- package/src/rules/detect-mixed-content/index.js +0 -10
- package/src/rules/no-allow-arbitrary-loads/index.js +0 -10
- package/src/rules/no-clickjacking/index.js +0 -37
- package/src/rules/no-client-side-auth-logic/index.js +0 -11
- package/src/rules/no-cookie-auth-tokens/index.js +0 -13
- package/src/rules/no-credentials-in-query-params/index.js +0 -10
- package/src/rules/no-disabled-certificate-validation/index.js +0 -10
- package/src/rules/no-dynamic-service-worker-url/index.js +0 -9
- package/src/rules/no-eval/index.js +1 -14
- package/src/rules/no-filereader-innerhtml/index.js +0 -23
- package/src/rules/no-http-urls/index.js +0 -13
- package/src/rules/no-innerhtml/index.js +0 -25
- package/src/rules/no-insecure-redirects/index.js +3 -39
- package/src/rules/no-insecure-websocket/index.js +0 -12
- package/src/rules/no-jwt-in-storage/index.js +19 -42
- package/src/rules/no-missing-cors-check/index.js +4 -57
- package/src/rules/no-missing-csrf-protection/index.js +0 -23
- package/src/rules/no-missing-security-headers/index.js +0 -29
- package/src/rules/no-password-in-url/index.js +0 -11
- package/src/rules/no-permissive-cors/index.js +0 -13
- package/src/rules/no-postmessage-innerhtml/index.js +0 -18
- package/src/rules/no-postmessage-wildcard-origin/index.js +0 -10
- package/src/rules/no-sensitive-cookie-js/index.js +0 -18
- package/src/rules/no-sensitive-data-in-analytics/index.js +0 -11
- package/src/rules/no-sensitive-data-in-cache/index.js +0 -10
- package/src/rules/no-sensitive-indexeddb/index.js +0 -8
- package/src/rules/no-sensitive-localstorage/index.js +0 -11
- package/src/rules/no-sensitive-sessionstorage/index.js +0 -9
- package/src/rules/no-tracking-without-consent/index.js +0 -10
- package/src/rules/no-unencrypted-transmission/index.js +0 -32
- package/src/rules/no-unescaped-url-parameter/index.js +5 -47
- package/src/rules/no-unsafe-eval-csp/index.js +0 -10
- package/src/rules/no-unsafe-inline-csp/index.js +0 -10
- package/src/rules/no-unvalidated-deeplinks/index.js +0 -11
- package/src/rules/no-websocket-eval/index.js +0 -26
- package/src/rules/no-websocket-innerhtml/index.js +0 -20
- package/src/rules/no-worker-message-innerhtml/index.js +0 -23
- package/src/rules/require-blob-url-revocation/index.js +0 -10
- package/src/rules/require-cookie-secure-attrs/index.js +0 -7
- package/src/rules/require-csp-headers/index.js +0 -13
- package/src/rules/require-https-only/index.js +0 -13
- package/src/rules/require-mime-type-validation/index.js +0 -13
- package/src/rules/require-postmessage-origin-check/index.js +0 -17
- package/src/rules/require-url-validation/index.js +0 -12
- package/src/rules/require-websocket-wss/index.js +0 -17
- package/AGENTS.md +0 -97
- package/CHANGELOG.md +0 -188
- package/src/rules/detect-mixed-content/index.d.ts +0 -12
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +0 -12
- package/src/rules/no-clickjacking/index.d.ts +0 -36
- package/src/rules/no-client-side-auth-logic/index.d.ts +0 -12
- package/src/rules/no-cookie-auth-tokens/index.d.ts +0 -23
- package/src/rules/no-credentials-in-query-params/index.d.ts +0 -12
- package/src/rules/no-disabled-certificate-validation/index.d.ts +0 -12
- package/src/rules/no-dynamic-service-worker-url/index.d.ts +0 -23
- package/src/rules/no-eval/index.d.ts +0 -26
- package/src/rules/no-filereader-innerhtml/index.d.ts +0 -24
- package/src/rules/no-http-urls/index.d.ts +0 -17
- package/src/rules/no-innerhtml/index.d.ts +0 -28
- package/src/rules/no-insecure-redirects/index.d.ts +0 -26
- package/src/rules/no-insecure-websocket/index.d.ts +0 -12
- package/src/rules/no-jwt-in-storage/index.d.ts +0 -24
- package/src/rules/no-missing-cors-check/index.d.ts +0 -28
- package/src/rules/no-missing-csrf-protection/index.d.ts +0 -30
- package/src/rules/no-missing-security-headers/index.d.ts +0 -26
- package/src/rules/no-password-in-url/index.d.ts +0 -12
- package/src/rules/no-permissive-cors/index.d.ts +0 -12
- package/src/rules/no-postmessage-innerhtml/index.d.ts +0 -24
- package/src/rules/no-postmessage-wildcard-origin/index.d.ts +0 -24
- package/src/rules/no-sensitive-cookie-js/index.d.ts +0 -26
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +0 -12
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +0 -12
- package/src/rules/no-sensitive-indexeddb/index.d.ts +0 -23
- package/src/rules/no-sensitive-localstorage/index.d.ts +0 -28
- package/src/rules/no-sensitive-sessionstorage/index.d.ts +0 -25
- package/src/rules/no-tracking-without-consent/index.d.ts +0 -12
- package/src/rules/no-unencrypted-transmission/index.d.ts +0 -30
- package/src/rules/no-unescaped-url-parameter/index.d.ts +0 -28
- package/src/rules/no-unsafe-eval-csp/index.d.ts +0 -24
- package/src/rules/no-unsafe-inline-csp/index.d.ts +0 -24
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +0 -12
- package/src/rules/no-websocket-eval/index.d.ts +0 -24
- package/src/rules/no-websocket-innerhtml/index.d.ts +0 -24
- package/src/rules/no-worker-message-innerhtml/index.d.ts +0 -24
- package/src/rules/require-blob-url-revocation/index.d.ts +0 -24
- package/src/rules/require-cookie-secure-attrs/index.d.ts +0 -23
- package/src/rules/require-csp-headers/index.d.ts +0 -12
- package/src/rules/require-https-only/index.d.ts +0 -12
- package/src/rules/require-mime-type-validation/index.d.ts +0 -12
- package/src/rules/require-postmessage-origin-check/index.d.ts +0 -26
- package/src/rules/require-url-validation/index.d.ts +0 -12
- package/src/rules/require-websocket-wss/index.d.ts +0 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-browser-security",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.10",
|
|
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",
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
11
11
|
"default": "./src/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./types": {
|
|
14
|
-
"types": "./src/types/index.d.ts",
|
|
15
|
-
"default": "./src/types/index.js"
|
|
16
|
-
},
|
|
17
13
|
"./oxlint": {
|
|
18
14
|
"types": "./src/oxlint.d.ts",
|
|
19
15
|
"default": "./src/oxlint.js"
|
|
@@ -24,7 +20,7 @@
|
|
|
24
20
|
"homepage": "https://eslint.interlace.tools/docs/security/plugin-browser-security?utm_source=npm&utm_medium=referral&utm_campaign=eslint-plugin-browser-security",
|
|
25
21
|
"repository": {
|
|
26
22
|
"type": "git",
|
|
27
|
-
"url": "https://github.com/ofri-peretz/eslint",
|
|
23
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git",
|
|
28
24
|
"directory": "packages/eslint-plugin-browser-security"
|
|
29
25
|
},
|
|
30
26
|
"bugs": {
|
|
@@ -35,11 +31,8 @@
|
|
|
35
31
|
},
|
|
36
32
|
"files": [
|
|
37
33
|
"src/",
|
|
38
|
-
"dist/",
|
|
39
34
|
"README.md",
|
|
40
|
-
"LICENSE"
|
|
41
|
-
"CHANGELOG.md",
|
|
42
|
-
"AGENTS.md"
|
|
35
|
+
"LICENSE"
|
|
43
36
|
],
|
|
44
37
|
"keywords": [
|
|
45
38
|
"eslint",
|
|
@@ -81,23 +74,13 @@
|
|
|
81
74
|
},
|
|
82
75
|
"dependencies": {
|
|
83
76
|
"tslib": "^2.3.0",
|
|
84
|
-
"@interlace/eslint-devkit": "^1.
|
|
77
|
+
"@interlace/eslint-devkit": "^1.6.1"
|
|
85
78
|
},
|
|
86
79
|
"peerDependencies": {
|
|
87
80
|
"eslint": "^8.0.0 || ^9.0.0 || ^10.0.0"
|
|
88
81
|
},
|
|
89
|
-
"devDependencies": {
|
|
90
|
-
"@typescript-eslint/parser": "^8.46.2",
|
|
91
|
-
"@typescript-eslint/rule-tester": "^8.46.2"
|
|
92
|
-
},
|
|
93
|
-
"scripts": {
|
|
94
|
-
"build": "tsx ../../scripts/build-package.ts",
|
|
95
|
-
"test": "vitest run",
|
|
96
|
-
"test:coverage": "vitest run --coverage",
|
|
97
|
-
"typecheck": "tsc -p tsconfig.lib.json --noEmit"
|
|
98
|
-
},
|
|
99
82
|
"funding": {
|
|
100
83
|
"type": "github",
|
|
101
|
-
"url": "https://github.com/ofri-peretz/eslint"
|
|
84
|
+
"url": "git+https://github.com/ofri-peretz/eslint.git"
|
|
102
85
|
}
|
|
103
86
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,64 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* - Cookie security
|
|
19
|
-
* - WebSocket security
|
|
20
|
-
* - Browser API security
|
|
21
|
-
*
|
|
22
|
-
* @see https://github.com/ofri-peretz/eslint#readme
|
|
23
|
-
*/
|
|
24
|
-
import { TSESLint } from '@interlace/eslint-devkit';
|
|
25
|
-
/**
|
|
26
|
-
* Collection of all browser security ESLint rules
|
|
27
|
-
*/
|
|
28
|
-
export declare const rules: Record<string, TSESLint.RuleModule<string, readonly unknown[]>>;
|
|
29
|
-
/**
|
|
30
|
-
* ESLint Plugin object
|
|
31
|
-
*/
|
|
32
|
-
export declare const plugin: TSESLint.FlatConfig.Plugin;
|
|
33
|
-
/**
|
|
34
|
-
* Preset configurations for browser security rules
|
|
35
|
-
*/
|
|
36
|
-
export declare const configs: Record<string, TSESLint.FlatConfig.Config>;
|
|
37
|
-
/**
|
|
38
|
-
* Default export for ESLint plugin
|
|
39
|
-
*/
|
|
40
|
-
export default plugin;
|
|
41
|
-
/**
|
|
42
|
-
* Re-export types
|
|
43
|
-
*/
|
|
44
|
-
export type { Options as NoInnerhtmlOptions } from './rules/no-innerhtml';
|
|
45
|
-
export type { Options as NoEvalOptions } from './rules/no-eval';
|
|
46
|
-
export type { Options as RequirePostmessageOriginCheckOptions } from './rules/require-postmessage-origin-check';
|
|
47
|
-
export type { Options as NoPostmessageWildcardOriginOptions } from './rules/no-postmessage-wildcard-origin';
|
|
48
|
-
export type { Options as NoPostmessageInnerhtmlOptions } from './rules/no-postmessage-innerhtml';
|
|
49
|
-
export type { Options as NoSensitiveLocalstorageOptions } from './rules/no-sensitive-localstorage';
|
|
50
|
-
export type { Options as NoJwtInStorageOptions } from './rules/no-jwt-in-storage';
|
|
51
|
-
export type { Options as NoSensitiveSessionstorageOptions } from './rules/no-sensitive-sessionstorage';
|
|
52
|
-
export type { Options as NoSensitiveIndexeddbOptions } from './rules/no-sensitive-indexeddb';
|
|
53
|
-
export type { Options as NoSensitiveCookieJsOptions } from './rules/no-sensitive-cookie-js';
|
|
54
|
-
export type { Options as NoCookieAuthTokensOptions } from './rules/no-cookie-auth-tokens';
|
|
55
|
-
export type { Options as RequireCookieSecureAttrsOptions } from './rules/require-cookie-secure-attrs';
|
|
56
|
-
export type { Options as RequireWebsocketWssOptions } from './rules/require-websocket-wss';
|
|
57
|
-
export type { Options as NoWebsocketInnerhtmlOptions } from './rules/no-websocket-innerhtml';
|
|
58
|
-
export type { Options as NoWebsocketEvalOptions } from './rules/no-websocket-eval';
|
|
59
|
-
export type { Options as NoFilereaderInnerhtmlOptions } from './rules/no-filereader-innerhtml';
|
|
60
|
-
export type { Options as RequireBlobUrlRevocationOptions } from './rules/require-blob-url-revocation';
|
|
61
|
-
export type { Options as NoDynamicServiceWorkerUrlOptions } from './rules/no-dynamic-service-worker-url';
|
|
62
|
-
export type { Options as NoWorkerMessageInnerhtmlOptions } from './rules/no-worker-message-innerhtml';
|
|
63
|
-
export type { Options as NoUnsafeInlineCspOptions } from './rules/no-unsafe-inline-csp';
|
|
64
|
-
export type { Options as NoUnsafeEvalCspOptions } from './rules/no-unsafe-eval-csp';
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/index.js
CHANGED
|
@@ -1,41 +1,27 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.configs = exports.plugin = exports.rules = void 0;
|
|
9
|
-
// XSS Prevention Rules
|
|
10
4
|
const no_innerhtml_1 = require("./rules/no-innerhtml");
|
|
11
5
|
const no_eval_1 = require("./rules/no-eval");
|
|
12
|
-
// postMessage Security
|
|
13
6
|
const require_postmessage_origin_check_1 = require("./rules/require-postmessage-origin-check");
|
|
14
7
|
const no_postmessage_wildcard_origin_1 = require("./rules/no-postmessage-wildcard-origin");
|
|
15
8
|
const no_postmessage_innerhtml_1 = require("./rules/no-postmessage-innerhtml");
|
|
16
|
-
// Storage Security
|
|
17
9
|
const no_sensitive_localstorage_1 = require("./rules/no-sensitive-localstorage");
|
|
18
10
|
const no_jwt_in_storage_1 = require("./rules/no-jwt-in-storage");
|
|
19
11
|
const no_sensitive_sessionstorage_1 = require("./rules/no-sensitive-sessionstorage");
|
|
20
12
|
const no_sensitive_indexeddb_1 = require("./rules/no-sensitive-indexeddb");
|
|
21
|
-
// Cookie Security
|
|
22
13
|
const no_sensitive_cookie_js_1 = require("./rules/no-sensitive-cookie-js");
|
|
23
14
|
const no_cookie_auth_tokens_1 = require("./rules/no-cookie-auth-tokens");
|
|
24
15
|
const require_cookie_secure_attrs_1 = require("./rules/require-cookie-secure-attrs");
|
|
25
|
-
// WebSocket Security
|
|
26
16
|
const require_websocket_wss_1 = require("./rules/require-websocket-wss");
|
|
27
17
|
const no_websocket_innerhtml_1 = require("./rules/no-websocket-innerhtml");
|
|
28
18
|
const no_websocket_eval_1 = require("./rules/no-websocket-eval");
|
|
29
|
-
// File API Security
|
|
30
19
|
const no_filereader_innerhtml_1 = require("./rules/no-filereader-innerhtml");
|
|
31
20
|
const require_blob_url_revocation_1 = require("./rules/require-blob-url-revocation");
|
|
32
|
-
// Workers Security
|
|
33
21
|
const no_dynamic_service_worker_url_1 = require("./rules/no-dynamic-service-worker-url");
|
|
34
22
|
const no_worker_message_innerhtml_1 = require("./rules/no-worker-message-innerhtml");
|
|
35
|
-
// CSP Security
|
|
36
23
|
const no_unsafe_inline_csp_1 = require("./rules/no-unsafe-inline-csp");
|
|
37
24
|
const no_unsafe_eval_csp_1 = require("./rules/no-unsafe-eval-csp");
|
|
38
|
-
// Migrated rules from secure-coding
|
|
39
25
|
const detect_mixed_content_1 = require("./rules/detect-mixed-content");
|
|
40
26
|
const no_allow_arbitrary_loads_1 = require("./rules/no-allow-arbitrary-loads");
|
|
41
27
|
const no_clickjacking_1 = require("./rules/no-clickjacking");
|
|
@@ -59,42 +45,29 @@ const require_https_only_1 = require("./rules/require-https-only");
|
|
|
59
45
|
const require_url_validation_1 = require("./rules/require-url-validation");
|
|
60
46
|
const require_mime_type_validation_1 = require("./rules/require-mime-type-validation");
|
|
61
47
|
const no_disabled_certificate_validation_1 = require("./rules/no-disabled-certificate-validation");
|
|
62
|
-
// Migrated from secure-coding (browser-specific auth)
|
|
63
48
|
const no_client_side_auth_logic_1 = require("./rules/no-client-side-auth-logic");
|
|
64
|
-
/**
|
|
65
|
-
* Collection of all browser security ESLint rules
|
|
66
|
-
*/
|
|
67
49
|
exports.rules = {
|
|
68
|
-
// XSS Prevention
|
|
69
50
|
'no-innerhtml': no_innerhtml_1.noInnerhtml,
|
|
70
51
|
'no-eval': no_eval_1.noEval,
|
|
71
|
-
// postMessage Security
|
|
72
52
|
'require-postmessage-origin-check': require_postmessage_origin_check_1.requirePostmessageOriginCheck,
|
|
73
53
|
'no-postmessage-wildcard-origin': no_postmessage_wildcard_origin_1.noPostmessageWildcardOrigin,
|
|
74
54
|
'no-postmessage-innerhtml': no_postmessage_innerhtml_1.noPostmessageInnerhtml,
|
|
75
|
-
// Storage Security
|
|
76
55
|
'no-sensitive-localstorage': no_sensitive_localstorage_1.noSensitiveLocalstorage,
|
|
77
56
|
'no-jwt-in-storage': no_jwt_in_storage_1.noJwtInStorage,
|
|
78
57
|
'no-sensitive-sessionstorage': no_sensitive_sessionstorage_1.noSensitiveSessionstorage,
|
|
79
58
|
'no-sensitive-indexeddb': no_sensitive_indexeddb_1.noSensitiveIndexeddb,
|
|
80
|
-
// Cookie Security
|
|
81
59
|
'no-sensitive-cookie-js': no_sensitive_cookie_js_1.noSensitiveCookieJs,
|
|
82
60
|
'no-cookie-auth-tokens': no_cookie_auth_tokens_1.noCookieAuthTokens,
|
|
83
61
|
'require-cookie-secure-attrs': require_cookie_secure_attrs_1.requireCookieSecureAttrs,
|
|
84
|
-
// WebSocket Security
|
|
85
62
|
'require-websocket-wss': require_websocket_wss_1.requireWebsocketWss,
|
|
86
63
|
'no-websocket-innerhtml': no_websocket_innerhtml_1.noWebsocketInnerhtml,
|
|
87
64
|
'no-websocket-eval': no_websocket_eval_1.noWebsocketEval,
|
|
88
|
-
// File API Security
|
|
89
65
|
'no-filereader-innerhtml': no_filereader_innerhtml_1.noFilereaderInnerhtml,
|
|
90
66
|
'require-blob-url-revocation': require_blob_url_revocation_1.requireBlobUrlRevocation,
|
|
91
|
-
// Workers Security
|
|
92
67
|
'no-dynamic-service-worker-url': no_dynamic_service_worker_url_1.noDynamicServiceWorkerUrl,
|
|
93
68
|
'no-worker-message-innerhtml': no_worker_message_innerhtml_1.noWorkerMessageInnerhtml,
|
|
94
|
-
// CSP Security
|
|
95
69
|
'no-unsafe-inline-csp': no_unsafe_inline_csp_1.noUnsafeInlineCsp,
|
|
96
70
|
'no-unsafe-eval-csp': no_unsafe_eval_csp_1.noUnsafeEvalCsp,
|
|
97
|
-
// Migrated rules
|
|
98
71
|
'detect-mixed-content': detect_mixed_content_1.detectMixedContent,
|
|
99
72
|
'no-allow-arbitrary-loads': no_allow_arbitrary_loads_1.noAllowArbitraryLoads,
|
|
100
73
|
'no-clickjacking': no_clickjacking_1.noClickjacking,
|
|
@@ -118,53 +91,37 @@ exports.rules = {
|
|
|
118
91
|
'require-url-validation': require_url_validation_1.requireUrlValidation,
|
|
119
92
|
'require-mime-type-validation': require_mime_type_validation_1.requireMimeTypeValidation,
|
|
120
93
|
'no-disabled-certificate-validation': no_disabled_certificate_validation_1.noDisabledCertificateValidation,
|
|
121
|
-
// Migrated from secure-coding
|
|
122
94
|
'no-client-side-auth-logic': no_client_side_auth_logic_1.noClientSideAuthLogic,
|
|
123
95
|
};
|
|
124
|
-
/**
|
|
125
|
-
* ESLint Plugin object
|
|
126
|
-
*/
|
|
127
96
|
exports.plugin = {
|
|
128
97
|
meta: {
|
|
129
98
|
name: 'eslint-plugin-browser-security',
|
|
130
|
-
version: '1.2.
|
|
99
|
+
version: '1.2.10',
|
|
131
100
|
},
|
|
132
101
|
rules: exports.rules,
|
|
133
102
|
};
|
|
134
|
-
/**
|
|
135
|
-
* Recommended configuration - balanced security enforcement
|
|
136
|
-
*/
|
|
137
103
|
const recommendedRules = {
|
|
138
|
-
// Critical - XSS Prevention
|
|
139
104
|
'browser-security/no-innerhtml': 'error',
|
|
140
105
|
'browser-security/no-eval': 'error',
|
|
141
|
-
// High - postMessage Security
|
|
142
106
|
'browser-security/require-postmessage-origin-check': 'error',
|
|
143
107
|
'browser-security/no-postmessage-wildcard-origin': 'error',
|
|
144
108
|
'browser-security/no-postmessage-innerhtml': 'error',
|
|
145
|
-
// High - Storage Security
|
|
146
109
|
'browser-security/no-sensitive-localstorage': 'error',
|
|
147
110
|
'browser-security/no-jwt-in-storage': 'error',
|
|
148
111
|
'browser-security/no-sensitive-sessionstorage': 'error',
|
|
149
112
|
'browser-security/no-sensitive-indexeddb': 'error',
|
|
150
|
-
// High - Cookie Security
|
|
151
113
|
'browser-security/no-sensitive-cookie-js': 'error',
|
|
152
114
|
'browser-security/no-cookie-auth-tokens': 'error',
|
|
153
115
|
'browser-security/require-cookie-secure-attrs': 'error',
|
|
154
|
-
// High - WebSocket Security
|
|
155
116
|
'browser-security/require-websocket-wss': 'error',
|
|
156
117
|
'browser-security/no-websocket-innerhtml': 'error',
|
|
157
118
|
'browser-security/no-websocket-eval': 'error',
|
|
158
|
-
// High - File API Security
|
|
159
119
|
'browser-security/no-filereader-innerhtml': 'error',
|
|
160
120
|
'browser-security/require-blob-url-revocation': 'warn',
|
|
161
|
-
// Medium - Workers Security
|
|
162
121
|
'browser-security/no-dynamic-service-worker-url': 'error',
|
|
163
122
|
'browser-security/no-worker-message-innerhtml': 'error',
|
|
164
|
-
// Medium - CSP Security
|
|
165
123
|
'browser-security/no-unsafe-inline-csp': 'error',
|
|
166
124
|
'browser-security/no-unsafe-eval-csp': 'error',
|
|
167
|
-
// Migrated Rules
|
|
168
125
|
'browser-security/detect-mixed-content': 'error',
|
|
169
126
|
'browser-security/no-allow-arbitrary-loads': 'error',
|
|
170
127
|
'browser-security/no-clickjacking': 'error',
|
|
@@ -176,15 +133,7 @@ const recommendedRules = {
|
|
|
176
133
|
'browser-security/no-unvalidated-deeplinks': 'error',
|
|
177
134
|
'browser-security/no-client-side-auth-logic': 'error',
|
|
178
135
|
};
|
|
179
|
-
/**
|
|
180
|
-
* Preset configurations for browser security rules
|
|
181
|
-
*/
|
|
182
136
|
exports.configs = {
|
|
183
|
-
/**
|
|
184
|
-
* Flagship preset — the rule from this plugin in the ecosystem-wide
|
|
185
|
-
* flagship list (`.agent/flagship-rules.md`). Narrow signature, no
|
|
186
|
-
* legitimate use case for `postMessage(data, '*')` — high-signal CI gate.
|
|
187
|
-
*/
|
|
188
137
|
flagship: {
|
|
189
138
|
plugins: {
|
|
190
139
|
'browser-security': exports.plugin,
|
|
@@ -193,18 +142,12 @@ exports.configs = {
|
|
|
193
142
|
'browser-security/no-postmessage-wildcard-origin': 'error',
|
|
194
143
|
},
|
|
195
144
|
},
|
|
196
|
-
/**
|
|
197
|
-
* Recommended security configuration
|
|
198
|
-
*/
|
|
199
145
|
recommended: {
|
|
200
146
|
plugins: {
|
|
201
147
|
'browser-security': exports.plugin,
|
|
202
148
|
},
|
|
203
149
|
rules: recommendedRules,
|
|
204
150
|
},
|
|
205
|
-
/**
|
|
206
|
-
* Strict security configuration - all rules as errors
|
|
207
|
-
*/
|
|
208
151
|
strict: {
|
|
209
152
|
plugins: {
|
|
210
153
|
'browser-security': exports.plugin,
|
|
@@ -214,9 +157,6 @@ exports.configs = {
|
|
|
214
157
|
'error',
|
|
215
158
|
])),
|
|
216
159
|
},
|
|
217
|
-
/**
|
|
218
|
-
* XSS-focused configuration
|
|
219
|
-
*/
|
|
220
160
|
xss: {
|
|
221
161
|
plugins: {
|
|
222
162
|
'browser-security': exports.plugin,
|
|
@@ -226,9 +166,6 @@ exports.configs = {
|
|
|
226
166
|
'browser-security/no-eval': 'error',
|
|
227
167
|
},
|
|
228
168
|
},
|
|
229
|
-
/**
|
|
230
|
-
* Storage security configuration
|
|
231
|
-
*/
|
|
232
169
|
storage: {
|
|
233
170
|
plugins: {
|
|
234
171
|
'browser-security': exports.plugin,
|
|
@@ -237,9 +174,6 @@ exports.configs = {
|
|
|
237
174
|
'browser-security/no-sensitive-localstorage': 'error',
|
|
238
175
|
},
|
|
239
176
|
},
|
|
240
|
-
/**
|
|
241
|
-
* postMessage security configuration
|
|
242
|
-
*/
|
|
243
177
|
postmessage: {
|
|
244
178
|
plugins: {
|
|
245
179
|
'browser-security': exports.plugin,
|
|
@@ -249,9 +183,6 @@ exports.configs = {
|
|
|
249
183
|
'browser-security/no-postmessage-wildcard-origin': 'error',
|
|
250
184
|
},
|
|
251
185
|
},
|
|
252
|
-
/**
|
|
253
|
-
* WebSocket security configuration
|
|
254
|
-
*/
|
|
255
186
|
websocket: {
|
|
256
187
|
plugins: {
|
|
257
188
|
'browser-security': exports.plugin,
|
|
@@ -260,9 +191,6 @@ exports.configs = {
|
|
|
260
191
|
'browser-security/require-websocket-wss': 'error',
|
|
261
192
|
},
|
|
262
193
|
},
|
|
263
|
-
/**
|
|
264
|
-
* Cookie security configuration
|
|
265
|
-
*/
|
|
266
194
|
cookies: {
|
|
267
195
|
plugins: {
|
|
268
196
|
'browser-security': exports.plugin,
|
|
@@ -272,7 +200,4 @@ exports.configs = {
|
|
|
272
200
|
},
|
|
273
201
|
},
|
|
274
202
|
};
|
|
275
|
-
/**
|
|
276
|
-
* Default export for ESLint plugin
|
|
277
|
-
*/
|
|
278
203
|
exports.default = exports.plugin;
|
package/src/oxlint.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
import { plugin } from './index';
|
|
20
|
-
export = plugin;
|
|
1
|
+
// Minimal declaration written by scripts/build-package.ts.
|
|
2
|
+
//
|
|
3
|
+
// tsc's generated entry declaration inlined every inferred rule-option type
|
|
4
|
+
// (up to 166 kB per plugin) for an API no consumer calls directly. This types
|
|
5
|
+
// what a flat config actually touches. Per-rule option types remain available
|
|
6
|
+
// from the "./types" subpath export where a plugin provides one.
|
|
7
|
+
import type { Linter, Rule } from 'eslint';
|
|
8
|
+
|
|
9
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
10
|
+
export declare const configs: Record<string, Linter.Config>;
|
|
11
|
+
export declare const plugin: {
|
|
12
|
+
meta: { name: string; version: string };
|
|
13
|
+
rules: Record<string, Rule.RuleModule>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
declare const _default: typeof plugin;
|
|
17
|
+
export default _default;
|
package/src/oxlint.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
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
|
-
/**
|
|
8
|
-
* oxlint sub-export.
|
|
9
|
-
*
|
|
10
|
-
* Consumers wire oxlint to this entry via:
|
|
11
|
-
* { "jsPlugins": ["eslint-plugin-browser-security/oxlint"] }
|
|
12
|
-
*
|
|
13
|
-
* oxlint's JS plugin loader does `require('eslint-plugin-browser-security/oxlint')` and reads
|
|
14
|
-
* `.rules` off the result. The compiled output of `export = plugin` is
|
|
15
|
-
* `module.exports = plugin`, which gives oxlint the plugin object directly
|
|
16
|
-
* (`{ meta, rules }`) — no wrapper, no `.default` indirection.
|
|
17
|
-
*
|
|
18
|
-
* Generated by scripts/generate-oxlint-shims.mjs. Do not edit by hand.
|
|
19
|
-
*/
|
|
20
2
|
const index_1 = require("./index");
|
|
21
3
|
module.exports = index_1.plugin;
|
|
@@ -1,16 +1,6 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
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
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
5
|
exports.detectMixedContent = (0, eslint_devkit_1.createRule)({
|
|
16
6
|
name: 'detect-mixed-content',
|
|
@@ -1,16 +1,6 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
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
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
15
5
|
exports.noAllowArbitraryLoads = (0, eslint_devkit_1.createRule)({
|
|
16
6
|
name: 'no-allow-arbitrary-loads',
|
|
@@ -1,9 +1,4 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.noClickjacking = void 0;
|
|
9
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
@@ -188,30 +183,21 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
188
183
|
const { trustedSources = ['self', 'same-origin'], requireFrameBusting = true, detectTransparentOverlays = true, trustedSanitizers = [], trustedAnnotations = [], strictMode = false, } = options;
|
|
189
184
|
const sourceCode = context.sourceCode;
|
|
190
185
|
const filename = context.filename;
|
|
191
|
-
// Create safety checker for false positive detection
|
|
192
186
|
const safetyChecker = (0, eslint_devkit_3.createSafetyChecker)({
|
|
193
187
|
trustedSanitizers,
|
|
194
188
|
trustedAnnotations,
|
|
195
189
|
trustedOrmPatterns: [],
|
|
196
190
|
strictMode,
|
|
197
191
|
});
|
|
198
|
-
// Track if frame-busting code is present
|
|
199
192
|
let hasFrameBusting = false;
|
|
200
|
-
/**
|
|
201
|
-
* Check if source is trusted
|
|
202
|
-
*/
|
|
203
193
|
const isTrustedSource = (source) => {
|
|
204
194
|
return trustedSources.some(trusted => source.includes(trusted) ||
|
|
205
195
|
(trusted === 'self' && (source === 'self' || source.startsWith('/'))) ||
|
|
206
196
|
(trusted === 'same-origin' && source === 'same-origin'));
|
|
207
197
|
};
|
|
208
|
-
/**
|
|
209
|
-
* Check if this is frame-busting code
|
|
210
|
-
*/
|
|
211
198
|
const isFrameBustingCode = (node) => {
|
|
212
199
|
const test = node.test;
|
|
213
200
|
const testText = sourceCode.getText(test).toLowerCase();
|
|
214
|
-
// Look for common frame-busting patterns
|
|
215
201
|
return testText.includes('top != self') ||
|
|
216
202
|
testText.includes('top !== self') ||
|
|
217
203
|
testText.includes('window.top !== window.self') ||
|
|
@@ -219,10 +205,6 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
219
205
|
testText.includes('top.location') ||
|
|
220
206
|
testText.includes('self.location');
|
|
221
207
|
};
|
|
222
|
-
/**
|
|
223
|
-
* Check for transparent/invisible elements that could hide clickjacking
|
|
224
|
-
*/
|
|
225
|
-
// oxlint-disable-next-line consistent-function-scoping
|
|
226
208
|
const hasTransparentStyles = (styleText) => {
|
|
227
209
|
const styles = styleText.toLowerCase();
|
|
228
210
|
return styles.includes('opacity: 0') ||
|
|
@@ -233,17 +215,14 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
233
215
|
styles.includes('position: absolute') && styles.includes('top: 0') && styles.includes('left: 0');
|
|
234
216
|
};
|
|
235
217
|
return {
|
|
236
|
-
// Check for frame-busting code
|
|
237
218
|
IfStatement(node) {
|
|
238
219
|
if (isFrameBustingCode(node)) {
|
|
239
220
|
hasFrameBusting = true;
|
|
240
221
|
}
|
|
241
222
|
},
|
|
242
|
-
// Check iframe elements (in JSX/TSX)
|
|
243
223
|
JSXElement(node) {
|
|
244
224
|
if (node.openingElement.name.type === 'JSXIdentifier' &&
|
|
245
225
|
node.openingElement.name.name === 'iframe') {
|
|
246
|
-
// Check iframe attributes
|
|
247
226
|
const attributes = node.openingElement.attributes;
|
|
248
227
|
let hasSrc = false;
|
|
249
228
|
let srcValue = '';
|
|
@@ -273,20 +252,13 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
273
252
|
}
|
|
274
253
|
}
|
|
275
254
|
},
|
|
276
|
-
// Check for frame manipulation code
|
|
277
255
|
MemberExpression(node) {
|
|
278
|
-
// Look for top.location or window.top manipulation
|
|
279
256
|
if (node.object.type === 'Identifier' &&
|
|
280
257
|
(node.object.name === 'top' || node.object.name === 'window')) {
|
|
281
258
|
if (node.property.type === 'Identifier' &&
|
|
282
259
|
(node.property.name === 'location' || node.property.name === 'top')) {
|
|
283
|
-
// Check if this is being assigned or compared
|
|
284
260
|
let current = node;
|
|
285
261
|
let isFrameManipulation = false;
|
|
286
|
-
// Walk up to see if this is an assignment or comparison. Every
|
|
287
|
-
// path that sets `isFrameManipulation = true` is followed by
|
|
288
|
-
// `break`, so the negation in the loop condition is redundant
|
|
289
|
-
// (CodeQL: `js/useless-conditional`).
|
|
290
262
|
while (current) {
|
|
291
263
|
if (current.type === 'AssignmentExpression' &&
|
|
292
264
|
current.left === node) {
|
|
@@ -295,11 +267,9 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
295
267
|
}
|
|
296
268
|
if (current.type === 'BinaryExpression' &&
|
|
297
269
|
(current.left === node || current.right === node)) {
|
|
298
|
-
// Comparison like top != self
|
|
299
270
|
const operator = current.operator;
|
|
300
271
|
if (operator === '!=' || operator === '!==' ||
|
|
301
272
|
operator === '==' || operator === '===') {
|
|
302
|
-
// This might be frame-busting code
|
|
303
273
|
break;
|
|
304
274
|
}
|
|
305
275
|
isFrameManipulation = true;
|
|
@@ -323,10 +293,8 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
323
293
|
}
|
|
324
294
|
}
|
|
325
295
|
},
|
|
326
|
-
// Check for CSS that could hide clickjacking attacks
|
|
327
296
|
Literal(node) {
|
|
328
297
|
if (typeof node.value === 'string' && detectTransparentOverlays) {
|
|
329
|
-
// Check if this looks like CSS
|
|
330
298
|
const text = node.value.toLowerCase();
|
|
331
299
|
if ((text.includes('style=') || text.includes('css')) &&
|
|
332
300
|
hasTransparentStyles(text)) {
|
|
@@ -344,7 +312,6 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
344
312
|
}
|
|
345
313
|
}
|
|
346
314
|
},
|
|
347
|
-
// Check template literals for CSS
|
|
348
315
|
TemplateLiteral(node) {
|
|
349
316
|
if (detectTransparentOverlays) {
|
|
350
317
|
const text = sourceCode.getText(node).toLowerCase();
|
|
@@ -363,19 +330,15 @@ exports.noClickjacking = (0, eslint_devkit_1.createRule)({
|
|
|
363
330
|
}
|
|
364
331
|
}
|
|
365
332
|
},
|
|
366
|
-
// At the end of the file, check if frame-busting is required but missing
|
|
367
333
|
'Program:exit'() {
|
|
368
334
|
if (requireFrameBusting && !hasFrameBusting) {
|
|
369
|
-
// Only check files that are likely entry points or render HTML
|
|
370
335
|
const isEntryPoint = /\.(html|htm)$/.test(filename) ||
|
|
371
336
|
/(index|app|main|page)\.(tsx|jsx)$/i.test(filename) ||
|
|
372
337
|
/pages?\/.*\.(tsx|jsx)$/i.test(filename) ||
|
|
373
338
|
/layout\.(tsx|jsx)$/i.test(filename);
|
|
374
|
-
// Skip non-entry point files
|
|
375
339
|
if (!isEntryPoint) {
|
|
376
340
|
return;
|
|
377
341
|
}
|
|
378
|
-
// Check if this file has actual UI rendering (JSX elements with event handlers)
|
|
379
342
|
const fileContent = sourceCode.getText();
|
|
380
343
|
const hasUIElements = fileContent.includes('<button') ||
|
|
381
344
|
fileContent.includes('<form') ||
|
|
@@ -1,14 +1,6 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
3
|
exports.noClientSideAuthLogic = void 0;
|
|
9
|
-
/**
|
|
10
|
-
* @fileoverview Prevent authentication logic in client code
|
|
11
|
-
*/
|
|
12
4
|
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
5
|
exports.noClientSideAuthLogic = (0, eslint_devkit_1.createRule)({
|
|
14
6
|
name: 'no-client-side-auth-logic',
|
|
@@ -41,7 +33,6 @@ exports.noClientSideAuthLogic = (0, eslint_devkit_1.createRule)({
|
|
|
41
33
|
const authKeywords = ['admin', 'authenticated', 'authorized', 'isAdmin', 'isAuthenticated', 'role'];
|
|
42
34
|
return {
|
|
43
35
|
IfStatement(node) {
|
|
44
|
-
// Detect role/auth checks from localStorage
|
|
45
36
|
if (node.test.type === 'CallExpression' &&
|
|
46
37
|
node.test.callee.type === 'MemberExpression' &&
|
|
47
38
|
node.test.callee.object.type === 'Identifier' &&
|
|
@@ -56,9 +47,7 @@ exports.noClientSideAuthLogic = (0, eslint_devkit_1.createRule)({
|
|
|
56
47
|
}
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
|
-
// Detect password comparison
|
|
60
50
|
if (node.test.type === 'BinaryExpression') {
|
|
61
|
-
// oxlint-disable-next-line consistent-function-scoping
|
|
62
51
|
const checkMember = (expr) => {
|
|
63
52
|
if (expr.type === 'MemberExpression' &&
|
|
64
53
|
expr.property.type === 'Identifier' &&
|