-
Notifications
You must be signed in to change notification settings - Fork 125
Description
Summary
Test-ActionVersionConsistency.ps1 already supports -Format Json -OutputPath parameters with full JSON serialization via Export-ConsistencyReport, but the npm script lint:version-consistency does not pass these flags. No JSON log file is written to logs/ during normal npm run lint:version-consistency execution.
Current Behavior
Running npm run lint:version-consistency produces only console table output. No file is created in logs/. The script has the capability but it is unused.
Current npm script:
pwsh -NoProfile -Command "./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch"
Expected Behavior
Running npm run lint:version-consistency writes logs/action-version-consistency-results.json containing violations, summary counts, and scan metadata in JSON format — consistent with other security scripts like Test-DependencyPinning.ps1 and Test-WorkflowPermissions.ps1.
Root Cause
The npm script in package.json invokes the script with only -FailOnMismatch and does not pass -Format Json -OutputPath.
Files Requiring Changes
| File | Change |
|---|---|
package.json |
Add -Format Json -OutputPath logs/action-version-consistency-results.json to the lint:version-consistency script |
Reproduction Steps
- Run
npm run lint:version-consistency. - Check
logs/for anaction-version-consistency*file — none exists. - Run
pwsh -NoProfile -Command "./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch -Format Json -OutputPath logs/action-version-consistency-results.json"— JSON file is created.
Fix Guidance
Update the npm script in package.json:
"lint:version-consistency": "pwsh -NoProfile -Command \"./scripts/security/Test-ActionVersionConsistency.ps1 -FailOnMismatch -Format Json -OutputPath logs/action-version-consistency-results.json\""Note: When -Format Json is used, the console output switches to JSON format. If table console output is preferred alongside the JSON file, a separate -JsonLogPath parameter would need to be added to the script (but that is a separate enhancement — for this issue, the JSON file output is the priority).
Unit Testing and Code Coverage Requirements
No new Pester tests required — the script's JSON output is already tested via existing tests for -Format Json -OutputPath. Manual verification: run npm run lint:version-consistency and confirm the JSON file is created.
RPI Framework Starter Prompts
Research Phase
Select Task Researcher from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Research JSON log output for
Test-ActionVersionConsistency.ps1. Investigate: (1) The script's existing-Formatand-OutputPathparameters — readscripts/security/Test-ActionVersionConsistency.ps1and find theExport-ConsistencyReportfunction to understand JSON serialization. (2) How other security scripts pass format/output params via npm scripts — examinelint:dependency-pinningandlint:permissionsinpackage.json. (3) The current npm script and what parameters it passes. (4) Existing Pester test coverage inscripts/tests/security/Test-ActionVersionConsistency.Tests.ps1for JSON output handling. (5) Whether using-Format Jsonchanges the console output behavior (table vs JSON). (6) The JSON schema produced byExport-ConsistencyReportwhen-Format Jsonis used.
Plan Phase
Select Task Planner from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Plan enabling JSON log output for the
lint:version-consistencynpm script using the research document. The plan should cover: (1) Updating the npm script inpackage.jsonto add-Format Json -OutputPath logs/action-version-consistency-results.json. (2) Verifying the JSON file is created with expected schema (violations array, summary, metadata). (3) Confirming existing Pester tests still pass. (4) Validating vianpm run lint:version-consistencyend-to-end.
Implement Phase
Select Task Implementor from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Implement JSON log output for
lint:version-consistency. Steps: (1) Updatepackage.jsonto add-Format Json -OutputPath logs/action-version-consistency-results.jsonto the existing command. (2) Runnpm run lint:version-consistencyand verifylogs/action-version-consistency-results.jsonis created. (3) Inspect the JSON file to confirm it contains violations array, summary counts, and scan metadata. (4) Runnpm run test:ps -- -TestPath "scripts/tests/security/"to verify no test regressions.
Review Phase
Select Task Reviewer from the agent picker at the bottom of the GitHub Copilot Chat prompt pane, then send the following prompt:
Review the
lint:version-consistencynpm script change. Verify: (1) Onlypackage.jsonwas modified. (2) The-Format Json -OutputPathflags match the pattern used bylint:dependency-pinningandlint:permissions. (3) The JSON output file path follows thelogs/-results.jsonnaming convention. (4) The npm command string is properly escaped with PowerShell quoting. (5) Runningnpm run lint:version-consistencyproduces the expected JSON file. (6)npm run test:pspasses with no regressions.
References
package.json—lint:version-consistencyscriptscripts/security/Test-ActionVersionConsistency.ps1—-Formatand-OutputPathparams,Export-ConsistencyReportfunctionscripts/security/Test-DependencyPinning.ps1— reference pattern for security script JSON output via npmscripts/security/Test-WorkflowPermissions.ps1— reference pattern for security script JSON output via npm