@strapi/upload 5.30.1 → 5.31.1

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.
Files changed (45) hide show
  1. package/dist/admin/ai/components/AIUploadModal.js +8 -1
  2. package/dist/admin/ai/components/AIUploadModal.js.map +1 -1
  3. package/dist/admin/ai/components/AIUploadModal.mjs +9 -2
  4. package/dist/admin/ai/components/AIUploadModal.mjs.map +1 -1
  5. package/dist/admin/components/BulkMoveDialog/BulkMoveDialog.js +2 -2
  6. package/dist/admin/components/BulkMoveDialog/BulkMoveDialog.js.map +1 -1
  7. package/dist/admin/components/BulkMoveDialog/BulkMoveDialog.mjs +2 -2
  8. package/dist/admin/components/BulkMoveDialog/BulkMoveDialog.mjs.map +1 -1
  9. package/dist/admin/components/MediaLibraryInput/Carousel/CarouselAssets.js +6 -1
  10. package/dist/admin/components/MediaLibraryInput/Carousel/CarouselAssets.js.map +1 -1
  11. package/dist/admin/components/MediaLibraryInput/Carousel/CarouselAssets.mjs +6 -1
  12. package/dist/admin/components/MediaLibraryInput/Carousel/CarouselAssets.mjs.map +1 -1
  13. package/dist/admin/components/MediaLibraryInput/MediaLibraryInput.js +4 -0
  14. package/dist/admin/components/MediaLibraryInput/MediaLibraryInput.js.map +1 -1
  15. package/dist/admin/components/MediaLibraryInput/MediaLibraryInput.mjs +4 -0
  16. package/dist/admin/components/MediaLibraryInput/MediaLibraryInput.mjs.map +1 -1
  17. package/dist/admin/components/TableList/TableRows.js +3 -0
  18. package/dist/admin/components/TableList/TableRows.js.map +1 -1
  19. package/dist/admin/components/TableList/TableRows.mjs +3 -0
  20. package/dist/admin/components/TableList/TableRows.mjs.map +1 -1
  21. package/dist/admin/package.json.js +7 -6
  22. package/dist/admin/package.json.js.map +1 -1
  23. package/dist/admin/package.json.mjs +7 -6
  24. package/dist/admin/package.json.mjs.map +1 -1
  25. package/dist/admin/src/components/MediaLibraryInput/Carousel/CarouselAssets.d.ts +1 -0
  26. package/dist/admin/translations/fr.json.js +8 -8
  27. package/dist/admin/translations/fr.json.mjs +8 -8
  28. package/dist/server/controllers/admin-upload.js +37 -5
  29. package/dist/server/controllers/admin-upload.js.map +1 -1
  30. package/dist/server/controllers/admin-upload.mjs +37 -5
  31. package/dist/server/controllers/admin-upload.mjs.map +1 -1
  32. package/dist/server/services/image-manipulation.js +1 -1
  33. package/dist/server/services/image-manipulation.js.map +1 -1
  34. package/dist/server/services/image-manipulation.mjs +1 -1
  35. package/dist/server/services/image-manipulation.mjs.map +1 -1
  36. package/dist/server/src/controllers/admin-upload.d.ts.map +1 -1
  37. package/dist/server/src/types.d.ts +1 -0
  38. package/dist/server/src/types.d.ts.map +1 -1
  39. package/dist/server/src/utils/mime-validation.d.ts +34 -0
  40. package/dist/server/src/utils/mime-validation.d.ts.map +1 -0
  41. package/dist/server/utils/mime-validation.js +222 -0
  42. package/dist/server/utils/mime-validation.js.map +1 -0
  43. package/dist/server/utils/mime-validation.mjs +215 -0
  44. package/dist/server/utils/mime-validation.mjs.map +1 -0
  45. package/package.json +7 -6
