Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/Invoke-PurviewDlpReport.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#Requires -Version 7.4

<#
.SYNOPSIS
Purview DLP Report - Exchange Online messages matched by a Microsoft Purview DLP rule
Expand Down Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
45 changes: 45 additions & 0 deletions tests/PurviewDlpReport.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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(?<Text>.*?)(?=^## |\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
Expand Down
4 changes: 2 additions & 2 deletions tools/New-DlpPackage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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)) }
Expand Down
Loading