-
Notifications
You must be signed in to change notification settings - Fork 1
cov-test: Fixing High and medium level issues[DONOT MERGE] #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,26 +6,36 @@ | |
| #include "NativeJSLogger.h" | ||
| int main() | ||
| { | ||
| std::string containerId = "com.sky.as.apps_TestApp"; | ||
| const std::string basePath = "/opt/twocontext"; // constant base path | ||
| const std::vector<std::string> apps = {"app1", "app2"}; | ||
|
|
||
| std::string ipAddress = JSRuntimeContainer::getContainerIpAddress(containerId); | ||
| if (ipAddress.empty()) { | ||
| NativeJSLogger::log(ERROR, "Failed to retrieve IP address for container"); | ||
| return 1; | ||
| } | ||
| try { | ||
| std::string containerId = "com.sky.as.apps_TestApp"; | ||
| const std::string basePath = "/opt/twocontext"; // constant base path | ||
| const std::vector<std::string> apps = {"app1", "app2"}; | ||
|
|
||
| std::string ipAddress = JSRuntimeContainer::getContainerIpAddress(containerId); | ||
| if (ipAddress.empty()) { | ||
| NativeJSLogger::log(ERROR, "Failed to retrieve IP address for container"); | ||
|
||
| return 1; | ||
| } | ||
|
|
||
| for (const auto &app : apps) { | ||
| std::string url = basePath + std::string("/") + app + std::string("/index.html"); | ||
| if (access(url.c_str(), F_OK) == 0) { | ||
| std::string pathAppConfig = basePath + std::string("/") + app + std::string("/app.config"); | ||
| std::string options = JSRuntimeContainer::parseAppConfig(pathAppConfig); | ||
| std::string message = JSRuntimeContainer::buildLaunchMessage(url, options); | ||
| JSRuntimeContainer::connectAndSend(ipAddress, message); | ||
| for (const auto &app : apps) { | ||
| std::string url = basePath + std::string("/") + app + std::string("/index.html"); | ||
| if (access(url.c_str(), F_OK) == 0) { | ||
| std::string pathAppConfig = basePath + std::string("/") + app + std::string("/app.config"); | ||
| std::string options = JSRuntimeContainer::parseAppConfig(pathAppConfig); | ||
| std::string message = JSRuntimeContainer::buildLaunchMessage(url, options); | ||
| JSRuntimeContainer::connectAndSend(ipAddress, message); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| return 0; | ||
| } | ||
| catch (const std::exception& e) { | ||
| NativeJSLogger::log(ERROR, "Exception in main: %s", e.what()); | ||
|
||
| return 1; | ||
| } | ||
| catch (...) { | ||
| NativeJSLogger::log(ERROR, "Unknown exception in main"); | ||
|
||
| return 1; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -330,7 +330,6 @@ void NativeJSRenderer::createApplicationInternal(ApplicationRequest& appRequest) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| context->setCreateApplicationEndTime(endTime, id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mContextMap[id].context=context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mUserMutex.unlock(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| void NativeJSRenderer::runApplicationInternal(ApplicationRequest& appRequest) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -445,7 +444,7 @@ void NativeJSRenderer::terminateApplicationInternal(ApplicationRequest& AppReque | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url.c_str()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d and url: %s\n", id, mContextMap[id].url.c_str()); | |
| NativeJSLogger::log(ERROR, "Unable to find application with id: %d\n", id); |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable 'id' is declared but not initialized before being passed to ApplicationRequest constructor. This will result in undefined behavior as the uninitialized value is used to construct the ApplicationRequest object and subsequently used in createApplicationInternal and runApplicationInternal calls.
| uint32_t id; | |
| uint32_t id = 0; |
Copilot
AI
Jan 16, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After curl_easy_cleanup is called on error, the function continues executing with the same curl handle which is now invalid. After each error case with curl_easy_cleanup, the function should return immediately to avoid using the freed handle.
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYHOST: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYPEER: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_USERAGENT: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_PROXY, ""); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_PROXY: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYHOST: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, true); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_SSL_VERIFYPEER: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0"); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_USERAGENT: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; | |
| } | |
| res = curl_easy_setopt(curl, CURLOPT_PROXY, ""); | |
| if (res != CURLE_OK) { | |
| NativeJSLogger::log(ERROR, "Failed to set CURLOPT_PROXY: %s\n", curl_easy_strerror(res)); | |
| curl_easy_cleanup(curl); | |
| return ret; |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -119,6 +119,14 @@ if (mModuleSettings.enablePlayer) | |||
| gTopLevelContext = nullptr; | ||||
| } | ||||
| mPriv->releaseAllProtected(); | ||||
|
|
||||
| //changed added | ||||
|
||||
| //changed added |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -115,7 +115,7 @@ void dispatchPending() | |||||
| { | ||||||
| std::unique_lock<std::mutex> lock(gDispatchMutex); | ||||||
| std::list<std::function<void ()>> pending = std::move(gPendingFun); | ||||||
| gDispatchMutex.unlock(); | ||||||
| lock.unlock(); | ||||||
| for(auto& fun : pending) | ||||||
| fun(); | ||||||
| } | ||||||
|
|
@@ -321,17 +321,32 @@ rtError rtReadBinaryBinding(int numArgs, const rtValue* args, rtValue* result, v | |||||
| const char *fd = "hello.wasm"; | ||||||
| struct stat buf; | ||||||
|
|
||||||
| stat(fd, &buf); | ||||||
| if (stat(fd, &buf) != 0) | ||||||
| { | ||||||
| rtLogError("Failed to stat file: %s", fd); | ||||||
| fclose(ptr); | ||||||
| return RT_ERROR; | ||||||
| } | ||||||
|
|
||||||
| int size = buf.st_size; | ||||||
|
|
||||||
| buffer = (char*)malloc(size); | ||||||
| fread(buffer,size,1,ptr); // read 10 bytes to our buffer | ||||||
| size_t bytesRead = fread(buffer, size, 1, ptr); | ||||||
|
Comment on lines
333
to
+334
|
||||||
| fclose(ptr); | ||||||
|
|
||||||
| if (bytesRead != 1) | ||||||
| { | ||||||
| rtLogError("Failed to read file: expected 1 item, read %zu items", bytesRead); | ||||||
| free(buffer); | ||||||
| return RT_ERROR; | ||||||
| } | ||||||
|
|
||||||
| if (result) | ||||||
| { | ||||||
| result->setString(buffer); | ||||||
| } | ||||||
|
|
||||||
| free(buffer); | ||||||
| return RT_OK; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -693,13 +708,15 @@ rtError rtJSRuntimeDownloadMetrics(int numArgs, const rtValue* args, rtValue* re | |||||
| rtValue keys; | ||||||
| if (map->Get("allKeys", &keys) != RT_OK) { | ||||||
| rtLogWarn("Could not retrieve url for network metrics data."); | ||||||
| delete netMetricsArray; //newly added | ||||||
|
||||||
| return RT_FAIL; | ||||||
| } | ||||||
| rtObjectRef objRef = keys.toObject(); | ||||||
| rtArrayObject* keysArray = static_cast<rtArrayObject*>(objRef.getPtr()); | ||||||
|
|
||||||
| if (!keysArray) { | ||||||
| rtLogWarn("No url found in the network metrics data."); | ||||||
| delete netMetricsArray; //newly added | ||||||
|
||||||
| return RT_FAIL; | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -715,6 +732,7 @@ rtError rtJSRuntimeDownloadMetrics(int numArgs, const rtValue* args, rtValue* re | |||||
| NetworkMetrics* metrics = (NetworkMetrics*)storedValue.toVoidPtr(); | ||||||
| if (!metrics) { | ||||||
| rtLogError("Failed to cast stored value to NetworkMetrics structure for url: %s.", key.cString()); | ||||||
| delete netMetricsArray; //newly added | ||||||
|
||||||
| delete netMetricsArray; //newly added | |
| delete netMetricsArray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "//change added" is unclear and unnecessary. Comments should explain why code exists, not document when it was added (that's what version control is for).