You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(windows): stop console window flashes during scheduled scans
Build the agent as GUI-subsystem (-ldflags "-H windowsgui") so Task
Scheduler can't allocate a console for it under /ru INTERACTIVE.
AttachConsole(ATTACH_PARENT_PROCESS) at the top of main() restores
os.Std* for interactive `agent.exe` runs from cmd/PowerShell; under
Task Scheduler the parent has no console and this no-ops, preserving
silent operation.
Known ergonomic trade-offs for interactive use (documented in
console_windows.go): the shell prompt returns immediately while output
streams async, stdout pipes do not work (reattached handle is a console
not a pipe), and $LASTEXITCODE is unreliable without Start-Process -Wait.
Companion changes (independent of subsystem choice):
- internal/winproc.HideWindow applied at every subprocess site
(executor.Run, executor.RunInDir, config_windows icacls,
aiagents/enrich/npm registry probes). Subprocess flashes are
orthogonal to the agent's subsystem.
- internal/schtasks: dropped the `cmd /c "... >>log 2>>err"` wrapper.
Task action now invokes the binary directly with --install-dir.
stepHome derived from logDir (ProgramData fallback) so it's
never empty.
- internal/detector/ide: VS Code-family resolveWindowsVersionFromDir
reads resources\app\package.json before invoking bin\*.cmd. Renamed
readProductInfoVersion -> readJSONVersion since the helper now
serves both shapes.
- internal/progress/filelog: teeLoop writes to file before origErr.
io.MultiWriter aborts on the first error, so a broken origErr
(GUI-subsystem agent with no parent console) used to drop the file
write entirely, leaving agent.error.log at 0 bytes. Test
TestStartWritesFileEvenWhenOrigStderrIsBroken locks in the fix.
Tests:
- internal/winproc: nil-safety, flag merge, idempotence on Windows.
- internal/schtasks: TaskCommandFormat regression guard.
- internal/detector: package.json fast-path precedence.
- internal/progress/filelog: broken-origErr regression guard.
Build:
- Makefile build-windows / build-windows-arm64: -H windowsgui.
- .goreleaser.yml: templated ldflag adds -H windowsgui for windows only.
.gitignore: explicit paths for the compiled binary at both the repo
root and the same-named source dir under cmd/. The previous
`**/stepsecurity-dev-machine-guard` pattern matched the source
directory too and silently dropped new files added inside it.
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
0 commit comments