Skip to content

Conversation

@andrejz2
Copy link

@andrejz2 andrejz2 commented Nov 4, 2025

No description provided.

@andrejz2 andrejz2 requested a review from a team as a code owner November 4, 2025 21:15
Copilot AI review requested due to automatic review settings November 4, 2025 21:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR significantly expands the test coverage for the FirmwareUpdate plugin. The changes include adding new test cases, helper methods, mock implementations, and improved code organization.

  • Added comprehensive test coverage for firmware update operations including various device types, firmware types, and error scenarios
  • Introduced NotificationHandlerMock for testing event notifications
  • Added helper methods for test setup/teardown and event triggering
  • Extended test cases for state management, auto-reboot functionality, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Core::JSONRPC::Message message;
string response;
WrapsImplMock *p_wrapsImplMock = nullptr ;
WrapsImplMock *p_wrapsImplMock = nullptr;
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent spacing: multiple spaces after variable type and before assignment operator. Should use single spaces for consistency.

Copilot uses AI. Check for mistakes.
, INIT_CONX(1, 0)
, workerPool(Core::ProxyType<WorkerPoolImplementation>::Create(
2, Core::Thread::DefaultStackSize(), 16))
, notificationMock(std::make_unique<NotificationHandlerMock>())
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: using tab character while other lines use spaces. Should maintain consistent indentation style throughout the file.

Suggested change
, notificationMock(std::make_unique<NotificationHandlerMock>())
, notificationMock(std::make_unique<NotificationHandlerMock>())

