forked from ModuleBuild/ModuleBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptAnalyzer.Tests.ps1
More file actions
32 lines (28 loc) · 1.04 KB
/
Copy pathScriptAnalyzer.Tests.ps1
File metadata and controls
32 lines (28 loc) · 1.04 KB
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
29
30
31
32
#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\ScriptAnalyzer.Tests.ps1'; Parameters = @{ Path = 'C:\Users\zloeber\Dropbox\Zach_Docs\Projects\Git\PSAD' }}
#>
[CmdletBinding()]
Param(
[Parameter(HelpMessage = 'Path to the files to scan.')]
[string]$Path
)
if (-not (Get-Item $Path -ErrorAction:SilentlyContinue).PSIsContainer) {
throw "Either $Path is not a directory or does not exist"
}
Describe 'Testing against PSSA rules' {
Context 'PSSA Standard Rules' {
$analysis = Invoke-ScriptAnalyzer -Path $Path
$scriptAnalyzerRules = Get-ScriptAnalyzerRule
forEach ($rule in $scriptAnalyzerRules) {
It "Should pass $rule" {
If ($analysis.RuleName -contains $rule) {
$analysis | Where RuleName -EQ $rule -outvariable failures | Out-Default
$failures.Count | Should Be 0
}
}
}
}
}