Repository navigation
fix(OSQUERY-003): CU-86akhf8u2 5 review findings across 2 files #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| #include "openframe_token_refresher.h" | ||
| #include "openframe_authorization_manager_provider.h" | ||
| #include <osquery/logger/logger.h> | ||
|
|
||
| namespace osquery { | ||
|
|
||
| OpenframeTokenRefresher::OpenframeTokenRefresher(std::shared_ptr<OpenframeTokenExtractor> extractor) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ OpenframeTokenRefresher constructor throws std::runtime_error instead of returning Status In OpenframeTokenRefresher::OpenframeTokenRefresher (constructor), replaced the π€ Prompt for AI agentsfix confidence: π‘ 65 medium β react π/π to teach the reviewer |
||
| : running_(false), extractor_(extractor) { | ||
| if (!extractor_) { | ||
| throw std::runtime_error("Token extractor cannot be null"); | ||
| LOG(ERROR) << "Token extractor cannot be null; token refresher will be inert"; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -21,6 +22,11 @@ void OpenframeTokenRefresher::start() { | |
| return; | ||
| } | ||
|
|
||
| if (!extractor_) { | ||
| LOG(ERROR) << "Cannot start token refresher: token extractor is null"; | ||
| return; | ||
| } | ||
|
|
||
| running_ = true; | ||
| refresh_thread_ = std::thread([this]() { | ||
| while (running_) { | ||
|
|
@@ -48,6 +54,11 @@ void OpenframeTokenRefresher::stop() { | |
|
|
||
| void OpenframeTokenRefresher::process() { | ||
| try { | ||
| if (!extractor_) { | ||
| LOG(ERROR) << "Token extractor is null; skipping token refresh"; | ||
| return; | ||
| } | ||
|
|
||
| auto new_token = extractor_->extractToken(); | ||
| if (new_token.empty()) { | ||
| LOG(ERROR) << "Failed to extract new token - empty token received"; | ||
|
|
@@ -68,4 +79,4 @@ void OpenframeTokenRefresher::process() { | |
| } | ||
| } | ||
|
|
||
| } // namespace osquery | ||
| } // namespace osquery | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -300,9 +300,12 @@ Status getDatabaseValue(const std::string& domain, | |
|
|
||
| ReadLock lock(kDatabaseReset); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ getDatabaseValue/setDatabaseValue/deleteDatabase throw std::runtime_error instead of returning Status* In getDatabaseValue(domain, key, value) (the std::string overload), replaced π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ getDatabaseValue/setDatabaseBatch/deleteDatabaseValue dereference a possibly-null plugin without checking Added π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| if (!kDBInitialized) { | ||
| throw std::runtime_error("Cannot get database value: " + key); | ||
| return Status(1, "Cannot get database value: " + key); | ||
| } else { | ||
| auto plugin = getDatabasePlugin(); | ||
| if (plugin == nullptr) { | ||
| return Status(1, "Cannot get database plugin for value: " + key); | ||
| } | ||
| return plugin->get(domain, key, value); | ||
| } | ||
| } | ||
|
|
@@ -342,10 +345,13 @@ Status setDatabaseBatch(const std::string& domain, | |
|
|
||
| ReadLock lock(kDatabaseReset); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ setDatabaseBatch throws std::runtime_error instead of returning a failure Status In setDatabaseBatch, replaced π€ Prompt for AI agentsfix confidence: π’ 92 high β react π/π to teach the reviewer |
||
| if (!kDBInitialized) { | ||
| throw std::runtime_error("Cannot set database values"); | ||
| return Status(1, "Cannot set database values"); | ||
| } | ||
|
|
||
| auto plugin = getDatabasePlugin(); | ||
| if (plugin == nullptr) { | ||
| return Status(1, "Cannot get database plugin to set values"); | ||
| } | ||
| return plugin->putBatch(domain, data); | ||
| } | ||
|
|
||
|
|
@@ -370,9 +376,12 @@ Status deleteDatabaseValue(const std::string& domain, const std::string& key) { | |
|
|
||
| ReadLock lock(kDatabaseReset); | ||
| if (!kDBInitialized) { | ||
| throw std::runtime_error("Cannot delete database value: " + key); | ||
| return Status(1, "Cannot delete database value: " + key); | ||
| } else { | ||
| auto plugin = getDatabasePlugin(); | ||
| if (plugin == nullptr) { | ||
| return Status(1, "Cannot get database plugin to delete value: " + key); | ||
| } | ||
| return plugin->remove(domain, key); | ||
| } | ||
| } | ||
|
|
@@ -396,10 +405,14 @@ Status deleteDatabaseRange(const std::string& domain, | |
|
|
||
| ReadLock lock(kDatabaseReset); | ||
| if (!kDBInitialized) { | ||
| throw std::runtime_error("Cannot delete database values: " + low + " - " + | ||
| high); | ||
| return Status(1, "Cannot delete database values: " + low + " - " + high); | ||
| } else { | ||
| auto plugin = getDatabasePlugin(); | ||
| if (plugin == nullptr) { | ||
| return Status(1, | ||
| "Cannot get database plugin to delete values: " + low + | ||
| " - " + high); | ||
| } | ||
| return plugin->removeRange(domain, low, high); | ||
| } | ||
| } | ||
|
|
@@ -439,9 +452,12 @@ Status scanDatabaseKeys(const std::string& domain, | |
|
|
||
| ReadLock lock(kDatabaseReset); | ||
| if (!kDBInitialized) { | ||
| throw std::runtime_error("Cannot scan database values: " + prefix); | ||
| return Status(1, "Cannot scan database values: " + prefix); | ||
| } else { | ||
| auto plugin = getDatabasePlugin(); | ||
| if (plugin == nullptr) { | ||
| return Status(1, "Cannot get database plugin to scan values: " + prefix); | ||
| } | ||
| return plugin->scan(domain, keys, prefix, max); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π 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
fix confidence: π’ 95 high β react π/π to teach the reviewer