-
Notifications
You must be signed in to change notification settings - Fork 2.1k
docs(recipes): add upload scanning recipe with pompelmi #3398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||
| ### Scan uploaded files with Pompelmi | ||||||
|
|
||||||
| Nest's built-in file upload support makes it straightforward to accept files with `FileInterceptor()` and validate basic constraints such as file size or MIME type. | ||||||
|
|
||||||
| For applications that accept untrusted uploads from users, you may also want to inspect the uploaded file contents before storing or further processing them. This can help catch cases such as spoofed file metadata or suspicious file structures. | ||||||
|
|
||||||
| One way to do that is with [Pompelmi](https://github.com/pompelmi/pompelmi), an open-source file upload scanning library for Node.js. | ||||||
|
|
||||||
| #### Installation | ||||||
|
|
||||||
| ```bash | ||||||
| npm install pompelmi @pompelmi/nestjs-integration multer | ||||||
|
||||||
| npm install pompelmi @pompelmi/nestjs-integration multer | |
| npm install pompelmi multer |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Express is typically used as a TypeScript namespace for Express.Multer.File and generally shouldn’t be imported as a named export from express (it may not exist as a runtime/named export depending on TS/module settings). Prefer removing this import and using the global Express namespace, or make it a type-only import that is valid for the project’s TS configuration.
| import { Express } from 'express'; |
Copilot
AI
Mar 30, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using memoryStorage() without demonstrating/mentioning Multer limits (especially fileSize) can enable memory exhaustion (DoS) if a large upload reaches this endpoint. Consider adding a limits: { fileSize: ... } example here (or an explicit note near this snippet) to ensure scanning-in-memory is paired with a strict size cap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This recipe starts with an H3 heading (
###). If recipes are expected to have a single top-level title for correct page structure/ToC (commonly#), consider promoting this to the appropriate top-level heading to keep rendering consistent across recipes.