Skip to content

Commit 1f85e7d

Browse files
authored
v1.3.0
2 parents 1d28dcd + b6d3ab1 commit 1f85e7d

8 files changed

Lines changed: 420 additions & 263 deletions

File tree

Directory.Version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.2.0</VersionPrefix>
3+
<VersionPrefix>1.3.0</VersionPrefix>
44
</PropertyGroup>
55
</Project>

README.md

Lines changed: 8 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# ByteGuard File Validator ![NuGet Version](https://img.shields.io/nuget/v/ByteGuard.FileValidator)
22

3-
**ByteGuard.FileValidator** is a lightweight security-focused library for validating user-supplied files in .NET applications.
3+
**ByteGuard.FileValidator** is a lightweight security-focused library for validating user-supplied files in .NET applications.
4+
45
It helps you enforce consistent file upload rules by checking:
56

67
- Allowed file extensions
78
- File size limits
89
- File signatures (magic numbers) to detect spoofed types
910
- Security validation for Office Open XML / Open Document Formats (`.docx`, `.xlsx`, `.pptx`, `.odt`, `.odp`, `.ods`)
10-
- Malware scan result using a varity of scanners (_requires the addition of a specific ByteGuard.FileValidator scanner package_)
11+
- Malware scan result using a varity of scanners (_requires the addition of a specific [ByteGuard.FileValidator](https://github.com/ByteGuard-HQ/byteguard-file-validator-net/wiki/Available-AV-scanners) scanner package_)
1112

1213
> ⚠️ **Important:** This package is one layer in a defense-in-depth strategy.
1314
> It does **not** replace endpoint protection, sandboxing, input validation, or other security controls.
@@ -18,9 +19,10 @@ It helps you enforce consistent file upload rules by checking:
1819
- ✅ Validate files by **size**
1920
- ✅ Validate files by **signature (_magic-numbers_)**
2021
- ✅ Validate **specification conformance** for archive-based formats (_Open XML and Open Document Formats_)
21-
-**Ensure no malware** through a variety of antimalware scanners
22+
-**Ensure no malware** through a variety of [antimalware scanners](https://github.com/ByteGuard-HQ/byteguard-file-validator-net/wiki/Available-AV-scanners)
2223
- ✅ Validate using file path, `Stream`, or `byte[]`
23-
- ✅ Configure which file types to support
24+
-[Rich integration with NET Core](https://github.com/ByteGuard-HQ/byteguard-file-validator-extensions-dependency-injection)
25+
- ✅ Configure which [file types](https://github.com/ByteGuard-HQ/byteguard-file-validator-net/wiki/Validation-features) to support
2426
- ✅ Configure whether to **throw exceptions** or simply return a boolean
2527
-**Fluent configuration API** for easy setup
2628

@@ -38,7 +40,7 @@ dotnet add package ByteGuard.FileValidator
3840

3941
### Antimalware scanners
4042

41-
In order to use the antimalware scanning capabilities, ensure you have a ByteGuard.FileValidator antimalware package referenced as well. You can find the relevant scanner package on [NuGet](https://www.nuget.org/packages?q=ByteGuard.FileValidator.Scanner.&includeComputedFrameworks=true&prerel=true&sortby=relevance) under the namespace `ByteGuard.FileValidator.Scanner`.
43+
In order to use the antimalware scanning capabilities, ensure you have a [ByteGuard.FileValidator antimalware package](https://github.com/ByteGuard-HQ/byteguard-file-validator-net/wiki/Available-AV-scanners) referenced as well. You can find the relevant scanner package on [NuGet](https://www.nuget.org/packages?q=ByteGuard.FileValidator.Scanner.&includeComputedFrameworks=true&prerel=true&sortby=relevance) under the namespace `ByteGuard.FileValidator.Scanner`.
4244

4345
## Usage
4446

@@ -130,38 +132,7 @@ public async Task<IActionResult> Upload(IFormFile file)
130132

131133
## Supported File Extensions
132134

133-
The following file types are supported by the `FileValidator`:
134-
135-
| Category | Supported extensions |
136-
| ------------- | --------------------------------------------------------------------------------- |
137-
| **Documents** | `.doc`, `.docx`, `.xls`, `.xlsx`, `.pptx`, `.odp`, `.ods`, `.odt`, `.pdf`, `.rtf` |
138-
| **Images** | `.jpg`, `.jpeg`, `.png,`, `.bmp` |
139-
| **Video** | `.mov`, `.avi`, `.mp4` |
140-
| **Audio** | `.m4a``.mp3`, `.wav` |
141-
142-
### Validation coverage per type
143-
144-
`IsValidFile` always validates:
145-
146-
- File extension (_against `SupportedFileTypes`_)
147-
- File size (_against `FileSizeLimit`_)
148-
- File signature (_magic number_)
149-
- Malware scan result (_if an antimalware scanner has been configured_)
150-
151-
For some formats, additional checks are performed:
152-
153-
- **Microsoft Office / Open Document Format** (`.docx`, `.xlsx`, `.pptx`, `.ods`, `.odp`, `.odt`):
154-
- Extension
155-
- File size
156-
- Signature
157-
- Basic specification conformance validation
158-
- Malware scan result
159-
160-
- **Other binary formats**:
161-
- Extension
162-
- File size
163-
- Signature
164-
- Malware scan result
135+
The file validator supports a variety of different file extensions. The complete list including the individual validation mechanisms per type, is available on the [WIKI](https://github.com/ByteGuard-HQ/byteguard-file-validator-net/wiki/Validation-features).
165136

166137
## Configuration Options
167138

src/ByteGuard.FileValidator/Configuration/ConfigurationValidator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void ThrowIfInvalid(FileValidatorConfiguration configuration)
3636
}
3737

3838
// Validate file type is supported by the current version of FileValidator.
39-
if (!FileValidator.SupportedFileDefinitions.Any(f => f.FileType.Equals(fileType)))
39+
if (!FileDefinitions.SupportedFileDefinitions.Any(f => f.FileType.Equals(fileType)))
4040
{
4141
throw new UnsupportedFileException($"File type '{fileType}' is not supported in the current version of FileValidator.");
4242
}

0 commit comments

Comments
 (0)