Commit b93d990
authored
feat(scripts): add SecurityHelpers and CIHelpers modules (#354)
## Description
This PR introduces two new PowerShell modules with shared utilities for
hve-core scripts:
**SecurityHelpers.psm1** - Security utility functions for security
scanning scripts:
- `Write-SecurityLog` - Timestamped logging with severity levels and
optional file output
- `New-SecurityIssue` - Structured security issue object creation
- `Write-SecurityReport` - Multi-format output (JSON, console, markdown)
- `Test-GitHubToken` - GitHub token validation with rate limit info
- `Invoke-GitHubAPIWithRetry` - GitHub API calls with exponential
backoff retry
**CIHelpers.psm1** - CI platform abstraction for GitHub Actions and
Azure DevOps:
- `Get-CIPlatform` / `Test-CIEnvironment` - Platform detection
- `Set-CIOutput` - Cross-platform output variables
- `Write-CIStepSummary` - Step summary output
- `Write-CIAnnotation` - Warnings, errors, and notices
- `Set-CITaskResult` / `Publish-CIArtifact` - Task management
Both modules include comprehensive Pester tests with 90%+ coverage.
## Related Issue(s)
N/A - Internal refactoring to reduce code duplication in security
scripts.
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [x] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that causes existing functionality
to change)
- [ ] Documentation (changes to documentation only)
- [ ] GitHub Actions (changes to workflow files)
- [ ] Linting (changes to linting configuration)
- [x] Security (changes to security configurations)
- [ ] DevContainer (changes to DevContainer configuration)
- [ ] Dependency (dependency updates)
- [ ] AI Artifacts (changes to prompts, instructions, or agents)
- [x] Script/automation (changes to scripts or tooling)
## Testing
- [x] Pester unit tests added for SecurityHelpers.psm1 (62 tests
passing)
- [x] Pester unit tests added for CIHelpers.psm1 (47 tests passing)
- [x] PSScriptAnalyzer clean (all 38 files pass)
- [x] All existing tests continue to pass
Test commands:
```powershell
# Run SecurityHelpers tests
Invoke-Pester -Path ./scripts/tests/security/SecurityHelpers.Tests.ps1 -Output Detailed
# Run CIHelpers tests
Invoke-Pester -Path ./scripts/tests/lib/CIHelpers.Tests.ps1 -Output Detailed
# Run PSScriptAnalyzer
npm run lint:ps
```
## Checklist
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
## Security Considerations
- No secrets or credentials in code
- GitHub token handling uses secure patterns (Bearer auth, rate limit
awareness)
- API retry logic prevents token leakage in error messages
- Module follows PowerShell security best practices
## Additional Notes
### Files Changed
| File | Change | Description |
|------|--------|-------------|
| scripts/security/Modules/SecurityHelpers.psm1 | Added | Shared
security utilities module |
| scripts/lib/Modules/CIHelpers.psm1 | Added | CI platform abstraction
module |
| scripts/tests/security/SecurityHelpers.Tests.ps1 | Added | Unit tests
(62 tests) |
| scripts/tests/lib/CIHelpers.Tests.ps1 | Added | Unit tests (47 tests)
|
| scripts/tests/Mocks/GitMocks.psm1 | Modified | Added Azure DevOps env
var support |
### Commits
1. `feat(scripts): add CIHelpers.psm1 module for CI platform
abstraction`
2. `fix(scripts): address PR review feedback and add copyright headers`
3. `feat(security): add SecurityHelpers module with shared utilities`1 parent 23e7a7e commit b93d990
4 files changed
Lines changed: 1435 additions & 7 deletions
File tree
- scripts
- lib/Modules
- security/Modules
- tests
- lib
- security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 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 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
9 | 102 | | |
10 | 103 | | |
11 | 104 | | |
| |||
84 | 177 | | |
85 | 178 | | |
86 | 179 | | |
87 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
88 | 184 | | |
89 | 185 | | |
90 | 186 | | |
91 | 187 | | |
92 | 188 | | |
93 | 189 | | |
94 | 190 | | |
95 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
96 | 194 | | |
97 | 195 | | |
98 | 196 | | |
| |||
204 | 302 | | |
205 | 303 | | |
206 | 304 | | |
207 | | - | |
| 305 | + | |
| 306 | + | |
208 | 307 | | |
209 | 308 | | |
210 | 309 | | |
211 | 310 | | |
212 | 311 | | |
213 | 312 | | |
214 | | - | |
| 313 | + | |
| 314 | + | |
215 | 315 | | |
216 | 316 | | |
217 | 317 | | |
| |||
222 | 322 | | |
223 | 323 | | |
224 | 324 | | |
225 | | - | |
| 325 | + | |
| 326 | + | |
226 | 327 | | |
227 | 328 | | |
228 | 329 | | |
229 | | - | |
| 330 | + | |
| 331 | + | |
230 | 332 | | |
231 | 333 | | |
232 | 334 | | |
| |||
322 | 424 | | |
323 | 425 | | |
324 | 426 | | |
325 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
326 | 431 | | |
327 | 432 | | |
328 | 433 | | |
| |||
331 | 436 | | |
332 | 437 | | |
333 | 438 | | |
| 439 | + | |
| 440 | + | |
334 | 441 | | |
335 | 442 | | |
336 | 443 | | |
| |||
0 commit comments