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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions build_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd ${GITHUB_WORKSPACE}
#1. Install Dependencies and packages

apt update
apt install -y ninja-build meson curl libsoup2.4-dev libxml2-dev libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev valac pandoc
apt install -y git python3 python3-pip cmake ninja-build meson curl libsoup2.4-dev libxml2-dev libglib2.0-dev gobject-introspection libgirepository1.0-dev libgtk-3-dev libcurl4-openssl-dev libcunit1-dev valac pandoc
pip install jsonref

############################
Expand All @@ -28,17 +28,25 @@ cd ..

rm -rf iarmbus ThunderTools Thunder entservices-apis entservices-testframework gssdp

THUNDER_TOOLS_COMMIT_SHA="d5dd83c7c19c49c7f25c558c126500bd2d64f7a4"
THUNDER_COMMIT_SHA="2c0fcc5529e7da734be558ca6efa05d934dcce31"

git clone https://github.com/rdkcentral/iarmbus.git
export IARMBUS_PATH=$GITHUB_WORKSPACE/iarmbus

git clone --branch R4.4.3 https://github.com/rdkcentral/ThunderTools.git
git clone --branch R4_4-RDK https://github.com/rdkcentral/ThunderTools.git
cd ThunderTools
git checkout $THUNDER_TOOLS_COMMIT_SHA
cd ..

git clone --branch R4.4.1 https://github.com/rdkcentral/Thunder.git
git clone --branch R4_4-RDK https://github.com/rdkcentral/Thunder.git
cd Thunder
git checkout $THUNDER_COMMIT_SHA
cd ..

git clone --branch main https://github.com/rdkcentral/entservices-apis.git
git clone --branch develop https://github.com/rdkcentral/entservices-apis.git

git clone https://$GITHUB_TOKEN@github.com/rdkcentral/entservices-testframework.git
git clone --branch 2.0.0 https://github.com/rdkcentral/entservices-testframework.git

git clone --branch gssdp-1.2.3 https://gitlab.gnome.org/GNOME/gssdp.git

Expand All @@ -60,7 +68,6 @@ cd -
echo "======================================================================================"
echo "buliding thunderTools"
cd ThunderTools
patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/00010-R4.4-Add-support-for-project-dir.patch
cd -


Expand All @@ -79,10 +86,6 @@ echo "==========================================================================
echo "buliding thunder"

cd Thunder
patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/Use_Legact_Alt_Based_On_ThunderTools_R4.4.3.patch
patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/error_code_R4_4.patch
patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/1004-Add-support-for-project-dir.patch
patch -p1 < $GITHUB_WORKSPACE/entservices-testframework/patches/RDKEMW-733-Add-ENTOS-IDS.patch
cd -

cmake -G Ninja -S Thunder -B build/Thunder \
Expand Down
13 changes: 6 additions & 7 deletions server/plat/gdialappcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,14 @@ std::string GDialAppStatusCache::SearchAppStatusInCache(const char* app_name)
std::string state = "NOT_FOUND";

std::string id = getAppCacheId(app_name);
if(doIdExist(id))
AppInfo appEntry("", "", "", "");
if(ObjectCache->findObject(id, appEntry))
{
AppInfo* appEntry = ObjectCache->findObject(id);

state = appEntry->appState;
state = appEntry.appState;
GDIAL_LOGINFO("APPCache: App Name[%s] AppID[%s] Error[%s]",
appEntry->appName.c_str(),
appEntry->appId.c_str(),
appEntry->appError.c_str());
appEntry.appName.c_str(),
appEntry.appId.c_str(),
appEntry.appError.c_str());
}
GDIAL_LOGINFO("App State = %s ",state.c_str());
GDIAL_LOGTRACE("Exiting ...");
Expand Down
16 changes: 12 additions & 4 deletions server/plat/gdialobjCacheHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <assert.h>
#include <chrono>
#include <unordered_map>
#include <mutex>
#include "gdialservicelogging.h"

enum AppCacheErrorCodes {
Expand Down Expand Up @@ -56,6 +57,7 @@ class GDialObjectCacheHelper
public:
GDialObjectCacheHelper(){ }
~GDialObjectCacheHelper() {
std::lock_guard<std::mutex> lock(objectsMutex);
for (auto& entry : objects) {
if (entry.second)
{
Expand All @@ -65,22 +67,25 @@ class GDialObjectCacheHelper
}
}

AppInfo* findObject(const std::string& appName) const
bool findObject(const std::string& appName, AppInfo& entry) const
{
GDIAL_LOGTRACE("Entering ...");
std::lock_guard<std::mutex> lock(objectsMutex);
auto it = objects.find(appName);
if (it != objects.end())
if (it != objects.end() && it->second)
{
entry = *it->second;
GDIAL_LOGTRACE("Exiting ...");
return it->second;
return true;
}
GDIAL_LOGTRACE("Exiting ...");
return nullptr;
return false;
}

AppCacheErrorCodes insert(std::string id, AppInfo* entry)
{
GDIAL_LOGTRACE("Entering ...");
std::lock_guard<std::mutex> lock(objectsMutex);
AppCacheErrorCodes returnValue = AppCacheError_NULL_ENTRY;
if (nullptr != entry)
{
Expand All @@ -102,6 +107,7 @@ class GDialObjectCacheHelper
{
AppCacheErrorCodes returnValue = AppCacheError_NOT_FOUND;
GDIAL_LOGTRACE("Entering [%s]...",appname.c_str());
std::lock_guard<std::mutex> lock(objectsMutex);
auto it = objects.find(appname);
if (it != objects.end())
{
Expand All @@ -117,6 +123,7 @@ class GDialObjectCacheHelper
{
AppCacheErrorCodes returnValue = AppCacheError_NOT_FOUND;
GDIAL_LOGTRACE("Entering ...");
std::lock_guard<std::mutex> lock(objectsMutex);
auto it = objects.find(appname);
if (it != objects.end())
{
Expand All @@ -129,5 +136,6 @@ class GDialObjectCacheHelper
}
private:
std::unordered_map<std::string, AppInfo*> objects;
mutable std::mutex objectsMutex;
};
#endif
17 changes: 17 additions & 0 deletions tests/test_security_cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pathlib
import unittest


class CacheSecurityGuardrail(unittest.TestCase):
def test_cache_operations_are_locked_and_reads_are_copied(self):
root = pathlib.Path(__file__).parents[1]
helper = (root / "server/plat/gdialobjCacheHelper.hpp").read_text()
caller = (root / "server/plat/gdialappcache.cpp").read_text()
self.assertGreaterEqual(helper.count("std::lock_guard<std::mutex> lock(objectsMutex);"), 5)
self.assertIn("bool findObject(const std::string& appName, AppInfo& entry) const", helper)
self.assertIn("entry = *it->second;", helper)
self.assertNotIn("AppInfo* appEntry = ObjectCache->findObject", caller)


if __name__ == "__main__":
unittest.main()
Loading