eslint-plugin-secure-coding 3.4.2 → 3.4.4
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 +2 -3
- package/src/index.js +1 -134
- package/src/oxlint.js +1 -3
- package/src/rules/detect-non-literal-regexp/index.js +1 -329
- package/src/rules/detect-object-injection/index.js +1 -691
- package/src/rules/detect-weak-password-validation/index.js +1 -54
- package/src/rules/no-directive-injection/index.js +1 -416
- package/src/rules/no-electron-security-issues/index.js +1 -385
- package/src/rules/no-format-string-injection/index.js +1 -565
- package/src/rules/no-graphql-injection/index.js +1 -612
- package/src/rules/no-hardcoded-credentials/index.js +1 -658
- package/src/rules/no-hardcoded-session-tokens/index.js +1 -56
- package/src/rules/no-improper-sanitization/index.js +1 -391
- package/src/rules/no-improper-type-validation/index.js +1 -422
- package/src/rules/no-insecure-comparison/index.js +1 -249
- package/src/rules/no-ldap-injection/index.js +1 -403
- package/src/rules/no-missing-authentication/index.js +1 -282
- package/src/rules/no-pii-in-logs/index.js +1 -63
- package/src/rules/no-privilege-escalation/index.js +1 -282
- package/src/rules/no-redos-vulnerable-regex/index.js +0 -0
- package/src/rules/no-sensitive-data-exposure/index.js +1 -249
- package/src/rules/no-template-injection/index.js +1 -84
- package/src/rules/no-unchecked-loop-condition/index.js +1 -541
- package/src/rules/no-unlimited-resource-allocation/index.js +1 -554
- package/src/rules/no-unsafe-deserialization/index.js +1 -497
- package/src/rules/no-unsafe-regex-construction/index.js +1 -275
- package/src/rules/no-weak-password-recovery/index.js +1 -382
- package/src/rules/no-xpath-injection/index.js +1 -431
- package/src/rules/no-xxe-injection/index.js +1 -230
- package/src/rules/require-backend-authorization/index.js +1 -58
- package/src/rules/require-secure-defaults/index.js +1 -41
- package/src/types/index.js +1 -2
|
@@ -1,230 +1 @@
|
|
|
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
|
-
const isXmlParsingCall = (node) => {
|
|
7
|
-
const callee = node.callee;
|
|
8
|
-
if (callee.type === 'MemberExpression' &&
|
|
9
|
-
callee.property.type === 'Identifier' &&
|
|
10
|
-
['parse', 'parseFromString', 'parseString', 'parseXmlString', 'parseXML'].includes(callee.property.name)) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
if (callee.type === 'Identifier' &&
|
|
14
|
-
['DOMParser', 'XMLHttpRequest', 'ActiveXObject'].includes(callee.name)) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
return false;
|
|
18
|
-
};
|
|
19
|
-
const hasDangerousParserOptions = (optionsNode) => {
|
|
20
|
-
if (optionsNode.type !== 'ObjectExpression') {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
for (const prop of optionsNode.properties) {
|
|
24
|
-
if (prop.type === 'Property' &&
|
|
25
|
-
prop.key.type === 'Identifier' &&
|
|
26
|
-
['resolveExternals', 'expandEntityReferences', 'noent'].includes(prop.key.name)) {
|
|
27
|
-
if (prop.value.type === 'Literal' && prop.value.value === true) {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return false;
|
|
33
|
-
};
|
|
34
|
-
const containsDangerousEntities = (xmlText) => {
|
|
35
|
-
return /<!ENTITY/i.test(xmlText) &&
|
|
36
|
-
/SYSTEM\s+["']/i.test(xmlText);
|
|
37
|
-
};
|
|
38
|
-
exports.noXxeInjection = (0, eslint_devkit_1.createRule)({
|
|
39
|
-
name: 'no-xxe-injection',
|
|
40
|
-
meta: {
|
|
41
|
-
type: 'problem',
|
|
42
|
-
docs: {
|
|
43
|
-
description: 'Detect XML External Entity (XXE) injection vulnerabilities',
|
|
44
|
-
url: 'https://cwe.mitre.org/data/definitions/611.html',
|
|
45
|
-
cwe: 'CWE-611',
|
|
46
|
-
cvss: 9.1,
|
|
47
|
-
},
|
|
48
|
-
messages: {
|
|
49
|
-
xxeInjection: (0, eslint_devkit_2.formatLLMMessage)({
|
|
50
|
-
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
51
|
-
issueName: 'XXE Injection',
|
|
52
|
-
cwe: 'CWE-611',
|
|
53
|
-
description: 'XML contains dangerous entity declarations',
|
|
54
|
-
severity: 'CRITICAL',
|
|
55
|
-
fix: 'Remove SYSTEM/PUBLIC entity declarations or use safe XML parser',
|
|
56
|
-
documentationLink: 'https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing',
|
|
57
|
-
}),
|
|
58
|
-
unsafeXmlParser: (0, eslint_devkit_2.formatLLMMessage)({
|
|
59
|
-
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
60
|
-
issueName: 'Unsafe XML Parser',
|
|
61
|
-
cwe: 'CWE-611',
|
|
62
|
-
description: 'Using unsafe XML parser without secure configuration',
|
|
63
|
-
severity: 'HIGH',
|
|
64
|
-
fix: 'Use libxmljs with noent: false or xmldom with entityResolver: null',
|
|
65
|
-
documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html',
|
|
66
|
-
}),
|
|
67
|
-
externalEntityEnabled: (0, eslint_devkit_2.formatLLMMessage)({
|
|
68
|
-
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
69
|
-
issueName: 'External Entity Processing',
|
|
70
|
-
cwe: 'CWE-611',
|
|
71
|
-
description: 'External entity processing is enabled',
|
|
72
|
-
severity: 'CRITICAL',
|
|
73
|
-
fix: 'Disable external entity processing',
|
|
74
|
-
documentationLink: 'https://cwe.mitre.org/data/definitions/611.html',
|
|
75
|
-
}),
|
|
76
|
-
untrustedXmlSource: (0, eslint_devkit_2.formatLLMMessage)({
|
|
77
|
-
icon: eslint_devkit_2.MessageIcons.SECURITY,
|
|
78
|
-
issueName: 'Untrusted XML Source',
|
|
79
|
-
cwe: 'CWE-611',
|
|
80
|
-
description: 'XML from untrusted source without validation',
|
|
81
|
-
severity: 'HIGH',
|
|
82
|
-
fix: 'Validate and sanitize XML input before parsing',
|
|
83
|
-
documentationLink: 'https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html',
|
|
84
|
-
}),
|
|
85
|
-
},
|
|
86
|
-
schema: [
|
|
87
|
-
{
|
|
88
|
-
type: 'object',
|
|
89
|
-
properties: {
|
|
90
|
-
safeParserOptions: {
|
|
91
|
-
type: 'array',
|
|
92
|
-
items: { type: 'string' },
|
|
93
|
-
},
|
|
94
|
-
xmlValidationFunctions: {
|
|
95
|
-
type: 'array',
|
|
96
|
-
items: { type: 'string' },
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
defaultOptions: [
|
|
104
|
-
{
|
|
105
|
-
safeParserOptions: ['noent', 'resolveExternals', 'expandEntityReferences', 'entityResolver'],
|
|
106
|
-
xmlValidationFunctions: ['validateXml', 'sanitizeXml', 'cleanXml', 'parseXmlSafe'],
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
create(context, [options]) {
|
|
110
|
-
const { safeParserOptions = ['noent', 'resolveExternals', 'expandEntityReferences', 'entityResolver'], xmlValidationFunctions = ['validateXml', 'sanitizeXml', 'cleanXml', 'parseXmlSafe'], } = options;
|
|
111
|
-
const filename = context.filename;
|
|
112
|
-
const hasSecureParserOptions = (optionsNode) => {
|
|
113
|
-
if (optionsNode.type !== 'ObjectExpression') {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
for (const prop of optionsNode.properties) {
|
|
117
|
-
if (prop.type === 'Property' &&
|
|
118
|
-
prop.key.type === 'Identifier' &&
|
|
119
|
-
safeParserOptions.includes(prop.key.name)) {
|
|
120
|
-
if (prop.value.type === 'Literal' && prop.value.value === false) {
|
|
121
|
-
return true;
|
|
122
|
-
}
|
|
123
|
-
if (prop.value.type === 'Literal' && prop.value.value === null) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return false;
|
|
129
|
-
};
|
|
130
|
-
const isXmlInputValidated = (xmlSource) => {
|
|
131
|
-
let current = xmlSource;
|
|
132
|
-
while (current) {
|
|
133
|
-
if (current.type === 'CallExpression' &&
|
|
134
|
-
current.callee.type === 'Identifier' &&
|
|
135
|
-
xmlValidationFunctions.includes(current.callee.name)) {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
current = current.parent;
|
|
139
|
-
}
|
|
140
|
-
return false;
|
|
141
|
-
};
|
|
142
|
-
const isUntrustedXmlSource = (xmlSource) => {
|
|
143
|
-
if (xmlSource.type === 'Identifier') {
|
|
144
|
-
const varName = xmlSource.name.toLowerCase();
|
|
145
|
-
if (['clean', 'safe', 'validated', 'sanitized', 'validatedxml', 'sanitizedxml'].some(safe => varName.includes(safe))) {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
return ['req', 'request', 'body', 'query', 'params', 'input', 'xml', 'data'].some(keyword => varName.includes(keyword));
|
|
149
|
-
}
|
|
150
|
-
let current = xmlSource;
|
|
151
|
-
while (current) {
|
|
152
|
-
if (current.type === 'CallExpression' &&
|
|
153
|
-
current.callee.type === 'MemberExpression' &&
|
|
154
|
-
current.callee.property.type === 'Identifier' &&
|
|
155
|
-
['readFileSync', 'readFile', 'createReadStream'].includes(current.callee.property.name)) {
|
|
156
|
-
return true;
|
|
157
|
-
}
|
|
158
|
-
current = current.parent;
|
|
159
|
-
}
|
|
160
|
-
return false;
|
|
161
|
-
};
|
|
162
|
-
return {
|
|
163
|
-
CallExpression(node) {
|
|
164
|
-
if (!isXmlParsingCall(node)) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const args = node.arguments;
|
|
168
|
-
if (args.length === 0) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
const xmlInput = args[0];
|
|
172
|
-
const isUntrusted = isUntrustedXmlSource(xmlInput);
|
|
173
|
-
const isValidated = isXmlInputValidated(xmlInput);
|
|
174
|
-
const hasSecureOptions = args.length >= 2 && hasSecureParserOptions(args[1]);
|
|
175
|
-
if (isUntrusted && !isValidated && !hasSecureOptions) {
|
|
176
|
-
context.report({
|
|
177
|
-
node: xmlInput,
|
|
178
|
-
messageId: 'untrustedXmlSource',
|
|
179
|
-
data: {
|
|
180
|
-
filePath: filename,
|
|
181
|
-
line: String(node.loc?.start.line ?? 0),
|
|
182
|
-
},
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
if (args.length >= 2) {
|
|
186
|
-
const optionsArg = args[1];
|
|
187
|
-
if (hasDangerousParserOptions(optionsArg)) {
|
|
188
|
-
context.report({
|
|
189
|
-
node: optionsArg,
|
|
190
|
-
messageId: 'externalEntityEnabled',
|
|
191
|
-
data: {
|
|
192
|
-
filePath: filename,
|
|
193
|
-
line: String(node.loc?.start.line ?? 0),
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
NewExpression(node) {
|
|
201
|
-
const callee = node.callee;
|
|
202
|
-
if (callee.type !== 'Identifier' ||
|
|
203
|
-
!['DOMParser', 'XMLHttpRequest', 'ActiveXObject'].includes(callee.name)) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
context.report({
|
|
207
|
-
node,
|
|
208
|
-
messageId: 'unsafeXmlParser',
|
|
209
|
-
data: {
|
|
210
|
-
filePath: filename,
|
|
211
|
-
line: String(node.loc?.start.line ?? 0),
|
|
212
|
-
},
|
|
213
|
-
});
|
|
214
|
-
},
|
|
215
|
-
Literal(node) {
|
|
216
|
-
if (typeof node.value === 'string' && containsDangerousEntities(node.value)) {
|
|
217
|
-
context.report({
|
|
218
|
-
node,
|
|
219
|
-
messageId: 'xxeInjection',
|
|
220
|
-
data: {
|
|
221
|
-
filePath: filename,
|
|
222
|
-
line: String(node.loc?.start.line ?? 0),
|
|
223
|
-
safeAlternative: 'Use sanitized XML or remove entity declarations',
|
|
224
|
-
},
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
};
|
|
229
|
-
},
|
|
230
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.noXxeInjection=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");const eslint_devkit_2=require("@interlace/eslint-devkit");const isXmlParsingCall=node=>{const callee=node.callee;if(callee.type==="MemberExpression"&&callee.property.type==="Identifier"&&["parse","parseFromString","parseString","parseXmlString","parseXML"].includes(callee.property.name)){return true}if(callee.type==="Identifier"&&["DOMParser","XMLHttpRequest","ActiveXObject"].includes(callee.name)){return true}return false};const hasDangerousParserOptions=optionsNode=>{if(optionsNode.type!=="ObjectExpression"){return false}for(const prop of optionsNode.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"&&["resolveExternals","expandEntityReferences","noent"].includes(prop.key.name)){if(prop.value.type==="Literal"&&prop.value.value===true){return true}}}return false};const containsDangerousEntities=xmlText=>{return/<!ENTITY/i.test(xmlText)&&/SYSTEM\s+["']/i.test(xmlText)};exports.noXxeInjection=(0,eslint_devkit_1.createRule)({name:"no-xxe-injection",meta:{type:"problem",docs:{description:"Detect XML External Entity (XXE) injection vulnerabilities",url:"https://cwe.mitre.org/data/definitions/611.html",cwe:"CWE-611",cvss:9.1},messages:{xxeInjection:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"XXE Injection",cwe:"CWE-611",description:"XML contains dangerous entity declarations",severity:"CRITICAL",fix:"Remove SYSTEM/PUBLIC entity declarations or use safe XML parser",documentationLink:"https://owasp.org/www-community/vulnerabilities/XML_External_Entity_(XXE)_Processing"}),unsafeXmlParser:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Unsafe XML Parser",cwe:"CWE-611",description:"Using unsafe XML parser without secure configuration",severity:"HIGH",fix:"Use libxmljs with noent: false or xmldom with entityResolver: null",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html"}),externalEntityEnabled:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"External Entity Processing",cwe:"CWE-611",description:"External entity processing is enabled",severity:"CRITICAL",fix:"Disable external entity processing",documentationLink:"https://cwe.mitre.org/data/definitions/611.html"}),untrustedXmlSource:(0,eslint_devkit_2.formatLLMMessage)({icon:eslint_devkit_2.MessageIcons.SECURITY,issueName:"Untrusted XML Source",cwe:"CWE-611",description:"XML from untrusted source without validation",severity:"HIGH",fix:"Validate and sanitize XML input before parsing",documentationLink:"https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html"})},schema:[{type:"object",properties:{safeParserOptions:{type:"array",items:{type:"string"}},xmlValidationFunctions:{type:"array",items:{type:"string"}}},additionalProperties:false}]},defaultOptions:[{safeParserOptions:["noent","resolveExternals","expandEntityReferences","entityResolver"],xmlValidationFunctions:["validateXml","sanitizeXml","cleanXml","parseXmlSafe"]}],create(context,[options]){const{safeParserOptions=["noent","resolveExternals","expandEntityReferences","entityResolver"],xmlValidationFunctions=["validateXml","sanitizeXml","cleanXml","parseXmlSafe"]}=options;const filename=context.filename;const hasSecureParserOptions=optionsNode=>{if(optionsNode.type!=="ObjectExpression"){return false}for(const prop of optionsNode.properties){if(prop.type==="Property"&&prop.key.type==="Identifier"&&safeParserOptions.includes(prop.key.name)){if(prop.value.type==="Literal"&&prop.value.value===false){return true}if(prop.value.type==="Literal"&&prop.value.value===null){return true}}}return false};const isXmlInputValidated=xmlSource=>{let current=xmlSource;while(current){if(current.type==="CallExpression"&¤t.callee.type==="Identifier"&&xmlValidationFunctions.includes(current.callee.name)){return true}current=current.parent}return false};const isUntrustedXmlSource=xmlSource=>{if(xmlSource.type==="Identifier"){const varName=xmlSource.name.toLowerCase();if(["clean","safe","validated","sanitized","validatedxml","sanitizedxml"].some(safe=>varName.includes(safe))){return false}return["req","request","body","query","params","input","xml","data"].some(keyword=>varName.includes(keyword))}let current=xmlSource;while(current){if(current.type==="CallExpression"&¤t.callee.type==="MemberExpression"&¤t.callee.property.type==="Identifier"&&["readFileSync","readFile","createReadStream"].includes(current.callee.property.name)){return true}current=current.parent}return false};return{CallExpression(node){if(!isXmlParsingCall(node)){return}const args=node.arguments;if(args.length===0){return}const xmlInput=args[0];const isUntrusted=isUntrustedXmlSource(xmlInput);const isValidated=isXmlInputValidated(xmlInput);const hasSecureOptions=args.length>=2&&hasSecureParserOptions(args[1]);if(isUntrusted&&!isValidated&&!hasSecureOptions){context.report({node:xmlInput,messageId:"untrustedXmlSource",data:{filePath:filename,line:String(node.loc?.start.line??0)}})}if(args.length>=2){const optionsArg=args[1];if(hasDangerousParserOptions(optionsArg)){context.report({node:optionsArg,messageId:"externalEntityEnabled",data:{filePath:filename,line:String(node.loc?.start.line??0)}});return}}},NewExpression(node){const callee=node.callee;if(callee.type!=="Identifier"||!["DOMParser","XMLHttpRequest","ActiveXObject"].includes(callee.name)){return}context.report({node,messageId:"unsafeXmlParser",data:{filePath:filename,line:String(node.loc?.start.line??0)}})},Literal(node){if(typeof node.value==="string"&&containsDangerousEntities(node.value)){context.report({node,messageId:"xxeInjection",data:{filePath:filename,line:String(node.loc?.start.line??0),safeAlternative:"Use sanitized XML or remove entity declarations"}})}}}}});
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireBackendAuthorization = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
exports.requireBackendAuthorization = (0, eslint_devkit_1.createRule)({
|
|
6
|
-
name: 'require-backend-authorization',
|
|
7
|
-
meta: {
|
|
8
|
-
type: 'problem',
|
|
9
|
-
docs: {
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-backend-authorization.md',
|
|
11
|
-
description: 'Require server-side authorization checks',
|
|
12
|
-
cwe: 'CWE-602',
|
|
13
|
-
cvss: 6.5,
|
|
14
|
-
},
|
|
15
|
-
messages: {
|
|
16
|
-
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
17
|
-
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
18
|
-
issueName: 'Client-Side Authorization',
|
|
19
|
-
cwe: 'CWE-602',
|
|
20
|
-
description: 'Authorization logic in client code - easily bypassed',
|
|
21
|
-
severity: 'CRITICAL',
|
|
22
|
-
fix: 'Move authorization checks to server-side API endpoints',
|
|
23
|
-
documentationLink: 'https://cwe.mitre.org/data/definitions/602.html',
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
schema: [],
|
|
27
|
-
},
|
|
28
|
-
defaultOptions: [],
|
|
29
|
-
create(context) {
|
|
30
|
-
function report(node) {
|
|
31
|
-
context.report({ node, messageId: 'violationDetected' });
|
|
32
|
-
}
|
|
33
|
-
const authProperties = new Set(['role', 'isAdmin', 'isAuthenticated', 'permissions', 'admin']);
|
|
34
|
-
return {
|
|
35
|
-
IfStatement(node) {
|
|
36
|
-
if (node.test.type === 'BinaryExpression') {
|
|
37
|
-
const checkMember = (expr) => {
|
|
38
|
-
if (expr.type === 'MemberExpression' &&
|
|
39
|
-
expr.property.type === 'Identifier' &&
|
|
40
|
-
authProperties.has(expr.property.name)) {
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
45
|
-
if (checkMember(node.test.left) ||
|
|
46
|
-
checkMember(node.test.right)) {
|
|
47
|
-
report(node);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (node.test.type === 'MemberExpression' &&
|
|
51
|
-
node.test.property.type === 'Identifier' &&
|
|
52
|
-
authProperties.has(node.test.property.name)) {
|
|
53
|
-
report(node);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireBackendAuthorization=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireBackendAuthorization=(0,eslint_devkit_1.createRule)({name:"require-backend-authorization",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-backend-authorization.md",description:"Require server-side authorization checks",cwe:"CWE-602",cvss:6.5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"Client-Side Authorization",cwe:"CWE-602",description:"Authorization logic in client code - easily bypassed",severity:"CRITICAL",fix:"Move authorization checks to server-side API endpoints",documentationLink:"https://cwe.mitre.org/data/definitions/602.html"})},schema:[]},defaultOptions:[],create(context){function report(node){context.report({node,messageId:"violationDetected"})}const authProperties=new Set(["role","isAdmin","isAuthenticated","permissions","admin"]);return{IfStatement(node){if(node.test.type==="BinaryExpression"){const checkMember=expr=>{if(expr.type==="MemberExpression"&&expr.property.type==="Identifier"&&authProperties.has(expr.property.name)){return true}return false};if(checkMember(node.test.left)||checkMember(node.test.right)){report(node)}}if(node.test.type==="MemberExpression"&&node.test.property.type==="Identifier"&&authProperties.has(node.test.property.name)){report(node)}}}}});
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.requireSecureDefaults = void 0;
|
|
4
|
-
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
5
|
-
exports.requireSecureDefaults = (0, eslint_devkit_1.createRule)({
|
|
6
|
-
name: 'require-secure-defaults',
|
|
7
|
-
meta: {
|
|
8
|
-
type: 'problem',
|
|
9
|
-
docs: {
|
|
10
|
-
url: 'https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-secure-defaults.md',
|
|
11
|
-
description: 'Ensure secure default configurations',
|
|
12
|
-
cwe: 'CWE-1188',
|
|
13
|
-
cvss: 5,
|
|
14
|
-
},
|
|
15
|
-
messages: {
|
|
16
|
-
violationDetected: (0, eslint_devkit_1.formatLLMMessage)({
|
|
17
|
-
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
18
|
-
issueName: 'violation Detected',
|
|
19
|
-
cwe: 'CWE-1188',
|
|
20
|
-
description: 'Ensure secure default configurations detected - Insecure default values',
|
|
21
|
-
severity: 'MEDIUM',
|
|
22
|
-
fix: 'Review and apply secure practices',
|
|
23
|
-
documentationLink: 'https://cwe.mitre.org/data/definitions/1188.html',
|
|
24
|
-
})
|
|
25
|
-
},
|
|
26
|
-
schema: [],
|
|
27
|
-
},
|
|
28
|
-
defaultOptions: [],
|
|
29
|
-
create(context) {
|
|
30
|
-
return {
|
|
31
|
-
Property(node) {
|
|
32
|
-
if (node.key.type === 'Identifier' &&
|
|
33
|
-
['secure', 'strictSSL', 'verify'].includes(node.key.name) &&
|
|
34
|
-
node.value.type === 'Literal' &&
|
|
35
|
-
node.value.value === false) {
|
|
36
|
-
context.report({ node, messageId: 'violationDetected' });
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.requireSecureDefaults=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");exports.requireSecureDefaults=(0,eslint_devkit_1.createRule)({name:"require-secure-defaults",meta:{type:"problem",docs:{url:"https://github.com/ofri-peretz/eslint/blob/main/packages/eslint-plugin-secure-coding/docs/rules/require-secure-defaults.md",description:"Ensure secure default configurations",cwe:"CWE-1188",cvss:5},messages:{violationDetected:(0,eslint_devkit_1.formatLLMMessage)({icon:eslint_devkit_1.MessageIcons.SECURITY,issueName:"violation Detected",cwe:"CWE-1188",description:"Ensure secure default configurations detected - Insecure default values",severity:"MEDIUM",fix:"Review and apply secure practices",documentationLink:"https://cwe.mitre.org/data/definitions/1188.html"})},schema:[]},defaultOptions:[],create(context){return{Property(node){if(node.key.type==="Identifier"&&["secure","strictSSL","verify"].includes(node.key.name)&&node.value.type==="Literal"&&node.value.value===false){context.report({node,messageId:"violationDetected"})}}}}});
|
package/src/types/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});
|