Conversation
|
Saranya seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
…ic Updates (#117) * Update rrdInterface.c * Update rrdInterface.c * Update rrdInterface.c * Update cov_build.sh * Update configure.ac * Update rrdInterface.c * Update rrdInterface.h * Update cov_build.sh * Update rrdInterface.c * Update rrdInterface.h * Update rrdInterface.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
…method (#123) * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdCommon.h * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdDynamic.c * Update rrdJsonParser.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdInterface.h * Update rrdInterface.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdRunCmdThread.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdCommon.h * Update rrdIarmEvents.c * Update rrdIarmEvents.c * Update rrdIarmEvents.c
…method (#125) * Update rrdIarmEvents.c * Update rrdInterface.c * Update rrdInterface.c * Update cov_build.sh * Update rrdIarmEvents.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
…d message type (SCXI11BEI) (#121) * Update rrdJsonParser.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdInterface.c * Update rrdInterface.c * Update rrdInterface.c * Update rrdJsonParser.c * Update rrdInterface.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdJsonParser.c * Update rrdEventProcess.c * Update rrdEventProcess.c * Update rrdInterface.c * Update rrdInterface.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
…elop Deploy cla action
Deploy fossid_integration_stateless_diffscan_target_repo action
…rget 80% [ Phase 2 ] (#157) * Update rrdInterface.c * Update rrdIarmEvents.c * Update configure.ac * Update cov_build.sh * Update remote_debugger.json * Update create_json.sh * Create Makefile * Create deepsleep_main.c --------- Co-authored-by: nhanasi <navihansi@gmail.com>
RRD 1.2.9 release
… C (#167) * Add comprehensive HLD documentation for uploadRRDLogs.sh migration to C - Requirements document with functional specs, I/O definitions, and constraints - High-Level Design with architecture, module breakdown, and data flows - Detailed flowcharts for all major operations (Mermaid + text-based) - Sequence diagrams showing component interactions - Low-Level Design with complete C code, data structures, and implementations Documentation covers migration of uploadRRDLogs.sh to embedded C program optimized for low-memory, low-CPU embedded systems with full error handling, security considerations, and platform portability. - Replace custom MAC retrieval logic with TR-181 parameters via RBus - Device.DeviceInfo.X_COMCAST-COM_STB_MAC (Video) - Device.DeviceInfo.X_COMCAST-COM_CM_MAC (Broadband) - Device.X_CISCO_COM_MACAddress (Alternative) - Add cache file fallback (/tmp/device_details.cache, /tmp/estb_mac) - Add early exit optimization in config parser when all required properties found - Mark libarchive as mandatory dependency, remove tar command fallback
There was a problem hiding this comment.
Pull request overview
This PR performs a rebase containing substantial enhancements to the Remote Debugger component, including new test coverage for deepsleep and dynamic profile scenarios, code quality improvements addressing Coverity issues, and comprehensive documentation additions.
Key Changes:
- Added L2 test coverage for dynamic subcategory reports, deepsleep scenarios, and append functionality
- Fixed multiple Coverity issues including resource leaks and buffer handling improvements
- Added extensive documentation for uploadRRDLogs component migration to C
- Updated CI/CD workflows and build configurations
Reviewed changes
Copilot reviewed 36 out of 36 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| test/functional-tests/tests/test_rrd_single_instance.py | Enhanced PID handling for instance checking with better parsing |
| test/functional-tests/tests/test_rrd_dynamic_subcategory_report.py | New L2 tests for dynamic subcategory report validation |
| test/functional-tests/tests/test_rrd_deepsleep_static_report.py | New L2 tests for deepsleep static profile handling |
| test/functional-tests/tests/test_rrd_append_report.py | New L2 tests for append request functionality |
| test/functional-tests/tests/power_controller.h | New header defining PowerController API interfaces |
| test/functional-tests/tests/deepsleep_main.c | New C test file for deepsleep event handling |
| test/functional-tests/tests/create_json.sh | Updated JSON generation with additional test entries |
| test/functional-tests/tests/Makefile | New makefile for building deepsleep test binary |
| test/functional-tests/features/*.feature | New feature files for BDD test scenarios |
| src/rrdRunCmdThread.c | Fixed systemd service handling and conditional compilation |
| src/rrdJsonParser.c | Fixed resource leak and added deepsleep validation logic |
| src/rrdInterface.h/c | Updated IARM support conditionals and buffer handling fix |
| src/rrdIarmEvents.c | Refactored WebCfg and IARM event handling logic |
| src/rrdEventProcess.c | Fixed memory management and added null checks |
| src/rrdDynamic.c | Fixed buffer size calculation for deep sleep events |
| src/unittest/rrdUnitTestRunner.cpp | Extensive unit test updates with new test cases |
| src/unittest/mocks/*.h/cpp | Updated mock implementations for RBus and IARM |
| remote_debugger.json | Added DeepSleep configuration entries |
| docs/uploadRRDLogs_*.md | New comprehensive documentation for C migration |
| run_l2.sh | Added new L2 test executions |
| cov_build.sh | Updated build configuration with new flags |
| configure.ac | Added L2 support configuration option |
| CHANGELOG.md | Updated with recent release information |
| .github/workflows/*.yml | Updated CI/CD workflows and permissions |
| .github/CODEOWNERS | Updated code ownership configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SCRIPT_SUCCESS = "Debug Information Report upload Failed" | ||
| SCRIPT_FAILURE = "Debug Information Report upload Success" |
There was a problem hiding this comment.
The success and failure message constants are swapped. SCRIPT_SUCCESS is set to "upload Failed" and SCRIPT_FAILURE is set to "upload Success", which is backwards and will cause confusing log messages.
| SCRIPT_SUCCESS = "Debug Information Report upload Failed" | ||
| SCRIPT_FAILURE = "Debug Information Report upload Success" |
There was a problem hiding this comment.
The success and failure message constants are swapped. SCRIPT_SUCCESS is set to "upload Failed" and SCRIPT_FAILURE is set to "upload Success", which is backwards and will cause confusing log messages.
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in comment: "shopuld" should be "should".
| And Command output shopuld be added to the output file | |
| And Command output should be added to the output file |
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in comment: "shopuld" should be "should".
| And Command output shopuld be added to the output file | |
| And Command output should be added to the output file |
| DEBUG_FILE = "Adding Details of Debug commands to Output File" | ||
| assert DEBUG_FILE in grep_rrdlogs(DEBUG_FILE) | ||
|
|
||
| issue_string = "DEEPSLEEP" |
There was a problem hiding this comment.
Variable issue_string is not used.
| @@ -0,0 +1,134 @@ | |||
| import json | |||
| from helper_functions import * | |||
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
|
|
||
| import json | ||
| import subprocess | ||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| import json |
There was a problem hiding this comment.
Import of 'json' is not used.
* RDK-58172: integrate dcm-agent uploadstblogs and cleanup logging; update Makefile and upload flow * Add unit tests for RRD upload orchestration This file contains unit tests for the RRD upload orchestration, covering various aspects such as configuration loading, system information retrieval, log directory validation, and the entire upload workflow. * Update Makefile.am * Remove uploadRRDLogs program from Makefile * Refactor uploadDebugoutput to use upload API Updated the uploadDebugoutput function to call the upload API instead of executing a script. Enhanced logging for upload orchestration success and failure. * Refactor upload orchestration into rrd_upload_orchestrate Refactor upload orchestration logic into a separate function and remove deprecated main function. * Update rrd_config.h * Include common_device_api.h in rrd_sysinfo.h Added inclusion of common_device_api.h for device API access. * Add comprehensive functional tests for C API upload orchestration - Add BDD feature file with 20 test scenarios for rrd_upload_orchestrate - Add Python test implementation with 14 test functions - Test coverage includes: * Valid and invalid parameter handling * Configuration loading from multiple sources (properties, RFC, DCM) * MAC address retrieval and timestamp generation * Issue type sanitization and normalization * Archive creation and format validation * Upload execution and lock handling * Cleanup operations * Error code propagation (codes 1-11) * Comprehensive logging verification * Integration with uploadDebugoutput wrapper - Tests validate the complete flow from event trigger through C API execution to upload completion - Helper class provides utilities for test setup, archive validation, and log verification Refactor source validation and log handling. Improve error handling for directory operations and add functionality to move live logs. * Refactor log upload handling and cleanup process Updated log upload process to handle LOGUPLOAD_ENABLE case and adjusted archive creation and upload paths.
* RDKEMW-12334-The log entries in remote-debugger.log RDKEMW-12334-The log entries in remote-debugger.log differ between C binary files and script files when compared * Change the log from Debug to Info * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Abhinavpv28 <162570454+Abhinavpv28@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 62 out of 62 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if '.' in ISSUE_STRING: | ||
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING |
There was a problem hiding this comment.
Variable node is not used.
| ISSUE_NODE, ISSUE_SUBNODE = ISSUE_STRING.split('.') | ||
| else: | ||
| node = ISSUE_STRING | ||
| subnode = None |
There was a problem hiding this comment.
Variable subnode is not used.
| node = ISSUE_STRING | ||
| subnode = None | ||
|
|
||
| ISSUE_FOUND = f"Issue Data Node: {ISSUE_NODE} and Sub-Node: {ISSUE_SUBNODE} found in Static JSON File /etc/rrd/remote_debugger.json" |
There was a problem hiding this comment.
Variable ISSUE_FOUND is not used.
| # limitations under the License. | ||
| ########################################################################## | ||
|
|
||
| from helper_functions import * |
There was a problem hiding this comment.
Import pollutes the enclosing namespace, as the imported module helper_functions does not define 'all'.
RRD release 1.3.1
…ode (#178) * Update Makefile.am * Update rrdExecuteScript.c * Update rrd_upload.h * Update Makefile.am * Update Makefile.am * Update Makefile.am * Update Makefile.am --------- Co-authored-by: nhanasi <navihansi@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 62 out of 62 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (10)
test/functional-tests/tests/test_rrd_deepsleep_static_report.py:1
subprocessis used but never imported in this file, which will raiseNameErrorat runtime. Addimport subprocess(and any other required stdlib imports) at the top of the test module.
test/functional-tests/tests/test_rrd_c_api_upload.py:1subprocessis used but not imported in this new test file, which will fail at runtime. Addimport subprocessat the top of the file.
test/functional-tests/tests/test_rrd_append_report.py:1- This test module mutates
/etc/rrd/remote_debugger.jsonat import time (before pytest collects/runs tests), which can cause non-deterministic failures and pollute the test environment. Move this mutation into a test setup/fixture with a clear teardown (restore the original file), or write to a test-scoped copy (e.g., under/tmp) and point the system-under-test at that copy.
test/functional-tests/tests/deepsleep_main.c:1 RRDEventThreadFuncloops forever and only breaks onmsgrcverror, butmain()unconditionallypthread_joins the thread. As written, the test harness can hang indefinitely. Add a termination mechanism (e.g., a shared atomic “stop” flag +msgrcvwith timeout / non-blocking + periodic check, or cancel/detach the thread and exit cleanly after the events are injected).
src/rrd_upload.c:1UploadSTBLogsParams/TRIGGER_ONDEMANDcome fromuploadstblogs.h, butsrc/rrd_upload.hexcludes that include whenGTEST_ENABLEis defined. Ifrrd_upload.cis compiled with-DGTEST_ENABLE, this will not compile. Consider providing a small local typedef/enum shim under#ifdef GTEST_ENABLE(in a C header used byrrd_upload.c), or includeuploadstblogs.hunconditionally for builds that compile this file.
src/rrd_upload.c:1- Calling
system("rm -rf %s")with an unquoted path is shell-injection prone ifdir_pathever contains whitespace or shell metacharacters. Replace this with a safe recursive delete implementation (e.g.,nftw+unlink/rmdir, oropenat/unlinkatwalking), or at minimum use anexecv-style call to/bin/rmwith--and an argument vector (no shell).
src/uploadRRDLogs.c:1 - This PR introduces a substantial new orchestration surface with multiple distinct error codes (config load, MAC/timestamp, dir validation, sanitize, archive create, upload, cleanup). Add gtest unit coverage that asserts the returned error codes and key log/behavior for the main failure paths (e.g., invalid params → 1, config failure → 3, empty dir → 6, archive failure → 10, upload failure → 11) using mocks for sysinfo/upload and temp directories for filesystem behavior.
src/rrd_sysinfo.h:1 - The header comment says the MAC buffer needs “min 18 bytes”, but the implementation strips colons and only requires 12 hex chars + terminator (13 bytes). Update the documentation (or the implementation) so the required minimum buffer size is consistent.
test/functional-tests/tests/power_controller.h:1 - Correct the spelling in the enum comment: 'Critial' → 'Critical'.
test/functional-tests/features/rrd_dynamic_profile_subcategory_report.feature:1 - Fix typo in the scenario step: 'shopuld' → 'should'.
| /*Stop or Reset runtime service for issue*/ | ||
| RDK_LOG(RDK_LOG_INFO,LOG_REMDEBUG,"[%s:%d]: Stopping remote_debugger_%s service...\n",__FUNCTION__,__LINE__,cmdData->rfcvalue); | ||
| #if !defined(GTEST_ENABLE) | ||
| v_secure_system("systemctl stop %s", remoteDebuggerServiceStr); | ||
| v_secure_system("systemctl reset-failed %s", remoteDebuggerServiceStr); | ||
| free(cmdData->rfcvalue); // free rfcvalue received from RRDEventThreadFunc | ||
| free(cmdData->command); // free updated command info received from RRDEventThreadFunc | ||
| free(cmdData); | ||
| #endif |
There was a problem hiding this comment.
When GTEST_ENABLE is defined, cmdData->rfcvalue, cmdData->command, and cmdData are no longer freed, introducing a guaranteed memory leak on the gtest path. Keep memory cleanup outside the #if !defined(GTEST_ENABLE) guard and only gate the systemctl calls.
| #ifdef IARMBUS_SUPPORT | ||
| if (isDeepSleepAwakeEvent) | ||
| strncpy(msgDataString, paramString, msgDataStringSize); | ||
| strncpy(msgDataString, paramString, (msgDataStringSize - strlen(RDM_PKG_SUFFIX))); |
There was a problem hiding this comment.
This strncpy call can produce a non-null-terminated string when truncated, and the computed bound (msgDataStringSize - strlen(RDM_PKG_SUFFIX)) can underflow if msgDataStringSize is smaller than strlen(RDM_PKG_SUFFIX). Switch to snprintf (or ensure the bound is validated and always explicitly null-terminate msgDataString).
| strncpy(msgDataString, paramString, (msgDataStringSize - strlen(RDM_PKG_SUFFIX))); | |
| { | |
| size_t paramLen = strlen(paramString); | |
| size_t suffixLen = strlen(RDM_PKG_SUFFIX); | |
| if (paramLen > suffixLen && msgDataStringSize > 0) | |
| { | |
| size_t baseLen = paramLen - suffixLen; | |
| if (baseLen >= msgDataStringSize) | |
| { | |
| baseLen = msgDataStringSize - 1; | |
| } | |
| /* Copy paramString without the RDM_PKG_SUFFIX, ensuring null termination */ | |
| snprintf(msgDataString, msgDataStringSize, "%.*s", (int)baseLen, paramString); | |
| } | |
| else if (msgDataStringSize > 0) | |
| { | |
| msgDataString[0] = '\0'; | |
| } | |
| } |
| if (name_len <= 100) { | ||
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | ||
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | ||
| } else if (name_len <= 255) { | ||
| /* split into prefix and name */ | ||
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | ||
| if (prefix_len > sizeof(hdr.prefix)) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | ||
| __FUNCTION__, name, name_len); | ||
| return -1; | ||
| } | ||
| strncpy(hdr.prefix, name, prefix_len); | ||
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | ||
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); |
There was a problem hiding this comment.
USTAR prefix/name splitting must occur on a directory separator boundary (and prefix should contain the directory portion). Splitting purely by character count can generate invalid headers that some tar implementations won’t extract correctly. Split on the last '/' that keeps prefix <= 155 and name <= 100, and fail cleanly if no valid split exists.
| if (name_len <= 100) { | |
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| } else if (name_len <= 255) { | |
| /* split into prefix and name */ | |
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | |
| if (prefix_len > sizeof(hdr.prefix)) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| strncpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | |
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); | |
| if (name_len <= sizeof(hdr.name)) { | |
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| } else if (name_len <= 255) { | |
| /* split into prefix and name on a directory separator boundary */ | |
| size_t prefix_len = 0; | |
| const char *name_part = NULL; | |
| /* search for the last '/' that yields a valid prefix and name */ | |
| for (size_t i = name_len; i > 0; --i) { | |
| if (name[i - 1] == '/') { | |
| size_t p_len = i - 1; /* directory portion, without trailing '/' */ | |
| size_t n_len = name_len - i; /* name portion after '/' */ | |
| if (p_len > 0 && | |
| p_len <= sizeof(hdr.prefix) && | |
| n_len > 0 && | |
| n_len <= sizeof(hdr.name)) { | |
| prefix_len = p_len; | |
| name_part = name + i; | |
| break; | |
| } | |
| } | |
| } | |
| if (name_part == NULL) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| /* copy prefix (directory part) */ | |
| memcpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len] = '\0'; | |
| /* copy name (final path component) */ | |
| strncpy(hdr.name, name_part, sizeof(hdr.name) - 1); |
This pull request addresses Coverity defects in the RDK Remote Debugger Device Management code, focusing on fixing memory leaks, buffer overflows, and resource handling issues. Changes: Added NULL checks for memory allocations (malloc, strdup, fread) with proper error handling and resource cleanup Fixed buffer overflow vulnerabilities by using correct size parameters in strncpy/strncat operations Corrected file pointer closure to only occur when pointers are valid (v_secure_pclose moved inside if blocks) Fixed memory management issues with rfcbuf allocations and ownership Co-authored-by: mtirum011 <madhubabu_tirumala@comcast.com>
Remote Debugger 1.3.2 release
| # Path to the existing JSON file | ||
| file_path = "/etc/rrd/remote_debugger.json" | ||
|
|
||
| # Read the existing JSON data | ||
| with open(file_path, "r") as json_file: | ||
| data = json.load(json_file) | ||
|
|
||
| # New entry to add | ||
| new_entry = { | ||
| "Test": { | ||
| "TestRun4": { | ||
| "Commands": "cat /version.txt;cat /tmp/.deviceDetails.cache", | ||
| "Timeout": 10 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Update the JSON data with the new entry | ||
| data.update(new_entry) | ||
|
|
||
| # Write the updated data back to the JSON file | ||
| with open(file_path, "w") as json_file: | ||
| json.dump(data, json_file, indent=4) |
There was a problem hiding this comment.
This test module performs file I/O and mutates /etc/rrd/remote_debugger.json at import time. Pytest will execute this on collection, which can make test runs order-dependent and can affect other tests (and local environments) even if these tests are skipped/xfail. Move this JSON read/update/write into a dedicated test/fixture (e.g., setup function) and ensure the original file contents are restored in teardown/finalizer.
| SCRIPT_SUCCESS = "Debug Information Report upload Failed" | ||
| SCRIPT_FAILURE = "Debug Information Report upload Success" | ||
| if SCRIPT_SUCCESS in grep_rrdlogs(SCRIPT_SUCCESS): | ||
| print("Script execution success") | ||
| elif SCRIPT_FAILURE in grep_rrdlogs(SCRIPT_FAILURE): | ||
| print("Script execution failed") |
There was a problem hiding this comment.
SCRIPT_SUCCESS / SCRIPT_FAILURE constants are swapped: SCRIPT_SUCCESS is set to the "...upload Failed" message and SCRIPT_FAILURE to the "...upload Success" message, and the printed status strings are inverted as well. This will report success on failure and vice versa. Swap the constants (or adjust the condition/print statements) so the labels match the expected log lines.
| try: | ||
| result = subprocess.run(['bash', script_path], check=True, text=True, capture_output=True) | ||
| print("Script output:") | ||
| print(result.stdout) | ||
| except subprocess.CalledProcessError as e: | ||
| print("Error while executing the script:") | ||
| print(e.stderr) |
There was a problem hiding this comment.
The CalledProcessError from running create_json.sh is caught and only printed, so the test will continue and potentially pass even when the script fails. Re-raise the exception or fail the test (e.g., assert False) in the except block so environment setup failures are not silently ignored.
| RDK_LOG(RDK_LOG_INFO, LOG_REMDEBUG, "%s: Removing source directory: %s\n", __FUNCTION__, dir_path); | ||
|
|
||
| char cmd[1024]; | ||
| snprintf(cmd, sizeof(cmd), "rm -rf %s", dir_path); | ||
|
|
||
| int ret = system(cmd); |
There was a problem hiding this comment.
rrd_upload_cleanup_source_dir builds an "rm -rf" shell command with an unquoted dir_path and executes it via system(). Since dir_path is derived from issue/category values that ultimately come from external input, this is vulnerable to command injection and also breaks paths containing spaces/shell metacharacters. Prefer a safe recursive delete using nftw()/unlinkat() (or, at minimum, execv("rm", {"rm","-rf","--",dir_path,...}) without invoking a shell).
| #if !defined(GTEST_ENABLE) | ||
| v_secure_system("systemctl stop %s", remoteDebuggerServiceStr); | ||
| v_secure_system("systemctl reset-failed %s", remoteDebuggerServiceStr); | ||
| free(cmdData->rfcvalue); // free rfcvalue received from RRDEventThreadFunc | ||
| free(cmdData->command); // free updated command info received from RRDEventThreadFunc | ||
| free(cmdData); | ||
| #endif |
There was a problem hiding this comment.
In the GTEST_ENABLE build, this block skips freeing cmdData->rfcvalue/cmdData->command/cmdData entirely, which introduces a leak in unit tests and makes behavior differ between test and production builds. Consider guarding only the systemctl calls with GTEST_ENABLE, but keep the memory cleanup outside the conditional.
| if (name_len <= 100) { | ||
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | ||
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | ||
| } else if (name_len <= 255) { | ||
| /* split into prefix and name */ | ||
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | ||
| if (prefix_len > sizeof(hdr.prefix)) { | ||
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | ||
| __FUNCTION__, name, name_len); | ||
| return -1; | ||
| } | ||
| strncpy(hdr.prefix, name, prefix_len); | ||
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | ||
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); | ||
| hdr.name[sizeof(hdr.name) - 1] = '\0'; |
There was a problem hiding this comment.
The ustar name/prefix split logic for paths 101–255 chars is incorrect: it splits at an arbitrary offset (name_len - 101) rather than at the last '/' boundary. This can produce invalid tar headers and lose path information. Split the path at the last '/' such that prefix <= 155 and name <= 100 per ustar rules, or reject names that can’t be represented correctly.
| if (name_len <= 100) { | |
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| } else if (name_len <= 255) { | |
| /* split into prefix and name */ | |
| size_t prefix_len = name_len - 100 - 1; /* leave room for null */ | |
| if (prefix_len > sizeof(hdr.prefix)) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, "[%s] File name too long: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| strncpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len < sizeof(hdr.prefix) ? prefix_len : sizeof(hdr.prefix) - 1] = '\0'; | |
| strncpy(hdr.name, name + prefix_len + 1, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| if (name_len <= sizeof(hdr.name)) { | |
| /* simple case: whole path fits in name field */ | |
| strncpy(hdr.name, name, sizeof(hdr.name) - 1); | |
| hdr.name[sizeof(hdr.name) - 1] = '\0'; | |
| } else if (name_len <= 255) { | |
| /* split into prefix and name according to POSIX ustar rules: | |
| * - prefix contains the directory path (no trailing '/') | |
| * - name contains the final path component | |
| * - both fields must fit in their respective header buffers | |
| */ | |
| size_t prefix_len = 0; | |
| size_t name_part_len = 0; | |
| int split_found = 0; | |
| /* search for last '/' that yields valid prefix and name lengths */ | |
| for (size_t i = name_len; i > 0; --i) { | |
| if (name[i - 1] == '/') { | |
| prefix_len = i - 1; /* up to but not including this '/' */ | |
| name_part_len = name_len - i; /* after '/' to end */ | |
| if (prefix_len > 0 && | |
| prefix_len <= sizeof(hdr.prefix) && | |
| name_part_len > 0 && | |
| name_part_len <= sizeof(hdr.name)) { | |
| split_found = 1; | |
| break; | |
| } | |
| } | |
| } | |
| if (!split_found) { | |
| RDK_LOG(RDK_LOG_ERROR, LOG_REMDEBUG, | |
| "[%s] File name too long or invalid for ustar: %s (length %zu)\n", | |
| __FUNCTION__, name, name_len); | |
| return -1; | |
| } | |
| /* copy prefix (directory path) */ | |
| memcpy(hdr.prefix, name, prefix_len); | |
| hdr.prefix[prefix_len] = '\0'; | |
| /* copy final path component */ | |
| memcpy(hdr.name, name + prefix_len + 1, name_part_len); | |
| hdr.name[name_part_len] = '\0'; |
| int rrd_upload_execute(const char *log_server, const char *protocol, const char *http_link, const char *working_dir, const char *archive_filename, const char *source_dir); | ||
| int rrd_upload_check_lock(bool *is_locked); | ||
| int rrd_upload_wait_for_lock(int max_attempts, int wait_seconds); | ||
| int rrd_upload_invoke_logupload_api(const char *log_server, const char *protocol, const char *http_link, const char *archive_filename); | ||
| int rrd_upload_orchestrate(const char *upload_dir, const char *issue_type); | ||
| int rrd_upload_cleanup_files(const char *archive_path, const char *source_dir); | ||
| int rrd_upload_cleanup_source_dir(const char *dir_path); | ||
| void rrd_upload_cleanup(void); | ||
|
|
There was a problem hiding this comment.
rrd_upload.h declares rrd_upload_invoke_logupload_api() and rrd_upload_cleanup(), but there are no implementations in the source tree. Since this header is installed as part of the public include set, this creates an API contract that will fail at link time for consumers. Either implement these functions or remove them from the public header until they exist.
| // Initialize rdklogger | ||
| int rrd_log_init(const char *debug_ini_file); | ||
|
|
||
| // Logging macro placeholder (replace with actual RDK_LOG macro) | ||
| #define LOG_UPLOADRRDLOGS "LOG.RDK.UPLOADRRDLOGS" | ||
|
|
There was a problem hiding this comment.
rrd_log.h declares rrd_log_init(), but there is no implementation in the repository. If this is intended as a public API, it should be implemented; otherwise, remove the declaration to avoid unresolved symbol/link-time failures for any consumer that includes this installed header.
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in step text: "shopuld" should be "should".
| And the issue data node and sub-node should be found in the JSON file | ||
| And the directory should be created to store the executed output | ||
| And Sanity check to validate the commands should be executed | ||
| And Command output shopuld be added to the output file |
There was a problem hiding this comment.
Typo in step text: "shopuld" should be "should".
No description provided.