Copilot uses AI. Check for mistakes.
{

p_wrapsImplMock = new testing::NiceMock <WrapsImplMock>;
p_wrapsImplMock = new testing::NiceMock<WrapsImplMock>;
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: mixing tabs and spaces. Lines 101, 103, 105-106 use tabs while surrounding code uses spaces for indentation.

Copilot uses AI. Check for mistakes.

std::remove(FIRMWARE_UPDATE_STATE);
EXPECT_EQ(string(""), plugin->Initialize(&service));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

[nitpick] Hard-coded sleep durations in tests can lead to flaky tests. Consider using more deterministic synchronization mechanisms or making the sleep duration configurable.

Copilot uses AI. Check for mistakes.
TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Using system() call can be a security risk and is not portable. Consider using C++ filesystem library (std::filesystem::create_directories) instead.

Copilot uses AI. Check for mistakes.

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/tmp/path/to/test_firmware.bin");
system("rm -rf /tmp/path");
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Using system() with rm -rf is dangerous and not portable. Consider using C++ filesystem library (std::filesystem::remove_all) instead.

Copilot uses AI. Check for mistakes.
EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/usb_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/tmp/usb_firmware.bin");
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 4, 2025

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/usb_firmware.bin")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 4, 2025

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 4, 2025

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 4, 2025

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("test_firmware.bin");
Copy link
Contributor

@rdkcmf-jenkins rdkcmf-jenkins Nov 4, 2025

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("test_firmware.bin")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Disable the PACKAGER and MAINTENANCEMANAGER plugins in the L1 tests workflow.
Copilot AI review requested due to automatic review settings November 4, 2025 22:11
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

, workerPool(Core::ProxyType<WorkerPoolImplementation>::Create(
2, Core::Thread::DefaultStackSize(), 16))
, notificationMock(std::make_unique<NotificationHandlerMock>())
, flashInProgress(false)
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Trailing whitespace at end of line should be removed.

Suggested change
, flashInProgress(false)
, flashInProgress(false)

Copilot uses AI. Check for mistakes.
ON_CALL(*p_iarmBusImplMock, IARM_Bus_Call)
.WillByDefault(::testing::Invoke(
[this](const char* ownerName, const char* methodName, void* arg, size_t argLen) {
flashInProgress = true;
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

The flashInProgress flag is unconditionally set to true for all IARM_Bus_Call invocations in the constructor. This default behavior may interfere with tests that don't actually trigger firmware updates. Consider only setting this flag in tests that genuinely require tracking flash progress, or check the methodName parameter to set it conditionally.

Suggested change
flashInProgress = true;
// Only set flashInProgress for actual firmware update methods
if (methodName != nullptr &&
(strcmp(methodName, "InitiateFirmwareFlash") == 0 ||
strcmp(methodName, "StartFirmwareUpdate") == 0)) {
flashInProgress = true;
}

Copilot uses AI. Check for mistakes.
TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Using system() calls in tests can be unreliable and creates a dependency on shell availability. Consider using C++ filesystem API (std::filesystem::create_directories) for better portability and error handling.

Copilot uses AI. Check for mistakes.
Comment on lines +245 to +258
TEST_F(FirmwareUpdateTest, UpdateFirmware_PostFlash_ValidPCI_Success)
{

createTestFirmwareFile();

std::ofstream deviceProps("/etc/device.properties");
deviceProps << "DEVICE_TYPE=mediaclient" << std::endl;
deviceProps.close();

EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
}
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

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

Test creates /etc/device.properties but doesn't verify if write succeeds or clean up on test failure. The cleanup at line 257 should be in TearDown() or use RAII pattern to ensure cleanup happens even if test fails.

Copilot uses AI. Check for mistakes.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 5, 2025 18:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Core::JSONRPC::Message message;
string response;
WrapsImplMock *p_wrapsImplMock = nullptr ;
WrapsImplMock *p_wrapsImplMock = nullptr;
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent spacing in pointer declaration. The original line had extra spaces before '= nullptr' which were removed, but this line still has extra spaces after 'p_wrapsImplMock'. Consider consistent spacing: WrapsImplMock* p_wrapsImplMock = nullptr;

Suggested change
WrapsImplMock *p_wrapsImplMock = nullptr;
WrapsImplMock* p_wrapsImplMock = nullptr;

Copilot uses AI. Check for mistakes.
Comment on lines +101 to +106
p_wrapsImplMock = new testing::NiceMock<WrapsImplMock>;
Wraps::setImpl(p_wrapsImplMock);
p_iarmBusImplMock = new NiceMock <IarmBusImplMock>;
p_iarmBusImplMock = new NiceMock<IarmBusImplMock>;
IarmBus::setImpl(p_iarmBusImplMock);
p_rfcApiImplMock = new testing::NiceMock<RfcApiImplMock>;
RfcApi::setImpl(p_rfcApiImplMock);
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: lines use a mix of tabs and spaces. Lines 101, 102, 104 use tabs followed by spaces, while lines 103, 105, 106 use only tabs. The entire block should use consistent indentation (preferably spaces to match the surrounding code).

Copilot uses AI. Check for mistakes.
Comment on lines +169 to +174
RfcApi::setImpl(nullptr);
if (p_rfcApiImplMock != nullptr)
{
delete p_rfcApiImplMock;
p_rfcApiImplMock = nullptr;
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: using tab characters instead of spaces. This block should use consistent spacing to match the surrounding cleanup code (lines 162-167, 177-182).

Suggested change
RfcApi::setImpl(nullptr);
if (p_rfcApiImplMock != nullptr)
{
delete p_rfcApiImplMock;
p_rfcApiImplMock = nullptr;
}
RfcApi::setImpl(nullptr);
if (p_rfcApiImplMock != nullptr)
{
delete p_rfcApiImplMock;
p_rfcApiImplMock = nullptr;
}

Copilot uses AI. Check for mistakes.
Comment on lines +207 to +223
// Helper method for testing events
void triggerFirmwareEvent(const Exchange::IFirmwareUpdate::State state,
const Exchange::IFirmwareUpdate::SubState substate) {
// Register notification handler if not already registered
Core::hresult result = FirmwareUpdateImpl->Register(notificationMock.get());
EXPECT_TRUE(result == Core::ERROR_NONE || result == Core::ERROR_ALREADY_CONNECTED);

// Trigger update state change through plugin handler
string stateString = (state == Exchange::IFirmwareUpdate::State::FLASHING_SUCCEEDED) ? "FLASHING_SUCCEEDED" :
(state == Exchange::IFirmwareUpdate::State::FLASHING_FAILED) ? "FLASHING_FAILED" : "IDLE";

string substateString = (substate == Exchange::IFirmwareUpdate::SubState::NOT_APPLICABLE) ? "NOT_APPLICABLE" : "GENERIC_ERROR";

string updateStatusRequest = "{\"state\":\"" + stateString + "\",\"substate\":\"" + substateString + "\"}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("onUpdateStateChange"), updateStatusRequest, response));
}

Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The helper method triggerFirmwareEvent is defined but appears unused based on the visible test cases. If this method is intended for future use, consider adding a comment explaining its purpose. If it's not used, it should be removed.

Suggested change
// Helper method for testing events
void triggerFirmwareEvent(const Exchange::IFirmwareUpdate::State state,
const Exchange::IFirmwareUpdate::SubState substate) {
// Register notification handler if not already registered
Core::hresult result = FirmwareUpdateImpl->Register(notificationMock.get());
EXPECT_TRUE(result == Core::ERROR_NONE || result == Core::ERROR_ALREADY_CONNECTED);
// Trigger update state change through plugin handler
string stateString = (state == Exchange::IFirmwareUpdate::State::FLASHING_SUCCEEDED) ? "FLASHING_SUCCEEDED" :
(state == Exchange::IFirmwareUpdate::State::FLASHING_FAILED) ? "FLASHING_FAILED" : "IDLE";
string substateString = (substate == Exchange::IFirmwareUpdate::SubState::NOT_APPLICABLE) ? "NOT_APPLICABLE" : "GENERIC_ERROR";
string updateStatusRequest = "{\"state\":\"" + stateString + "\",\"substate\":\"" + substateString + "\"}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("onUpdateStateChange"), updateStatusRequest, response));
}

Copilot uses AI. Check for mistakes.
Comment on lines +224 to +232
void triggerProgressEvent(uint32_t progress) {
// Register notification handler if not already registered
Core::hresult result = FirmwareUpdateImpl->Register(notificationMock.get());
EXPECT_TRUE(result == Core::ERROR_NONE || result == Core::ERROR_ALREADY_CONNECTED);

// Trigger progress update through plugin handler
string progressRequest = "{\"progress\":" + std::to_string(progress) + "}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("onFlashingProgressChange"), progressRequest, response));
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The helper method triggerProgressEvent is defined but appears unused based on the visible test cases. If this method is intended for future use, consider adding a comment explaining its purpose. If it's not used, it should be removed.

Suggested change
void triggerProgressEvent(uint32_t progress) {
// Register notification handler if not already registered
Core::hresult result = FirmwareUpdateImpl->Register(notificationMock.get());
EXPECT_TRUE(result == Core::ERROR_NONE || result == Core::ERROR_ALREADY_CONNECTED);
// Trigger progress update through plugin handler
string progressRequest = "{\"progress\":" + std::to_string(progress) + "}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("onFlashingProgressChange"), progressRequest, response));
}

Copilot uses AI. Check for mistakes.
}
#endif

//Newtest ends
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Comment has incorrect spacing and capitalization. Should be '// New test ends' or '// New tests end' with proper spacing after '//'.

Suggested change
//Newtest ends
// New tests end

Copilot uses AI. Check for mistakes.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 5, 2025 21:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Refactor FirmwareUpdateTest constructor and cleanup methods. Simplify mock expectations and improve readability.
Removed unused mock calls for fclose and fgets in tests.
Copilot AI review requested due to automatic review settings November 5, 2025 22:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 265 to 284
TEST_F(FirmwareUpdateTest, UpdateFirmware_ValidPCIFirmware)
{
const char* filePath = "/tmp/ELTE11MWR_MIDDLEWARE_DEV_default_20241122145614.bin";
std::ofstream outfile(filePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}

std::ofstream versionFile("/version.txt");
if (versionFile.is_open()) {
versionFile << "imagename:DIFFERENT_IMAGE\n";
versionFile.close();
}

EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR_MIDDLEWARE_DEV_default_20241122145614.bin\",\"firmwareType\":\"PCI\"}"), response));
EXPECT_TRUE(response.find("\"success\":true") != string::npos);

std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The test creates a temporary file and version.txt without cleanup. Add file cleanup in teardown or at test end to prevent test pollution and ensure test isolation. Multiple tests create similar files that may interfere with each other.

Copilot uses AI. Check for mistakes.
Comment on lines 588 to 605
TEST_F(FirmwareUpdateTest, UpdateFirmware_SymbolicLink)
{
const char* realPath = "/tmp/real_firmware.bin";
const char* linkPath = "/tmp/link_firmware.bin";

std::ofstream outfile(realPath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}

symlink(realPath, linkPath);

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/link_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

unlink(linkPath);
unlink(realPath);
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The symlink() call may fail if the link already exists from a previous test run, causing the test to pass incorrectly. Check the return value of symlink() or remove any existing link before creation to ensure test reliability.

Copilot uses AI. Check for mistakes.
Comment on lines 607 to 614
TEST_F(FirmwareUpdateTest, UpdateFirmware_DirectoryInsteadOfFile)
{
mkdir("/tmp/firmware_dir", 0755);

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/firmware_dir\",\"firmwareType\":\"PCI\"}"), response));

rmdir("/tmp/firmware_dir");
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

The mkdir() call may fail if the directory already exists, causing the test to verify incorrect behavior. Check the return value of mkdir() or use mkdir with error checking to ensure the test setup is correct.

Copilot uses AI. Check for mistakes.
Comment on lines 325 to 335
TEST_F(FirmwareUpdateTest, UpdateFirmware_InvalidFilePath_SpecialCharacters)
{
const char* filePath = "/tmp/ELTE11MWR_@#$%^&*.bin";
std::ofstream outfile(filePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR_@#$%^&*.bin\",\"firmwareType\":\"PCI\"}"), response));
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Test creates a file but does not clean it up. Add cleanup code (e.g., std::remove(filePath)) after the test assertion to maintain test isolation and prevent leftover files.

Copilot uses AI. Check for mistakes.
Comment on lines 337 to 347
TEST_F(FirmwareUpdateTest, UpdateFirmware_InvalidFilePath_WithSpaces)
{
const char* filePath = "/tmp/ELTE11MWR MIDDLEWARE.bin";
std::ofstream outfile(filePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR MIDDLEWARE.bin\",\"firmwareType\":\"PCI\"}"), response));
}
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Test creates a file but does not clean it up. Add cleanup code (e.g., std::remove(filePath)) after the test assertion to maintain test isolation and prevent leftover files.

Copilot uses AI. Check for mistakes.
outfile.close();
}

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR_MIDDLEWARE_DEV_default.txt\",\"firmwareType\":\"PCI\"}"), response));
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Test creates a file but does not clean it up. Add cleanup code (e.g., std::remove(filePath)) after the test assertion to maintain test isolation and prevent leftover files.

