Skip to content

Commit

Permalink
RDKTV-31830 : split Secure Store in a separate plugin
Browse files Browse the repository at this point in the history
Reason for change: Separate plugin for separate functionality.
Fixes the problem of FTA/IPC/Thunder thread pool.
Test Procedure: None
Risks: None
Signed-off-by: Nikita Poltorapavlo <[email protected]>
  • Loading branch information
npoltorapavlo committed Jul 16, 2024
1 parent 444826a commit ef32741
Show file tree
Hide file tree
Showing 39 changed files with 1,101 additions and 303 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/BuildThunder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ cmake --build build/Thunder --target install
############################
# 4. Build ThunderInterfaces

git clone https://github.com/rdkcentral/ThunderInterfaces.git
git clone -b RDKTV-31830 https://github.com/npoltorapavlo/ThunderInterfaces.git

cmake -G Ninja -S ThunderInterfaces -B build/ThunderInterfaces \
-DCMAKE_INSTALL_PREFIX="install"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: L0-PersistentStore-grpc
name: L0-SecureStore-grpc

on:
push:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- SecureStore/**
- .github/workflows/*SecureStore*.yml
pull_request:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- SecureStore/**
- .github/workflows/*SecureStore*.yml

jobs:
build:
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake -S ${GITHUB_REPOSITORY}/SecureStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/grpcl0test --target install
- name: Run
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/L0-SecureStore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: L0-SecureStore

on:
push:
paths:
- SecureStore/**
- .github/workflows/*SecureStore*.yml
pull_request:
paths:
- SecureStore/**
- .github/workflows/*SecureStore*.yml

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: ${{github.repository}}

- name: Install valgrind, coverage, cmake
run: |
sudo apt update
sudo apt install -y valgrind lcov cmake
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/SecureStore/l0test -B build/securestorel0test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/securestorel0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try securestorel0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/securestorel0test
genhtml -o coverage coverage.info
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
6 changes: 3 additions & 3 deletions .github/workflows/L2-PersistentStore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
path: ${{github.repository}}

- name: Install cmake, sqlite, protoc, grpc_cpp_plugin, grpc
- name: Install cmake, sqlite
run: |
sudo apt update
sudo apt install -y cmake libsqlite3-dev protobuf-compiler protobuf-compiler-grpc libgrpc++-dev
sudo apt install -y cmake libsqlite3-dev
- name: Build Thunder
working-directory: ${{github.workspace}}
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore -B build/PersistentStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/persistentstore/l2test/test" -DPLUGIN_PERSISTENTSTORE_WITH_ACCOUNT_SCOPE=true -DPLUGIN_PERSISTENTSTORE_MODE=Local -DPLUGIN_PERSISTENTSTORE_URI=ss.eu.prod.developer.comcast.com:443
cmake -S ${GITHUB_REPOSITORY}/PersistentStore -B build/PersistentStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_PERSISTENTSTORE_PATH="/tmp/persistentstore/l2test/test" -DPLUGIN_PERSISTENTSTORE_MODE=Local
cmake --build build/PersistentStore --target install
# Usage:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: L2-PersistentStore-grpc
name: L2-SecureStore-grpc

on:
push:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- SecureStore/**
- .github/workflows/*SecureStore*.yml
pull_request:
paths:
- PersistentStore/**
- .github/workflows/*PersistentStore*.yml
- SecureStore/**
- .github/workflows/*SecureStore*.yml

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l2test -B build/grpcl2test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror"
cmake -S ${GITHUB_REPOSITORY}/SecureStore/grpc/l2test -B build/grpcl2test -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror"
cmake --build build/grpcl2test --target install
# Usage:
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/L2-SecureStore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: L2-SecureStore

on:
push:
paths:
- SecureStore/**
- .github/workflows/*SecureStore*.yml
pull_request:
paths:
- SecureStore/**
- .github/workflows/*SecureStore*.yml

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: ${{github.repository}}

- name: Install cmake, protoc, grpc_cpp_plugin, grpc
run: |
sudo apt update
sudo apt install -y cmake protobuf-compiler protobuf-compiler-grpc libgrpc++-dev
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/SecureStore -B build/SecureStore -DCMAKE_INSTALL_PREFIX="install" -DCMAKE_CXX_FLAGS="-Wall -Werror" -DPLUGIN_SECURESTORE_MODE=Local -DPLUGIN_SECURESTORE_URI=ss.eu.prod.developer.comcast.com:443
cmake --build build/SecureStore --target install
# Usage:
# PATH=${PWD}/install/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try Thunder -f -c ${PWD}/install/etc/Thunder/config.json
# (to stop press q & enter)
# curl -d '{"jsonrpc":"2.0","id":0,"method":"org.rdk.SecureStore.setValue","params":{"namespace":"test","key":"key1","value":"1","ttl":100}}' http://localhost:55555/jsonrpc
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ if (PLUGIN_RESOURCEMANAGER)
add_subdirectory(ResourceManager)
endif()

if(PLUGIN_SECURESTORE)
add_subdirectory(SecureStore)
endif()

if(WPEFRAMEWORK_CREATE_IPKG_TARGETS)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEB_COMPONENT_INSTALL ON)
Expand Down
35 changes: 0 additions & 35 deletions PersistentStore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,13 @@ set(MODULE_NAME ${NAMESPACE}${PLUGIN_NAME})
set(CMAKE_CXX_STANDARD 11)

set(PLUGIN_PERSISTENTSTORE_MODE "Off" CACHE STRING "Controls if the plugin should run in its own process, in process or remote")
set(PLUGIN_PERSISTENTSTORE_URI "" CACHE STRING "Account scope endpoint")
set(PLUGIN_PERSISTENTSTORE_PATH "/opt/secure/persistent/rdkservicestore" CACHE STRING "Path")
set(PLUGIN_PERSISTENTSTORE_LEGACYPATH "/opt/persistent/rdkservicestore" CACHE STRING "Previously used path")
set(PLUGIN_PERSISTENTSTORE_KEY "" CACHE STRING "Encryption key")
set(PLUGIN_PERSISTENTSTORE_MAXSIZE "1000000" CACHE STRING "For all text data, in bytes")
set(PLUGIN_PERSISTENTSTORE_MAXVALUE "3000" CACHE STRING "For single text data, in bytes")
set(PLUGIN_PERSISTENTSTORE_LIMIT "10000" CACHE STRING "Default for all text data in namespace, in bytes")
set(PLUGIN_PERSISTENTSTORE_TOKEN_COMMAND "" CACHE STRING "Shell command to get the service access token")
set(PLUGIN_PERSISTENTSTORE_STARTUPORDER "" CACHE STRING "To configure startup order of PersistentStore plugin")
set(PLUGIN_PERSISTENTSTORE_WITH_ACCOUNT_SCOPE false CACHE BOOL "Enable account scope")

add_library(${MODULE_NAME} SHARED
PersistentStore.cpp
Expand All @@ -48,14 +45,6 @@ target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Definitions::${NAMESPACE}Definitions
)

find_library(RFC_LIBRARIES NAMES rfcapi)
if (RFC_LIBRARIES)
find_path(RFC_INCLUDE_DIRS NAMES rfcapi.h REQUIRED)
target_include_directories(${MODULE_NAME} PRIVATE ${RFC_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${RFC_LIBRARIES})
target_compile_definitions(${MODULE_NAME} PRIVATE WITH_RFC)
endif ()

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

Expand Down Expand Up @@ -83,30 +72,6 @@ if (IARMBUS_LIBRARIES)
target_compile_definitions(${PLUGIN_IMPLEMENTATION} PRIVATE WITH_SYSMGR)
endif ()

if (PLUGIN_PERSISTENTSTORE_WITH_ACCOUNT_SCOPE)
find_package(Protobuf REQUIRED)
target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE ${Protobuf_LIBRARIES})

add_custom_target(protoc
${Protobuf_PROTOC_EXECUTABLE} --cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage/secure_storage.proto
)
add_dependencies(${PLUGIN_IMPLEMENTATION} protoc)

target_link_libraries(${PLUGIN_IMPLEMENTATION} PRIVATE grpc++)
find_program(GRPC_CPP_PLUGIN grpc_cpp_plugin REQUIRED)

add_custom_target(protoc-gen-grpc
${Protobuf_PROTOC_EXECUTABLE} --grpc_out ${CMAKE_CURRENT_BINARY_DIR} --plugin=protoc-gen-grpc=${GRPC_CPP_PLUGIN} -I ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage ${CMAKE_CURRENT_SOURCE_DIR}/grpc/secure_storage/secure_storage.proto
)
add_dependencies(${PLUGIN_IMPLEMENTATION} protoc-gen-grpc)

set(PROTO_SRCS secure_storage.pb.cc secure_storage.grpc.pb.cc)
target_sources(${PLUGIN_IMPLEMENTATION} PRIVATE ${PROTO_SRCS})
set_property(SOURCE ${PROTO_SRCS} PROPERTY GENERATED 1)
target_include_directories(${PLUGIN_IMPLEMENTATION} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(${PLUGIN_IMPLEMENTATION} PRIVATE WITH_ACCOUNT_SCOPE)
endif ()

install(TARGETS ${PLUGIN_IMPLEMENTATION}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)

Expand Down
2 changes: 0 additions & 2 deletions PersistentStore/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@
#include <interfaces/definitions.h>
#endif

#define URI_ENV "PERSISTENTSTORE_URI"
#define PATH_ENV "PERSISTENTSTORE_PATH"
#define MAXSIZE_ENV "PERSISTENTSTORE_MAXSIZE"
#define MAXVALUE_ENV "PERSISTENTSTORE_MAXVALUE"
#define LIMIT_ENV "PERSISTENTSTORE_LIMIT"
#define IARM_INIT_NAME "Thunder_Plugins"
#define URI_RFC "Device.DeviceInfo.X_RDKCENTRAL-COM_RFC.PersistentStore.Uri"

#undef EXTERNAL
#define EXTERNAL
1 change: 0 additions & 1 deletion PersistentStore/PersistentStore.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ rootobject.add("mode", "@PLUGIN_PERSISTENTSTORE_MODE@")
rootobject.add("locator", "lib@[email protected]")
configuration.add("root", rootobject)

configuration.add("uri", "@PLUGIN_PERSISTENTSTORE_URI@")
configuration.add("path", "@PLUGIN_PERSISTENTSTORE_PATH@")
configuration.add("legacypath", "@PLUGIN_PERSISTENTSTORE_LEGACYPATH@")
configuration.add("key", "@PLUGIN_PERSISTENTSTORE_KEY@")
Expand Down
1 change: 0 additions & 1 deletion PersistentStore/PersistentStore.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ map()
kv(mode ${PLUGIN_PERSISTENTSTORE_MODE})
kv(locator lib${PLUGIN_IMPLEMENTATION}.so)
end()
kv(uri ${PLUGIN_PERSISTENTSTORE_URI})
kv(path ${PLUGIN_PERSISTENTSTORE_PATH})
kv(legacypath ${PLUGIN_PERSISTENTSTORE_LEGACYPATH})
kv(key ${PLUGIN_PERSISTENTSTORE_KEY})
Expand Down
20 changes: 1 addition & 19 deletions PersistentStore/PersistentStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

#include "PersistentStore.h"
#include <fstream>
#ifdef WITH_RFC
#include "rfcapi.h"
#endif

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MINOR 0
Expand Down Expand Up @@ -83,21 +80,6 @@ namespace Plugin {
}
}

auto uri = _config.Uri.Value();

#ifdef WITH_RFC
RFC_ParamData_t rfcParam;
auto rfcStatus = getRFCParameter(nullptr, URI_RFC, &rfcParam);
if (rfcStatus == WDMP_SUCCESS) {
if (rfcParam.value[0]) {
uri = rfcParam.value;
}
} else {
TRACE(Trace::Error, (_T("%s rfc error %d"), __FUNCTION__, rfcStatus));
}
#endif

Core::SystemInfo::SetEnvironment(URI_ENV, uri);
Core::SystemInfo::SetEnvironment(PATH_ENV, _config.Path.Value());
Core::SystemInfo::SetEnvironment(MAXSIZE_ENV, std::to_string(_config.MaxSize.Value()));
Core::SystemInfo::SetEnvironment(MAXVALUE_ENV, std::to_string(_config.MaxValue.Value()));
Expand Down Expand Up @@ -130,7 +112,7 @@ namespace Plugin {
{
ASSERT(_service == service);

SYSLOG(Logging::Shutdown, (string(_T("DTV::Deinitialize"))));
SYSLOG(Logging::Shutdown, (string(_T("PersistentStore::Deinitialize"))));

_service->Unregister(&_notification);

Expand Down
2 changes: 0 additions & 2 deletions PersistentStore/PersistentStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ namespace Plugin {
, MaxValue(0)
, Limit(0)
{
Add(_T("uri"), &Uri);
Add(_T("path"), &Path);
Add(_T("legacypath"), &LegacyPath);
Add(_T("key"), &Key);
Expand All @@ -52,7 +51,6 @@ namespace Plugin {
}

public:
Core::JSON::String Uri;
Core::JSON::String Path;
Core::JSON::String LegacyPath;
Core::JSON::String Key;
Expand Down
12 changes: 0 additions & 12 deletions PersistentStore/PersistentStoreImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
*/

