Skip to content

Commit 940efbe

Browse files
committed
Update readme [skip ci]
1 parent aac98af commit 940efbe

3 files changed

Lines changed: 43 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
name: Continout Integration
1+
name: Continous Integration
22

33
on:
44
push:
5-
branches: [ "dev", "master" ]
5+
branches: ["dev", "master"]
66
pull_request:
7-
branches: [ "dev", "master" ]
7+
branches: ["dev", "master"]
88

99
env:
1010
CI_BUILD_NUMBER_BASE: ${{ github.run_number }}
@@ -13,29 +13,28 @@ env:
1313

1414
jobs:
1515
build:
16-
1716
# We need to run on Windows as we're supporting .NET Framework
1817
runs-on: windows-latest
1918

2019
permissions:
2120
contents: write
2221

2322
steps:
24-
- uses: actions/checkout@v5
25-
- name: Setup .NET
26-
uses: actions/setup-dotnet@v5
27-
with:
28-
dotnet-version: 10.0.x
29-
- name: Compute and set build number
30-
shell: bash
31-
run: |
23+
- uses: actions/checkout@v5
24+
- name: Setup .NET
25+
uses: actions/setup-dotnet@v5
26+
with:
27+
dotnet-version: 10.0.x
28+
- name: Compute and set build number
29+
shell: bash
30+
run: |
3231
echo "CI_BUILD_NUMBER=$(($CI_BUILD_NUMBER_BASE+1000))" >> $GITHUB_ENV
33-
- name: Build & Push
34-
env:
35-
PR_TRIGGER: ${{ env.PR_TRIGGER }}
36-
DOTNET_CLI_TELEMTRY_OPTOUT: true
37-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
38-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39-
shell: pwsh
40-
run: |
41-
./Build.ps1
32+
- name: Build & Push
33+
env:
34+
PR_TRIGGER: ${{ env.PR_TRIGGER }}
35+
DOTNET_CLI_TELEMTRY_OPTOUT: true
36+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
shell: pwsh
39+
run: |
40+
./Build.ps1

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ It helps you enforce consistent file upload rules by checking:
1717
- ✅ Validate files by **extension**
1818
- ✅ Validate files by **size**
1919
- ✅ 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_)
2121
-**Ensure no malware** through a variety of antimalware scanners
2222
- ✅ Validate using file path, `Stream`, or `byte[]`
2323
- ✅ Configure which file types to support
@@ -154,7 +154,7 @@ For some formats, additional checks are performed:
154154
- Extension
155155
- File size
156156
- Signature
157-
- Archive-based security validation
157+
- Basic specification conformance validation
158158
- Malware scan result
159159

160160
- **Other binary formats**:
@@ -173,6 +173,23 @@ The `FileValidatorConfiguration` supports:
173173
| `FileSizeLimit` | Yes | N/A | Maximum permitted size of files.<br>Use the static `ByteSize` class provided with this package, to simplify your limit. |
174174
| `ThrowExceptionOnInvalidFile` | No | `true` | Whether to throw an exception on invalid files or return `false`. |
175175

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.
179+
180+
#### ODF rules
181+
182+
| Setting | Default | Description |
183+
| ------------------ | ------- | --------------------------------------------------------- |
184+
|  `RequireMimetype` | `true` |  Whether a `mimetype` file is required to pass validation |
185+
186+
#### Open XML rules
187+
188+
| Setting | Default | Description |
189+
| ------------------------------ | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
190+
| `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+
176193
### Exceptions
177194

178195
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
183200
| `UnsupportedFileException` | Thrown when the file extension is not in the list of supported types. |
184201
| `InvalidFileSizeException` | Thrown when the file size exceeds the configured file size limit. |
185202
| `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.). |
188205
| `MalwareDetectedException` | Thrown when the configured antimalware scanner detected malware in the file from a scan result. |
189206

190207
## When to use this package

src/ByteGuard.FileValidator/Configuration/Rules/OpenXmlRules.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ public class OpenXmlRules
1111
/// Whether to perform conformance validation. Defaults to <c>true</c>.
1212
/// </summary>
1313
public bool PerformConformanceValidation { get; set; } = true;
14-
14+
1515
/// <summary>
1616
/// Version to use for conformance validation if enabled. Defaults to <c>Office2007</c>.
1717
/// </summary>
1818
/// <remarks>
1919
/// See <see cref="FileFormatVersions"/> form the <c>DocumentFormat.OpenXml</c> NuGet package.
2020
/// </remarks>
21-
public FileFormatVersions ConformanceVersion { get; set; } = FileFormatVersions.Office2007;
21+
public FileFormatVersions ConformanceVersion { get; set; } = FileFormatVersions.Office2010;
2222
}

0 commit comments

Comments
 (0)