Suggested change
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR_MIDDLEWARE_DEV_default.txt\",\"firmwareType\":\"PCI\"}"), response));
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/ELTE11MWR_MIDDLEWARE_DEV_default.txt\",\"firmwareType\":\"PCI\"}"), response));
std::remove(filePath);

Copilot uses AI. Check for mistakes.
Comment on lines 412 to 419
const char* filePath = "/ELTE11MWR_MIDDLEWARE_DEV_default.bin";
std::ofstream outfile(filePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}

EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/ELTE11MWR_MIDDLEWARE_DEV_default.bin\",\"firmwareType\":\"PCI\"}"), response));
Copy link

Copilot AI Nov 5, 2025

Choose a reason for hiding this comment

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

Test attempts to create a file in the root directory which requires elevated permissions and will likely fail. The test should either check file creation success or skip cleanup if creation fails, or use a mock/temp directory instead.

Suggested change
const char* filePath = "/ELTE11MWR_MIDDLEWARE_DEV_default.bin";
std::ofstream outfile(filePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/ELTE11MWR_MIDDLEWARE_DEV_default.bin\",\"firmwareType\":\"PCI\"}"), response));
// Create the file in /tmp to avoid permission issues, but test with root path
const char* tmpFilePath = "/tmp/ELTE11MWR_MIDDLEWARE_DEV_default.bin";
std::ofstream outfile(tmpFilePath);
if (outfile.is_open()) {
outfile << "dummy firmware content";
outfile.close();
}
// Pass the root path to the handler to test rejection
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/ELTE11MWR_MIDDLEWARE_DEV_default.bin\",\"firmwareType\":\"PCI\"}"), response));
// Cleanup: remove the file if it was created
std::remove(tmpFilePath);

