Mongoose 7
Last reviewed Sep 20, 2026
Prompt Details
Prompt Composition
4prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Node.js 22114 lines · 3.7K tokens
- TypeScript 5.940 lines · 1.2K tokens
- Mongoose 775 lines · 3.5K tokens
Total331 lines · 11.6K tokens
CWE Coverage
- 15
- 20
- 22
- 59
- 73
- 78
- 79
- 89
- 95
- 113
- 117
- 200
- 208
- 209
- 214
- 250
- 252
- 295
- 297
- 319
- 323
- 327
- 338
- 346
- 347
- 352
- 354
- 362
- 367
- 377
- 426
- 444
- 459
- 471
- 488
- 494
- 502
- 522
- 532
- 602
- 639
- 653
- 732
- 754
- 770
- 807
- 829
- 838
- 862
- 863
- 908
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1321
- 1333
Prompt Preview
Apply the Node.js 22 and TypeScript 5.9 prompts first. These rules cover Mongoose 7 and were checked against 7.8.12 with its MongoDB Node.js driver 5.9.2 dependency. The package declares Node.js >= 14.20.1; use the included maintained runtime baseline rather than treating that minimum as a deployment recommendation. Mongoose 7 is in legacy support and receives important fixes.
Schema strictness and write boundaries
- Construct allowlisted documents and update objects before calling
new Model(),doc.set(),create(),insertMany(), or update APIs. Assign tenant, owner, role, workflow, billing, discriminator, and version-key paths through authorized server code. - Reject caller-controlled
idas well as_idwherever identity must be server assigned: the built-inidvirtual in 7.8.12 has a setter that changes_id, including during construction anddoc.set(). - Set
strict: "throw"on security-sensitive schemas to reject unknown write paths; the defaultstrict: truestrips them. Separately authorize known paths, and keep operation options such asstrict,upsert, andoverwriteDiscriminatorKeyunder server control. - Use explicit nested schemas for security-relevant structures.
Mixed,Object,{}, and untyped arrays permit arbitrary content; validate any deliberately schemaless subtree separately and callmarkModified()when persisting in-place Mixed changes. - Map allowed update fields to fixed dotted paths and construct operators and
arrayFiltersin trusted code. Reject unexpected path segments, including prototype-related segments, before