From 63128848ea692888bd8367ab9338207639a80755 Mon Sep 17 00:00:00 2001 From: Nicolas Fabert <195452170+Nico77600@users.noreply.github.com> Date: Mon, 12 Oct 2026 13:59:31 +0100 Subject: [PATCH] Align runtime disclaimer with project README --- package/Invoke-PurviewDlpReport.ps1 | 6 ++++ package/README.md | 7 +++++ tests/PurviewDlpReport.Tests.ps1 | 45 +++++++++++++++++++++++++++++ tools/New-DlpPackage.ps1 | 4 +-- 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/package/Invoke-PurviewDlpReport.ps1 b/package/Invoke-PurviewDlpReport.ps1 index 84ee70e..8d72fcf 100644 --- a/package/Invoke-PurviewDlpReport.ps1 +++ b/package/Invoke-PurviewDlpReport.ps1 @@ -1,4 +1,5 @@ #Requires -Version 7.4 + <# .SYNOPSIS Purview DLP Report - Exchange Online messages matched by a Microsoft Purview DLP rule @@ -71,6 +72,11 @@ Version : 2.1.1 Exit codes : 0 = success, 1 = failure, 2 = finished but incomplete (see the summary). Documentation : docs\PurviewDlpReport-Guide.md (or .html) + + This Script is a Personal project. + It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft. + + As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production. #> [CmdletBinding()] param( diff --git a/package/README.md b/package/README.md index f7068cc..14f4e77 100644 --- a/package/README.md +++ b/package/README.md @@ -54,3 +54,10 @@ notepad .\config\PurviewDlpReport.config.psd1 # TenantId, PolicyId, RuleId, Project page, releases and change log: https://github.com/Nico77600/PurviewDlpReport License: [MIT](LICENSE). Third-party components: [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). + +## Disclaimer + +This Script is a Personal project. +It's provided "AS-IS". It's not an official Microsoft product so no support can be expected from Microsoft. + +As any scripts you must read carefully the documentation and test it first in a Test environment before any run in Production. diff --git a/tests/PurviewDlpReport.Tests.ps1 b/tests/PurviewDlpReport.Tests.ps1 index 5b3913d..5cc14af 100644 --- a/tests/PurviewDlpReport.Tests.ps1 +++ b/tests/PurviewDlpReport.Tests.ps1 @@ -89,6 +89,51 @@ AfterAll { if ($script:ConfigDirectory -and (Test-Path -LiteralPath $script:ConfigDirectory)) { Remove-Item -LiteralPath $script:ConfigDirectory -Recurse -Force } } +Describe 'Disclaimer synchronization' { + BeforeAll { + $script:DisclaimerPattern = '(?ms)^## Disclaimer\r?\n(?.*?)(?=^## |\z)' + $sections = [regex]::Matches((Get-Content (Join-Path $script:RepoRoot 'README.md') -Raw), $script:DisclaimerPattern) + if ($sections.Count -ne 1) { throw 'The root README must have exactly one Disclaimer section.' } + $script:Disclaimer = ($sections[0].Groups['Text'].Value -replace "`r`n", "`n").Trim() + } + + It 'ships the complete root disclaimer in the runtime README' { + $sections = [regex]::Matches((Get-Content (Join-Path $script:Root 'README.md') -Raw), $script:DisclaimerPattern) + $sections.Count | Should -Be 1 + ($sections[0].Groups['Text'].Value -replace "`r`n", "`n").Trim() | Should -BeExactly $script:Disclaimer + } + + It 'includes the complete root disclaimer in the entry script help notes' { + $errors = $null + $ast = [Management.Automation.Language.Parser]::ParseFile((Join-Path $script:Root 'Invoke-PurviewDlpReport.ps1'), [ref]$null, [ref]$errors) + $errors | Should -BeNullOrEmpty + $help = $ast.GetHelpContent() + $help | Should -Not -BeNullOrEmpty + $notes = ($help.Notes -replace "`r`n", "`n" -replace '(?m)^[ \t]+', '').Trim() + $start = $notes.IndexOf(($script:Disclaimer -split "`n")[0], [StringComparison]::Ordinal) + $start | Should -BeGreaterOrEqual 0 + $notes.Substring($start) | Should -BeExactly $script:Disclaimer + } + + It 'ships the exact runtime README and disclaimer through the existing package builder' { + $destination = Join-Path ([IO.Path]::GetTempPath()) ('PurviewDlpPackageTests-' + [guid]::NewGuid().ToString('N')) + Test-Path -LiteralPath $destination | Should -BeFalse + try { + & (Join-Path $script:RepoRoot 'tools\New-DlpPackage.ps1') -Destination $destination | Out-Null + $readme = Join-Path $destination 'README.md' + $readme | Should -Exist + (Get-FileHash -LiteralPath $readme -Algorithm SHA256).Hash | + Should -BeExactly (Get-FileHash -LiteralPath (Join-Path $script:Root 'README.md') -Algorithm SHA256).Hash + $sections = [regex]::Matches((Get-Content -LiteralPath $readme -Raw), $script:DisclaimerPattern) + $sections.Count | Should -Be 1 + ($sections[0].Groups['Text'].Value -replace "`r`n", "`n").Trim() | Should -BeExactly $script:Disclaimer + } + finally { + if (Test-Path -LiteralPath $destination) { Remove-Item -LiteralPath $destination -Recurse -Force } + } + } +} + Describe 'Configuration' { It 'loads the delivered configuration file (tenant values filled in)' { $s = Import-DlpConfiguration -Path $script:ConfigPath -Root $script:Root diff --git a/tools/New-DlpPackage.ps1 b/tools/New-DlpPackage.ps1 index e10b362..aa1b4cd 100644 --- a/tools/New-DlpPackage.ps1 +++ b/tools/New-DlpPackage.ps1 @@ -8,7 +8,7 @@ and the licence notice of the SQLite binaries: Invoke-PurviewDlpReport.ps1, PurviewDlpReport.psd1, PurviewDlpReport.psm1, config\, src\, templates\, lib\sqlite\, docs\PurviewDlpReport-UserGuide.html, - docs\PurviewDlpReport-Guide.html, THIRD-PARTY-NOTICES.md + docs\PurviewDlpReport-Guide.html, README.md, THIRD-PARTY-NOTICES.md It never copies data\, reports\, logs\ or bin\: there is no database in the package, the tool creates an empty one at the first run. @@ -57,7 +57,7 @@ if (Test-Path -LiteralPath $Destination) { # ---- Files needed at run time --------------------------------------------------------------------------- $files = [Collections.Generic.List[string]]::new() -foreach ($f in 'Invoke-PurviewDlpReport.ps1', 'PurviewDlpReport.psd1', 'PurviewDlpReport.psm1', 'THIRD-PARTY-NOTICES.md', +foreach ($f in 'Invoke-PurviewDlpReport.ps1', 'PurviewDlpReport.psd1', 'PurviewDlpReport.psm1', 'README.md', 'THIRD-PARTY-NOTICES.md', 'src\PurviewDlpReport.Engine.cs', 'templates\Report.template.html', 'docs\PurviewDlpReport-UserGuide.html', 'docs\PurviewDlpReport-Guide.html') { $files.Add($f) } Get-ChildItem -LiteralPath (Join-Path $packageRoot 'lib\sqlite') -Recurse -File | ForEach-Object { $files.Add($_.FullName.Substring($packageRoot.Length + 1)) }