Copilot uses AI. Check for mistakes.
file.close();

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "mkdir("/tmp/firmware_dir", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/tmp/path/to/test_firmware.bin");
system("rm -rf /tmp/path");
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

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

Using system() with string literals is generally acceptable, but the test should verify the commands succeeded. Add error checking or use std::filesystem for safer directory operations.

Copilot uses AI. Check for mistakes.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Removed expectation for firmware update handler invocation.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 6, 2025 19:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 12, 2025 19:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 13 to 14
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing,software
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Duplicate line: The license comment line "Unless required by applicable law or agreed to in writing,software" appears twice. Additionally, there's a missing space after the comma before "software". This should be one line that reads: "Unless required by applicable law or agreed to in writing, software"

Suggested change
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing, software

Copilot uses AI. Check for mistakes.
result.success = true;
status =Core::ERROR_NONE;

LOGINFO("[%s:%d] UpdateFirmware completed successfully, returning with status: Core::ERROR_NONE", __FUNCTION__, __LINE__);
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Excessive logging: Adding LOGINFO statements at every return point and decision branch creates log noise and makes debugging harder. Consider consolidating logging to key decision points only (e.g., function entry, validation failures with specific reasons, and critical state changes). The FUNCTION and LINE macros are already included in most log statements, making this redundant information.