@@ -0,0 +1,222 @@
1
+ 'use strict';
2
+
3
+ var promises = require('node:fs/promises');
4
+ var utils = require('@strapi/utils');
5
+
6
+ async function readFileChunk(filePath, chunkSize = 4100) {
7
+ const buffer = await promises.readFile(filePath);
8
+ return buffer.length > chunkSize ? buffer.subarray(0, chunkSize) : buffer;
9
+ }
10
+ async function detectMimeType(file) {
11
+ let buffer;
12
+ const filePath = file.path || file.filepath || file.tempFilePath;
13
+ if (filePath) {
14
+ try {
15
+ buffer = await readFileChunk(filePath, 4100);
16
+ } catch (error) {
17
+ throw new Error(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
18
+ }
19
+ } else if (file.buffer) {
20
+ buffer = file.buffer.length > 4100 ? file.buffer.subarray(0, 4100) : file.buffer;
21
+ } else {
22
+ // No file data available
23
+ return undefined;
24
+ }
25
+ try {
26
+ /**
27
+ * Use dynamic import to support file-type which is ESM-only
28
+ * Static imports fail during CommonJS build since bundler can't transform ESM-only packages
29
+ * @see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
30
+ */ const { fileTypeFromBuffer } = await import('file-type');
31
+ const result = await fileTypeFromBuffer(new Uint8Array(buffer));
32
+ return result?.mime;
33
+ } catch (error) {
34
+ throw new Error(`Failed to detect MIME type: ${error instanceof Error ? error.message : String(error)}`);
35
+ }
36
+ }
37
+ function matchesMimePattern(mimeType, patterns) {
38
+ if (!patterns?.length) return false;
39
+ return patterns.some((pattern)=>{
40
+ const normalizedPattern = pattern.toLowerCase();
41
+ const normalizedMimeType = mimeType.toLowerCase();
42
+ if (normalizedPattern.includes('*')) {
43
+ const regexPattern = normalizedPattern.replace(/\*/g, '.*');
44
+ const regex = new RegExp(`^${regexPattern}$`);
45
+ const matches = regex.test(normalizedMimeType);
46
+ return matches;
47
+ }
48
+ const exactMatch = normalizedPattern === normalizedMimeType;
49
+ return exactMatch;
50
+ });
51
+ }
52
+ function isMimeTypeAllowed(mimeType, config) {
53
+ const { allowedTypes, deniedTypes } = config;
54
+ if (!mimeType) return false;
55
+ if (deniedTypes?.length && matchesMimePattern(mimeType, deniedTypes)) {
56
+ return false;
57
+ }
58
+ if (allowedTypes?.length) {
59
+ return matchesMimePattern(mimeType, allowedTypes);
60
+ }
61
+ return true;
62
+ }
63
+ function extractFileInfo(file) {
64
+ const fileName = file.originalFilename || file.name || file.filename || file.newFilename || 'unknown';
65
+ const declaredMimeType = file.mimetype || file.type || file.mimeType || file.mime || '';
66
+ return {
67
+ fileName,
68
+ declaredMimeType
69
+ };
70
+ }
71
+ async function validateFile(file, config, strapi) {
72
+ const { allowedTypes, deniedTypes } = config;
73
+ if (!allowedTypes && !deniedTypes) {
74
+ return {
75
+ isValid: true
76
+ };
77
+ }
78
+ const { fileName, declaredMimeType } = extractFileInfo(file);
79
+ let detectedMime;
80
+ let mimeDetectionFailed = false;
81
+ try {
82
+ detectedMime = await detectMimeType(file);
83
+ } catch (error) {
84
+ mimeDetectionFailed = true;
85
+ strapi.log.warn('Failed to detect MIME type from file', {
86
+ fileName,
87
+ error: error instanceof Error ? error.message : String(error)
88
+ });
89
+ }
90
+ const mimeToValidate = detectedMime || declaredMimeType;
91
+ if (!detectedMime && (declaredMimeType === 'application/octet-stream' || !declaredMimeType || mimeDetectionFailed)) {
92
+ if (allowedTypes?.length || deniedTypes?.length) {
93
+ return {
94
+ isValid: false,
95
+ error: {
96
+ code: 'MIME_TYPE_NOT_ALLOWED',
97
+ message: `Cannot verify file type for security reasons`,
98
+ details: {
99
+ fileName,
100
+ reason: 'Unable to detect MIME type from file content',
101
+ declaredType: declaredMimeType,
102
+ mimeDetectionFailed
103
+ }
104
+ }
105
+ };
106
+ }
107
+ }
108
+ if (mimeToValidate && (allowedTypes || deniedTypes) && !isMimeTypeAllowed(mimeToValidate, config)) {
109
+ return {
110
+ isValid: false,
111
+ error: {
112
+ code: 'MIME_TYPE_NOT_ALLOWED',
113
+ message: `File type '${mimeToValidate}' is not allowed`,
114
+ details: {
115
+ fileName,
116
+ detectedType: detectedMime,
117
+ declaredType: declaredMimeType,
118
+ finalType: mimeToValidate,
119
+ allowedTypes,
120
+ deniedTypes
121
+ }
122
+ }
123
+ };
124
+ }
125
+ return {
126
+ isValid: true
127
+ };
128
+ }
129
+ async function validateFiles(files, strapi) {
130
+ const filesArray = Array.isArray(files) ? files : [
131
+ files
132
+ ];
133
+ if (!filesArray.length) {
134
+ return [];
135
+ }
136
+ const config = strapi.config.get('plugin::upload.security', {});
137
+ if (config.allowedTypes && (!Array.isArray(config.allowedTypes) || !config.allowedTypes.every((item)=>typeof item === 'string'))) {
138
+ throw new utils.errors.ApplicationError('Invalid configuration: allowedTypes must be an array of strings.');
139
+ }
140
+ if (config.deniedTypes && (!Array.isArray(config.deniedTypes) || !config.deniedTypes.every((item)=>typeof item === 'string'))) {
141
+ throw new utils.errors.ApplicationError('Invalid configuration: deniedTypes must be an array of strings.');
142
+ }
143
+ if (!config.allowedTypes && !config.deniedTypes) {
144
+ strapi.log.warn('No upload security configuration found. Consider configuring plugin.upload.security for enhanced file validation.');
145
+ return filesArray.map(()=>({
146
+ isValid: true
147
+ }));
148
+ }
149
+ const validationPromises = filesArray.map(async (file, index)=>{
150
+ try {
151
+ return await validateFile(file, config, strapi);
152
+ } catch (error) {
153
+ strapi.log.error('Unexpected error during file validation', {
154
+ fileIndex: index,
155
+ fileName: file?.name || file?.originalname,
156
+ error: error instanceof Error ? error.message : String(error)
157
+ });
158
+ return {
159
+ isValid: false,
160
+ error: {
161
+ code: 'VALIDATION_ERROR',
162
+ message: `Validation failed for file at index ${index}`,
163
+ details: {
164
+ index,
165
+ fileName: file?.name || file?.originalname,
166
+ originalError: error instanceof Error ? error.message : String(error)
167
+ }
168
+ }
169
+ };
170
+ }
171
+ });
172
+ return Promise.all(validationPromises);
173
+ }
174
+ async function enforceUploadSecurity(files, strapi) {
175
+ const validationResults = await validateFiles(files, strapi);
176
+ const filesArray = Array.isArray(files) ? files : [
177
+ files
178
+ ];
179
+ const validFiles = [];
180
+ const validFileNames = [];
181
+ const errors = [];
182
+ for (const [index, result] of validationResults.entries()){
183
+ if (result.isValid) {
184
+ const file = filesArray[index];
185
+ validFiles.push(file);
186
+ validFileNames.push(file.originalFilename || file.name);
187
+ } else if (result.error) {
188
+ errors.push({
189
+ file: filesArray[index],
190
+ originalIndex: index,
191
+ error: result.error
192
+ });
193
+ } else {
194
+ // Handle case where validation failed but no error details are provided
195
+ errors.push({
196
+ file: filesArray[index],
197
+ originalIndex: index,
198
+ error: {
199
+ code: 'UNKNOWN_ERROR',
200
+ message: 'File validation failed for unknown reason',
201
+ details: {
202
+ index,
203
+ fileName: filesArray[index]?.name || filesArray[index]?.originalname
204
+ }
205
+ }
206
+ });
207
+ }
208
+ }
209
+ return {
210
+ validFiles,
211
+ validFileNames,
212
+ errors
213
+ };
214
+ }
215
+
216
+ exports.detectMimeType = detectMimeType;
217
+ exports.enforceUploadSecurity = enforceUploadSecurity;
218
+ exports.extractFileInfo = extractFileInfo;
219
+ exports.isMimeTypeAllowed = isMimeTypeAllowed;
220
+ exports.validateFile = validateFile;
221
+ exports.validateFiles = validateFiles;
222
+ //# sourceMappingURL=mime-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime-validation.js","sources":["../../../server/src/utils/mime-validation.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\nimport { errors } from '@strapi/utils';\n\nexport type SecurityConfig = {\n allowedTypes?: string[];\n deniedTypes?: string[];\n};\ntype UploadValidationError = {\n code: 'MIME_TYPE_NOT_ALLOWED' | 'VALIDATION_ERROR' | 'UNKNOWN_ERROR';\n message: string;\n details: Record<string, any>;\n};\n\ntype ValidationResult = {\n isValid: boolean;\n error?: UploadValidationError;\n};\n\ntype ErrorDetail = {\n file: any;\n originalIndex: number;\n error: UploadValidationError;\n};\n\nasync function readFileChunk(filePath: string, chunkSize: number = 4100): Promise<Buffer> {\n const buffer = await readFile(filePath);\n return buffer.length > chunkSize ? buffer.subarray(0, chunkSize) : buffer;\n}\n\nexport async function detectMimeType(file: any): Promise<string | undefined> {\n let buffer: Buffer;\n\n const filePath = file.path || file.filepath || file.tempFilePath;\n\n if (filePath) {\n try {\n buffer = await readFileChunk(filePath, 4100);\n } catch (error) {\n throw new Error(\n `Failed to read file: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n } else if (file.buffer) {\n buffer = file.buffer.length > 4100 ? file.buffer.subarray(0, 4100) : file.buffer;\n } else {\n // No file data available\n return undefined;\n }\n\n try {\n /**\n * Use dynamic import to support file-type which is ESM-only\n * Static imports fail during CommonJS build since bundler can't transform ESM-only packages\n * @see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n */\n const { fileTypeFromBuffer } = await import('file-type');\n\n const result = await fileTypeFromBuffer(new Uint8Array(buffer));\n return result?.mime;\n } catch (error) {\n throw new Error(\n `Failed to detect MIME type: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\nfunction matchesMimePattern(mimeType: string, patterns: string[]): boolean {\n if (!patterns?.length) return false;\n\n return patterns.some((pattern) => {\n const normalizedPattern = pattern.toLowerCase();\n const normalizedMimeType = mimeType.toLowerCase();\n\n if (normalizedPattern.includes('*')) {\n const regexPattern = normalizedPattern.replace(/\\*/g, '.*');\n\n const regex = new RegExp(`^${regexPattern}$`);\n const matches = regex.test(normalizedMimeType);\n return matches;\n }\n\n const exactMatch = normalizedPattern === normalizedMimeType;\n return exactMatch;\n });\n}\n\nexport function isMimeTypeAllowed(mimeType: string, config: SecurityConfig): boolean {\n const { allowedTypes, deniedTypes } = config;\n\n if (!mimeType) return false;\n\n if (deniedTypes?.length && matchesMimePattern(mimeType, deniedTypes)) {\n return false;\n }\n\n if (allowedTypes?.length) {\n return matchesMimePattern(mimeType, allowedTypes);\n }\n\n return true;\n}\n\nexport function extractFileInfo(file: any) {\n const fileName =\n file.originalFilename || file.name || file.filename || file.newFilename || 'unknown';\n const declaredMimeType = file.mimetype || file.type || file.mimeType || file.mime || '';\n\n return { fileName, declaredMimeType };\n}\n\nexport async function validateFile(\n file: any,\n config: SecurityConfig,\n strapi: Core.Strapi\n): Promise<ValidationResult> {\n const { allowedTypes, deniedTypes } = config;\n\n if (!allowedTypes && !deniedTypes) {\n return { isValid: true };\n }\n\n const { fileName, declaredMimeType } = extractFileInfo(file);\n\n let detectedMime: string | undefined;\n let mimeDetectionFailed = false;\n\n try {\n detectedMime = await detectMimeType(file);\n } catch (error) {\n mimeDetectionFailed = true;\n strapi.log.warn('Failed to detect MIME type from file', {\n fileName,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n const mimeToValidate = detectedMime || declaredMimeType;\n\n if (\n !detectedMime &&\n (declaredMimeType === 'application/octet-stream' || !declaredMimeType || mimeDetectionFailed)\n ) {\n if (allowedTypes?.length || deniedTypes?.length) {\n return {\n isValid: false,\n error: {\n code: 'MIME_TYPE_NOT_ALLOWED',\n message: `Cannot verify file type for security reasons`,\n details: {\n fileName,\n reason: 'Unable to detect MIME type from file content',\n declaredType: declaredMimeType,\n mimeDetectionFailed,\n },\n },\n };\n }\n }\n\n if (\n mimeToValidate &&\n (allowedTypes || deniedTypes) &&\n !isMimeTypeAllowed(mimeToValidate, config)\n ) {\n return {\n isValid: false,\n error: {\n code: 'MIME_TYPE_NOT_ALLOWED',\n message: `File type '${mimeToValidate}' is not allowed`,\n details: {\n fileName,\n detectedType: detectedMime,\n declaredType: declaredMimeType,\n finalType: mimeToValidate,\n allowedTypes,\n deniedTypes,\n },\n },\n };\n }\n\n return { isValid: true };\n}\n\nexport async function validateFiles(files: any, strapi: Core.Strapi): Promise<ValidationResult[]> {\n const filesArray = Array.isArray(files) ? files : [files];\n\n if (!filesArray.length) {\n return [];\n }\n\n const config: SecurityConfig = strapi.config.get('plugin::upload.security', {});\n if (\n config.allowedTypes &&\n (!Array.isArray(config.allowedTypes) ||\n !config.allowedTypes.every((item) => typeof item === 'string'))\n ) {\n throw new errors.ApplicationError(\n 'Invalid configuration: allowedTypes must be an array of strings.'\n );\n }\n\n if (\n config.deniedTypes &&\n (!Array.isArray(config.deniedTypes) ||\n !config.deniedTypes.every((item) => typeof item === 'string'))\n ) {\n throw new errors.ApplicationError(\n 'Invalid configuration: deniedTypes must be an array of strings.'\n );\n }\n\n if (!config.allowedTypes && !config.deniedTypes) {\n strapi.log.warn(\n 'No upload security configuration found. Consider configuring plugin.upload.security for enhanced file validation.'\n );\n return filesArray.map(() => ({ isValid: true }));\n }\n\n const validationPromises = filesArray.map(async (file, index) => {\n try {\n return await validateFile(file, config, strapi);\n } catch (error) {\n strapi.log.error('Unexpected error during file validation', {\n fileIndex: index,\n fileName: file?.name || file?.originalname,\n error: error instanceof Error ? error.message : String(error),\n });\n\n return {\n isValid: false,\n error: {\n code: 'VALIDATION_ERROR' as const,\n message: `Validation failed for file at index ${index}`,\n details: {\n index,\n fileName: file?.name || file?.originalname,\n originalError: error instanceof Error ? error.message : String(error),\n },\n },\n };\n }\n });\n\n return Promise.all(validationPromises);\n}\n\nexport async function enforceUploadSecurity(\n files: any,\n strapi: Core.Strapi\n): Promise<{\n validFiles: any[];\n validFileNames: string[];\n errors: Array<ErrorDetail>;\n}> {\n const validationResults = await validateFiles(files, strapi);\n const filesArray = Array.isArray(files) ? files : [files];\n\n const validFiles: any[] = [];\n const validFileNames: string[] = [];\n const errors: Array<ErrorDetail> = [];\n\n for (const [index, result] of validationResults.entries()) {\n if (result.isValid) {\n const file = filesArray[index];\n validFiles.push(file);\n validFileNames.push(file.originalFilename || file.name);\n } else if (result.error) {\n errors.push({\n file: filesArray[index],\n originalIndex: index,\n error: result.error,\n });\n } else {\n // Handle case where validation failed but no error details are provided\n errors.push({\n file: filesArray[index],\n originalIndex: index,\n error: {\n code: 'UNKNOWN_ERROR' as const,\n message: 'File validation failed for unknown reason',\n details: {\n index,\n fileName: filesArray[index]?.name || filesArray[index]?.originalname,\n },\n },\n });\n }\n }\n\n return { validFiles, validFileNames, errors };\n}\n"],"names":["readFileChunk","filePath","chunkSize","buffer","readFile","length","subarray","detectMimeType","file","path","filepath","tempFilePath","error","Error","message","String","undefined","fileTypeFromBuffer","result","Uint8Array","mime","matchesMimePattern","mimeType","patterns","some","pattern","normalizedPattern","toLowerCase","normalizedMimeType","includes","regexPattern","replace","regex","RegExp","matches","test","exactMatch","isMimeTypeAllowed","config","allowedTypes","deniedTypes","extractFileInfo","fileName","originalFilename","name","filename","newFilename","declaredMimeType","mimetype","type","validateFile","strapi","isValid","detectedMime","mimeDetectionFailed","log","warn","mimeToValidate","code","details","reason","declaredType","detectedType","finalType","validateFiles","files","filesArray","Array","isArray","get","every","item","errors","ApplicationError","map","validationPromises","index","fileIndex","originalname","originalError","Promise","all","enforceUploadSecurity","validationResults","validFiles","validFileNames","entries","push","originalIndex"],"mappings":";;;;;AAyBA,eAAeA,aAAcC,CAAAA,QAAgB,EAAEC,SAAAA,GAAoB,IAAI,EAAA;IACrE,MAAMC,MAAAA,GAAS,MAAMC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AAKmC,gBAAgB,IAAInC,KAAKoC,IAAI,CAAA;SACjD,MAAA,IAAI1B,MAAON,CAAAA,KAAK,EAAE;AACvB4D,YAAAA,MAAAA,CAAOe,IAAI,CAAC;gBACV/E,IAAM0D,EAAAA,UAAU,CAACU,KAAM,CAAA;gBACvBY,aAAeZ,EAAAA,KAAAA;AACfhE,gBAAAA,KAAAA,EAAOM,OAAON;AAChB,aAAA,CAAA;SACK,MAAA;;AAEL4D,YAAAA,MAAAA,CAAOe,IAAI,CAAC;gBACV/E,IAAM0D,EAAAA,UAAU,CAACU,KAAM,CAAA;gBACvBY,aAAeZ,EAAAA,KAAAA;gBACfhE,KAAO,EAAA;oBACL8C,IAAM,EAAA,eAAA;oBACN5C,OAAS,EAAA,2CAAA;oBACT6C,OAAS,EAAA;AACPiB,wBAAAA,KAAAA;wBACAlC,QAAUwB,EAAAA,UAAU,CAACU,KAAM,CAAA,EAAEhC,QAAQsB,UAAU,CAACU,MAAM,EAAEE;AAC1D;AACF;AACF,aAAA,CAAA;AACF;AACF;IAEA,OAAO;AAAEM,QAAAA,UAAAA;AAAYC,QAAAA,cAAAA;AAAgBb,QAAAA;AAAO,KAAA;AAC9C;;;;;;;;;"}
@@ -0,0 +1,215 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { errors } from '@strapi/utils';
3
+
4
+ async function readFileChunk(filePath, chunkSize = 4100) {
5
+ const buffer = await readFile(filePath);
6
+ return buffer.length > chunkSize ? buffer.subarray(0, chunkSize) : buffer;
7
+ }
8
+ async function detectMimeType(file) {
9
+ let buffer;
10
+ const filePath = file.path || file.filepath || file.tempFilePath;
11
+ if (filePath) {
12
+ try {
13
+ buffer = await readFileChunk(filePath, 4100);
14
+ } catch (error) {
15
+ throw new Error(`Failed to read file: ${error instanceof Error ? error.message : String(error)}`);
16
+ }
17
+ } else if (file.buffer) {
18
+ buffer = file.buffer.length > 4100 ? file.buffer.subarray(0, 4100) : file.buffer;
19
+ } else {
20
+ // No file data available
21
+ return undefined;
22
+ }
23
+ try {
24
+ /**
25
+ * Use dynamic import to support file-type which is ESM-only
26
+ * Static imports fail during CommonJS build since bundler can't transform ESM-only packages
27
+ * @see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
28
+ */ const { fileTypeFromBuffer } = await import('file-type');
29
+ const result = await fileTypeFromBuffer(new Uint8Array(buffer));
30
+ return result?.mime;
31
+ } catch (error) {
32
+ throw new Error(`Failed to detect MIME type: ${error instanceof Error ? error.message : String(error)}`);
33
+ }
34
+ }
35
+ function matchesMimePattern(mimeType, patterns) {
36
+ if (!patterns?.length) return false;
37
+ return patterns.some((pattern)=>{
38
+ const normalizedPattern = pattern.toLowerCase();
39
+ const normalizedMimeType = mimeType.toLowerCase();
40
+ if (normalizedPattern.includes('*')) {
41
+ const regexPattern = normalizedPattern.replace(/\*/g, '.*');
42
+ const regex = new RegExp(`^${regexPattern}$`);
43
+ const matches = regex.test(normalizedMimeType);
44
+ return matches;
45
+ }
46
+ const exactMatch = normalizedPattern === normalizedMimeType;
47
+ return exactMatch;
48
+ });
49
+ }
50
+ function isMimeTypeAllowed(mimeType, config) {
51
+ const { allowedTypes, deniedTypes } = config;
52
+ if (!mimeType) return false;
53
+ if (deniedTypes?.length && matchesMimePattern(mimeType, deniedTypes)) {
54
+ return false;
55
+ }
56
+ if (allowedTypes?.length) {
57
+ return matchesMimePattern(mimeType, allowedTypes);
58
+ }
59
+ return true;
60
+ }
61
+ function extractFileInfo(file) {
62
+ const fileName = file.originalFilename || file.name || file.filename || file.newFilename || 'unknown';
63
+ const declaredMimeType = file.mimetype || file.type || file.mimeType || file.mime || '';
64
+ return {
65
+ fileName,
66
+ declaredMimeType
67
+ };
68
+ }
69
+ async function validateFile(file, config, strapi) {
70
+ const { allowedTypes, deniedTypes } = config;
71
+ if (!allowedTypes && !deniedTypes) {
72
+ return {
73
+ isValid: true
74
+ };
75
+ }
76
+ const { fileName, declaredMimeType } = extractFileInfo(file);
77
+ let detectedMime;
78
+ let mimeDetectionFailed = false;
79
+ try {
80
+ detectedMime = await detectMimeType(file);
81
+ } catch (error) {
82
+ mimeDetectionFailed = true;
83
+ strapi.log.warn('Failed to detect MIME type from file', {
84
+ fileName,
85
+ error: error instanceof Error ? error.message : String(error)
86
+ });
87
+ }
88
+ const mimeToValidate = detectedMime || declaredMimeType;
89
+ if (!detectedMime && (declaredMimeType === 'application/octet-stream' || !declaredMimeType || mimeDetectionFailed)) {
90
+ if (allowedTypes?.length || deniedTypes?.length) {
91
+ return {
92
+ isValid: false,
93
+ error: {
94
+ code: 'MIME_TYPE_NOT_ALLOWED',
95
+ message: `Cannot verify file type for security reasons`,
96
+ details: {
97
+ fileName,
98
+ reason: 'Unable to detect MIME type from file content',
99
+ declaredType: declaredMimeType,
100
+ mimeDetectionFailed
101
+ }
102
+ }
103
+ };
104
+ }
105
+ }
106
+ if (mimeToValidate && (allowedTypes || deniedTypes) && !isMimeTypeAllowed(mimeToValidate, config)) {
107
+ return {
108
+ isValid: false,
109
+ error: {
110
+ code: 'MIME_TYPE_NOT_ALLOWED',
111
+ message: `File type '${mimeToValidate}' is not allowed`,
112
+ details: {
113
+ fileName,
114
+ detectedType: detectedMime,
115
+ declaredType: declaredMimeType,
116
+ finalType: mimeToValidate,
117
+ allowedTypes,
118
+ deniedTypes
119
+ }
120
+ }
121
+ };
122
+ }
123
+ return {
124
+ isValid: true
125
+ };
126
+ }
127
+ async function validateFiles(files, strapi) {
128
+ const filesArray = Array.isArray(files) ? files : [
129
+ files
130
+ ];
131
+ if (!filesArray.length) {
132
+ return [];
133
+ }
134
+ const config = strapi.config.get('plugin::upload.security', {});
135
+ if (config.allowedTypes && (!Array.isArray(config.allowedTypes) || !config.allowedTypes.every((item)=>typeof item === 'string'))) {
136
+ throw new errors.ApplicationError('Invalid configuration: allowedTypes must be an array of strings.');
137
+ }
138
+ if (config.deniedTypes && (!Array.isArray(config.deniedTypes) || !config.deniedTypes.every((item)=>typeof item === 'string'))) {
139
+ throw new errors.ApplicationError('Invalid configuration: deniedTypes must be an array of strings.');
140
+ }
141
+ if (!config.allowedTypes && !config.deniedTypes) {
142
+ strapi.log.warn('No upload security configuration found. Consider configuring plugin.upload.security for enhanced file validation.');
143
+ return filesArray.map(()=>({
144
+ isValid: true
145
+ }));
146
+ }
147
+ const validationPromises = filesArray.map(async (file, index)=>{
148
+ try {
149
+ return await validateFile(file, config, strapi);
150
+ } catch (error) {
151
+ strapi.log.error('Unexpected error during file validation', {
152
+ fileIndex: index,
153
+ fileName: file?.name || file?.originalname,
154
+ error: error instanceof Error ? error.message : String(error)
155
+ });
156
+ return {
157
+ isValid: false,
158
+ error: {
159
+ code: 'VALIDATION_ERROR',
160
+ message: `Validation failed for file at index ${index}`,
161
+ details: {
162
+ index,
163
+ fileName: file?.name || file?.originalname,
164
+ originalError: error instanceof Error ? error.message : String(error)
165
+ }
166
+ }
167
+ };
168
+ }
169
+ });
170
+ return Promise.all(validationPromises);
171
+ }
172
+ async function enforceUploadSecurity(files, strapi) {
173
+ const validationResults = await validateFiles(files, strapi);
174
+ const filesArray = Array.isArray(files) ? files : [
175
+ files
176
+ ];
177
+ const validFiles = [];
178
+ const validFileNames = [];
179
+ const errors = [];
180
+ for (const [index, result] of validationResults.entries()){
181
+ if (result.isValid) {
182
+ const file = filesArray[index];
183
+ validFiles.push(file);
184
+ validFileNames.push(file.originalFilename || file.name);
185
+ } else if (result.error) {
186
+ errors.push({
187
+ file: filesArray[index],
188
+ originalIndex: index,
189
+ error: result.error
190
+ });
191
+ } else {
192
+ // Handle case where validation failed but no error details are provided
193
+ errors.push({
194
+ file: filesArray[index],
195
+ originalIndex: index,
196
+ error: {
197
+ code: 'UNKNOWN_ERROR',
198
+ message: 'File validation failed for unknown reason',
199
+ details: {
200
+ index,
201
+ fileName: filesArray[index]?.name || filesArray[index]?.originalname
202
+ }
203
+ }
204
+ });
205
+ }
206
+ }
207
+ return {
208
+ validFiles,
209
+ validFileNames,
210
+ errors
211
+ };
212
+ }
213
+
214
+ export { detectMimeType, enforceUploadSecurity, extractFileInfo, isMimeTypeAllowed, validateFile, validateFiles };
215
+ //# sourceMappingURL=mime-validation.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mime-validation.mjs","sources":["../../../server/src/utils/mime-validation.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\nimport { errors } from '@strapi/utils';\n\nexport type SecurityConfig = {\n allowedTypes?: string[];\n deniedTypes?: string[];\n};\ntype UploadValidationError = {\n code: 'MIME_TYPE_NOT_ALLOWED' | 'VALIDATION_ERROR' | 'UNKNOWN_ERROR';\n message: string;\n details: Record<string, any>;\n};\n\ntype ValidationResult = {\n isValid: boolean;\n error?: UploadValidationError;\n};\n\ntype ErrorDetail = {\n file: any;\n originalIndex: number;\n error: UploadValidationError;\n};\n\nasync function readFileChunk(filePath: string, chunkSize: number = 4100): Promise<Buffer> {\n const buffer = await readFile(filePath);\n return buffer.length > chunkSize ? buffer.subarray(0, chunkSize) : buffer;\n}\n\nexport async function detectMimeType(file: any): Promise<string | undefined> {\n let buffer: Buffer;\n\n const filePath = file.path || file.filepath || file.tempFilePath;\n\n if (filePath) {\n try {\n buffer = await readFileChunk(filePath, 4100);\n } catch (error) {\n throw new Error(\n `Failed to read file: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n } else if (file.buffer) {\n buffer = file.buffer.length > 4100 ? file.buffer.subarray(0, 4100) : file.buffer;\n } else {\n // No file data available\n return undefined;\n }\n\n try {\n /**\n * Use dynamic import to support file-type which is ESM-only\n * Static imports fail during CommonJS build since bundler can't transform ESM-only packages\n * @see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n */\n const { fileTypeFromBuffer } = await import('file-type');\n\n const result = await fileTypeFromBuffer(new Uint8Array(buffer));\n return result?.mime;\n } catch (error) {\n throw new Error(\n `Failed to detect MIME type: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n}\n\nfunction matchesMimePattern(mimeType: string, patterns: string[]): boolean {\n if (!patterns?.length) return false;\n\n return patterns.some((pattern) => {\n const normalizedPattern = pattern.toLowerCase();\n const normalizedMimeType = mimeType.toLowerCase();\n\n if (normalizedPattern.includes('*')) {\n const regexPattern = normalizedPattern.replace(/\\*/g, '.*');\n\n const regex = new RegExp(`^${regexPattern}$`);\n const matches = regex.test(normalizedMimeType);\n return matches;\n }\n\n const exactMatch = normalizedPattern === normalizedMimeType;\n return exactMatch;\n });\n}\n\nexport function isMimeTypeAllowed(mimeType: string, config: SecurityConfig): boolean {\n const { allowedTypes, deniedTypes } = config;\n\n if (!mimeType) return false;\n\n if (deniedTypes?.length && matchesMimePattern(mimeType, deniedTypes)) {\n return false;\n }\n\n if (allowedTypes?.length) {\n return matchesMimePattern(mimeType, allowedTypes);\n }\n\n return true;\n}\n\nexport function extractFileInfo(file: any) {\n const fileName =\n file.originalFilename || file.name || file.filename || file.newFilename || 'unknown';\n const declaredMimeType = file.mimetype || file.type || file.mimeType || file.mime || '';\n\n return { fileName, declaredMimeType };\n}\n\nexport async function validateFile(\n file: any,\n config: SecurityConfig,\n strapi: Core.Strapi\n): Promise<ValidationResult> {\n const { allowedTypes, deniedTypes } = config;\n\n if (!allowedTypes && !deniedTypes) {\n return { isValid: true };\n }\n\n const { fileName, declaredMimeType } = extractFileInfo(file);\n\n let detectedMime: string | undefined;\n let mimeDetectionFailed = false;\n\n try {\n detectedMime = await detectMimeType(file);\n } catch (error) {\n mimeDetectionFailed = true;\n strapi.log.warn('Failed to detect MIME type from file', {\n fileName,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n\n const mimeToValidate = detectedMime || declaredMimeType;\n\n if (\n !detectedMime &&\n (declaredMimeType === 'application/octet-stream' || !declaredMimeType || mimeDetectionFailed)\n ) {\n if (allowedTypes?.length || deniedTypes?.length) {\n return {\n isValid: false,\n error: {\n code: 'MIME_TYPE_NOT_ALLOWED',\n message: `Cannot verify file type for security reasons`,\n details: {\n fileName,\n reason: 'Unable to detect MIME type from file content',\n declaredType: declaredMimeType,\n mimeDetectionFailed,\n },\n },\n };\n }\n }\n\n if (\n mimeToValidate &&\n (allowedTypes || deniedTypes) &&\n !isMimeTypeAllowed(mimeToValidate, config)\n ) {\n return {\n isValid: false,\n error: {\n code: 'MIME_TYPE_NOT_ALLOWED',\n message: `File type '${mimeToValidate}' is not allowed`,\n details: {\n fileName,\n detectedType: detectedMime,\n declaredType: declaredMimeType,\n finalType: mimeToValidate,\n allowedTypes,\n deniedTypes,\n },\n },\n };\n }\n\n return { isValid: true };\n}\n\nexport async function validateFiles(files: any, strapi: Core.Strapi): Promise<ValidationResult[]> {\n const filesArray = Array.isArray(files) ? files : [files];\n\n if (!filesArray.length) {\n return [];\n }\n\n const config: SecurityConfig = strapi.config.get('plugin::upload.security', {});\n if (\n config.allowedTypes &&\n (!Array.isArray(config.allowedTypes) ||\n !config.allowedTypes.every((item) => typeof item === 'string'))\n ) {\n throw new errors.ApplicationError(\n 'Invalid configuration: allowedTypes must be an array of strings.'\n );\n }\n\n if (\n config.deniedTypes &&\n (!Array.isArray(config.deniedTypes) ||\n !config.deniedTypes.every((item) => typeof item === 'string'))\n ) {\n throw new errors.ApplicationError(\n 'Invalid configuration: deniedTypes must be an array of strings.'\n );\n }\n\n if (!config.allowedTypes && !config.deniedTypes) {\n strapi.log.warn(\n 'No upload security configuration found. Consider configuring plugin.upload.security for enhanced file validation.'\n );\n return filesArray.map(() => ({ isValid: true }));\n }\n\n const validationPromises = filesArray.map(async (file, index) => {\n try {\n return await validateFile(file, config, strapi);\n } catch (error) {\n strapi.log.error('Unexpected error during file validation', {\n fileIndex: index,\n fileName: file?.name || file?.originalname,\n error: error instanceof Error ? error.message : String(error),\n });\n\n return {\n isValid: false,\n error: {\n code: 'VALIDATION_ERROR' as const,\n message: `Validation failed for file at index ${index}`,\n details: {\n index,\n fileName: file?.name || file?.originalname,\n originalError: error instanceof Error ? error.message : String(error),\n },\n },\n };\n }\n });\n\n return Promise.all(validationPromises);\n}\n\nexport async function enforceUploadSecurity(\n files: any,\n strapi: Core.Strapi\n): Promise<{\n validFiles: any[];\n validFileNames: string[];\n errors: Array<ErrorDetail>;\n}> {\n const validationResults = await validateFiles(files, strapi);\n const filesArray = Array.isArray(files) ? files : [files];\n\n const validFiles: any[] = [];\n const validFileNames: string[] = [];\n const errors: Array<ErrorDetail> = [];\n\n for (const [index, result] of validationResults.entries()) {\n if (result.isValid) {\n const file = filesArray[index];\n validFiles.push(file);\n validFileNames.push(file.originalFilename || file.name);\n } else if (result.error) {\n errors.push({\n file: filesArray[index],\n originalIndex: index,\n error: result.error,\n });\n } else {\n // Handle case where validation failed but no error details are provided\n errors.push({\n file: filesArray[index],\n originalIndex: index,\n error: {\n code: 'UNKNOWN_ERROR' as const,\n message: 'File validation failed for unknown reason',\n details: {\n index,\n fileName: filesArray[index]?.name || filesArray[index]?.originalname,\n },\n },\n });\n }\n }\n\n return { validFiles, validFileNames, errors };\n}\n"],"names":["readFileChunk","filePath","chunkSize","buffer","readFile","length","subarray","detectMimeType","file","path","filepath","tempFilePath","error","Error","message","String","undefined","fileTypeFromBuffer","result","Uint8Array","mime","matchesMimePattern","mimeType","patterns","some","pattern","normalizedPattern","toLowerCase","normalizedMimeType","includes","regexPattern","replace","regex","RegExp","matches","test","exactMatch","isMimeTypeAllowed","config","allowedTypes","deniedTypes","extractFileInfo","fileName","originalFilename","name","filename","newFilename","declaredMimeType","mimetype","type","validateFile","strapi","isValid","detectedMime","mimeDetectionFailed","log","warn","mimeToValidate","code","details","reason","declaredType","detectedType","finalType","validateFiles","files","filesArray","Array","isArray","get","every","item","errors","ApplicationError","map","validationPromises","index","fileIndex","originalname","originalError","Promise","all","enforceUploadSecurity","validationResults","validFiles","validFileNames","entries","push","originalIndex"],"mappings":";;;AAyBA,eAAeA,aAAcC,CAAAA,QAAgB,EAAEC,SAAAA,GAAoB,IAAI,EAAA;IACrE,MAAMC,MAAAA,GAAS,MAAMC,QAASH,CAAAA,QAAAA,CAAAA;IAC9B,OAAOE,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ACjD,MAAA,IAAI1B,MAAON,CAAAA,KAAK,EAAE;AACvB4D,YAAAA,MAAAA,CAAOe,IAAI,CAAC;gBACV/E,IAAM0D,EAAAA,UAAU,CAACU,KAAM,CAAA;gBACvBY,aAAeZ,EAAAA,KAAAA;AACfhE,gBAAAA,KAAAA,EAAOM,OAAON;AAChB,aAAA,CAAA;SACK,MAAA;;AAEL4D,YAAAA,MAAAA,CAAOe,IAAI,CAAC;gBACV/E,IAAM0D,EAAAA,UAAU,CAACU,KAAM,CAAA;gBACvBY,aAAeZ,EAAAA,KAAAA;gBACfhE,KAAO,EAAA;oBACL8C,IAAM,EAAA,eAAA;oBACN5C,OAAS,EAAA,2CAAA;oBACT6C,OAAS,EAAA;AACPiB,wBAAAA,KAAAA;wBACAlC,QAAUwB,EAAAA,UAAU,CAACU,KAAM,CAAA,EAAEhC,QAAQsB,UAAU,CAACU,MAAM,EAAEE;AAC1D;AACF;AACF,aAAA,CAAA;AACF;AACF;IAEA,OAAO;AAAEM,QAAAA,UAAAA;AAAYC,QAAAA,cAAAA;AAAgBb,QAAAA;AAAO,KAAA;AAC9C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/upload",
3
- "version": "5.30.1",
3
+ "version": "5.31.1",
4
4
  "description": "Makes it easy to upload images and files to your Strapi Application.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
@@ -64,11 +64,12 @@
64
64
  "@reduxjs/toolkit": "1.9.7",
65
65
  "@strapi/design-system": "2.0.0-rc.30",
66
66
  "@strapi/icons": "2.0.0-rc.30",
67
- "@strapi/provider-upload-local": "5.30.1",
68
- "@strapi/utils": "5.30.1",
67
+ "@strapi/provider-upload-local": "5.31.1",
68
+ "@strapi/utils": "5.31.1",
69
69
  "byte-size": "8.1.1",
70
70
  "cropperjs": "1.6.1",
71
71
  "date-fns": "2.30.0",
72
+ "file-type": "21.0.0",
72
73
  "formik": "2.4.5",
73
74
  "fs-extra": "11.2.0",
74
75
  "immer": "9.0.21",
@@ -88,8 +89,8 @@
88
89
  "zod": "3.25.67"
89
90
  },
90
91
  "devDependencies": {
91
- "@strapi/admin": "5.30.1",
92
- "@strapi/types": "5.30.1",
92
+ "@strapi/admin": "5.31.1",
93
+ "@strapi/types": "5.31.1",
93
94
  "@testing-library/dom": "10.1.0",
94
95
  "@testing-library/react": "15.0.7",
95
96
  "@testing-library/user-event": "14.5.2",
@@ -115,7 +116,7 @@
115
116
  "styled-components": "^6.0.0"
116
117
  },
117
118
  "engines": {
118
- "node": ">=18.0.0 <=22.x.x",
119
+ "node": ">=20.0.0 <=24.x.x",
119
120
  "npm": ">=6.0.0"
120
121
  },
121
122
  "strapi": {