forked from ModuleBuild/ModuleBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensitiveTermScan.Tests.ps1
More file actions
28 lines (25 loc) · 938 Bytes
/
Copy pathSensitiveTermScan.Tests.ps1
File metadata and controls
28 lines (25 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#Requires -Modules Pester
<#
This pester test verifies the files in the specified path do not contain sensitive information.
Example:
Invoke-Pester -Script @{Path = '.\src\tests\SensitiveTermScan.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD'; Terms = @('mydomainname.com', 'myservername') }}
#>
[CmdletBinding()]
Param(
[Parameter(HelpMessage = 'Path to the files to scan.')]
[string]$Path,
[Parameter(HelpMessage = 'Terms to scan for.')]
[string[]]$Terms
)
if (Test-Path $Path) {
Describe 'Scan for sensitive terms.' {
foreach ($Term in $Terms) {
$TermSearch = @(Get-ChildItem -Recurse -Path $Path | Select-String -Pattern $Term)
Context "Files in $Path" {
It "should not contain the term $Term" {
$TermSearch.Count -gt 0 | Should Be $false
}
}
}
}
}