Suggested change
LOGINFO("[%s:%d] UpdateFirmware completed successfully, returning with status: Core::ERROR_NONE", __FUNCTION__, __LINE__);

Copilot uses AI. Check for mistakes.
MOCK_METHOD(void, OnUpdateStateChange, (const Exchange::IFirmwareUpdate::State state,
const Exchange::IFirmwareUpdate::SubState substate), (override));
MOCK_METHOD(void, OnFlashingStateChange, (const uint32_t percentageComplete), (override));

Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Trailing whitespace: Remove the trailing spaces after the semicolon on this line.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines 13 to 14
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing,software
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Missing space after the comma before "software". Should be: "Unless required by applicable law or agreed to in writing, software"

Suggested change
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing,software
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software

Copilot uses AI. Check for mistakes.
, INIT_CONX(1, 0)
, workerPool(Core::ProxyType<WorkerPoolImplementation>::Create(
2, Core::Thread::DefaultStackSize(), 16))
, notificationMock(std::make_unique<NotificationHandlerMock>())
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: This line uses a tab character instead of spaces. The codebase appears to use spaces for indentation (4 spaces based on surrounding code). This should be aligned with the rest of the initialization list using spaces.

Suggested change
, notificationMock(std::make_unique<NotificationHandlerMock>())
, notificationMock(std::make_unique<NotificationHandlerMock>())

Copilot uses AI. Check for mistakes.
p_iarmBusImplMock = new NiceMock<IarmBusImplMock>;
IarmBus::setImpl(p_iarmBusImplMock);
p_rfcApiImplMock = new testing::NiceMock<RfcApiImplMock>;
RfcApi::setImpl(p_rfcApiImplMock);
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: These lines use tab characters for indentation instead of spaces. Convert tabs to spaces to match the rest of the codebase (appears to use 4 or 8 spaces based on context).

Suggested change
RfcApi::setImpl(p_rfcApiImplMock);
RfcApi::setImpl(p_rfcApiImplMock);

Copilot uses AI. Check for mistakes.

std::remove(FIRMWARE_UPDATE_STATE);
EXPECT_EQ(string(""), plugin->Initialize(&service));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: This line uses tab characters for indentation. Convert to spaces to match the rest of the codebase.

Suggested change
std::this_thread::sleep_for(std::chrono::milliseconds(100));
std::this_thread::sleep_for(std::chrono::milliseconds(100));

Copilot uses AI. Check for mistakes.
// Implement IReferenceCounted interface
MOCK_METHOD(void, AddRef, (), (const, override));
MOCK_METHOD(uint32_t, Release, (), (const, override));

Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Trailing whitespace: Remove the trailing spaces after the semicolon on this line.

Suggested change

Copilot uses AI. Check for mistakes.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Copilot AI review requested due to automatic review settings November 12, 2025 19:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 16 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +979 to +1081
#if 0
TEST_F(FirmwareUpdateTest, UpdateFirmware_ValidPCI)
{
createTestFirmwareFile();

string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_ValidDRI)
{
createTestFirmwareFile();

string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"DRI\"}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), request, response));
}
#endif

