eslint-plugin-secure-coding 1.0.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/AGENTS.md +196 -0
- package/CHANGELOG.md +105 -0
- package/LICENSE +23 -0
- package/README.md +377 -0
- package/package.json +80 -0
- package/src/index.d.ts +32 -0
- package/src/index.js +345 -0
- package/src/index.js.map +1 -0
- package/src/rules/security/database-injection.d.ts +13 -0
- package/src/rules/security/database-injection.js +407 -0
- package/src/rules/security/database-injection.js.map +1 -0
- package/src/rules/security/detect-child-process.d.ts +11 -0
- package/src/rules/security/detect-child-process.js +460 -0
- package/src/rules/security/detect-child-process.js.map +1 -0
- package/src/rules/security/detect-eval-with-expression.d.ts +9 -0
- package/src/rules/security/detect-eval-with-expression.js +393 -0
- package/src/rules/security/detect-eval-with-expression.js.map +1 -0
- package/src/rules/security/detect-non-literal-fs-filename.d.ts +7 -0
- package/src/rules/security/detect-non-literal-fs-filename.js +322 -0
- package/src/rules/security/detect-non-literal-fs-filename.js.map +1 -0
- package/src/rules/security/detect-non-literal-regexp.d.ts +9 -0
- package/src/rules/security/detect-non-literal-regexp.js +387 -0
- package/src/rules/security/detect-non-literal-regexp.js.map +1 -0
- package/src/rules/security/detect-object-injection.d.ts +11 -0
- package/src/rules/security/detect-object-injection.js +411 -0
- package/src/rules/security/detect-object-injection.js.map +1 -0
- package/src/rules/security/no-buffer-overread.d.ts +14 -0
- package/src/rules/security/no-buffer-overread.js +519 -0
- package/src/rules/security/no-buffer-overread.js.map +1 -0
- package/src/rules/security/no-clickjacking.d.ts +10 -0
- package/src/rules/security/no-clickjacking.js +381 -0
- package/src/rules/security/no-clickjacking.js.map +1 -0
- package/src/rules/security/no-directive-injection.d.ts +12 -0
- package/src/rules/security/no-directive-injection.js +446 -0
- package/src/rules/security/no-directive-injection.js.map +1 -0
- package/src/rules/security/no-document-cookie.d.ts +5 -0
- package/src/rules/security/no-document-cookie.js +90 -0
- package/src/rules/security/no-document-cookie.js.map +1 -0
- package/src/rules/security/no-electron-security-issues.d.ts +10 -0
- package/src/rules/security/no-electron-security-issues.js +421 -0
- package/src/rules/security/no-electron-security-issues.js.map +1 -0
- package/src/rules/security/no-exposed-sensitive-data.d.ts +11 -0
- package/src/rules/security/no-exposed-sensitive-data.js +341 -0
- package/src/rules/security/no-exposed-sensitive-data.js.map +1 -0
- package/src/rules/security/no-format-string-injection.d.ts +17 -0
- package/src/rules/security/no-format-string-injection.js +653 -0
- package/src/rules/security/no-format-string-injection.js.map +1 -0
- package/src/rules/security/no-graphql-injection.d.ts +12 -0
- package/src/rules/security/no-graphql-injection.js +410 -0
- package/src/rules/security/no-graphql-injection.js.map +1 -0
- package/src/rules/security/no-hardcoded-credentials.d.ts +26 -0
- package/src/rules/security/no-hardcoded-credentials.js +377 -0
- package/src/rules/security/no-hardcoded-credentials.js.map +1 -0
- package/src/rules/security/no-improper-sanitization.d.ts +12 -0
- package/src/rules/security/no-improper-sanitization.js +408 -0
- package/src/rules/security/no-improper-sanitization.js.map +1 -0
- package/src/rules/security/no-improper-type-validation.d.ts +10 -0
- package/src/rules/security/no-improper-type-validation.js +420 -0
- package/src/rules/security/no-improper-type-validation.js.map +1 -0
- package/src/rules/security/no-insecure-comparison.d.ts +7 -0
- package/src/rules/security/no-insecure-comparison.js +125 -0
- package/src/rules/security/no-insecure-comparison.js.map +1 -0
- package/src/rules/security/no-insecure-cookie-settings.d.ts +9 -0
- package/src/rules/security/no-insecure-cookie-settings.js +305 -0
- package/src/rules/security/no-insecure-cookie-settings.js.map +1 -0
- package/src/rules/security/no-insecure-jwt.d.ts +10 -0
- package/src/rules/security/no-insecure-jwt.js +338 -0
- package/src/rules/security/no-insecure-jwt.js.map +1 -0
- package/src/rules/security/no-insecure-redirects.d.ts +7 -0
- package/src/rules/security/no-insecure-redirects.js +215 -0
- package/src/rules/security/no-insecure-redirects.js.map +1 -0
- package/src/rules/security/no-insufficient-postmessage-validation.d.ts +14 -0
- package/src/rules/security/no-insufficient-postmessage-validation.js +390 -0
- package/src/rules/security/no-insufficient-postmessage-validation.js.map +1 -0
- package/src/rules/security/no-insufficient-random.d.ts +9 -0
- package/src/rules/security/no-insufficient-random.js +207 -0
- package/src/rules/security/no-insufficient-random.js.map +1 -0
- package/src/rules/security/no-ldap-injection.d.ts +10 -0
- package/src/rules/security/no-ldap-injection.js +449 -0
- package/src/rules/security/no-ldap-injection.js.map +1 -0
- package/src/rules/security/no-missing-authentication.d.ts +13 -0
- package/src/rules/security/no-missing-authentication.js +322 -0
- package/src/rules/security/no-missing-authentication.js.map +1 -0
- package/src/rules/security/no-missing-cors-check.d.ts +9 -0
- package/src/rules/security/no-missing-cors-check.js +449 -0
- package/src/rules/security/no-missing-cors-check.js.map +1 -0
- package/src/rules/security/no-missing-csrf-protection.d.ts +11 -0
- package/src/rules/security/no-missing-csrf-protection.js +183 -0
- package/src/rules/security/no-missing-csrf-protection.js.map +1 -0
- package/src/rules/security/no-missing-security-headers.d.ts +7 -0
- package/src/rules/security/no-missing-security-headers.js +217 -0
- package/src/rules/security/no-missing-security-headers.js.map +1 -0
- package/src/rules/security/no-privilege-escalation.d.ts +13 -0
- package/src/rules/security/no-privilege-escalation.js +321 -0
- package/src/rules/security/no-privilege-escalation.js.map +1 -0
- package/src/rules/security/no-redos-vulnerable-regex.d.ts +7 -0
- package/src/rules/security/no-redos-vulnerable-regex.js +307 -0
- package/src/rules/security/no-redos-vulnerable-regex.js.map +1 -0
- package/src/rules/security/no-sensitive-data-exposure.d.ts +11 -0
- package/src/rules/security/no-sensitive-data-exposure.js +251 -0
- package/src/rules/security/no-sensitive-data-exposure.js.map +1 -0
- package/src/rules/security/no-sql-injection.d.ts +10 -0
- package/src/rules/security/no-sql-injection.js +332 -0
- package/src/rules/security/no-sql-injection.js.map +1 -0
- package/src/rules/security/no-timing-attack.d.ts +10 -0
- package/src/rules/security/no-timing-attack.js +358 -0
- package/src/rules/security/no-timing-attack.js.map +1 -0
- package/src/rules/security/no-toctou-vulnerability.d.ts +7 -0
- package/src/rules/security/no-toctou-vulnerability.js +165 -0
- package/src/rules/security/no-toctou-vulnerability.js.map +1 -0
- package/src/rules/security/no-unchecked-loop-condition.d.ts +12 -0
- package/src/rules/security/no-unchecked-loop-condition.js +635 -0
- package/src/rules/security/no-unchecked-loop-condition.js.map +1 -0
- package/src/rules/security/no-unencrypted-transmission.d.ts +11 -0
- package/src/rules/security/no-unencrypted-transmission.js +237 -0
- package/src/rules/security/no-unencrypted-transmission.js.map +1 -0
- package/src/rules/security/no-unescaped-url-parameter.d.ts +9 -0
- package/src/rules/security/no-unescaped-url-parameter.js +266 -0
- package/src/rules/security/no-unescaped-url-parameter.js.map +1 -0
- package/src/rules/security/no-unlimited-resource-allocation.d.ts +12 -0
- package/src/rules/security/no-unlimited-resource-allocation.js +659 -0
- package/src/rules/security/no-unlimited-resource-allocation.js.map +1 -0
- package/src/rules/security/no-unsafe-deserialization.d.ts +10 -0
- package/src/rules/security/no-unsafe-deserialization.js +501 -0
- package/src/rules/security/no-unsafe-deserialization.js.map +1 -0
- package/src/rules/security/no-unsafe-dynamic-require.d.ts +5 -0
- package/src/rules/security/no-unsafe-dynamic-require.js +107 -0
- package/src/rules/security/no-unsafe-dynamic-require.js.map +1 -0
- package/src/rules/security/no-unsafe-regex-construction.d.ts +9 -0
- package/src/rules/security/no-unsafe-regex-construction.js +292 -0
- package/src/rules/security/no-unsafe-regex-construction.js.map +1 -0
- package/src/rules/security/no-unsanitized-html.d.ts +9 -0
- package/src/rules/security/no-unsanitized-html.js +347 -0
- package/src/rules/security/no-unsanitized-html.js.map +1 -0
- package/src/rules/security/no-unvalidated-user-input.d.ts +9 -0
- package/src/rules/security/no-unvalidated-user-input.js +418 -0
- package/src/rules/security/no-unvalidated-user-input.js.map +1 -0
- package/src/rules/security/no-weak-crypto.d.ts +11 -0
- package/src/rules/security/no-weak-crypto.js +350 -0
- package/src/rules/security/no-weak-crypto.js.map +1 -0
- package/src/rules/security/no-weak-password-recovery.d.ts +12 -0
- package/src/rules/security/no-weak-password-recovery.js +401 -0
- package/src/rules/security/no-weak-password-recovery.js.map +1 -0
- package/src/rules/security/no-xpath-injection.d.ts +10 -0
- package/src/rules/security/no-xpath-injection.js +487 -0
- package/src/rules/security/no-xpath-injection.js.map +1 -0
- package/src/rules/security/no-xxe-injection.d.ts +7 -0
- package/src/rules/security/no-xxe-injection.js +270 -0
- package/src/rules/security/no-xxe-injection.js.map +1 -0
- package/src/rules/security/no-zip-slip.d.ts +9 -0
- package/src/rules/security/no-zip-slip.js +446 -0
- package/src/rules/security/no-zip-slip.js.map +1 -0
- package/src/types/index.d.ts +131 -0
- package/src/types/index.js +18 -0
- package/src/types/index.js.map +1 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noXxeInjection = void 0;
|
|
4
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
+
const eslint_devkit_2 = require("@interlace/eslint-devkit");
|
|
6
|
+
exports.noXxeInjection = (0, eslint_devkit_1.createRule)({
|
|
7
|
+
name: 'no-xxe-injection',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Detect XML External Entity (XXE) injection vulnerabilities',
|
|
12
|
+
url: 'https://cwe.mitre.org/data/definitions/611.html',
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
xxeInjection: (0, eslint_devkit_2.formatLLMMessage)({
|
|
16
|
+
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
17
|
+
issueName: 'XXE Injection',
|
|
18
|
+
cwe: 'CWE-611',
|
|
19
|
+
description: 'XML contains dangerous entity declarations',
|
|
20
|
+
severity: 'CRITICAL',
|
|
21
|
+
fix: 'Remove SYSTEM/PUBLIC entity declarations or use safe XML parser',
|
|
22
|
+
documentationLink: 'https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing',
|
|
23
|
+
}),
|
|
24
|
+
unsafeXmlParser: (0, eslint_devkit_2.formatLLMMessage)({
|
|
25
|
+
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
26
|
+
issueName: 'Unsafe XML Parser',
|
|
27
|
+
cwe: 'CWE-611',
|
|
28
|
+
description: 'Using unsafe XML parser without secure configuration',
|
|
29
|
+
severity: 'HIGH',
|
|
30
|
+
fix: 'Use libxmljs with noent: false or xmldom with entityResolver: null',
|
|
31
|
+
documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html',
|
|
32
|
+
}),
|
|
33
|
+
externalEntityEnabled: (0, eslint_devkit_2.formatLLMMessage)({
|
|
34
|
+
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
35
|
+
issueName: 'External Entity Processing',
|
|
36
|
+
cwe: 'CWE-611',
|
|
37
|
+
description: 'External entity processing is enabled',
|
|
38
|
+
severity: 'CRITICAL',
|
|
39
|
+
fix: 'Disable external entity processing',
|
|
40
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/611.html',
|
|
41
|
+
}),
|
|
42
|
+
untrustedXmlSource: (0, eslint_devkit_2.formatLLMMessage)({
|
|
43
|
+
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
44
|
+
issueName: 'Untrusted XML Source',
|
|
45
|
+
cwe: 'CWE-611',
|
|
46
|
+
description: 'XML from untrusted source without validation',
|
|
47
|
+
severity: 'HIGH',
|
|
48
|
+
fix: 'Validate and sanitize XML input before parsing',
|
|
49
|
+
documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html',
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
schema: [
|
|
53
|
+
{
|
|
54
|
+
type: 'object',
|
|
55
|
+
properties: {
|
|
56
|
+
safeParserOptions: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: { type: 'string' },
|
|
59
|
+
},
|
|
60
|
+
xmlValidationFunctions: {
|
|
61
|
+
type: 'array',
|
|
62
|
+
items: { type: 'string' },
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
defaultOptions: [
|
|
70
|
+
{
|
|
71
|
+
safeParserOptions: ['noent', 'resolveExternals', 'expandEntityReferences', 'entityResolver'],
|
|
72
|
+
xmlValidationFunctions: ['validateXml', 'sanitizeXml', 'cleanXml', 'parseXmlSafe'],
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
create(context, [options]) {
|
|
76
|
+
const { safeParserOptions = ['noent', 'resolveExternals', 'expandEntityReferences', 'entityResolver'], xmlValidationFunctions = ['validateXml', 'sanitizeXml', 'cleanXml', 'parseXmlSafe'], } = options || {};
|
|
77
|
+
const filename = context.filename || context.getFilename();
|
|
78
|
+
/**
|
|
79
|
+
* Check if this is an XML parsing operation
|
|
80
|
+
*/
|
|
81
|
+
const isXmlParsingCall = (node) => {
|
|
82
|
+
const callee = node.callee;
|
|
83
|
+
// Check for XML library method calls
|
|
84
|
+
if (callee.type === 'MemberExpression' &&
|
|
85
|
+
callee.property.type === 'Identifier' &&
|
|
86
|
+
['parse', 'parseFromString', 'parseString', 'parseXmlString', 'parseXML'].includes(callee.property.name)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
// Check for constructor calls
|
|
90
|
+
if (callee.type === 'Identifier' &&
|
|
91
|
+
['DOMParser', 'XMLHttpRequest', 'ActiveXObject'].includes(callee.name)) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Check if parser options are secure
|
|
98
|
+
*/
|
|
99
|
+
const hasSecureParserOptions = (optionsNode) => {
|
|
100
|
+
if (optionsNode.type !== 'ObjectExpression') {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
// Check for secure options
|
|
104
|
+
for (const prop of optionsNode.properties) {
|
|
105
|
+
if (prop.type === 'Property' &&
|
|
106
|
+
prop.key.type === 'Identifier' &&
|
|
107
|
+
safeParserOptions.includes(prop.key.name)) {
|
|
108
|
+
// Check if the value is secure
|
|
109
|
+
if (prop.value.type === 'Literal' && prop.value.value === false) {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
if (prop.value.type === 'Literal' && prop.value.type === 'Literal' && prop.value.value === null) {
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (prop.value.type === 'Identifier' && prop.value.name === 'null') {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Check if parser options enable dangerous features
|
|
124
|
+
*/
|
|
125
|
+
const hasDangerousParserOptions = (optionsNode) => {
|
|
126
|
+
if (optionsNode.type !== 'ObjectExpression') {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
// Check for dangerous options
|
|
130
|
+
for (const prop of optionsNode.properties) {
|
|
131
|
+
if (prop.type === 'Property' &&
|
|
132
|
+
prop.key.type === 'Identifier' &&
|
|
133
|
+
['resolveExternals', 'expandEntityReferences', 'noent'].includes(prop.key.name)) {
|
|
134
|
+
// Check if the value enables dangerous features
|
|
135
|
+
if (prop.value.type === 'Literal' && prop.value.value === true) {
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return false;
|
|
141
|
+
};
|
|
142
|
+
/**
|
|
143
|
+
* Check if input has been validated
|
|
144
|
+
*/
|
|
145
|
+
const isXmlInputValidated = (xmlSource) => {
|
|
146
|
+
// Check if the input comes from a validation function
|
|
147
|
+
let current = xmlSource;
|
|
148
|
+
while (current) {
|
|
149
|
+
if (current.type === 'CallExpression' &&
|
|
150
|
+
current.callee.type === 'Identifier' &&
|
|
151
|
+
xmlValidationFunctions.includes(current.callee.name)) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
current = current.parent;
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Check if XML contains dangerous entity declarations
|
|
160
|
+
*/
|
|
161
|
+
const containsDangerousEntities = (xmlText) => {
|
|
162
|
+
return /<!ENTITY/i.test(xmlText) &&
|
|
163
|
+
/SYSTEM\s+["']/i.test(xmlText);
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Check if input source is untrusted
|
|
167
|
+
*/
|
|
168
|
+
const isUntrustedXmlSource = (xmlSource) => {
|
|
169
|
+
// Check for user input sources
|
|
170
|
+
if (xmlSource.type === 'Identifier') {
|
|
171
|
+
const varName = xmlSource.name.toLowerCase();
|
|
172
|
+
// Consider variables with safe/validated names as trusted
|
|
173
|
+
if (['clean', 'safe', 'validated', 'sanitized', 'validatedxml', 'sanitizedxml'].some(safe => varName.includes(safe))) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
return ['req', 'request', 'body', 'query', 'params', 'input', 'xml', 'data'].some(keyword => varName.includes(keyword));
|
|
177
|
+
}
|
|
178
|
+
// Check for file system reads (potentially untrusted)
|
|
179
|
+
let current = xmlSource;
|
|
180
|
+
while (current) {
|
|
181
|
+
if (current.type === 'CallExpression' &&
|
|
182
|
+
current.callee.type === 'MemberExpression' &&
|
|
183
|
+
current.callee.property.type === 'Identifier' &&
|
|
184
|
+
['readFileSync', 'readFile', 'createReadStream'].includes(current.callee.property.name)) {
|
|
185
|
+
return true; // File input is potentially untrusted
|
|
186
|
+
}
|
|
187
|
+
current = current.parent;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
};
|
|
191
|
+
return {
|
|
192
|
+
// Check XML parsing calls
|
|
193
|
+
CallExpression(node) {
|
|
194
|
+
if (!isXmlParsingCall(node)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const args = node.arguments;
|
|
198
|
+
if (args.length === 0) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
// Check XML input source
|
|
202
|
+
const xmlInput = args[0];
|
|
203
|
+
const isUntrusted = isUntrustedXmlSource(xmlInput);
|
|
204
|
+
const isValidated = isXmlInputValidated(xmlInput);
|
|
205
|
+
// Check if this parser call uses secure options
|
|
206
|
+
const hasSecureOptions = args.length >= 2 && hasSecureParserOptions(args[1]);
|
|
207
|
+
// CRITICAL: Untrusted XML input without validation (only if parser is not secure)
|
|
208
|
+
if (isUntrusted && !isValidated && !hasSecureOptions) {
|
|
209
|
+
context.report({
|
|
210
|
+
node: xmlInput,
|
|
211
|
+
messageId: 'untrustedXmlSource',
|
|
212
|
+
data: {
|
|
213
|
+
filePath: filename,
|
|
214
|
+
line: String(node.loc?.start.line ?? 0),
|
|
215
|
+
},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// Check for dangerous parser options
|
|
219
|
+
if (args.length >= 2) {
|
|
220
|
+
const optionsArg = args[1];
|
|
221
|
+
if (hasDangerousParserOptions(optionsArg)) {
|
|
222
|
+
context.report({
|
|
223
|
+
node: optionsArg,
|
|
224
|
+
messageId: 'externalEntityEnabled',
|
|
225
|
+
data: {
|
|
226
|
+
filePath: filename,
|
|
227
|
+
line: String(node.loc?.start.line ?? 0),
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
// DOMParser method safety is covered by constructor detection
|
|
233
|
+
// No need to report unsafeXmlParser for individual method calls
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
// Check XML parser constructor calls
|
|
237
|
+
NewExpression(node) {
|
|
238
|
+
const callee = node.callee;
|
|
239
|
+
if (callee.type !== 'Identifier' ||
|
|
240
|
+
!['DOMParser', 'XMLHttpRequest', 'ActiveXObject'].includes(callee.name)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
// Constructor calls for XML parsers are considered unsafe
|
|
244
|
+
context.report({
|
|
245
|
+
node,
|
|
246
|
+
messageId: 'unsafeXmlParser',
|
|
247
|
+
data: {
|
|
248
|
+
filePath: filename,
|
|
249
|
+
line: String(node.loc?.start.line ?? 0),
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
// Check for dangerous XML literals
|
|
254
|
+
Literal(node) {
|
|
255
|
+
if (typeof node.value === 'string' && containsDangerousEntities(node.value)) {
|
|
256
|
+
context.report({
|
|
257
|
+
node,
|
|
258
|
+
messageId: 'xxeInjection',
|
|
259
|
+
data: {
|
|
260
|
+
filePath: filename,
|
|
261
|
+
line: String(node.loc?.start.line ?? 0),
|
|
262
|
+
safeAlternative: 'Use sanitized XML or remove entity declarations',
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
//# sourceMappingURL=no-xxe-injection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-xxe-injection.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-secure-coding/src/rules/security/no-xxe-injection.ts"],"names":[],"mappings":";;;AAmBA,4DAAsD;AACtD,4DAA0E;AAkB7D,QAAA,cAAc,GAAG,IAAA,0BAAU,EAA0B;IAChE,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;YACzE,GAAG,EAAE,iDAAiD;SACvD;QACD,QAAQ,EAAE;YACR,YAAY,EAAE,IAAA,gCAAgB,EAAC;gBAC7B,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,eAAe;gBAC1B,GAAG,EAAE,SAAS;gBACd,WAAW,EAAE,4CAA4C;gBACzD,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,iEAAiE;gBACtE,iBAAiB,EAAE,sFAAsF;a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BAAgB,EAAE,eAAe,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC5E,OAAO;gBACT,CAAC;gBAED,0DAA0D;gBAC1D,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,iBAAiB;oBAC5B,IAAI,EAAE;wBACJ,QAAQ,EAAE,QAAQ;wBAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;qBACxC;iBACF,CAAC,CAAC;YACL,CAAC;YAED,mCAAmC;YACnC,OAAO,CAAC,IAAsB;gBAC5B,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC5E,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAE,cAAc;wBACzB,IAAI,EAAE;4BACJ,QAAQ,EAAE,QAAQ;4BAClB,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC;4BACvC,eAAe,EAAE,iDAAiD;yBACnE;qBACF,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
/** Archive extraction functions to check */
|
|
3
|
+
archiveFunctions?: string[];
|
|
4
|
+
/** Functions that safely validate archive paths */
|
|
5
|
+
pathValidationFunctions?: string[];
|
|
6
|
+
/** Safe archive extraction libraries */
|
|
7
|
+
safeLibraries?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const noZipSlip: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|