Repository navigation
fix(OSQUERY-003): CU-86akhf8u2 5 review findings across 2 files - #97
flamingo[bot] wants to merge 2 commits into
Conversation
| @@ -300,9 +300,12 @@ Status getDatabaseValue(const std::string& domain, | |||
|
|
|||
| ReadLock lock(kDatabaseReset); | |||
There was a problem hiding this comment.
🦩 🔴 getDatabaseValue/setDatabaseValue/deleteDatabase throw std::runtime_error instead of returning Status*
In getDatabaseValue(domain, key, value) (the std::string overload), replaced throw std::runtime_error("Cannot get database value: " + key); with return Status(1, "Cannot get database value: " + key);, matching the file's Status-based error convention.
🤖 Prompt for AI agents
In osquery/database/database.cpp around line 301, review and complete this code-review fix: getDatabaseValue/setDatabaseValue/deleteDatabase* throw std::runtime_error instead of returning Status.
What the draft fix changed: In getDatabaseValue(domain, key, value) (the std::string overload), replaced `throw std::runtime_error("Cannot get database value: " + key);` with `return Status(1, "Cannot get database value: " + key);`, matching the file's Status-based error convention.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer
| @@ -342,10 +345,13 @@ Status setDatabaseBatch(const std::string& domain, | |||
|
|
|||
| ReadLock lock(kDatabaseReset); | |||
There was a problem hiding this comment.
🦩 🔴 setDatabaseBatch throws std::runtime_error instead of returning a failure Status
In setDatabaseBatch, replaced throw std::runtime_error("Cannot set database values"); with return Status(1, "Cannot set database values");. Also applied the same throw-to-Status conversion for consistency in deleteDatabaseValue, deleteDatabaseRange, and scanDatabaseKeys, which had the identical pattern and are named directly in the same finding group.
🤖 Prompt for AI agents
In osquery/database/database.cpp around line 343, review and complete this code-review fix: setDatabaseBatch throws std::runtime_error instead of returning a failure Status.
What the draft fix changed: In setDatabaseBatch, replaced `throw std::runtime_error("Cannot set database values");` with `return Status(1, "Cannot set database values");`. Also applied the same throw-to-Status conversion for consistency in deleteDatabaseValue, deleteDatabaseRange, and scanDatabaseKeys, which had the identical pattern and are named directly in the same finding group.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 92 high — react 👍/👎 to teach the reviewer
| @@ -300,9 +300,12 @@ Status getDatabaseValue(const std::string& domain, | |||
|
|
|||
| ReadLock lock(kDatabaseReset); | |||
There was a problem hiding this comment.
🦩 🔴 getDatabaseValue/setDatabaseBatch/deleteDatabaseValue dereference a possibly-null plugin without checking
Added if (plugin == nullptr) { return Status(1, ...); } null checks after every getDatabasePlugin() call in getDatabaseValue, setDatabaseBatch, deleteDatabaseValue, deleteDatabaseRange, and scanDatabaseKeys, preventing a null-pointer dereference when the registry lookup fails (rf.exists(...) returns false), before invoking plugin->get/putBatch/remove/removeRange/scan.
🤖 Prompt for AI agents
In osquery/database/database.cpp around line 301, review and complete this code-review fix: getDatabaseValue/setDatabaseBatch/deleteDatabaseValue dereference a possibly-null plugin without checking.
What the draft fix changed: Added `if (plugin == nullptr) { return Status(1, ...); }` null checks after every `getDatabasePlugin()` call in getDatabaseValue, setDatabaseBatch, deleteDatabaseValue, deleteDatabaseRange, and scanDatabaseKeys, preventing a null-pointer dereference when the registry lookup fails (rf.exists(...) returns false), before invoking plugin->get/putBatch/remove/removeRange/scan.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
|
|
||
| namespace osquery { | ||
|
|
||
| OpenframeTokenRefresher::OpenframeTokenRefresher(std::shared_ptr<OpenframeTokenExtractor> extractor) |
There was a problem hiding this comment.
🦩 🔴 OpenframeTokenRefresher constructor throws std::runtime_error instead of returning Status
In OpenframeTokenRefresher::OpenframeTokenRefresher (constructor), replaced the throw std::runtime_error(...) with a LOG(ERROR) and no throw, so a null extractor no longer crashes the daemon. Added a guard in start() that checks extractor_ and logs+returns instead of starting a thread that would dereference a null pointer, and an equivalent guard in process() as defense in depth. This does not add a Status-returning factory function (none exists in the header shown, and adding one would require editing the header file which is out of scope for a single-file fix), so the finding is only partially resolved toward the ideal OSQUERY-003 pattern — a complete fix would also add a static Status OpenframeTokenRefresher::create(...) factory in the header/other file.
🤖 Prompt for AI agents
In openframe/openframe_token_refresher.cpp around line 6, review and complete this code-review fix: OpenframeTokenRefresher constructor throws std::runtime_error instead of returning Status.
What the draft fix changed: In OpenframeTokenRefresher::OpenframeTokenRefresher (constructor), replaced the `throw std::runtime_error(...)` with a `LOG(ERROR)` and no throw, so a null extractor no longer crashes the daemon. Added a guard in `start()` that checks `extractor_` and logs+returns instead of starting a thread that would dereference a null pointer, and an equivalent guard in `process()` as defense in depth. This does not add a Status-returning factory function (none exists in the header shown, and adding one would require editing the header file which is out of scope for a single-file fix), so the finding is only partially resolved toward the ideal OSQUERY-003 pattern — a complete fix would also add a static `Status OpenframeTokenRefresher::create(...)` factory in the header/other file.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 65 medium — react 👍/👎 to teach the reviewer
| @@ -1,12 +1,13 @@ | |||
| #include "openframe_token_refresher.h" | |||
There was a problem hiding this comment.
🦩 🟠 Missing <osquery/logger/logger.h> include despite using LOG() macros
Added #include <osquery/logger/logger.h> after the existing includes at the top of the file, exactly as suggested, ensuring LOG() macros are explicitly declared rather than relying on transitive includes.
🤖 Prompt for AI agents
In openframe/openframe_token_refresher.cpp around line 1, review and complete this code-review fix: Missing <osquery/logger/logger.h> include despite using LOG() macros.
What the draft fix changed: Added `#include <osquery/logger/logger.h>` after the existing includes at the top of the file, exactly as suggested, ensuring LOG() macros are explicitly declared rather than relying on transitive includes.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
Closes 5 review findings across 2 files.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
osquery/database/database.cpp:301osquery/database/database.cpp:343osquery/database/database.cpp:301openframe/openframe_token_refresher.cpp:6openframe/openframe_token_refresher.cpp:1What 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:
46e37628-c6c9-49a4-aa29-9b30b2c8be3fMerging 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-86akhf8u2 Osquery review findings sweep (15 PRs)