TEST_F(FirmwareUpdateTest, UpdateFirmware_EmptyFirmwareFilepath)
{
string request = "{\"firmwareFilepath\":\"\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_EmptyFirmwareType)
{
createTestFirmwareFile();
string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"\"}";
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_InvalidFirmwareType)
{
createTestFirmwareFile();
string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"INVALID\"}";
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_FileNotExists)
{
string request = "{\"firmwareFilepath\":\"/nonexistent/firmware.bin\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), request, response));
}
#if 0
TEST_F(FirmwareUpdateTest, UpdateFirmware_FileAccessDenied)
{
createTestFirmwareFile();
string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_PRIVILIGED_REQUEST, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_UpToDateFirmware)
{
std::ofstream versionFile("/version.txt");
versionFile << "imagename:test_firmware" << std::endl;
versionFile.close();

createTestFirmwareFile();
string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("updateFirmware"), request, response));

std::remove("/version.txt");
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashingInProgress)
{

createTestFirmwareFile();

string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), request, response));

std::this_thread::sleep_for(std::chrono::milliseconds(100));

EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("updateFirmware"), request, response));
}

TEST_F(FirmwareUpdateTest, UpdateFirmware_IARMConnectionFailed)
{
EXPECT_CALL(*p_iarmBusImplMock, IARM_Bus_IsConnected(::testing::_, ::testing::_))
.WillOnce(::testing::DoAll(
::testing::SetArgPointee<1>(0),
::testing::Return(IARM_RESULT_IPCCORE_FAIL)));

createTestFirmwareFile();
string request = "{\"firmwareFilepath\":\"" + TEST_FIRMWARE_PATH + "\",\"firmwareType\":\"PCI\"}";
EXPECT_EQ(Core::ERROR_GENERAL, handler.Invoke(connection, _T("updateFirmware"), request, response));
}
#endif

