Commit bd7d512
authored
feat(scripts): add per-violation CI annotations and colorized console output (#637)
## Description
Add per-violation `Write-CIAnnotation` calls and colorized `Write-Host`
output to both `Test-DependencyPinning.ps1` and
`Test-ActionVersionConsistency.ps1`. Previously, CI annotations fired
only on fatal errors (catch block) and console output used plain
`Write-Output`. Contributors now see inline PR annotations per violation
and colored terminal output grouped by file, with severity-based icons
and levels.
Also adds `Write-CIStepSummary` to `Test-ActionVersionConsistency.ps1`
with a markdown violations table, and removes the redundant `::warning`
annotation loop from `dependency-pinning-scan.yml` since the script now
handles annotations natively.
Closes #632
## Related Issue(s)
- Closes #632
## Type of Change
### Code & Documentation
- [x] New feature (non-breaking change that adds functionality)
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
### Infrastructure & Configuration
- [ ] CI/CD pipeline changes
- [x] GitHub Actions workflow changes
- [ ] Build system changes
- [x] Security configuration
- [x] Script/automation changes
### AI Artifacts
- [ ] Instructions file (.instructions.md)
- [ ] Prompt template (.prompt.md)
- [ ] Agent definition (.agent.md)
- [ ] Skill package (SKILL.md)
- [ ] Copilot configuration (copilot-instructions.md)
### Other
- [ ] Refactoring (no functional changes)
- [ ] Code style/formatting
- [ ] Test coverage improvements
- [ ] Other (please describe):
## Testing
- **Test-DependencyPinning.Tests.ps1**: 68/68 tests passing, 80.67% code
coverage
- Added 7 tests for CI annotations per violation (severity mapping,
file/line inclusion, message content, multi-violation)
- Added 3 tests for Write-PinningLog CI annotation forwarding (Warning,
Error, Info-excluded)
- Added 2 tests for per-violation console output (colored output,
success message)
- **Test-ActionVersionConsistency.Tests.ps1**: 62/62 tests passing,
94.62% code coverage
- Added 3 tests for Write-ConsistencyLog CI annotation forwarding
- Added 5 tests for CI annotations per violation
- Added 8 tests for CI step summary (pass/fail status, violation counts,
table headers, mixed violations)
## Checklist
### Required Checks
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings or errors
- [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
### AI Artifact Contributions
- [ ] Frontmatter follows conventions in contributing guide
- [ ] applyTo patterns are specific and accurate
- [ ] No secrets, tokens, or sensitive data in artifact content
- [ ] Tested with GitHub Copilot to verify behavior
### Required Automated Checks
- [x] Linting passes (`npm run lint:all`)
- [x] Tests pass (`npm run test:ps`)
## Security Considerations
- [x] No sensitive information (API keys, passwords, tokens) included
- [ ] Security-related changes have been reviewed for vulnerabilities
- [ ] Dependencies have been checked for known vulnerabilities
## Additional Notes
### Changes by file
| File | Summary |
|------|---------|
| `scripts/security/Test-DependencyPinning.ps1` | Converted
`Write-PinningLog` from `Write-Output` to `Write-Host` with color
mapping (Info→Cyan, Warning→Yellow, Error→Red, Success→Green). Added CI
annotation forwarding for Warning/Error levels. Added per-violation loop
emitting `Write-CIAnnotation` with severity mapping (High→Error,
Medium→Warning, Low→Notice) and colorized `Write-Host` output grouped by
file with severity icons. |
| `scripts/security/Test-ActionVersionConsistency.ps1` | Added CI
annotation forwarding to `Write-ConsistencyLog` for Warning/Error
levels. Added per-violation `Write-CIAnnotation` loop with severity
mapping. Added `Write-CIStepSummary` with pass/fail status and markdown
violations table. |
| `.github/workflows/dependency-pinning-scan.yml` | Removed redundant
`::warning` annotation loop (26 lines including `ConvertTo-GHAEscaped`
function) since `Test-DependencyPinning.ps1` now handles annotations
natively via `Write-CIAnnotation`. |
| `scripts/tests/security/Test-DependencyPinning.Tests.ps1` | Added 12
Pester tests across 3 new contexts for CI annotations per violation,
Write-PinningLog CI annotation forwarding, and per-violation console
output. |
| `scripts/tests/security/Test-ActionVersionConsistency.Tests.ps1` |
Added 16 Pester tests across 3 new contexts for Write-ConsistencyLog CI
annotation forwarding, CI annotations per violation, and CI step summary
content. |
🔧 - Generated by Copilot1 parent 5fa6328 commit bd7d512
5 files changed
Lines changed: 549 additions & 51 deletions
File tree
- .github/workflows
- scripts
- security
- tests/security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | 124 | | |
151 | 125 | | |
152 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
97 | 105 | | |
98 | 106 | | |
99 | 107 | | |
| |||
391 | 399 | | |
392 | 400 | | |
393 | 401 | | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
394 | 416 | | |
395 | 417 | | |
396 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
397 | 454 | | |
398 | 455 | | |
399 | 456 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
319 | 319 | | |
320 | 320 | | |
321 | 321 | | |
322 | | - | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
323 | 337 | | |
324 | 338 | | |
325 | 339 | | |
| |||
860 | 874 | | |
861 | 875 | | |
862 | 876 | | |
863 | | - | |
864 | | - | |
865 | | - | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
866 | 882 | | |
867 | 883 | | |
868 | 884 | | |
869 | 885 | | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
880 | 890 | | |
881 | | - | |
882 | | - | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
883 | 895 | | |
884 | | - | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
885 | 902 | | |
886 | | - | |
887 | | - | |
888 | | - | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
889 | 906 | | |
890 | 907 | | |
891 | 908 | | |
| |||
894 | 911 | | |
895 | 912 | | |
896 | 913 | | |
897 | | - | |
898 | | - | |
899 | 914 | | |
900 | 915 | | |
901 | 916 | | |
| |||
0 commit comments