-
Notifications
You must be signed in to change notification settings - Fork 0
fix(OSQUERY-008): 3 review findings across 3 files #46
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 |
|---|---|---|
|
|
@@ -35,27 +35,27 @@ | |
| namespace osquery { | ||
| namespace tables { | ||
|
|
||
|
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. 𦩠π windowsSearchTableName constant does not follow kPascalCase naming convention Renamed the file-scope constant π€ Prompt for AI agentsfix confidence: π’ 95 high β react π/π to teach the reviewer |
||
| const std::string windowsSearchTableName = "windows_search"; | ||
| const std::string kWindowsSearchTableName = "windows_search"; | ||
|
|
||
| LONGLONG dateToUnixTime(const DATE date) { | ||
| SYSTEMTIME st = {0}; | ||
| FILETIME ft = {0}; | ||
|
|
||
| if (!VariantTimeToSystemTime(date, &st)) { | ||
| LOG(ERROR) << windowsSearchTableName | ||
| LOG(ERROR) << kWindowsSearchTableName | ||
| << ": failed to convert date to system time"; | ||
| return 0; | ||
| } | ||
|
|
||
| if (!SystemTimeToFileTime(&st, &ft)) { | ||
| LOG(ERROR) << windowsSearchTableName | ||
| LOG(ERROR) << kWindowsSearchTableName | ||
| << ": failed to convert system time to file time"; | ||
| return 0; | ||
| } | ||
|
|
||
| LONGLONG unixtime = filetimeToUnixtime(ft); | ||
| if (unixtime == 0) { | ||
| LOG(ERROR) << windowsSearchTableName | ||
| LOG(ERROR) << kWindowsSearchTableName | ||
| << ": failed to convert file time to unix time"; | ||
| return 0; | ||
| } | ||
|
|
@@ -72,7 +72,7 @@ void writePropVariant(REFPROPVARIANT variant, std::wstringstream& wss) { | |
| SafeArrayAccessData(variant.parray, reinterpret_cast<void**>(&pBStr)); | ||
|
|
||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": SafeArrayAccessData failed"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": SafeArrayAccessData failed"; | ||
| return; | ||
| } | ||
|
|
||
|
|
@@ -220,7 +220,7 @@ osquery::QueryData executeWindowsSearchQuery(CSession& cSession, | |
| hr = cCommand.Open(cSession, query.c_str()); | ||
|
|
||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": error executing query"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": error executing query"; | ||
| return results; | ||
| } | ||
|
|
||
|
|
@@ -256,7 +256,7 @@ std::string generateSqlFromUserQuery(const std::string& userInput, | |
| CLSCTX_LOCAL_SERVER, | ||
| IID_PPV_ARGS(&pSearchManager)); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName | ||
| LOG(ERROR) << kWindowsSearchTableName | ||
| << ": failed to create ISearchManager instance"; | ||
| return ""; | ||
| } | ||
|
|
@@ -269,7 +269,7 @@ std::string generateSqlFromUserQuery(const std::string& userInput, | |
| // the ISearchCatalogManager | ||
| hr = pSearchManager->GetCatalog(L"SystemIndex", &pSearchCatalogManager); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": failed to get catalog manager"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": failed to get catalog manager"; | ||
| return ""; | ||
| } | ||
| auto const pSearchCatalogManagerGuard = scope_guard::create( | ||
|
|
@@ -280,15 +280,15 @@ std::string generateSqlFromUserQuery(const std::string& userInput, | |
| ISearchQueryHelper* pQueryHelper = nullptr; | ||
| hr = pSearchCatalogManager->GetQueryHelper(&pQueryHelper); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": failed to get query helper"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": failed to get query helper"; | ||
| return ""; | ||
| } | ||
| auto const pQueryHelperGuard = | ||
| scope_guard::create([pQueryHelper]() { pQueryHelper->Release(); }); | ||
|
|
||
| hr = pQueryHelper->put_QueryMaxResults(maxResults); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": failed to set max results"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": failed to set max results"; | ||
| return ""; | ||
| } | ||
|
|
||
|
|
@@ -309,15 +309,15 @@ std::string generateSqlFromUserQuery(const std::string& userInput, | |
| hr = pQueryHelper->put_QuerySelectColumns( | ||
| stringToWstring(selectColumns).c_str()); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": failed to set columns"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": failed to set columns"; | ||
| return ""; | ||
| } | ||
| } | ||
|
|
||
| if (!sort.empty()) { | ||
| hr = pQueryHelper->put_QuerySorting(stringToWstring(sort).c_str()); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": failed to set sort"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": failed to set sort"; | ||
| return ""; | ||
| } | ||
| } | ||
|
|
@@ -326,7 +326,7 @@ std::string generateSqlFromUserQuery(const std::string& userInput, | |
| hr = pQueryHelper->GenerateSQLFromUserQuery( | ||
| stringToWstring(userInput).c_str(), &sql); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName | ||
| LOG(ERROR) << kWindowsSearchTableName | ||
| << ": failed to generate SQL from user query"; | ||
| return ""; | ||
| } | ||
|
|
@@ -347,7 +347,7 @@ QueryData genWindowsSearch(QueryContext& context) { | |
| L"provider=Search.CollatorDSO.1;EXTENDED " | ||
| L"PROPERTIES=\"Application=Windows\""); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": error initializing CDataSource"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": error initializing CDataSource"; | ||
| return results; | ||
| } | ||
| auto const cDataSourceGuard = | ||
|
|
@@ -356,7 +356,7 @@ QueryData genWindowsSearch(QueryContext& context) { | |
| CSession cSession; | ||
| hr = cSession.Open(cDataSource); | ||
| if (FAILED(hr)) { | ||
| LOG(ERROR) << windowsSearchTableName << ": error opening CSession"; | ||
| LOG(ERROR) << kWindowsSearchTableName << ": error opening CSession"; | ||
| return results; | ||
| } | ||
| auto const cSessionGuard = | ||
|
|
@@ -476,3 +476,4 @@ QueryData genWindowsSearch(QueryContext& context) { | |
|
|
||
| } // namespace tables | ||
| } // namespace osquery | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,16 +10,17 @@ | |
| #include <osquery/utils/system/errno.h> | ||
|
|
||
| #include <string.h> | ||
|
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. 𦩠π kInitialBufferSize and kEnvironmentExpansionMax declared with Replaced π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| #include <cstddef> | ||
| #include <vector> | ||
|
|
||
| #define MAX_BUFFER_SIZE 256 | ||
| constexpr std::size_t kMaxBufferSize = 256; | ||
|
|
||
| namespace osquery { | ||
| const auto kWindowsLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT); | ||
|
|
||
| std::string platformStrerr(int errnum) { | ||
| std::vector<char> buffer; | ||
| buffer.assign(MAX_BUFFER_SIZE, '\0'); | ||
| buffer.assign(kMaxBufferSize, '\0'); | ||
|
|
||
| auto status = ::strerror_s(buffer.data(), buffer.size(), errnum); | ||
| if (status != 0) { | ||
|
|
@@ -57,3 +58,4 @@ Status getWindowsErrorDescription(std::wstring& error_message, DWORD error_id) { | |
| } | ||
|
|
||
| } // namespace osquery | ||
|
|
||
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.
𦩠π SeccompEventSubscriber static maps use snake_case instead of the required kPascalCase constant naming
Renamed the three static const class members in
SeccompEventSubscriber(declared inosquery/tables/events/linux/seccomp_events.h) from snake_case to kPascalCase:seccomp_actions_map->kSeccompActionsMap,arch_codes_map->kArchCodesMap,syscall_x86_64_map->kSyscallX8664Map. This is a header-only change; the corresponding definitions inseccomp_events.cpp(not visible here) must be updated to match these new names or the build will fail to link/compile, so this fix is incomplete without a corresponding change to the .cpp file.π€ Prompt for AI agents
fix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer