You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-4Lines changed: 21 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ It helps you enforce consistent file upload rules by checking:
17
17
- ✅ Validate files by **extension**
18
18
- ✅ Validate files by **size**
19
19
- ✅ Validate files by **signature (_magic-numbers_)**
20
-
- ✅ Validate **security aspects** for archive-based formats (_Open XML and Open Document Formats_)
20
+
- ✅ Validate **specification conformance** for archive-based formats (_Open XML and Open Document Formats_)
21
21
- ✅ **Ensure no malware** through a variety of antimalware scanners
22
22
- ✅ Validate using file path, `Stream`, or `byte[]`
23
23
- ✅ Configure which file types to support
@@ -154,7 +154,7 @@ For some formats, additional checks are performed:
154
154
- Extension
155
155
- File size
156
156
- Signature
157
-
-Archive-based security validation
157
+
-Basic specification conformance validation
158
158
- Malware scan result
159
159
160
160
-**Other binary formats**:
@@ -173,6 +173,23 @@ The `FileValidatorConfiguration` supports:
173
173
|`FileSizeLimit`| Yes | N/A | Maximum permitted size of files.<br>Use the static `ByteSize` class provided with this package, to simplify your limit. |
174
174
|`ThrowExceptionOnInvalidFile`| No |`true`| Whether to throw an exception on invalid files or return `false`. |
175
175
176
+
### File type specific validation rules
177
+
178
+
The `FileValidatorConfiguration` contains file type specific validation rules through `FileTypeRules`. These settings allow for fine control over validation rules for the individual file types, where supported.
|`PerformConformanceValidation`|`true`| Whether a conformance/specification validation should be performed as part of the seucirt validation |
191
+
|`ConformanceVersion`|`Office2010`| Defines the version speification version to validate against (_valid options are defined by `FileFormatVersion` in [`DocumentFormat.OpenXml`](https://github.com/dotnet/Open-XML-SDK)_) |
192
+
176
193
### Exceptions
177
194
178
195
When `ThrowExceptionOnInvalidFile` is set to `true`, validation functions will throw one of the appropriate exceptions defined below. However, when `ThrowExceptionOnInvalidFile` is set to `false`, all validation functions will either return `true` or `false`.
@@ -183,8 +200,8 @@ When `ThrowExceptionOnInvalidFile` is set to `true`, validation functions will t
183
200
|`UnsupportedFileException`| Thrown when the file extension is not in the list of supported types. |
184
201
|`InvalidFileSizeException`| Thrown when the file size exceeds the configured file size limit. |
185
202
|`InvalidSignatureException`| Thrown when the file's signature does not match the expected signature for its type. |
186
-
|`InvalidOpenXmlFormatException`| Thrown when the internal structure of an Open XML file is invalid (`.docx`, `.xlsx`, `.pptx`, etc.). |
187
-
|`InvalidOpenDocumentFormatException`| Thrown when the specification conformance of an Open Document Format file is invalid (`.odt`, etc.). |
203
+
|`InvalidOpenXmlFormatException`| Thrown when the validation of an Open XML file is invalid (`.docx`, `.xlsx`, `.pptx`, etc.).|
204
+
|`InvalidOpenDocumentFormatException`| Thrown when the validation of an Open Document Format file is invalid (`.odt`,`.ods`, `.odp` etc.). |
188
205
|`MalwareDetectedException`| Thrown when the configured antimalware scanner detected malware in the file from a scan result. |
0 commit comments