TEST_F(FirmwareUpdateTest, UpdateFirmware_FirmwareFilepathNotExist)
{
EXPECT_EQ(Core::ERROR_INVALID_PARAMETER, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/nonexistent_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));
}
#if 0
TEST_F(FirmwareUpdateTest, UpdateFirmware_ValidSI)
{
createTestFirmwareFile();
EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"SI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
#endif
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

More commented-out tests: Lines 979-1067 and 1073-1081 contain additional large blocks of commented-out test code. Same concern as before - either remove them or document why they're disabled.

Copilot uses AI. Check for mistakes.
Comment on lines +79 to 80
WrapsImplMock *p_wrapsImplMock = nullptr;
IarmBusImplMock *p_iarmBusImplMock = nullptr;
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Inconsistent whitespace: Line 79 has trailing spaces removed (changing from nullptr ; to nullptr) but line 80 still has the same pattern with spaces. Consider applying consistent formatting across both lines.

Copilot uses AI. Check for mistakes.
Comment on lines +193 to +196
if (flashInProgress) {
handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Potential race condition: The flashInProgress flag check in TearDown() is not thread-safe. If the flash thread is still running and modifying this flag, there's a race condition. Consider using proper synchronization or checking the actual thread state instead.

Copilot uses AI. Check for mistakes.
std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Security concern: Test uses chmod with hardcoded permissions 0755 on /rebootNow.sh. This creates an executable file with world-readable permissions. While this is a test environment, it's better practice to use more restrictive permissions (e.g., 0700) and ensure proper cleanup.

Suggested change
chmod("/rebootNow.sh", 0755);
chmod("/rebootNow.sh", 0700);

Copilot uses AI. Check for mistakes.

EXPECT_EQ(Core::ERROR_NONE, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Hardcoded magic number: Multiple tests use std::chrono::milliseconds(200) as a sleep duration. This magic number should be extracted to a named constant (e.g., FLASH_OPERATION_TIMEOUT_MS) for better maintainability and to make it easier to adjust if needed.

Copilot uses AI. Check for mistakes.
Comment on lines +127 to +129
TEST_LOG("Pass created FirmwareUpdateImpl: %p &FirmwareUpdateImpl: %p",
static_cast<void*>(FirmwareUpdateImpl.operator->()),
static_cast<void*>(&FirmwareUpdateImpl));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Typo in comment: "Corrected spelling of 'receive' to 'receive'" appears in the header but the actual change here is adding static_cast<void*> to properly cast the pointer for printf-style formatting. The comment about TEST_LOG improvement is accurate, but there's no spelling correction happening in this change.

Copilot uses AI. Check for mistakes.
std::ofstream maintenanceFile("/opt/swupdate_maintenance_upgrade");
maintenanceFile.close();

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Inconsistent test expectations: This test expects ERROR_FIRMWAREUPDATE_INPROGRESS (line 305), but the test name suggests it's testing the scenario where the reboot script doesn't exist. The expectation seems incorrect - shouldn't this fail with a different error code since the reboot script is missing?

Suggested change
EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));
EXPECT_EQ(ERROR_FIRMWAREUPDATE_REBOOTSCRIPT_MISSING, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

Copilot uses AI. Check for mistakes.
TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Use of system() call is unsafe: Line 584 uses system("mkdir -p /tmp/path/to") which is vulnerable to command injection if any variables were used (though none are here). Consider using C++ filesystem library (std::filesystem::create_directories) instead for better safety and portability.

Copilot uses AI. Check for mistakes.
Comment on lines +115 to +120
ON_CALL(*p_iarmBusImplMock, IARM_Bus_Call)
.WillByDefault(::testing::Invoke(
[this](const char* ownerName, const char* methodName, void* arg, size_t argLen) {
flashInProgress = true;
return IARM_RESULT_SUCCESS;
}));
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

Potential resource leak: The flashInProgress flag is set to true in the mock but never automatically reset to false. If a test fails before calling cancelFirmwareUpdate, subsequent tests may be affected. Consider resetting this flag in the TearDown() method to ensure test isolation.

Copilot uses AI. Check for mistakes.
Comment on lines +148 to 149
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

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

[nitpick] Hardcoded sleep duration may cause flaky tests: The 100ms sleep after plugin initialization may not be sufficient on slower systems or under heavy load. Consider using a more robust synchronization mechanism or making the timeout configurable.

Suggested change
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
// Wait for plugin to be ready by polling for the status file, with timeout
const int max_wait_ms = 5000;
const int poll_interval_ms = 50;
int waited_ms = 0;
while (waited_ms < max_wait_ms) {
std::ifstream statusFile(FIRMWARE_UPDATE_STATE);
if (statusFile.good()) {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(poll_interval_ms));
waited_ms += poll_interval_ms;
}

Copilot uses AI. Check for mistakes.
std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nsleep 1\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream rebootScript("/rebootNow.sh");
rebootScript << "#!/bin/bash\nexit 0\n";
rebootScript.close();
chmod("/rebootNow.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/rebootNow.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


TEST_F(FirmwareUpdateTest, GetUpdateState_InitialState)
{
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::ofstream imageFlasher("/lib/rdk/imageFlasher.sh");
imageFlasher << "#!/bin/bash\nexit 0\n";
imageFlasher.close();
chmod("/lib/rdk/imageFlasher.sh", 0755);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "chmod("/lib/rdk/imageFlasher.sh", 493U)" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

TEST_F(FirmwareUpdateTest, UpdateFirmware_FlashImage_FileWithPathSeparator)
{

system("mkdir -p /tmp/path/to");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value

Calling "system" without checking return value (as is done elsewhere 3 out of 3 times).

Medium Impact, CWE-252
CHECKED_RETURN

EXPECT_EQ(ERROR_FIRMWAREUPDATE_INPROGRESS, handler.Invoke(connection, _T("updateFirmware"), _T("{\"firmwareFilepath\":\"/tmp/test_firmware.bin\",\"firmwareType\":\"PCI\"}"), response));

std::this_thread::sleep_for(std::chrono::milliseconds(200));
std::remove("/etc/device.properties");
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/etc/device.properties")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

handler.Invoke(connection, _T("cancelFirmwareUpdate"), _T("{}"), response);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

std::this_thread::sleep_for(std::chrono::milliseconds(500));
}
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN


}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove("/tmp/FirmwareUpdateStatus.txt")" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

}
void SetUp() override {
std::remove(FIRMWARE_UPDATE_STATE);
std::remove(TEST_FIRMWARE_PATH.c_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Unchecked return value from library

Calling "remove(::TEST_FIRMWARE_PATH[abi:cxx11].c_str())" without checking return value. This library function may fail and return an error code.

Medium Impact, CWE-252
CHECKED_RETURN

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants