Skip to content

Commit 2d1d844

Browse files
authored
Update PSGraphQL.Tests.ps1
1 parent 71659c9 commit 2d1d844

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

PSGraphQL/Tests/PSGraphQL.Tests.ps1

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,22 @@ Describe "Testing module and cmdlets against PSSA rules" -Tag Linting -WarningAc
8383
foreach ($rule in $scriptAnalyzerRules) {
8484
It "should pass $rule" {
8585
If ($analysis.RuleName -contains $rule) {
86-
$analysis | Where RuleName -eq $rule -OutVariable failures
86+
$analysis | Where-Object RuleName -eq $rule -OutVariable failures
87+
$failures.Count | Should -Be 0
88+
}
89+
}
90+
}
91+
}
92+
93+
Context "$_ test against InjectionHunter rules" {
94+
$injectionHunterModulePath = Get-Module -Name InjectionHunter -ListAvailable | Select-Object -ExpandProperty Path
95+
96+
$analysis = Invoke-ScriptAnalyzer -Path $_.FullName -CustomRulePath $injectionHunterModulePath
97+
98+
foreach ($rule in $scriptAnalyzerRules) {
99+
It "should pass $rule" {
100+
If ($analysis.RuleName -contains $rule) {
101+
$analysis | Where-Object RuleName -eq $rule -OutVariable failures
87102
$failures.Count | Should -Be 0
88103
}
89104
}
@@ -98,7 +113,22 @@ Describe "Testing module and cmdlets against PSSA rules" -Tag Linting -WarningAc
98113
foreach ($rule in $scriptAnalyzerRules) {
99114
It "should pass $rule" {
100115
If ($analysis.RuleName -contains $rule) {
101-
$analysis | Where RuleName -eq $rule -OutVariable failures
116+
$analysis | Where-Object RuleName -eq $rule -OutVariable failures
117+
$failures.Count | Should -Be 0
118+
}
119+
}
120+
}
121+
}
122+
123+
Context "$_ test against InjectionHunter rules" {
124+
$injectionHunterModulePath = Get-Module -Name InjectionHunter -ListAvailable | Select-Object -ExpandProperty Path
125+
126+
$analysis = Invoke-ScriptAnalyzer -Path $_.FullName -CustomRulePath $injectionHunterModulePath
127+
128+
foreach ($rule in $scriptAnalyzerRules) {
129+
It "should pass $rule" {
130+
If ($analysis.RuleName -contains $rule) {
131+
$analysis | Where-Object RuleName -eq $rule -OutVariable failures
102132
$failures.Count | Should -Be 0
103133
}
104134
}

0 commit comments

Comments
 (0)