Skip to content

Test l1: Do not merge#92

Closed
trupthi1403 wants to merge 18 commits into
developfrom
test-L1
Closed

Test l1: Do not merge#92
trupthi1403 wants to merge 18 commits into
developfrom
test-L1

Conversation

@trupthi1403

Copy link
Copy Markdown
Contributor

Reason for change: For testing purpose only

Reason for change: For testing purpose only
@trupthi1403 trupthi1403 requested a review from a team as a code owner December 8, 2025 12:16
isModule = false;
}
if(!isModule){
src_file.open(file);

Check failure

Code scanning / CodeQL

Time-of-check time-of-use filesystem race condition High

The
filename
being operated upon was previously
checked
, but the underlying file may have been changed since then.

Copilot Autofix

AI 7 months ago

The core recommendation is to avoid the check-before-use pattern on file paths. Instead, attempt to open the file directly and, if unsuccessful, fall back to alternative locations or extensions as needed. In this concrete case, the purpose of the stat call is to check if the file exists in the current directory before searching the module path. This can be replaced by attempting to open the file directly from the current directory and, if unsuccessful, proceeding to check other locations—no separate stat is necessary. Only the file open operation should determine whether the file exists and is accessible.

Best fix:
Update the function to remove the stat call entirely and replace the check with an attempt to open the file in CWD. If the open succeeds, read the contents; otherwise, proceed to open from the module path, continue as before. This removes the time window between check and use, preventing the TOCTOU issue.

Files/regions to change:

  • Edit JavaScriptContextBase::readFile body (lines 101–141).
  • Remove stat call, replace with open-then-check for success.

Additional needs:

  • No new imports needed, as fstream is already included.
  • No need for additional methods or definitions.

Suggested changeset 1
src/JavaScriptContextBase.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/JavaScriptContextBase.cpp b/src/JavaScriptContextBase.cpp
--- a/src/JavaScriptContextBase.cpp
+++ b/src/JavaScriptContextBase.cpp
@@ -100,19 +100,14 @@
 }*/
 std::string JavaScriptContextBase::readFile(const char *file)
 {
-    bool isModule = true;
     std::ifstream src_file;
     std::stringstream src_script;
-    struct stat path;
 
-    // Try CWD first
-    if(stat(file, &path) == 0){
-        isModule = false;
-    }
-    if(!isModule){
-        src_file.open(file);
+    // Try opening from current working directory first
+    src_file.open(file);
+    if(src_file.is_open()) {
         src_script << src_file.rdbuf();
-        return src_script.str();  // <--- Early return if found in CWD!
+        return src_script.str();
     }
 
     // Try sModulesPath + file
EOF
@@ -100,19 +100,14 @@
}*/
std::string JavaScriptContextBase::readFile(const char *file)
{
bool isModule = true;
std::ifstream src_file;
std::stringstream src_script;
struct stat path;

// Try CWD first
if(stat(file, &path) == 0){
isModule = false;
}
if(!isModule){
src_file.open(file);
// Try opening from current working directory first
src_file.open(file);
if(src_file.is_open()) {
src_script << src_file.rdbuf();
return src_script.str(); // <--- Early return if found in CWD!
return src_script.str();
}

// Try sModulesPath + file
Copilot is powered by AI and may make mistakes. Always verify output.
trupthi1403 and others added 10 commits December 11, 2025 09:57
…hin a single process

Reason for change: Changes related to client/server
Test Procedure: build should be successful.
Risks: low
Priority: P2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
RDKEMW-9355: Add Support to run app widgets in different contexts wit…
@trupthi1403

Copy link
Copy Markdown
Contributor Author

LCOV - code coverage report

Current view: top level Coverage Total Hit
Test: rdkNativeScript L1 Coverage Lines: 58.5 % 4743 2773
Test Date: 2025-12-11 12:04:48 Functions: 71.8 % 412 296

Directory Line Coverage (%) Line Coverage (Total) Line Coverage (Hit) Functions (%) Functions (Total) Functions (Hit)
src 82.5 % 1109 915 87.5 % 128 112
src/jsc 43.6 % 2669 1164 71.4 % 220 157
src/jsc/jsc_lib 44.8 % 489 219 38.3 % 60 23
src/linux 99.8 % 476 475 100.0 % 4 4

@trupthi1403

Copy link
Copy Markdown
Contributor Author

LCOV - code coverage report

Current view: top level Coverage Total Hit
Test: rdkNativeScript L2 Coverage Lines: 66.9 % 2611 1747
Test Date: 2025-12-11 12:13:48 Functions: 73.0 % 293 214
Branches: 37.3 % 3981 1483

Directory Line Coverage (%) Line Coverage (Total) Line Coverage (Hit) Functions (%) Functions (Total) Functions (Hit)
include 100.0 % 44 44 34.8 % 66 23
include/jsc 94.7 % 38 36 75.0 % 16 12
src 71.9 % 1061 763 41.9 % 1481 620
src/jsc 61.6 % 1468 904 34.2 % 2418 828

@trupthi1403

Copy link
Copy Markdown
Contributor Author

LCOV - code coverage report

Current view: top level Coverage Total Hit
Test: rdkNativeScript L2 Coverage Lines: 66.9 % 2611 1747
Test Date: 2025-12-12 05:49:36 Functions: 73.0 % 293 214
Branches: 37.3 % 3981 1483

Directory Line Coverage (%) Line Coverage (Total) Line Coverage (Hit) Functions (%) Functions (Total) Functions (Hit)
include 100.0 % 44 44 34.8 % 66 23
include/jsc 94.7 % 38 36 75.0 % 16 12
src 71.9 % 1061 763 41.9 % 1481 620
src/jsc 61.6 % 1468 904 34.2 % 2418 828

@trupthi1403

Copy link
Copy Markdown
Contributor Author

LCOV - code coverage report

Current view: top level Coverage Total Hit
Test: rdkNativeScript L1 Coverage Lines: 58.5 % 4743 2773
Test Date: 2025-12-13 06:41:02 Functions: 71.8 % 412 296

Directory Line Coverage (%) Line Coverage (Total) Line Coverage (Hit) Functions (%) Functions (Total) Functions (Hit)
src 82.5 % 1109 915 87.5 % 128 112
src/jsc 43.6 % 2669 1164 71.4 % 220 157
src/jsc/jsc_lib 44.8 % 489 219 38.3 % 60 23
src/linux 99.8 % 476 475 100.0 % 4 4

gsarng517_comcast and others added 7 commits December 15, 2025 16:04
Reason for change: Fixing undefined errors in during VIPA playback
Test Procedure: VIPA JS version should launch using this widget.
Risks: low
Priority: P2
RDKEMW-11507: Viper IPA not working with rdknative widget
Reason for change: For testing purpose only
@trupthi1403

Copy link
Copy Markdown
Contributor Author

LCOV - code coverage report

Current view: top level Coverage Total Hit
Test: rdkNativeScript L2 Coverage Lines: 62.0 % 2824 1752
Test Date: 2025-12-16 06:56:57 Functions: 69.9 % 306 214
Branches: 34.2 % 4351 1488

Directory Line Coverage (%) Line Coverage (Total) Line Coverage (Hit) Functions (%) Functions (Total) Functions (Hit)
include 100.0 % 44 44 34.8 % 66 23
include/jsc 94.7 % 38 36 75.0 % 16 12
src 60.3 % 1274 768 33.8 % 1851 625
src/jsc 61.6 % 1468 904 34.2 % 2418 828

@github-actions github-actions Bot locked and limited conversation to collaborators Dec 17, 2025
@trupthi1403 trupthi1403 deleted the test-L1 branch December 17, 2025 10:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants