Repository navigation
fix(OSQUERY-003): CU-86aknprfh PipeChannelFactory::createChannelTicket throws std::runtime_error instead of returning Status - #108
Conversation
…:runtime_error instead of returning Status
| std::array<int, 2> write_pipe_fds) | ||
| : read_pipe_fds_(read_pipe_fds), write_pipe_fds_(write_pipe_fds) {} | ||
|
|
||
| PipeChannelTicket PipeChannelFactory::createChannelTicket() { |
There was a problem hiding this comment.
🦩 🔴 PipeChannelFactory::createChannelTicket throws std::runtime_error instead of returning Status
In PipeChannelFactory::createChannelTicket (pipe_channel_factory.cpp), replaced the two throw std::runtime_error(...) calls on pipe() failure with return Status::failure(...), and changed the function signature from PipeChannelTicket createChannelTicket() to Status createChannelTicket(PipeChannelTicket& ticket) (ticket now passed by out-parameter reference, with Status::success() returned on the happy path). This directly removes the exception-throwing behavior called out in the finding and aligns with the Status-based convention used elsewhere in the file (e.g. LinuxTableContainerIPC::connectToContainer). RISK: this is a signature change to a function whose declaration lives in pipe_channel_factory.h (not shown/provided) and whose caller is in connectToContainer (also not shown) — I could not update either the header declaration or the call site in this response since only this .cpp file was in scope, so as given this file will fail to compile against an unmodified header, and connectToContainer's call like auto ticket = createChannelTicket(); would also need to become PipeChannelTicket ticket; auto status = createChannelTicket(ticket); if (!status.ok()) return status; or similar. A complete fix requires: (a) updating the header's method declaration to Status createChannelTicket(PipeChannelTicket& ticket);, and (b) updating connectToContainer to handle the new Status return instead of relying on no-throw value construction. I did not have visibility into those files to make this change safely end-to-end, so this should be treated as a starting point requiring companion edits before merge.
🤖 Prompt for AI agents
In osquery/worker/ipc/posix/pipe_channel_factory.cpp around line 24, review and complete this code-review fix: PipeChannelFactory::createChannelTicket throws std::runtime_error instead of returning Status.
What the draft fix changed: In `PipeChannelFactory::createChannelTicket` (pipe_channel_factory.cpp), replaced the two `throw std::runtime_error(...)` calls on `pipe()` failure with `return Status::failure(...)`, and changed the function signature from `PipeChannelTicket createChannelTicket()` to `Status createChannelTicket(PipeChannelTicket& ticket)` (ticket now passed by out-parameter reference, with `Status::success()` returned on the happy path). This directly removes the exception-throwing behavior called out in the finding and aligns with the Status-based convention used elsewhere in the file (e.g. `LinuxTableContainerIPC::connectToContainer`). RISK: this is a signature change to a function whose declaration lives in `pipe_channel_factory.h` (not shown/provided) and whose caller is in `connectToContainer` (also not shown) — I could not update either the header declaration or the call site in this response since only this .cpp file was in scope, so as given this file will fail to compile against an unmodified header, and `connectToContainer`'s call like `auto ticket = createChannelTicket();` would also need to become `PipeChannelTicket ticket; auto status = createChannelTicket(ticket); if (!status.ok()) return status;` or similar. A complete fix requires: (a) updating the header's method declaration to `Status createChannelTicket(PipeChannelTicket& ticket);`, and (b) updating `connectToContainer` to handle the new Status return instead of relying on no-throw value construction. I did not have visibility into those files to make this change safely end-to-end, so this should be treated as a starting point requiring companion edits before merge.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 25 low — review closely — react 👍/👎 to teach the reviewer
Closes findings from rule OSQUERY-003 — PipeChannelFactory::createChannelTicket throws std::runtime_error instead of returning Status.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
osquery/worker/ipc/posix/pipe_channel_factory.cpp:24What changed — and what was deliberately left — is explained per finding as inline review comments on the lines each finding touched.
Run: https://product-hub.flamingo.so/admin/code-review
Run id:
116a6ce1-ae2a-4217-a4a6-046396b5281cMerging this PR is recorded as acceptance of the rule that produced it;
closing it unmerged is recorded as rejection. Both feed rule health, so
closing a wrong suggestion is useful rather than merely tidy.
ClickUp task: CU-86aknprfh Osquery review findings sweep (14 PRs)