eslint-plugin-browser-security 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -133
- package/package.json +4 -3
- package/src/index.js +62 -0
- package/src/rules/detect-mixed-content/index.d.ts +12 -0
- package/src/rules/detect-mixed-content/index.js +45 -0
- package/src/rules/no-allow-arbitrary-loads/index.d.ts +12 -0
- package/src/rules/no-allow-arbitrary-loads/index.js +48 -0
- package/src/rules/no-clickjacking/index.d.ts +36 -0
- package/src/rules/no-clickjacking/index.js +401 -0
- package/src/rules/no-client-side-auth-logic/index.d.ts +12 -0
- package/src/rules/no-client-side-auth-logic/index.js +74 -0
- package/src/rules/no-cookie-auth-tokens/index.d.ts +3 -1
- package/src/rules/no-credentials-in-query-params/index.d.ts +12 -0
- package/src/rules/no-credentials-in-query-params/index.js +62 -0
- package/src/rules/no-disabled-certificate-validation/index.d.ts +12 -0
- package/src/rules/no-disabled-certificate-validation/index.js +66 -0
- package/src/rules/no-dynamic-service-worker-url/index.d.ts +3 -1
- package/src/rules/no-eval/index.d.ts +3 -1
- package/src/rules/no-filereader-innerhtml/index.d.ts +3 -1
- package/src/rules/no-http-urls/index.d.ts +17 -0
- package/src/rules/no-http-urls/index.js +119 -0
- package/src/rules/no-innerhtml/index.d.ts +3 -1
- package/src/rules/no-insecure-redirects/index.d.ts +26 -0
- package/src/rules/no-insecure-redirects/index.js +221 -0
- package/src/rules/no-insecure-websocket/index.d.ts +12 -0
- package/src/rules/no-insecure-websocket/index.js +66 -0
- package/src/rules/no-jwt-in-storage/index.d.ts +3 -1
- package/src/rules/no-missing-cors-check/index.d.ts +28 -0
- package/src/rules/no-missing-cors-check/index.js +404 -0
- package/src/rules/no-missing-csrf-protection/index.d.ts +30 -0
- package/src/rules/no-missing-csrf-protection/index.js +185 -0
- package/src/rules/no-missing-security-headers/index.d.ts +26 -0
- package/src/rules/no-missing-security-headers/index.js +223 -0
- package/src/rules/no-password-in-url/index.d.ts +12 -0
- package/src/rules/no-password-in-url/index.js +55 -0
- package/src/rules/no-permissive-cors/index.d.ts +12 -0
- package/src/rules/no-permissive-cors/index.js +74 -0
- package/src/rules/no-postmessage-innerhtml/index.d.ts +3 -1
- package/src/rules/no-postmessage-wildcard-origin/index.d.ts +3 -1
- package/src/rules/no-sensitive-cookie-js/index.d.ts +3 -1
- package/src/rules/no-sensitive-data-in-analytics/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-analytics/index.js +66 -0
- package/src/rules/no-sensitive-data-in-cache/index.d.ts +12 -0
- package/src/rules/no-sensitive-data-in-cache/index.js +53 -0
- package/src/rules/no-sensitive-indexeddb/index.d.ts +3 -1
- package/src/rules/no-sensitive-localstorage/index.d.ts +3 -1
- package/src/rules/no-sensitive-sessionstorage/index.d.ts +3 -1
- package/src/rules/no-tracking-without-consent/index.d.ts +12 -0
- package/src/rules/no-tracking-without-consent/index.js +72 -0
- package/src/rules/no-unencrypted-transmission/index.d.ts +30 -0
- package/src/rules/no-unencrypted-transmission/index.js +241 -0
- package/src/rules/no-unescaped-url-parameter/index.d.ts +28 -0
- package/src/rules/no-unescaped-url-parameter/index.js +360 -0
- package/src/rules/no-unsafe-eval-csp/index.d.ts +3 -1
- package/src/rules/no-unsafe-inline-csp/index.d.ts +3 -1
- package/src/rules/no-unvalidated-deeplinks/index.d.ts +12 -0
- package/src/rules/no-unvalidated-deeplinks/index.js +67 -0
- package/src/rules/no-websocket-eval/index.d.ts +3 -1
- package/src/rules/no-websocket-innerhtml/index.d.ts +3 -1
- package/src/rules/no-worker-message-innerhtml/index.d.ts +3 -1
- package/src/rules/require-blob-url-revocation/index.d.ts +3 -1
- package/src/rules/require-cookie-secure-attrs/index.d.ts +3 -1
- package/src/rules/require-csp-headers/index.d.ts +12 -0
- package/src/rules/require-csp-headers/index.js +69 -0
- package/src/rules/require-https-only/index.d.ts +12 -0
- package/src/rules/require-https-only/index.js +67 -0
- package/src/rules/require-mime-type-validation/index.d.ts +12 -0
- package/src/rules/require-mime-type-validation/index.js +71 -0
- package/src/rules/require-postmessage-origin-check/index.d.ts +3 -1
- package/src/rules/require-url-validation/index.d.ts +12 -0
- package/src/rules/require-url-validation/index.js +77 -0
- package/src/rules/require-websocket-wss/index.d.ts +3 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,72 @@
|
|
|
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.noTrackingWithoutConsent = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* @fileoverview Require consent before tracking
|
|
11
|
+
*/
|
|
12
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
13
|
+
exports.noTrackingWithoutConsent = (0, eslint_devkit_1.createRule)({
|
|
14
|
+
name: 'no-tracking-without-consent',
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
description: 'Require consent before analytics tracking',
|
|
19
|
+
},
|
|
20
|
+
messages: {
|
|
21
|
+
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
22
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
23
|
+
issueName: 'Tracking Without Consent',
|
|
24
|
+
cwe: 'CWE-359',
|
|
25
|
+
description: 'Analytics tracking without consent check - violates privacy regulations',
|
|
26
|
+
severity: 'MEDIUM',
|
|
27
|
+
fix: 'Wrap tracking calls in consent check: if (hasConsent) { analytics.track(...) }',
|
|
28
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/359.html',
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
schema: [],
|
|
32
|
+
},
|
|
33
|
+
defaultOptions: [],
|
|
34
|
+
create(context) {
|
|
35
|
+
function report(node) {
|
|
36
|
+
context.report({ node, messageId: 'violationDetected' });
|
|
37
|
+
}
|
|
38
|
+
function isInsideConsentCheck(node) {
|
|
39
|
+
let current = node.parent;
|
|
40
|
+
while (current) {
|
|
41
|
+
if (current.type === 'IfStatement') {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
if (current.type === 'ConditionalExpression') {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
current = current.parent;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
CallExpression(node) {
|
|
53
|
+
// Detect analytics.track() or similar
|
|
54
|
+
if (node.callee.type === 'MemberExpression' &&
|
|
55
|
+
node.callee.object.type === 'Identifier' &&
|
|
56
|
+
node.callee.object.name === 'analytics' &&
|
|
57
|
+
node.callee.property.type === 'Identifier' &&
|
|
58
|
+
['track', 'identify', 'page'].includes(node.callee.property.name)) {
|
|
59
|
+
if (!isInsideConsentCheck(node)) {
|
|
60
|
+
report(node);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Google Analytics gtag
|
|
64
|
+
if (node.callee.type === 'Identifier' && node.callee.name === 'gtag') {
|
|
65
|
+
if (!isInsideConsentCheck(node)) {
|
|
66
|
+
report(node);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
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-unencrypted-transmission
|
|
8
|
+
* Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols)
|
|
9
|
+
* CWE-319: Cleartext Transmission of Sensitive Information
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/319.html
|
|
12
|
+
* @see https://owasp.org/www-community/vulnerabilities/Insecure_Transport
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'unencryptedTransmission' | 'useHttps';
|
|
16
|
+
export interface Options {
|
|
17
|
+
/** Allow unencrypted transmission in test files. Default: false */
|
|
18
|
+
allowInTests?: boolean;
|
|
19
|
+
/** Insecure protocol patterns. Default: ['http://', 'ws://', 'ftp://', 'tcp://', 'mongodb://', 'redis://', 'mysql://'] */
|
|
20
|
+
insecureProtocols?: string[];
|
|
21
|
+
/** Secure protocol alternatives mapping. Default: { 'http://': 'https://', 'ws://': 'wss://', ... } */
|
|
22
|
+
secureAlternatives?: Record<string, string>;
|
|
23
|
+
/** Additional safe patterns to ignore. Default: [] */
|
|
24
|
+
ignorePatterns?: string[];
|
|
25
|
+
}
|
|
26
|
+
type RuleOptions = [Options?];
|
|
27
|
+
export declare const noUnencryptedTransmission: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
28
|
+
name: string;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,241 @@
|
|
|
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.noUnencryptedTransmission = void 0;
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
const eslint_devkit_2 = require("@interlace/eslint-devkit");
|
|
11
|
+
/**
|
|
12
|
+
* Default insecure protocol patterns
|
|
13
|
+
*/
|
|
14
|
+
const DEFAULT_INSECURE_PROTOCOLS = [
|
|
15
|
+
'http://',
|
|
16
|
+
'ws://',
|
|
17
|
+
'ftp://',
|
|
18
|
+
'tcp://',
|
|
19
|
+
'mongodb://',
|
|
20
|
+
'redis://',
|
|
21
|
+
'mysql://',
|
|
22
|
+
];
|
|
23
|
+
/**
|
|
24
|
+
* Secure protocol alternatives
|
|
25
|
+
*/
|
|
26
|
+
const SECURE_ALTERNATIVES = {
|
|
27
|
+
'http://': 'https://',
|
|
28
|
+
'ws://': 'wss://',
|
|
29
|
+
'ftp://': 'ftps://',
|
|
30
|
+
'tcp://': 'tls://',
|
|
31
|
+
'mongodb://': 'mongodb+srv://',
|
|
32
|
+
'redis://': 'rediss://',
|
|
33
|
+
'mysql://': 'mysqls://',
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Check if a string contains insecure protocol
|
|
37
|
+
*/
|
|
38
|
+
function containsInsecureProtocol(value, insecureProtocols, secureAlternatives) {
|
|
39
|
+
const lowerValue = value.toLowerCase();
|
|
40
|
+
for (const protocol of insecureProtocols) {
|
|
41
|
+
const lowerProtocol = protocol.toLowerCase();
|
|
42
|
+
// Check if the protocol appears in the value (as a URL scheme)
|
|
43
|
+
if (lowerValue.includes(lowerProtocol)) {
|
|
44
|
+
// Check if it's not already using the secure version
|
|
45
|
+
const secureAlternative = secureAlternatives[lowerProtocol];
|
|
46
|
+
if (secureAlternative) {
|
|
47
|
+
// Only report if secure version is not present
|
|
48
|
+
if (!lowerValue.includes(secureAlternative.toLowerCase())) {
|
|
49
|
+
return { isInsecure: true, protocol };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// No secure alternative defined, so it's insecure
|
|
54
|
+
return { isInsecure: true, protocol };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { isInsecure: false, protocol: '' };
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Check if a string matches any ignore pattern
|
|
62
|
+
*/
|
|
63
|
+
/* c8 ignore start -- ignore-pattern matching is defensive */
|
|
64
|
+
function matchesIgnorePattern(text, patterns) {
|
|
65
|
+
return patterns.some(pattern => {
|
|
66
|
+
try {
|
|
67
|
+
const regex = new RegExp(pattern, 'i');
|
|
68
|
+
return regex.test(text);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/* c8 ignore stop */
|
|
76
|
+
exports.noUnencryptedTransmission = (0, eslint_devkit_2.createRule)({
|
|
77
|
+
name: 'no-unencrypted-transmission',
|
|
78
|
+
meta: {
|
|
79
|
+
type: 'problem',
|
|
80
|
+
docs: {
|
|
81
|
+
description: 'Detects unencrypted data transmission (HTTP vs HTTPS, plain text protocols)',
|
|
82
|
+
},
|
|
83
|
+
hasSuggestions: true,
|
|
84
|
+
messages: {
|
|
85
|
+
unencryptedTransmission: (0, eslint_devkit_1.formatLLMMessage)({
|
|
86
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
87
|
+
issueName: 'Unencrypted Transmission',
|
|
88
|
+
cwe: 'CWE-319',
|
|
89
|
+
description: 'Unencrypted transmission detected: {{issue}}',
|
|
90
|
+
severity: 'HIGH',
|
|
91
|
+
fix: '{{safeAlternative}}',
|
|
92
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/319.html',
|
|
93
|
+
}),
|
|
94
|
+
useHttps: (0, eslint_devkit_1.formatLLMMessage)({
|
|
95
|
+
icon: eslint_devkit_1.MessageIcons.INFO,
|
|
96
|
+
issueName: 'Use HTTPS',
|
|
97
|
+
description: 'Use secure protocol',
|
|
98
|
+
severity: 'LOW',
|
|
99
|
+
fix: 'Replace http:// with https://',
|
|
100
|
+
documentationLink: 'https://developer.mozilla.org/en-US/docs/Web/Security/Transport_Layer_Security',
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
103
|
+
schema: [
|
|
104
|
+
{
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
allowInTests: {
|
|
108
|
+
type: 'boolean',
|
|
109
|
+
default: false,
|
|
110
|
+
description: 'Allow unencrypted transmission in test files',
|
|
111
|
+
},
|
|
112
|
+
insecureProtocols: {
|
|
113
|
+
type: 'array',
|
|
114
|
+
items: { type: 'string' },
|
|
115
|
+
default: [],
|
|
116
|
+
description: 'Insecure protocol patterns to detect',
|
|
117
|
+
},
|
|
118
|
+
secureAlternatives: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
additionalProperties: { type: 'string' },
|
|
121
|
+
default: {},
|
|
122
|
+
description: 'Mapping of insecure protocols to their secure alternatives',
|
|
123
|
+
},
|
|
124
|
+
ignorePatterns: {
|
|
125
|
+
type: 'array',
|
|
126
|
+
items: { type: 'string' },
|
|
127
|
+
default: [],
|
|
128
|
+
description: 'Additional safe patterns to ignore',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
additionalProperties: false,
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
defaultOptions: [
|
|
136
|
+
{
|
|
137
|
+
allowInTests: false,
|
|
138
|
+
insecureProtocols: [],
|
|
139
|
+
secureAlternatives: {},
|
|
140
|
+
ignorePatterns: [],
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
create(context, [options = {}]) {
|
|
144
|
+
const { allowInTests = false, insecureProtocols, secureAlternatives, ignorePatterns = [], } = options;
|
|
145
|
+
const protocolsToCheck = insecureProtocols && insecureProtocols.length > 0
|
|
146
|
+
? insecureProtocols
|
|
147
|
+
: DEFAULT_INSECURE_PROTOCOLS;
|
|
148
|
+
// Merge user-provided secure alternatives with defaults
|
|
149
|
+
const secureAlternativesToUse = secureAlternatives && Object.keys(secureAlternatives).length > 0
|
|
150
|
+
? { ...SECURE_ALTERNATIVES, ...secureAlternatives }
|
|
151
|
+
: SECURE_ALTERNATIVES;
|
|
152
|
+
const filename = context.getFilename();
|
|
153
|
+
const isTestFile = allowInTests && /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
|
|
154
|
+
const sourceCode = context.sourceCode || context.sourceCode;
|
|
155
|
+
function checkLiteral(node) {
|
|
156
|
+
if (typeof node.value !== 'string') {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const value = node.value;
|
|
160
|
+
const text = sourceCode.getText(node);
|
|
161
|
+
// Check if it matches any ignore pattern
|
|
162
|
+
if (matchesIgnorePattern(text, ignorePatterns)) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// Skip test files (allow localhost in test files)
|
|
166
|
+
if (isTestFile) {
|
|
167
|
+
// Only allow localhost URLs in test files
|
|
168
|
+
if (text.includes('localhost')) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// For other URLs in test files, still check them
|
|
172
|
+
}
|
|
173
|
+
const { isInsecure, protocol } = containsInsecureProtocol(value, protocolsToCheck, secureAlternativesToUse);
|
|
174
|
+
if (isInsecure) {
|
|
175
|
+
// Allow localhost URLs in test files
|
|
176
|
+
if (isTestFile && text.includes('localhost')) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const secureProtocol = secureAlternativesToUse[protocol.toLowerCase()] || 'secure protocol';
|
|
180
|
+
const safeAlternative = `Use ${secureProtocol} instead of ${protocol}`;
|
|
181
|
+
context.report({
|
|
182
|
+
node,
|
|
183
|
+
messageId: 'unencryptedTransmission',
|
|
184
|
+
data: {
|
|
185
|
+
issue: `using insecure protocol ${protocol}`,
|
|
186
|
+
safeAlternative,
|
|
187
|
+
},
|
|
188
|
+
suggest: [
|
|
189
|
+
{
|
|
190
|
+
messageId: 'useHttps',
|
|
191
|
+
data: {
|
|
192
|
+
protocol,
|
|
193
|
+
secureProtocol,
|
|
194
|
+
},
|
|
195
|
+
fix(fixer) {
|
|
196
|
+
if (secureProtocol && secureProtocol !== 'secure protocol') {
|
|
197
|
+
// Replace the insecure protocol with secure one
|
|
198
|
+
const newValue = value.replace(new RegExp(protocol.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'gi'), secureProtocol);
|
|
199
|
+
return fixer.replaceText(node, JSON.stringify(newValue));
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
],
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function checkTemplateLiteral(node) {
|
|
209
|
+
if (isTestFile) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const text = sourceCode.getText(node);
|
|
213
|
+
// Check if it matches any ignore pattern
|
|
214
|
+
if (matchesIgnorePattern(text, ignorePatterns)) {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
// Check each quasis (static parts) and expressions
|
|
218
|
+
for (const quasi of node.quasis) {
|
|
219
|
+
const value = quasi.value.raw;
|
|
220
|
+
const { isInsecure, protocol } = containsInsecureProtocol(value, protocolsToCheck, secureAlternativesToUse);
|
|
221
|
+
if (isInsecure) {
|
|
222
|
+
const secureProtocol = secureAlternativesToUse[protocol.toLowerCase()] || 'secure protocol';
|
|
223
|
+
const safeAlternative = `Use ${secureProtocol} instead of ${protocol}`;
|
|
224
|
+
context.report({
|
|
225
|
+
node: quasi,
|
|
226
|
+
messageId: 'unencryptedTransmission',
|
|
227
|
+
data: {
|
|
228
|
+
issue: `using insecure protocol ${protocol} in template literal`,
|
|
229
|
+
safeAlternative,
|
|
230
|
+
},
|
|
231
|
+
// Don't provide auto-fix for template literals (too risky - might break interpolation)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
Literal: checkLiteral,
|
|
238
|
+
TemplateLiteral: checkTemplateLiteral,
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
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-unescaped-url-parameter
|
|
8
|
+
* Detects unescaped URL parameters
|
|
9
|
+
* CWE-79: Cross-site Scripting (XSS)
|
|
10
|
+
*
|
|
11
|
+
* @see https://cwe.mitre.org/data/definitions/79.html
|
|
12
|
+
* @see https://owasp.org/www-community/attacks/xss/
|
|
13
|
+
*/
|
|
14
|
+
import type { TSESLint } from '@interlace/eslint-devkit';
|
|
15
|
+
type MessageIds = 'unescapedUrlParameter' | 'useEncodeURIComponent' | 'useURLSearchParams';
|
|
16
|
+
export interface Options {
|
|
17
|
+
/** Allow unescaped URL parameters in test files. Default: false */
|
|
18
|
+
allowInTests?: boolean;
|
|
19
|
+
/** Trusted URL construction libraries. Default: ['url', 'querystring'] */
|
|
20
|
+
trustedLibraries?: string[];
|
|
21
|
+
/** Additional safe patterns to ignore. Default: [] */
|
|
22
|
+
ignorePatterns?: string[];
|
|
23
|
+
}
|
|
24
|
+
type RuleOptions = [Options?];
|
|
25
|
+
export declare const noUnescapedUrlParameter: TSESLint.RuleModule<MessageIds, RuleOptions, unknown, TSESLint.RuleListener> & {
|
|
26
|
+
name: string;
|
|
27
|
+
};
|
|
28
|
+
export {};
|