Repository navigation
fix(adhoc-sweep-fixes): CU-86akhf8u2 27 review findings across 21 files - #99
flamingo[bot] wants to merge 21 commits into
Conversation
| {"architecture", NormalType}, | ||
| {"offer", NormalType}, | ||
| {"publisher", NormalType}, | ||
| {"sku", NormalType} {"version", NormalType}, |
There was a problem hiding this comment.
🦩 🔴 Missing comma in aggregate initializer list breaks compilation
Fixed the missing comma between {"sku", NormalType} and {"version", NormalType} in the ValidationMap initializer list inside TEST_F(azureInstanceMetadata, test_sanity), now {"sku", NormalType}, followed by {"version", NormalType}, on separate lines as suggested.
🤖 Prompt for AI agents
In tests/integration/tables/azure_instance_metadata.cpp around line 31, review and complete this code-review fix: Missing comma in aggregate initializer list breaks compilation.
What the draft fix changed: Fixed the missing comma between `{"sku", NormalType}` and `{"version", NormalType}` in the ValidationMap initializer list inside TEST_F(azureInstanceMetadata, test_sanity), now `{"sku", NormalType},` followed by `{"version", NormalType},` on separate lines as suggested.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
| {"architecture", NormalType}, | ||
| {"offer", NormalType}, | ||
| {"publisher", NormalType}, | ||
| {"sku", NormalType} {"version", NormalType}, | ||
| {"sku", NormalType}, | ||
| {"version", NormalType}, | ||
| {"os_type", NormalType}, | ||
| {"platform_update_domain", NormalType}, | ||
| {"platform_fault_domain", NormalType}, |
There was a problem hiding this comment.
🦩 🔴 Missing closing brace for TEST_F body and unbalanced namespace closures
Added the missing closing brace } for the TEST_F function body after the if (!data.empty()) { ... } block, and corrected the two trailing brace-closing comment lines so the file now ends with } // namespace table_tests followed by } // namespace osquery, matching sibling test files' structure.
🤖 Prompt for AI agents
In tests/integration/tables/azure_instance_metadata.cpp around line 22, review and complete this code-review fix: Missing closing brace for TEST_F body and unbalanced namespace closures.
What the draft fix changed: Added the missing closing brace `}` for the TEST_F function body after the `if (!data.empty()) { ... }` block, and corrected the two trailing brace-closing comment lines so the file now ends with `} // namespace table_tests` followed by `} // namespace osquery`, matching sibling test files' structure.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
|
|
||
| namespace osquery { | ||
|
|
||
| class OpenframeEncryptionService { |
There was a problem hiding this comment.
🦩 🔴 OpenframeEncryptionService class defined outside the osquery namespace
Wrapped the OpenframeEncryptionService class declaration in namespace osquery { ... } in openframe/openframe_encryption_service.h, matching the sibling OpenframeTokenRefresher convention. Added closing brace with // namespace osquery comment.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.h around line 11, review and complete this code-review fix: OpenframeEncryptionService class defined outside the osquery namespace.
What the draft fix changed: Wrapped the OpenframeEncryptionService class declaration in `namespace osquery { ... }` in openframe/openframe_encryption_service.h, matching the sibling OpenframeTokenRefresher convention. Added closing brace with `// namespace osquery` comment.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| @@ -16,10 +20,10 @@ class OpenframeEncryptionService { | |||
| /** | |||
There was a problem hiding this comment.
🦩 🔴 decrypt() documented to throw std::runtime_error instead of returning osquery::Status
Changed decrypt()'s signature from std::string decrypt(const std::string& data) (documented to throw std::runtime_error) to Status decrypt(const std::string& data, std::string& decrypted), updated the doc comment to describe the Status-based contract, and added #include "osquery/core/status.h". This header-only change is consistent with the repo's Status convention, but the corresponding .cpp implementation (not shown/provided) must be updated to match this new signature and populate the output parameter instead of throwing/returning a string, or the build will fail to link/compile; that implementation change is outside this file and is not verified here.
🤖 Prompt for AI agents
In openframe/openframe_encryption_service.h around line 16, review and complete this code-review fix: decrypt() documented to throw std::runtime_error instead of returning osquery::Status.
What the draft fix changed: Changed decrypt()'s signature from `std::string decrypt(const std::string& data)` (documented to throw std::runtime_error) to `Status decrypt(const std::string& data, std::string& decrypted)`, updated the doc comment to describe the Status-based contract, and added `#include "osquery/core/status.h"`. This header-only change is consistent with the repo's Status convention, but the corresponding .cpp implementation (not shown/provided) must be updated to match this new signature and populate the output parameter instead of throwing/returning a string, or the build will fail to link/compile; that implementation change is outside this file and is not verified here.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.
fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer
| ['sc.exe'] + list(args), | ||
| stderr=subprocess.PIPE, | ||
| stdout=subprocess.PIPE) | ||
| except subprocess.CalledProcessError, err: |
There was a problem hiding this comment.
🦩 🔴 test_windows_service.py uses Python 2-only except syntax
In sc(), changed except subprocess.CalledProcessError, err: to except subprocess.CalledProcessError as err:, the standard Python 3 exception-binding syntax, resolving the SyntaxError that prevented the module from parsing at all.
🤖 Prompt for AI agents
In tools/tests/test_windows_service.py around line 106, review and complete this code-review fix: test_windows_service.py uses Python 2-only except syntax.
What the draft fix changed: In `sc()`, changed `except subprocess.CalledProcessError, err:` to `except subprocess.CalledProcessError as err:`, the standard Python 3 exception-binding syntax, resolving the SyntaxError that prevented the module from parsing at all.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 95 high — react 👍/👎 to teach the reviewer
| @@ -182,7 +182,15 @@ Status archive(const std::set<boost::filesystem::path>& paths, | |||
| archive_entry_set_size(entry, pFile.size()); | |||
| archive_entry_set_filetype(entry, AE_IFREG); | |||
| archive_entry_set_perm(entry, 0644); | |||
There was a problem hiding this comment.
🦩 🟠 archive() ignores archive_write_header/archive_write_data return codes, can silently produce truncated/corrupt tar archives
In archive(), the return values of archive_write_header() and archive_write_data() are now checked. archive_write_header()'s result is checked for ARCHIVE_FATAL/ARCHIVE_WARN, and archive_write_data()'s result is checked for a negative value or a byte count less than the requested block size; on either failure the entry/archive handles are freed and a failure Status with the libarchive error string (via archive_error_string()) is returned instead of silently continuing and returning Status::success().
🤖 Prompt for AI agents
In osquery/filesystem/file_compression.cpp around line 184, review and complete this code-review fix: archive() ignores archive_write_header/archive_write_data return codes, can silently produce truncated/corrupt tar archives.
What the draft fix changed: In archive(), the return values of archive_write_header() and archive_write_data() are now checked. archive_write_header()'s result is checked for ARCHIVE_FATAL/ARCHIVE_WARN, and archive_write_data()'s result is checked for a negative value or a byte count less than the requested block size; on either failure the entry/archive handles are freed and a failure Status with the libarchive error string (via archive_error_string()) is returned instead of silently continuing and returning Status::success().
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
| /** | ||
| * @brief Publisher constants | ||
| */ | ||
| static const USHORT etwDefaultKernelID = 0; |
There was a problem hiding this comment.
🦩 🟠 File-scope constant kEtwDNSPublisherName is fine, but etwDefaultKernelID/etwDNSStartID/etwDNSStopID break kPascalCase and are unused static member constants
Renamed the static class constants in EtwPublisherDNS (etw_publisher_dns.h) from etwDefaultKernelID, etwDNSStartID, etwDNSStopID to kEtwDefaultKernelId, kEtwDnsStartId, kEtwDnsStopId to follow kPascalCase per OSQUERY-008, matching the existing kEtwDNSPublisherName convention. Since these are declared but unused within this header (per the finding), no other in-file references needed updating; any external usage in the corresponding .cpp file (not provided) would need matching updates, which is unverified here.
🤖 Prompt for AI agents
In osquery/events/windows/etw/etw_publisher_dns.h around line 49, review and complete this code-review fix: File-scope constant kEtwDNSPublisherName is fine, but etwDefaultKernelID/etwDNSStartID/etwDNSStopID break kPascalCase and are unused static member constants.
What the draft fix changed: Renamed the static class constants in EtwPublisherDNS (etw_publisher_dns.h) from `etwDefaultKernelID`, `etwDNSStartID`, `etwDNSStopID` to `kEtwDefaultKernelId`, `kEtwDnsStartId`, `kEtwDnsStopId` to follow kPascalCase per OSQUERY-008, matching the existing `kEtwDNSPublisherName` convention. Since these are declared but unused within this header (per the finding), no other in-file references needed updating; any external usage in the corresponding .cpp file (not provided) would need matching updates, which is unverified here.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 85 medium — react 👍/👎 to teach the reviewer
|
|
||
| std::unique_ptr<IUpdateHistoryEntry, InterfaceReleaser<IUpdateHistoryEntry>> | ||
| entry(pEntry, InterfaceReleaser<IUpdateHistoryEntry>()); | ||
| return populateWindowsUpdateHistoryEntry(pEntry); | ||
| return populateWindowsUpdateHistoryEntry(entry.get()); | ||
| } | ||
|
|
||
| Expected<WindowsUpdateHistory, WindowsUpdateHistoryError> |
There was a problem hiding this comment.
🦩 🟠 getAt() double-manages ownership of pEntry via two RAII wrappers with no clear owner
In getAt (osquery/tables/system/windows/windows_update_history.cpp), changed the call populateWindowsUpdateHistoryEntry(pEntry) to populateWindowsUpdateHistoryEntry(entry.get()), making the RAII wrapper entry the sole formally-referenced owner of the interface pointer used past its construction, removing the ambiguity about which object owns the lifetime and eliminating the appearance of an unused variable while preserving identical runtime behavior (same pointer value passed through, released once when entry goes out of scope).
🤖 Prompt for AI agents
In osquery/tables/system/windows/windows_update_history.cpp around line 288, review and complete this code-review fix: getAt() double-manages ownership of pEntry via two RAII wrappers with no clear owner.
What the draft fix changed: In `getAt` (osquery/tables/system/windows/windows_update_history.cpp), changed the call `populateWindowsUpdateHistoryEntry(pEntry)` to `populateWindowsUpdateHistoryEntry(entry.get())`, making the RAII wrapper `entry` the sole formally-referenced owner of the interface pointer used past its construction, removing the ambiguity about which object owns the lifetime and eliminating the appearance of an unused variable while preserving identical runtime behavior (same pointer value passed through, released once when `entry` goes out of scope).
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
| tryTo<std::int32_t>(FLAGS_logger_mode, 8); | ||
|
|
||
| /* This is here as safety, but the logger_mode flag should be already | ||
| validated, so no exception should be really thrown here */ | ||
| validated, so no exception should be really thrown here. If this is | ||
| somehow reached (e.g. the validator was bypassed), log the error and | ||
| fall back to a safe default mode instead of throwing from the | ||
| constructor, since plugin setup code does not expect exceptions. */ | ||
| if (logger_mode_octal_exp.isError()) { | ||
| throw std::runtime_error("Failed to convert logger_mode string to octal"); | ||
| LOG(ERROR) << kLoggerModeConversionFailureError | ||
| << "; falling back to default logger_mode"; | ||
| logger_mode_octal = kDefaultLoggerModeOctal; | ||
| } else { | ||
| logger_mode_octal = logger_mode_octal_exp.get(); | ||
| } | ||
|
|
||
| logger_mode_octal = logger_mode_octal_exp.get(); | ||
| } | ||
|
|
||
| /// The folder where Glog and the result/snapshot files are written. |
There was a problem hiding this comment.
🦩 🟠 FilesystemLoggerPlugin::impl constructor throws std::runtime_error on a config validation failure that should already be unreachable
In FilesystemLoggerPlugin::impl constructor (struct FilesystemLoggerPlugin::impl in plugins/logger/filesystem_logger.cpp), replaced the throw std::runtime_error(...) on tryTo<std::int32_t> conversion failure with a LOG(ERROR) call plus a safe fallback assignment to a new kDefaultLoggerModeOctal constant (0640, matching the CLI flag's own default). This removes the possibility of an unhandled C++ exception propagating out of plugin construction during setUp/registration, while preserving behavior in the normal case (validated flag converts successfully). Risk: this changes runtime behavior in the previously-unreachable error path from "crash" to "silently continue with default permissions"; a more thorough fix per the finding (returning Status from setUp() and deferring impl construction) would be more invasive and touch the header (filesystem_logger.h), which was not given, so it was not attempted.
🤖 Prompt for AI agents
In plugins/logger/filesystem_logger.cpp around line 175, review and complete this code-review fix: FilesystemLoggerPlugin::impl constructor throws std::runtime_error on a config validation failure that should already be unreachable.
What the draft fix changed: In `FilesystemLoggerPlugin::impl` constructor (struct `FilesystemLoggerPlugin::impl` in `plugins/logger/filesystem_logger.cpp`), replaced the `throw std::runtime_error(...)` on `tryTo<std::int32_t>` conversion failure with a `LOG(ERROR)` call plus a safe fallback assignment to a new `kDefaultLoggerModeOctal` constant (0640, matching the CLI flag's own default). This removes the possibility of an unhandled C++ exception propagating out of plugin construction during `setUp`/registration, while preserving behavior in the normal case (validated flag converts successfully). Risk: this changes runtime behavior in the previously-unreachable error path from "crash" to "silently continue with default permissions"; a more thorough fix per the finding (returning `Status` from `setUp()` and deferring `impl` construction) would be more invasive and touch the header (`filesystem_logger.h`), which was not given, so it was not attempted.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟡 75 medium — react 👍/👎 to teach the reviewer
| @@ -76,8 +76,13 @@ void enumerateTasksForFolder(std::string path, QueryData& results) { | |||
| } | |||
|
|
|||
| long numTasks = 0; | |||
There was a problem hiding this comment.
🦩 🟠 numTasks (long) compared against unsigned size_t loop index causes signed/unsigned mismatch risk
In enumerateTasksForFolder, the get_Count return value (HRESULT) is now checked with FAILED(ret), and a negative numTasks is also rejected before the loop runs, returning early (after releasing pTaskCollection) on failure. The loop variable i was changed from size_t to long so the comparison i < numTasks is a signed/signed comparison with no implicit unsigned wraparound, eliminating the out-of-bounds indexing risk via get_Item(_variant_t(i + 1), ...).
🤖 Prompt for AI agents
In osquery/tables/system/windows/scheduled_tasks.cpp around line 78, review and complete this code-review fix: numTasks (long) compared against unsigned size_t loop index causes signed/unsigned mismatch risk.
What the draft fix changed: In `enumerateTasksForFolder`, the `get_Count` return value (HRESULT) is now checked with `FAILED(ret)`, and a negative `numTasks` is also rejected before the loop runs, returning early (after releasing `pTaskCollection`) on failure. The loop variable `i` was changed from `size_t` to `long` so the comparison `i < numTasks` is a signed/signed comparison with no implicit unsigned wraparound, eliminating the out-of-bounds indexing risk via `get_Item(_variant_t(i + 1), ...)`.
Verify the change is correct and complete; do not refactor unrelated code.
fix confidence: 🟢 90 high — react 👍/👎 to teach the reviewer
Closes 27 review findings across 21 files.
Draft — this is a starting point, not a finished change. The fix required judgment, so read it before trusting it.
tests/integration/tables/azure_instance_metadata.cpp:31tests/integration/tables/azure_instance_metadata.cpp:22openframe/openframe_encryption_service.h:11openframe/openframe_encryption_service.h:16tools/tests/test_windows_service.py:106tools/tests/test_windows_service.py:248osquery/remote/transports/tls.cpp:115osquery/remote/transports/tls.cpp:96openframe/openframe_authorization_manager.h:10plugins/logger/filesystem_logger.h:58osquery/tables/events/tests/windows/etw_process_events_tests.cpp:51osquery/tables/events/tests/windows/etw_process_events_tests.cpp:60osquery/tables/applications/posix/carbon_black.cpp:34osquery/tables/applications/posix/carbon_black.cpp:45osquery/tables/system/system_utils.cpp:34osquery/tables/system/darwin/sharing_preferences.cpp:174osquery/database/ephemeral.cpp:168osquery/events/windows/windowseventlogpublisher.cpp:208osquery/extensions/extensions.cpp:180osquery/tables/system/darwin/iokit_registry.cpp:59osquery/tables/system/windows/registry.cpp:473osquery/tables/system/windows/wmi_bios_info.cpp:67osquery/filesystem/file_compression.cpp:184osquery/events/windows/etw/etw_publisher_dns.h:49osquery/tables/system/windows/windows_update_history.cpp:288plugins/logger/filesystem_logger.cpp:175osquery/tables/system/windows/scheduled_tasks.cpp:78What 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)