Skip to content

🐛 powershell: write stderr read error to the stderr field#8650

Open
tas50 wants to merge 1 commit into
mainfrom
claude/fix-powershell-stderr-field
Open

🐛 powershell: write stderr read error to the stderr field#8650
tas50 wants to merge 1 commit into
mainfrom
claude/fix-powershell-stderr-field

Conversation

@tas50

@tas50 tas50 commented Jun 23, 2026

Copy link
Copy Markdown
Member

Bug

In powershell.go, the branch that handles a failed io.ReadAll(x.Stderr) assigned the error to c.Stdout instead of c.Stderr:

stderr, err := io.ReadAll(x.Stderr)
if err != nil {
    c.Stdout = plugin.TValue[string]{Error: err, State: plugin.StateIsSet}  // wrong field
} else {
    ...
    c.Stderr = plugin.TValue[string]{...}
}

This is a copy-paste slip from the stdout block above it. When reading stderr fails, it clobbers the stdout value that was just populated correctly and leaves c.Stderr in its zero/unset state — so powershell { stdout, stderr } reports a bogus error on .stdout while .stderr is silently never set.

The powershell resource underlies auditpol and secpol, so those inherit the corruption on this error path.

Fix

Assign the stderr read error to c.Stderr.

🤖 Generated with Claude Code

https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ


Generated by Claude Code

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mondoo-code-review mondoo-code-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fixes PowerShell stderr read errors being incorrectly reported on the stdout field instead of stderr.

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Test Results

11 153 tests  ±0   11 146 ✅ ±0   3m 24s ⏱️ - 1m 56s
   545 suites ±0        7 💤 ±0 
    40 files   ±0        0 ❌ ±0 

Results for commit 8ccea2a. ± Comparison against base commit a92a575.

♻️ This comment has been updated with latest results.

@tas50 tas50 force-pushed the claude/fix-powershell-stderr-field branch 4 times, most recently from 92114e7 to 29e5ae5 Compare June 24, 2026 18:02
The stderr-read error branch assigned the error to c.Stdout, clobbering
the stdout value populated just above and leaving c.Stderr unset. Assign
it to c.Stderr instead. This also affects auditpol/secpol, which build
on the powershell resource.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015U1ocAxfcBhVYi3f9JnyZZ
@tas50 tas50 force-pushed the claude/fix-powershell-stderr-field branch from 29e5ae5 to 8ccea2a Compare June 29, 2026 17:24
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.

1 participant