eslint-plugin-mongodb-security 8.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 +181 -0
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +238 -0
- package/package.json +91 -0
- package/src/index.d.ts +32 -0
- package/src/index.js +148 -0
- package/src/index.js.map +1 -0
- package/src/rules/no-bypass-middleware/index.d.ts +5 -0
- package/src/rules/no-bypass-middleware/index.js +35 -0
- package/src/rules/no-bypass-middleware/index.js.map +1 -0
- package/src/rules/no-debug-mode-production/index.d.ts +5 -0
- package/src/rules/no-debug-mode-production/index.js +35 -0
- package/src/rules/no-debug-mode-production/index.js.map +1 -0
- package/src/rules/no-hardcoded-connection-string/index.d.ts +5 -0
- package/src/rules/no-hardcoded-connection-string/index.js +34 -0
- package/src/rules/no-hardcoded-connection-string/index.js.map +1 -0
- package/src/rules/no-hardcoded-credentials/index.d.ts +5 -0
- package/src/rules/no-hardcoded-credentials/index.js +34 -0
- package/src/rules/no-hardcoded-credentials/index.js.map +1 -0
- package/src/rules/no-operator-injection/index.d.ts +5 -0
- package/src/rules/no-operator-injection/index.js +50 -0
- package/src/rules/no-operator-injection/index.js.map +1 -0
- package/src/rules/no-select-sensitive-fields/index.d.ts +6 -0
- package/src/rules/no-select-sensitive-fields/index.js +35 -0
- package/src/rules/no-select-sensitive-fields/index.js.map +1 -0
- package/src/rules/no-unbounded-find/index.d.ts +5 -0
- package/src/rules/no-unbounded-find/index.js +35 -0
- package/src/rules/no-unbounded-find/index.js.map +1 -0
- package/src/rules/no-unsafe-populate/index.d.ts +5 -0
- package/src/rules/no-unsafe-populate/index.js +35 -0
- package/src/rules/no-unsafe-populate/index.js.map +1 -0
- package/src/rules/no-unsafe-query/index.d.ts +8 -0
- package/src/rules/no-unsafe-query/index.js +189 -0
- package/src/rules/no-unsafe-query/index.js.map +1 -0
- package/src/rules/no-unsafe-regex-query/index.d.ts +5 -0
- package/src/rules/no-unsafe-regex-query/index.js +35 -0
- package/src/rules/no-unsafe-regex-query/index.js.map +1 -0
- package/src/rules/no-unsafe-where/index.d.ts +5 -0
- package/src/rules/no-unsafe-where/index.js +50 -0
- package/src/rules/no-unsafe-where/index.js.map +1 -0
- package/src/rules/require-auth-mechanism/index.d.ts +5 -0
- package/src/rules/require-auth-mechanism/index.js +35 -0
- package/src/rules/require-auth-mechanism/index.js.map +1 -0
- package/src/rules/require-lean-queries/index.d.ts +5 -0
- package/src/rules/require-lean-queries/index.js +35 -0
- package/src/rules/require-lean-queries/index.js.map +1 -0
- package/src/rules/require-projection/index.d.ts +5 -0
- package/src/rules/require-projection/index.js +35 -0
- package/src/rules/require-projection/index.js.map +1 -0
- package/src/rules/require-schema-validation/index.d.ts +5 -0
- package/src/rules/require-schema-validation/index.js +35 -0
- package/src/rules/require-schema-validation/index.js.map +1 -0
- package/src/rules/require-tls-connection/index.d.ts +5 -0
- package/src/rules/require-tls-connection/index.js +35 -0
- package/src/rules/require-tls-connection/index.js.map +1 -0
- package/src/types/index.d.ts +48 -0
- package/src/types/index.js +13 -0
- package/src/types/index.js.map +1 -0
package/src/index.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* eslint-plugin-mongodb-security
|
|
4
|
+
*
|
|
5
|
+
* Security-focused ESLint plugin for MongoDB & Mongoose.
|
|
6
|
+
* Detects NoSQL injection, operator attacks, credential exposure,
|
|
7
|
+
* and ODM-specific vulnerabilities with AI-optimized fix guidance.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - LLM-optimized error messages with CWE references
|
|
11
|
+
* - OWASP Top 10 coverage (A01-A07)
|
|
12
|
+
* - CVE detection (CVE-2025-23061, CVE-2024-53900)
|
|
13
|
+
* - Full support for mongodb, mongoose, mongodb-client-encryption
|
|
14
|
+
*
|
|
15
|
+
* @see https://github.com/ofri-peretz/eslint/tree/main/packages/eslint-plugin-mongodb-security
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.configs = exports.plugin = exports.rules = void 0;
|
|
19
|
+
// Critical - NoSQL Injection
|
|
20
|
+
const no_unsafe_query_1 = require("./rules/no-unsafe-query");
|
|
21
|
+
const no_operator_injection_1 = require("./rules/no-operator-injection");
|
|
22
|
+
const no_unsafe_where_1 = require("./rules/no-unsafe-where");
|
|
23
|
+
const no_unsafe_regex_query_1 = require("./rules/no-unsafe-regex-query");
|
|
24
|
+
// High - Credentials & Connection
|
|
25
|
+
const no_hardcoded_connection_string_1 = require("./rules/no-hardcoded-connection-string");
|
|
26
|
+
const no_hardcoded_credentials_1 = require("./rules/no-hardcoded-credentials");
|
|
27
|
+
const require_tls_connection_1 = require("./rules/require-tls-connection");
|
|
28
|
+
const require_auth_mechanism_1 = require("./rules/require-auth-mechanism");
|
|
29
|
+
// Medium - Mongoose ODM
|
|
30
|
+
const require_schema_validation_1 = require("./rules/require-schema-validation");
|
|
31
|
+
const no_select_sensitive_fields_1 = require("./rules/no-select-sensitive-fields");
|
|
32
|
+
const no_bypass_middleware_1 = require("./rules/no-bypass-middleware");
|
|
33
|
+
const no_unsafe_populate_1 = require("./rules/no-unsafe-populate");
|
|
34
|
+
// Low - Best Practices
|
|
35
|
+
const no_unbounded_find_1 = require("./rules/no-unbounded-find");
|
|
36
|
+
const require_projection_1 = require("./rules/require-projection");
|
|
37
|
+
const require_lean_queries_1 = require("./rules/require-lean-queries");
|
|
38
|
+
const no_debug_mode_production_1 = require("./rules/no-debug-mode-production");
|
|
39
|
+
/**
|
|
40
|
+
* Collection of all MongoDB security rules
|
|
41
|
+
*/
|
|
42
|
+
exports.rules = {
|
|
43
|
+
// Critical - NoSQL Injection (OWASP A03)
|
|
44
|
+
'no-unsafe-query': no_unsafe_query_1.noUnsafeQuery,
|
|
45
|
+
'no-operator-injection': no_operator_injection_1.noOperatorInjection,
|
|
46
|
+
'no-unsafe-where': no_unsafe_where_1.noUnsafeWhere,
|
|
47
|
+
'no-unsafe-regex-query': no_unsafe_regex_query_1.noUnsafeRegexQuery,
|
|
48
|
+
// High - Credentials & Connection (OWASP A02, A07)
|
|
49
|
+
'no-hardcoded-connection-string': no_hardcoded_connection_string_1.noHardcodedConnectionString,
|
|
50
|
+
'no-hardcoded-credentials': no_hardcoded_credentials_1.noHardcodedCredentials,
|
|
51
|
+
'require-tls-connection': require_tls_connection_1.requireTlsConnection,
|
|
52
|
+
'require-auth-mechanism': require_auth_mechanism_1.requireAuthMechanism,
|
|
53
|
+
// Medium - Mongoose ODM (OWASP A01, A04)
|
|
54
|
+
'require-schema-validation': require_schema_validation_1.requireSchemaValidation,
|
|
55
|
+
'no-select-sensitive-fields': no_select_sensitive_fields_1.noSelectSensitiveFields,
|
|
56
|
+
'no-bypass-middleware': no_bypass_middleware_1.noBypassMiddleware,
|
|
57
|
+
'no-unsafe-populate': no_unsafe_populate_1.noUnsafePopulate,
|
|
58
|
+
// Low - Best Practices
|
|
59
|
+
'no-unbounded-find': no_unbounded_find_1.noUnboundedFind,
|
|
60
|
+
'require-projection': require_projection_1.requireProjection,
|
|
61
|
+
'require-lean-queries': require_lean_queries_1.requireLeanQueries,
|
|
62
|
+
'no-debug-mode-production': no_debug_mode_production_1.noDebugModeProduction,
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* ESLint Plugin object
|
|
66
|
+
*/
|
|
67
|
+
exports.plugin = {
|
|
68
|
+
meta: {
|
|
69
|
+
name: 'eslint-plugin-mongodb-security',
|
|
70
|
+
version: '1.0.0',
|
|
71
|
+
},
|
|
72
|
+
rules: exports.rules,
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Recommended rules configuration
|
|
76
|
+
*/
|
|
77
|
+
const recommendedRules = {
|
|
78
|
+
// Critical - NoSQL Injection
|
|
79
|
+
'mongodb-security/no-unsafe-query': 'error',
|
|
80
|
+
'mongodb-security/no-operator-injection': 'error',
|
|
81
|
+
'mongodb-security/no-unsafe-where': 'error',
|
|
82
|
+
'mongodb-security/no-unsafe-regex-query': 'error',
|
|
83
|
+
// High - Credentials & Connection
|
|
84
|
+
'mongodb-security/no-hardcoded-connection-string': 'error',
|
|
85
|
+
'mongodb-security/no-hardcoded-credentials': 'error',
|
|
86
|
+
'mongodb-security/require-tls-connection': 'warn',
|
|
87
|
+
'mongodb-security/require-auth-mechanism': 'warn',
|
|
88
|
+
// Medium - Mongoose ODM
|
|
89
|
+
'mongodb-security/require-schema-validation': 'warn',
|
|
90
|
+
'mongodb-security/no-select-sensitive-fields': 'warn',
|
|
91
|
+
'mongodb-security/no-bypass-middleware': 'warn',
|
|
92
|
+
'mongodb-security/no-unsafe-populate': 'error',
|
|
93
|
+
// Low - Best Practices
|
|
94
|
+
'mongodb-security/no-unbounded-find': 'warn',
|
|
95
|
+
'mongodb-security/require-projection': 'off',
|
|
96
|
+
'mongodb-security/require-lean-queries': 'off',
|
|
97
|
+
'mongodb-security/no-debug-mode-production': 'error',
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Preset configurations
|
|
101
|
+
*/
|
|
102
|
+
exports.configs = {
|
|
103
|
+
/**
|
|
104
|
+
* Recommended configuration
|
|
105
|
+
* Critical rules as errors, high as warnings
|
|
106
|
+
*/
|
|
107
|
+
recommended: {
|
|
108
|
+
plugins: {
|
|
109
|
+
'mongodb-security': exports.plugin,
|
|
110
|
+
},
|
|
111
|
+
rules: recommendedRules,
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* Strict configuration
|
|
115
|
+
* All rules as errors
|
|
116
|
+
*/
|
|
117
|
+
strict: {
|
|
118
|
+
plugins: {
|
|
119
|
+
'mongodb-security': exports.plugin,
|
|
120
|
+
},
|
|
121
|
+
rules: Object.fromEntries(Object.keys(exports.rules).map((ruleName) => [`mongodb-security/${ruleName}`, 'error'])),
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Mongoose-focused configuration
|
|
125
|
+
* ODM-specific rules for Mongoose projects
|
|
126
|
+
*/
|
|
127
|
+
mongoose: {
|
|
128
|
+
plugins: {
|
|
129
|
+
'mongodb-security': exports.plugin,
|
|
130
|
+
},
|
|
131
|
+
rules: {
|
|
132
|
+
'mongodb-security/no-unsafe-query': 'error',
|
|
133
|
+
'mongodb-security/no-operator-injection': 'error',
|
|
134
|
+
'mongodb-security/no-unsafe-where': 'error',
|
|
135
|
+
'mongodb-security/require-schema-validation': 'error',
|
|
136
|
+
'mongodb-security/no-select-sensitive-fields': 'error',
|
|
137
|
+
'mongodb-security/no-bypass-middleware': 'error',
|
|
138
|
+
'mongodb-security/no-unsafe-populate': 'error',
|
|
139
|
+
'mongodb-security/require-lean-queries': 'warn',
|
|
140
|
+
'mongodb-security/no-debug-mode-production': 'error',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Default export for ESLint plugin
|
|
146
|
+
*/
|
|
147
|
+
exports.default = exports.plugin;
|
|
148
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/eslint-plugin-mongodb-security/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAIH,6BAA6B;AAC7B,6DAAwD;AACxD,yEAAoE;AACpE,6DAAwD;AACxD,yEAAmE;AAEnE,kCAAkC;AAClC,2FAAqF;AACrF,+EAA0E;AAC1E,2EAAsE;AACtE,2EAAsE;AAEtE,wBAAwB;AACxB,iFAA4E;AAC5E,mFAA6E;AAC7E,uEAAkE;AAClE,mEAA8D;AAE9D,uBAAuB;AACvB,iEAA4D;AAC5D,mEAA+D;AAC/D,uEAAkE;AAClE,+EAAyE;AAEzE;;GAEG;AACU,QAAA,KAAK,GAAoE;IACpF,yCAAyC;IACzC,iBAAiB,EAAE,+BAAa;IAChC,uBAAuB,EAAE,2CAAmB;IAC5C,iBAAiB,EAAE,+BAAa;IAChC,uBAAuB,EAAE,0CAAkB;IAE3C,mDAAmD;IACnD,gCAAgC,EAAE,4DAA2B;IAC7D,0BAA0B,EAAE,iDAAsB;IAClD,wBAAwB,EAAE,6CAAoB;IAC9C,wBAAwB,EAAE,6CAAoB;IAE9C,yCAAyC;IACzC,2BAA2B,EAAE,mDAAuB;IACpD,4BAA4B,EAAE,oDAAuB;IACrD,sBAAsB,EAAE,yCAAkB;IAC1C,oBAAoB,EAAE,qCAAgB;IAEtC,uBAAuB;IACvB,mBAAmB,EAAE,mCAAe;IACpC,oBAAoB,EAAE,sCAAiB;IACvC,sBAAsB,EAAE,yCAAkB;IAC1C,0BAA0B,EAAE,gDAAqB;CACwB,CAAC;AAE5E;;GAEG;AACU,QAAA,MAAM,GAA+B;IAChD,IAAI,EAAE;QACJ,IAAI,EAAE,gCAAgC;QACtC,OAAO,EAAE,OAAO;KACjB;IACD,KAAK,EAAL,aAAK;CAC+B,CAAC;AAEvC;;GAEG;AACH,MAAM,gBAAgB,GAAkD;IACtE,6BAA6B;IAC7B,kCAAkC,EAAE,OAAO;IAC3C,wCAAwC,EAAE,OAAO;IACjD,kCAAkC,EAAE,OAAO;IAC3C,wCAAwC,EAAE,OAAO;IAEjD,kCAAkC;IAClC,iDAAiD,EAAE,OAAO;IAC1D,2CAA2C,EAAE,OAAO;IACpD,yCAAyC,EAAE,MAAM;IACjD,yCAAyC,EAAE,MAAM;IAEjD,wBAAwB;IACxB,4CAA4C,EAAE,MAAM;IACpD,6CAA6C,EAAE,MAAM;IACrD,uCAAuC,EAAE,MAAM;IAC/C,qCAAqC,EAAE,OAAO;IAE9C,uBAAuB;IACvB,oCAAoC,EAAE,MAAM;IAC5C,qCAAqC,EAAE,KAAK;IAC5C,uCAAuC,EAAE,KAAK;IAC9C,2CAA2C,EAAE,OAAO;CACrD,CAAC;AAEF;;GAEG;AACU,QAAA,OAAO,GAA+C;IACjE;;;OAGG;IACH,WAAW,EAAE;QACX,OAAO,EAAE;YACP,kBAAkB,EAAE,cAAM;SAC3B;QACD,KAAK,EAAE,gBAAgB;KACa;IAEtC;;;OAGG;IACH,MAAM,EAAE;QACN,OAAO,EAAE;YACP,kBAAkB,EAAE,cAAM;SAC3B;QACD,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,IAAI,CAAC,aAAK,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,oBAAoB,QAAQ,EAAE,EAAE,OAAO,CAAC,CAAC,CAChF;KACmC;IAEtC;;;OAGG;IACH,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,kBAAkB,EAAE,cAAM;SAC3B;QACD,KAAK,EAAE;YACL,kCAAkC,EAAE,OAAO;YAC3C,wCAAwC,EAAE,OAAO;YACjD,kCAAkC,EAAE,OAAO;YAC3C,4CAA4C,EAAE,OAAO;YACrD,6CAA6C,EAAE,OAAO;YACtD,uCAAuC,EAAE,OAAO;YAChD,qCAAqC,EAAE,OAAO;YAC9C,uCAAuC,EAAE,MAAM;YAC/C,2CAA2C,EAAE,OAAO;SACrD;KACmC;CACvC,CAAC;AAEF;;GAEG;AACH,kBAAe,cAAM,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noBypassMiddleware = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-bypass-middleware
|
|
6
|
+
* Prevents bypassing Mongoose middleware
|
|
7
|
+
* CWE-284: Improper Access Control
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noBypassMiddleware = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-bypass-middleware',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'suggestion',
|
|
14
|
+
docs: { description: 'Prevent bypassing Mongoose pre/post middleware hooks' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
bypassMiddleware: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.INFO,
|
|
19
|
+
issueName: 'Middleware Bypass',
|
|
20
|
+
cwe: 'CWE-284',
|
|
21
|
+
owasp: 'A01:2021',
|
|
22
|
+
cvss: 5.3,
|
|
23
|
+
description: 'This method bypasses Mongoose middleware hooks',
|
|
24
|
+
severity: 'MEDIUM',
|
|
25
|
+
fix: 'Use findOne + save() pattern to ensure middleware runs',
|
|
26
|
+
documentationLink: 'https://mongoosejs.com/docs/middleware.html',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
30
|
+
},
|
|
31
|
+
defaultOptions: [{ allowInTests: true }],
|
|
32
|
+
create() { return {}; },
|
|
33
|
+
});
|
|
34
|
+
exports.default = exports.noBypassMiddleware;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-bypass-middleware/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,kBAAkB,GAAG,IAAA,0BAAU,EAA0B;IACpE,IAAI,EAAE,sBAAsB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC7E,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,gBAAgB,EAAE,IAAA,gCAAgB,EAAC;gBACjC,IAAI,EAAE,4BAAY,CAAC,IAAI;gBACvB,SAAS,EAAE,mBAAmB;gBAC9B,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,gDAAgD;gBAC7D,QAAQ,EAAE,QAAQ;gBAClB,GAAG,EAAE,wDAAwD;gBAC7D,iBAAiB,EAAE,6CAA6C;aACjE,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,0BAAkB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noDebugModeProduction = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-debug-mode-production
|
|
6
|
+
* Prevents Mongoose debug mode in production
|
|
7
|
+
* CWE-489: Active Debug Code
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noDebugModeProduction = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-debug-mode-production',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: { description: 'Prevent Mongoose debug mode in production' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
debugModeProduction: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
19
|
+
issueName: 'Debug Mode in Production',
|
|
20
|
+
cwe: 'CWE-489',
|
|
21
|
+
owasp: 'A05:2021',
|
|
22
|
+
cvss: 3.1,
|
|
23
|
+
description: 'mongoose.set("debug", true) exposes query details in production',
|
|
24
|
+
severity: 'LOW',
|
|
25
|
+
fix: 'Use mongoose.set("debug", process.env.NODE_ENV !== "production")',
|
|
26
|
+
documentationLink: 'https://mongoosejs.com/docs/api/mongoose.html#Mongoose.prototype.set()',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
30
|
+
},
|
|
31
|
+
defaultOptions: [{ allowInTests: true }],
|
|
32
|
+
create() { return {}; },
|
|
33
|
+
});
|
|
34
|
+
exports.default = exports.noDebugModeProduction;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-debug-mode-production/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,qBAAqB,GAAG,IAAA,0BAAU,EAA0B;IACvE,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE;QAClE,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,mBAAmB,EAAE,IAAA,gCAAgB,EAAC;gBACpC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,0BAA0B;gBACrC,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,iEAAiE;gBAC9E,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,kEAAkE;gBACvE,iBAAiB,EAAE,wEAAwE;aAC5F,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,6BAAqB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noHardcodedConnectionString = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-hardcoded-connection-string
|
|
6
|
+
* Detects hardcoded MongoDB connection strings with credentials
|
|
7
|
+
* CWE-798: Hardcoded Credentials
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noHardcodedConnectionString = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-hardcoded-connection-string',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: { description: 'Prevent hardcoded MongoDB connection strings with credentials' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
hardcodedConnectionString: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
19
|
+
issueName: 'Hardcoded Connection String',
|
|
20
|
+
cwe: 'CWE-798',
|
|
21
|
+
cvss: 7.5,
|
|
22
|
+
description: 'MongoDB connection string contains hardcoded credentials',
|
|
23
|
+
severity: 'HIGH',
|
|
24
|
+
fix: 'Use process.env.MONGODB_URI instead of hardcoded connection strings',
|
|
25
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/798.html',
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
29
|
+
},
|
|
30
|
+
defaultOptions: [{ allowInTests: true }],
|
|
31
|
+
create() { return {}; },
|
|
32
|
+
});
|
|
33
|
+
exports.default = exports.noHardcodedConnectionString;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-hardcoded-connection-string/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,2BAA2B,GAAG,IAAA,0BAAU,EAA0B;IAC7E,IAAI,EAAE,gCAAgC;IACtC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,+DAA+D,EAAE;QACtF,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,yBAAyB,EAAE,IAAA,gCAAgB,EAAC;gBAC1C,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,6BAA6B;gBACxC,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,0DAA0D;gBACvE,QAAQ,EAAE,MAAM;gBAChB,GAAG,EAAE,qEAAqE;gBAC1E,iBAAiB,EAAE,iDAAiD;aACrE,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,mCAA2B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noHardcodedCredentials = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-hardcoded-credentials
|
|
6
|
+
* Detects hardcoded MongoDB auth credentials
|
|
7
|
+
* CWE-798: Hardcoded Credentials
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noHardcodedCredentials = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-hardcoded-credentials',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: { description: 'Prevent hardcoded MongoDB authentication credentials' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
hardcodedCredentials: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
19
|
+
issueName: 'Hardcoded Credentials',
|
|
20
|
+
cwe: 'CWE-798',
|
|
21
|
+
cvss: 7.5,
|
|
22
|
+
description: 'MongoDB authentication credentials are hardcoded',
|
|
23
|
+
severity: 'HIGH',
|
|
24
|
+
fix: 'Use environment variables for username and password',
|
|
25
|
+
documentationLink: 'https://cwe.mitre.org/data/definitions/798.html',
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
29
|
+
},
|
|
30
|
+
defaultOptions: [{ allowInTests: true }],
|
|
31
|
+
create() { return {}; },
|
|
32
|
+
});
|
|
33
|
+
exports.default = exports.noHardcodedCredentials;
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-hardcoded-credentials/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,sBAAsB,GAAG,IAAA,0BAAU,EAA0B;IACxE,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC7E,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,oBAAoB,EAAE,IAAA,gCAAgB,EAAC;gBACrC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,uBAAuB;gBAClC,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,kDAAkD;gBAC/D,QAAQ,EAAE,MAAM;gBAChB,GAAG,EAAE,qDAAqD;gBAC1D,iBAAiB,EAAE,iDAAiD;aACrE,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,8BAAsB,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noOperatorInjection = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-operator-injection
|
|
6
|
+
* Detects potential operator injection attacks ($ne, $gt, $lt, etc.)
|
|
7
|
+
* CWE-943: NoSQL Injection
|
|
8
|
+
*
|
|
9
|
+
* @see https://cwe.mitre.org/data/definitions/943.html
|
|
10
|
+
*/
|
|
11
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
12
|
+
exports.noOperatorInjection = (0, eslint_devkit_1.createRule)({
|
|
13
|
+
name: 'no-operator-injection',
|
|
14
|
+
meta: {
|
|
15
|
+
type: 'problem',
|
|
16
|
+
docs: {
|
|
17
|
+
description: 'Prevent MongoDB operator injection attacks via user input',
|
|
18
|
+
},
|
|
19
|
+
hasSuggestions: true,
|
|
20
|
+
messages: {
|
|
21
|
+
operatorInjection: (0, eslint_devkit_1.formatLLMMessage)({
|
|
22
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
23
|
+
issueName: 'MongoDB Operator Injection',
|
|
24
|
+
cwe: 'CWE-943',
|
|
25
|
+
owasp: 'A03:2021',
|
|
26
|
+
cvss: 9.1,
|
|
27
|
+
description: 'User input may contain MongoDB operators like { $ne: null } to bypass filters',
|
|
28
|
+
severity: 'CRITICAL',
|
|
29
|
+
fix: 'Use { field: { $eq: value } } pattern to prevent operator injection',
|
|
30
|
+
documentationLink: 'https://owasp.org/www-project-web-security-testing-guide/latest/4-Web_Application_Security_Testing/07-Input_Validation_Testing/05.6-Testing_for_NoSQL_Injection',
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
33
|
+
schema: [
|
|
34
|
+
{
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
allowInTests: { type: 'boolean', default: true },
|
|
38
|
+
},
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
defaultOptions: [{ allowInTests: true }],
|
|
44
|
+
create() {
|
|
45
|
+
// TODO: Implement rule logic
|
|
46
|
+
return {};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
exports.default = exports.noOperatorInjection;
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-operator-injection/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,4DAIkC;AAUrB,QAAA,mBAAmB,GAAG,IAAA,0BAAU,EAA0B;IACrE,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE;YACJ,WAAW,EAAE,2DAA2D;SACzE;QACD,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,iBAAiB,EAAE,IAAA,gCAAgB,EAAC;gBAClC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,4BAA4B;gBACvC,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,+EAA+E;gBAC5F,QAAQ,EAAE,UAAU;gBACpB,GAAG,EAAE,qEAAqE;gBAC1E,iBAAiB,EAAE,iKAAiK;aACrL,CAAC;SACH;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;iBACjD;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;KACF;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM;QACJ,6BAA6B;QAC7B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC;AAEH,kBAAe,2BAAmB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noSelectSensitiveFields = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-select-sensitive-fields
|
|
6
|
+
* Prevents returning sensitive fields like password
|
|
7
|
+
* CWE-200: Information Exposure
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noSelectSensitiveFields = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-select-sensitive-fields',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: { description: 'Prevent returning sensitive fields like password in queries' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
selectSensitiveFields: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
19
|
+
issueName: 'Sensitive Field Exposure',
|
|
20
|
+
cwe: 'CWE-200',
|
|
21
|
+
owasp: 'A01:2021',
|
|
22
|
+
cvss: 5.3,
|
|
23
|
+
description: 'Query may return sensitive fields like password or token',
|
|
24
|
+
severity: 'MEDIUM',
|
|
25
|
+
fix: 'Add .select("-password -refreshToken") to exclude sensitive fields',
|
|
26
|
+
documentationLink: 'https://mongoosejs.com/docs/api/query.html#Query.prototype.select()',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true }, sensitiveFields: { type: 'array', items: { type: 'string' } } }, additionalProperties: false }],
|
|
30
|
+
},
|
|
31
|
+
defaultOptions: [{ allowInTests: true, sensitiveFields: ['password', 'refreshToken', 'apiKey', 'secret'] }],
|
|
32
|
+
create() { return {}; },
|
|
33
|
+
});
|
|
34
|
+
exports.default = exports.noSelectSensitiveFields;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-select-sensitive-fields/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,uBAAuB,GAAG,IAAA,0BAAU,EAA0B;IACzE,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,6DAA6D,EAAE;QACpF,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,qBAAqB,EAAE,IAAA,gCAAgB,EAAC;gBACtC,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,0BAA0B;gBACrC,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,0DAA0D;gBACvE,QAAQ,EAAE,QAAQ;gBAClB,GAAG,EAAE,oEAAoE;gBACzE,iBAAiB,EAAE,qEAAqE;aACzF,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC3L;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC;IAC3G,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,+BAAuB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noUnboundedFind = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-unbounded-find
|
|
6
|
+
* Requires limit() on find queries
|
|
7
|
+
* CWE-400: Resource Exhaustion
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noUnboundedFind = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-unbounded-find',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'suggestion',
|
|
14
|
+
docs: { description: 'Require limit() on find queries to prevent resource exhaustion' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
unboundedFind: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.INFO,
|
|
19
|
+
issueName: 'Unbounded Query',
|
|
20
|
+
cwe: 'CWE-400',
|
|
21
|
+
owasp: 'A04:2021',
|
|
22
|
+
cvss: 4.3,
|
|
23
|
+
description: 'find() without limit() may return excessive data',
|
|
24
|
+
severity: 'LOW',
|
|
25
|
+
fix: 'Add .limit(100) or appropriate limit to the query',
|
|
26
|
+
documentationLink: 'https://www.mongodb.com/docs/manual/reference/method/cursor.limit/',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
30
|
+
},
|
|
31
|
+
defaultOptions: [{ allowInTests: true }],
|
|
32
|
+
create() { return {}; },
|
|
33
|
+
});
|
|
34
|
+
exports.default = exports.noUnboundedFind;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-unbounded-find/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,eAAe,GAAG,IAAA,0BAAU,EAA0B;IACjE,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,gEAAgE,EAAE;QACvF,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,aAAa,EAAE,IAAA,gCAAgB,EAAC;gBAC9B,IAAI,EAAE,4BAAY,CAAC,IAAI;gBACvB,SAAS,EAAE,iBAAiB;gBAC5B,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,kDAAkD;gBAC/D,QAAQ,EAAE,KAAK;gBACf,GAAG,EAAE,mDAAmD;gBACxD,iBAAiB,EAAE,oEAAoE;aACxF,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,uBAAe,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noUnsafePopulate = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ESLint Rule: no-unsafe-populate
|
|
6
|
+
* Prevents user-controlled populate() (CVE-2025-23061 related)
|
|
7
|
+
* CWE-943: NoSQL Injection
|
|
8
|
+
*/
|
|
9
|
+
const eslint_devkit_1 = require("@interlace/eslint-devkit");
|
|
10
|
+
exports.noUnsafePopulate = (0, eslint_devkit_1.createRule)({
|
|
11
|
+
name: 'no-unsafe-populate',
|
|
12
|
+
meta: {
|
|
13
|
+
type: 'problem',
|
|
14
|
+
docs: { description: 'Prevent user-controlled populate() paths (CVE-2025-23061)' },
|
|
15
|
+
hasSuggestions: true,
|
|
16
|
+
messages: {
|
|
17
|
+
unsafePopulate: (0, eslint_devkit_1.formatLLMMessage)({
|
|
18
|
+
icon: eslint_devkit_1.MessageIcons.SECURITY,
|
|
19
|
+
issueName: 'Unsafe populate()',
|
|
20
|
+
cwe: 'CWE-943',
|
|
21
|
+
owasp: 'A03:2021',
|
|
22
|
+
cvss: 6.5,
|
|
23
|
+
description: 'User-controlled populate() can lead to data exposure or injection',
|
|
24
|
+
severity: 'MEDIUM',
|
|
25
|
+
fix: 'Use hardcoded populate paths instead of user input',
|
|
26
|
+
documentationLink: 'https://nvd.nist.gov/vuln/detail/CVE-2025-23061',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
schema: [{ type: 'object', properties: { allowInTests: { type: 'boolean', default: true } }, additionalProperties: false }],
|
|
30
|
+
},
|
|
31
|
+
defaultOptions: [{ allowInTests: true }],
|
|
32
|
+
create() { return {}; },
|
|
33
|
+
});
|
|
34
|
+
exports.default = exports.noUnsafePopulate;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/eslint-plugin-mongodb-security/src/rules/no-unsafe-populate/index.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACH,4DAAsF;AAMzE,QAAA,gBAAgB,GAAG,IAAA,0BAAU,EAA0B;IAClE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,EAAE,WAAW,EAAE,2DAA2D,EAAE;QAClF,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE;YACR,cAAc,EAAE,IAAA,gCAAgB,EAAC;gBAC/B,IAAI,EAAE,4BAAY,CAAC,QAAQ;gBAC3B,SAAS,EAAE,mBAAmB;gBAC9B,GAAG,EAAE,SAAS;gBACd,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,mEAAmE;gBAChF,QAAQ,EAAE,QAAQ;gBAClB,GAAG,EAAE,oDAAoD;gBACzD,iBAAiB,EAAE,iDAAiD;aACrE,CAAC;SACH;QACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;KAC5H;IACD,cAAc,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC;CACxB,CAAC,CAAC;AAEH,kBAAe,wBAAgB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Options {
|
|
2
|
+
/** Allow in test files. Default: true */
|
|
3
|
+
allowInTests?: boolean;
|
|
4
|
+
/** Additional method names to check. Default: [] */
|
|
5
|
+
additionalMethods?: string[];
|
|
6
|
+
}
|
|
7
|
+
export declare const noUnsafeQuery: ESLintUtils.RuleModule<MessageIds, Options, unknown, ESLintUtils.RuleListener>;
|
|
8
|
+
export default noUnsafeQuery;
|