#include "PersistentStoreImplementation.h"
#ifdef WITH_ACCOUNT_SCOPE
#include "grpc/Store2.h"
#endif
#include "sqlite/Store2.h"

namespace WPEFramework {
Expand All @@ -33,7 +30,6 @@ namespace Plugin {
, _deviceStoreCache(nullptr)
, _deviceStoreInspector(nullptr)
, _deviceStoreLimit(nullptr)
, _accountStore2(nullptr)
, _store2Sink(*this)
{
if (_deviceStore2 != nullptr) {
Expand All @@ -47,10 +43,6 @@ namespace Plugin {
ASSERT(_deviceStoreCache != nullptr);
ASSERT(_deviceStoreInspector != nullptr);
ASSERT(_deviceStoreLimit != nullptr);
#ifdef WITH_ACCOUNT_SCOPE
_accountStore2 = Core::Service<Grpc::Store2>::Create<Exchange::IStore2>();
ASSERT(_accountStore2 != nullptr);
#endif
}

PersistentStoreImplementation::~PersistentStoreImplementation()
Expand All @@ -72,10 +64,6 @@ namespace Plugin {
_deviceStoreLimit->Release();
_deviceStoreLimit = nullptr;
}
if (_accountStore2 != nullptr) {
_accountStore2->Release();
_accountStore2 = nullptr;
}
}

} // namespace Plugin
Expand Down
Loading

0 comments on commit ef32741

Please sign in to comment.