Fix Windows VCS auth: PowerShell syntax + token expiry tracking
Apra Fleet is an open-source MCP server
Brought to you by:
apralabs
Originally created by: joiskash
gitCredentialHelperWrite() in src/os/windows.ts used PowerShell here-strings (@'...'@) joined with semicolons, which is invalid syntax (here-string delimiters must be alone on their own lines). Replaced with array -join pattern using backtick-escaped newlines.expiresAt was only shown in transient output, never stored. Added vcsProvider and vcsTokenExpiresAt fields to the Agent type, persisted to registry after deployment, and added expiry warnings when tokens are expired or within 10 minutes of expiry.src/os/windows.ts — Fixed gitCredentialHelperWrite() to generate valid PowerShellsrc/types.ts — Added vcsProvider? and vcsTokenExpiresAt? to Agent interfacesrc/tools/provision-vcs-auth.ts — Persist VCS metadata to registry after deploysrc/utils/agent-helpers.ts — New checkVcsTokenExpiry() helper with configurable now for testingtests/windows-credential-helper.test.ts — 7 tests for PowerShell fix (special chars, no here-strings)tests/vcs-token-expiry.test.ts — 7 tests for expiry warning logic and registry persistencenpm test)npm run build)
Originally posted by: kumaakh
Code Review — fleet-rev
Verdict: APPROVED with non-blocking issues below. Requesting fixes before merge.
Actionable fixes (fleet-dev)
.batcredential helper (src/os/windows.ts:144)'→'') but written into a.batfile executed bycmd.exe. Batch metacharacters (&,|,>,<,^,%) in the token would break the script.Fix: Add batch-level
^escaping for the token value before writing it into the.batcontent.LOW: Escaping inconsistency between write and remove (
src/os/windows.ts:140vs:153)gitCredentialHelperWritepasses host throughescapeWindowsArg(), butgitCredentialHelperRemoveonly does PowerShell single-quote escaping. Asymmetry is a code smell.Fix: Use
escapeWindowsArg()consistently in both write and remove.LOW: Redundant
?? undefined(src/tools/provision-vcs-auth.ts:97)deployResult.metadata?.expiresAt ?? undefined— the?? undefinedis redundant.?? undefined.Not fixing in this PR
Full review details in
feedback.mdon the branch.Ticket changed by: kumaakh