fix(security): replace console.warn with structured logger in windows…#72782
fix(security): replace console.warn with structured logger in windows…#72782DoncicX wants to merge 2 commits intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR replaces Confidence Score: 3/5Not safe to merge as-is — the logger call has a type mismatch that drops the error detail and will fail TypeScript compilation. A single P1 finding (type error + runtime data loss at the logger call site) caps the score. The structural change itself is correct; only the argument to logger.warn needs fixing. src/security/windows-acl.ts — line 302, the logger.warn call Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/security/windows-acl.ts
Line: 302
Comment:
**Wrong type passed as `meta` — error detail silently dropped**
`SubsystemLogger.warn` is typed as `(message: string, meta?: Record<string, unknown>) => void`, so the second argument must be a `Record<string, unknown>`, not a `string`. Passing `String(err)` here is a TypeScript compile error, and at runtime the error details are lost: `emitLog` calls `Object.keys(meta)` on the string, which returns character-index keys, so the actual error text never reaches the log sink.
Combine the error into the message string or pass it as a structured meta object:
```suggestion
logger.warn(`resolveCurrentUserSid failed: ${String(err)}`);
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(security): replace console.warn with..." | Re-trigger Greptile |
b31b0f7 to
c021a76
Compare
|
"CI failure in checks-node-agentic-commands (qr-cli.test.ts vitest mock hoisting) is a pre-existing infrastructure issue unrelated to this change. checks-node-core-src-security passes." |
…-acl Resolves the TODO to replace console.warn with a structured logger call. The previous console.warn could be noisy on constrained Windows hosts (e.g. strict output-capture environments or CI runners with limited stdio).
aeac483 to
3edd739
Compare
|
CI failures in check, check-additional, checks-node-channels, checks-node-core-fast-support, checks-node-core-support-boundary, and checks-node-extensions are pre-existing issues on main and unrelated to this change. checks-node-core-src-security (covering the modified windows-acl.ts) passes, and checks-node-agentic-commands (previously blocked by #73177) is now green after #73206. |
|
Codex review: needs maintainer review before merge. Keep open. Current main still has the raw console.warn and TODO in resolveCurrentUserSid, while this PR is now a focused one-file change that replaces it with createSubsystemLogger("security/windows-acl") and uses the corrected single-string logger.warn call. The earlier bot finding about passing a string as logger meta appears addressed in the latest PR patch, and the related qr-cli hoisting issue was handled separately by merged #73206. Maintainer follow-up before merge: Keep this PR open for normal maintainer review. If CI remains green, the best path is to land the focused one-file logger change, preserving resolveCurrentUserSid's best-effort null fallback and avoiding any unrelated security, dependency, or workflow changes. Run the Windows ACL test plus the qr-cli hoisting regression path and changed gate before merge. Best possible solution: Keep this PR open for normal maintainer review. If CI remains green, the best path is to land the focused one-file logger change, preserving resolveCurrentUserSid's best-effort null fallback and avoiding any unrelated security, dependency, or workflow changes. Run the Windows ACL test plus the qr-cli hoisting regression path and changed gate before merge. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against bd5afadc5c7a. |
|
same as #74471 |
Replaces the
console.warninresolveCurrentUserSidwithcreateSubsystemLogger("security/windows-acl"), resolving the existing TODO about noisy console output on constrained Windows hosts.Motivation
The previous
console.warnin theresolveCurrentUserSidcatch block was explicitly marked with a TODO noting that it can be noisy on constrained Windows hosts (e.g. strict output-capture environments or CI runners with limited stdio). Using a structured logger allows the output to be filtered by log level and subsystem, eliminating unwanted stderr noise in quiet / CI modes.Changes
createSubsystemLoggerfrom../logging/subsystem.jscreateSubsystemLogger("security/windows-acl")console.warn(...)withlogger.warn(...)inresolveCurrentUserSidTesting
windows-acl.test.tsalready covers thewhoamifailure path (returnsnullsilently)