Skip to content

fix(windows): stop console window flashes during scheduled scans#100

Open
swarit-stepsecurity wants to merge 3 commits into
step-security:mainfrom
swarit-stepsecurity:swarit/fix/windows-app-exec
Open

fix(windows): stop console window flashes during scheduled scans#100
swarit-stepsecurity wants to merge 3 commits into
step-security:mainfrom
swarit-stepsecurity:swarit/fix/windows-app-exec

Conversation

@swarit-stepsecurity
Copy link
Copy Markdown
Member

What does this PR do?

Type of change

  • Bug fix
  • Enhancement
  • Documentation

Testing

  • Tested on macOS (version: ___)
  • Binary runs without errors: ./stepsecurity-dev-machine-guard --verbose
  • JSON output is valid: ./stepsecurity-dev-machine-guard --json | python3 -m json.tool
  • No secrets or credentials included
  • Lint passes: make lint
  • Tests pass: make test

Related Issues

Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to prevent visible console window flashes on Windows during scheduled scans by changing how the scheduled task launches the agent and by suppressing console creation for subprocesses.

Changes:

  • Add a Windows GUI-subsystem launcher (stepsecurity-dev-machine-guard-task.exe) and install it side-by-side with the agent in the MSI.
  • Update Task Scheduler registration to invoke the binary directly (no cmd /c wrapper) and prefer the launcher when present.
  • Introduce a cross-platform internal/winproc helper to apply Windows process attributes that suppress console windows for spawned child processes, and apply it in key call sites.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packaging/windows/Product.wxs Adds launcher binary to MSI payload and feature refs.
Makefile Adds build targets for the launcher and includes it in MSI builds/clean.
internal/winproc/winproc.go Non-Windows stub for HideWindow.
internal/winproc/winproc_windows.go Windows implementation setting HideWindow + CREATE_NO_WINDOW.
internal/winproc/winproc_windows_test.go Windows-only tests for attribute merging/idempotency.
internal/winproc/winproc_test.go Cross-platform safety tests (nil-safe, no panic).
internal/schtasks/schtasks.go Prefers launcher for scheduled task; removes cmd /c wrapper; uses --install-dir.
internal/schtasks/schtasks_test.go Updates args tests and adds launcher preference + /tr format tests.
internal/executor/executor.go Applies winproc.HideWindow to subprocess execution paths.
internal/detector/ide.go Adds package.json fast-path for VS Code-derived IDE version detection.
internal/detector/ide_test.go Adds test ensuring VS Code version comes from package.json (no .cmd shell-out).
internal/config/config_windows.go Suppresses console window for icacls invocation.
internal/aiagents/enrich/npm/registry.go Suppresses console window for npm-related subprocess invocation.
internal/aiagents/cli/.stepsecurity/ai-agent-hook-errors.jsonl Adds a new log entry line.
cmd/stepsecurity-dev-machine-guard-task/main.go New Windows-only GUI launcher that spawns agent with CREATE_NO_WINDOW and job object lifecycle binding.
.goreleaser.yml Adds build + archive configuration for the launcher binary.
.github/workflows/release.yml Updates release workflow to locate/sign/upload both agent and launcher Windows assets.
.github/workflows/msi-smoke.yml Builds/verifies both binaries in MSI smoke workflow and asserts task action points at launcher.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/schtasks/schtasks.go Outdated
Comment on lines +72 to +78
args := buildCreateArgs(binaryPath, logDir, stepHome, hours, exec.IsRoot())
log.Debug("schtasks create: binary=%q log_dir=%q step_home=%q hours=%d is_admin=%v", binaryPath, logDir, stepHome, hours, exec.IsRoot())
taskBinary := resolveTaskBinary(exec, binaryPath)
args := buildCreateArgs(taskBinary, stepHome, hours, exec.IsRoot())
Comment thread internal/detector/ide.go
Comment on lines 389 to +392
func (d *IDEDetector) resolveWindowsVersionFromDir(ctx context.Context, spec ideSpec, installDir string) string {
if v := readProductInfoVersion(d.exec, filepath.Join(installDir, "resources", "app", "package.json")); v != "unknown" {
return v
}
Comment on lines +1 to +2
{"ts":"2026-05-21T16:38:14.309922Z","stage":"install","code":"no_home","message":"should be silently dropped"}
{"ts":"2026-05-22T00:59:13.355439Z","stage":"install","code":"no_home","message":"should be silently dropped"}
Signed-off-by: Swarit Pandey <swarit@stepsecurity.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants