Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions osquery/core/windows/wmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ void WmiResultItem::PrintType(const std::string& name) const {
VARIANT value;
HRESULT hr = result_->Get(property_name.c_str(), 0, &value, nullptr, nullptr);
if (hr != S_OK) {
std::cerr << "Failed: " << name << "\n";
LOG(ERROR) << "Failed: " << name;
} else {
std::cout << "Name=" << name << ", Type=" << value.vt << "\n";
VLOG(1) << "Name=" << name << ", Type=" << value.vt;
if (value.vt == VT_I4) {
std::cout << " Value=" << value.lVal << "\n";
VLOG(1) << " Value=" << value.lVal;
} else if (value.vt == VT_BSTR) {
std::wcout << " Value=" << value.bstrVal << "\n";
VLOG(1) << " Value=" << wstringToString(value.bstrVal);
}
}
VariantClear(&value);
Comment on lines 77 to 89

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 wmi.cpp PrintType uses std::cerr/std::cout/std::wcout for diagnostics instead of LOG()/VLOG()

In WmiResultItem::PrintType (osquery/core/windows/wmi.cpp), replaced the direct std::cerr/std::cout/std::wcout diagnostic writes with LOG(ERROR) for the failure path and VLOG(1) for the success/value-printing path, using the existing osquery/logger/logger.h include already present in this file. The std::wcout call for BSTR values was converted via the already-included wstringToString helper (from osquery/utils/conversions/windows/strings.h, already used elsewhere in this file) so the value can be streamed into VLOG(1) as a std::string rather than requiring wide-stream output. No new includes or external modules were introduced.

πŸ€– Prompt for AI agents
In osquery/core/windows/wmi.cpp around line 75, review and complete this code-review fix: wmi.cpp PrintType uses std::cerr/std::cout/std::wcout for diagnostics instead of LOG()/VLOG().
What the draft fix changed: In `WmiResultItem::PrintType` (osquery/core/windows/wmi.cpp), replaced the direct `std::cerr`/`std::cout`/`std::wcout` diagnostic writes with `LOG(ERROR)` for the failure path and `VLOG(1)` for the success/value-printing path, using the existing `osquery/logger/logger.h` include already present in this file. The `std::wcout` call for BSTR values was converted via the already-included `wstringToString` helper (from `osquery/utils/conversions/windows/strings.h`, already used elsewhere in this file) so the value can be streamed into `VLOG(1)` as a `std::string` rather than requiring wide-stream output. No new includes or external modules were introduced.
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟒 90 high β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Expand Down Expand Up @@ -598,3 +598,4 @@ Status WmiRequest::ExecMethod(const WmiResultItem& object,
}

} // namespace osquery

7 changes: 4 additions & 3 deletions plugins/logger/filesystem_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool validateLoggerMode(const char* flagname, const std::string& value) {
// Account for leading 0, special bit, and normal permissions
if (value.size() > 5) {
osquery::systemLog(kLoggerModeInvalidValueError);
std::cerr << kLoggerModeInvalidValueError << std::endl;
LOG(ERROR) << kLoggerModeInvalidValueError;

return false;
}
Comment on lines 33 to 39

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🟠 std::cerr used for diagnostics instead of LOG()/VLOG() macros

In validateLoggerMode (plugins/logger/filesystem_logger.cpp), replaced the three redundant std::cerr << ... << std::endl; diagnostic lines with LOG(ERROR) << ...;, routing output through the glog-backed LOG() macro instead of raw stderr, per OSQUERY-004/004-2. The <iostream> include was left in place since it is not otherwise flagged and removing it is outside the scope of this finding (risk: low, unused include may remain but causes no build issue since other headers may still rely on standard streams indirectly).

πŸ€– Prompt for AI agents
In plugins/logger/filesystem_logger.cpp around line 32, review and complete this code-review fix: std::cerr used for diagnostics instead of LOG()/VLOG() macros.
What the draft fix changed: In `validateLoggerMode` (plugins/logger/filesystem_logger.cpp), replaced the three redundant `std::cerr << ... << std::endl;` diagnostic lines with `LOG(ERROR) << ...;`, routing output through the glog-backed LOG() macro instead of raw stderr, per OSQUERY-004/004-2. The `<iostream>` include was left in place since it is not otherwise flagged and removing it is outside the scope of this finding (risk: low, unused include may remain but causes no build issue since other headers may still rely on standard streams indirectly).
Verify the change is correct and complete; do not refactor unrelated code.

fix confidence: 🟑 75 medium β€” react πŸ‘/πŸ‘Ž to teach the reviewer

Expand All @@ -42,7 +42,7 @@ bool validateLoggerMode(const char* flagname, const std::string& value) {

if (logger_mode_octal_exp.isError()) {
osquery::systemLog(kLoggerModeConversionFailureError);
std::cerr << kLoggerModeConversionFailureError << std::endl;
LOG(ERROR) << kLoggerModeConversionFailureError;

return false;
}
Expand All @@ -51,7 +51,7 @@ bool validateLoggerMode(const char* flagname, const std::string& value) {

if (logger_mode_octal <= 0 || logger_mode_octal > 07777) {
osquery::systemLog(kLoggerModeInvalidValueError);
std::cerr << kLoggerModeInvalidValueError << std::endl;
LOG(ERROR) << kLoggerModeInvalidValueError;
return false;
}

Expand Down Expand Up @@ -320,3 +320,4 @@ void FilesystemLoggerPlugin::init(const std::string& name,
FLAGS_stderrthreshold = stderr_threshold;
}
} // namespace osquery

Loading