Skip to content

sandbox: add a direct test for icacls error wrapping - #400

Open
jay23606 wants to merge 2 commits into
solongate:mainfrom
jay23606:pr-go/350-sandbox-icacls-has-no-direct-test-of-its
Open

jay23606 wants to merge 2 commits into
solongate:mainfrom
jay23606:pr-go/350-sandbox-icacls-has-no-direct-test-of-its

Conversation

@jay23606

Copy link
Copy Markdown

Problem

icacls() in packages/sandbox/windows.go is the single point where every deny and cleanup ACL call made from Launch can fail. It wraps a failing command's output as "icacls: " + strings.TrimSpace(out.String()). No test called icacls directly, so a change to that wrapping, or a regression in how the output is captured, would only surface through a Launch-level test failing for an unrelated reason.

Change

Test-only. Adds TestWindowsIcaclsWrapsFailureAndReturnsNilOnSuccess to packages/sandbox/windows_test.go:

  • Calls icacls against a path that does not exist and asserts a non-nil error with the icacls: prefix and non-empty captured output after it.
  • Calls icacls against an existing temporary directory and asserts a nil return.

No production code changes.

Testing

Run on Windows, where the file is built (//go:build windows):

  • go -C packages/sandbox test -count=1 -run TestWindowsIcaclsWrapsFailureAndReturnsNilOnSuccess -v . passed.
  • go -C packages/sandbox vet . was clean.
  • go -C packages/sandbox test -count=1 -v -run "Windows|SystemBinary" . passed, including the existing Windows tests.

The test is excluded on Linux and macOS by its build tag, so it does not run in the Debian/WSL environment.

Regression test: untested: a small feature has no test that fails before the change

Fixes #350

Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
@jay23606

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@codacy-production

codacy-production Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 2 critical

Alerts:
⚠ 2 issues (≤ 0 issues of at least minor severity)

Results:
2 new issues

Category Results
Security 2 critical

View in Codacy

🟢 Metrics 7 complexity · 0 duplication

Metric Results
Complexity 7
Duplication 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production 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.

Pull Request Overview

⚠️ Resolve issues before merging

The regression test does not reliably verify that icacls command output is included in the wrapped error; an exit-status-only message could pass. Strengthen the assertion before merging.

Test suggestions

  • Verify icacls wraps a missing-path failure with the expected prefix and captured output.
  • Verify icacls returns nil for an existing directory.

TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback

Comment thread packages/sandbox/windows_test.go Outdated
if !strings.HasPrefix(err.Error(), "icacls: ") {
t.Errorf("icacls error = %q, want prefix %q", err.Error(), "icacls: ")
}
if strings.TrimPrefix(err.Error(), "icacls: ") == "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 MEDIUM RISK

Assert that the wrapped error contains the missing-path command's captured output, not merely non-empty text or an exit-status message.

TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.

Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
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.

sandbox: icacls() has no direct test of its error-wrapping path

1 participant