Skip to content

Commit

Permalink
RDK-45037 : Secure Storage Thunder Plugin
Browse files Browse the repository at this point in the history
Reason for change: Account scope, refactoring.
Tests written for all the test levels (L0,L1,L2) for the entire plugin.
Test Procedure: None
Risks: None
Signed-off-by: Nikita Poltorapavlo <npoltorapavlo@productengine.com>
  • Loading branch information
npoltorapavlo committed Mar 4, 2024
1 parent 5d0673c commit 915d251
Show file tree
Hide file tree
Showing 66 changed files with 38,296 additions and 2,369 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/L0-PersistentStore-grpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: L0-PersistentStore-grpc

on:
push:
paths:
- PersistentStore/grpc/**
pull_request:
paths:
- PersistentStore/grpc/**

jobs:
build:
runs-on: ubuntu-latest

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

- name: Install valgrind, coverage, cmake, protoc, grpc_cpp_plugin, grpc
run: |
sudo apt update
sudo apt install -y valgrind lcov 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}/PersistentStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/grpcl0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/usr/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try grpcl0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/grpcl0test
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
53 changes: 53 additions & 0 deletions .github/workflows/L0-PersistentStore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: L0-PersistentStore

on:
push:
paths:
- PersistentStore/**
pull_request:
paths:
- PersistentStore/**

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}/PersistentStore/l0test -B build/persistentstorel0test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/persistentstorel0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/usr/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try persistentstorel0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/persistentstorel0test
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: L1-Sqlite
name: L1-PersistentStore-sqlite

on:
push:
Expand All @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest

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

- name: Install valgrind, coverage, cmake, sqlite
run: |
Expand All @@ -24,15 +24,13 @@ jobs:
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x rdkservices/.github/workflows/BuildThunder.sh

- name: Configure
working-directory: ${{github.workspace}}
run: cmake -S rdkservices/PersistentStore/sqlite/l1test -B build/sqlitel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: cmake --build build/sqlitel1test --target install
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/sqlite/l1test -B build/sqlitel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/sqlitel1test --target install
- name: Run
working-directory: ${{github.workspace}}
Expand All @@ -46,10 +44,10 @@ jobs:
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
if-no-files-found: warn
22 changes: 10 additions & 12 deletions .github/workflows/L1-PersistentStore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,24 @@ jobs:
runs-on: ubuntu-latest

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

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

- name: Configure
working-directory: ${{github.workspace}}
run: cmake -S rdkservices/PersistentStore/l1test -B build/persistentstorel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: cmake --build build/persistentstorel1test --target install
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/l1test -B build/persistentstorel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/persistentstorel1test --target install
- name: Run
working-directory: ${{github.workspace}}
Expand All @@ -46,10 +44,10 @@ jobs:
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
if-no-files-found: warn
29 changes: 29 additions & 0 deletions .github/workflows/L2-PersistentStore-grpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: L2-PersistentStore-grpc

on:
push:
paths:
- PersistentStore/grpc/generated/**
pull_request:
paths:
- PersistentStore/grpc/generated/**

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
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l2test -B build/grpcl2test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="-Wall -Werror"
cmake --build build/grpcl2test --target install
74 changes: 38 additions & 36 deletions PersistentStore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.14)

project(PersistentStore)

cmake_minimum_required(VERSION 3.3)
set(CMAKE_CXX_STANDARD 11)

find_package(WPEFramework)

project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")
set(MODULE_NAME "${NAMESPACE}${PROJECT_NAME}")

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 "ss.eu.prod.developer.comcast.com:443" 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")
Expand All @@ -36,49 +34,53 @@ set(PLUGIN_PERSISTENTSTORE_MAXVALUE "3000" CACHE STRING "For single text data, i
set(PLUGIN_PERSISTENTSTORE_LIMIT "10000" CACHE STRING "Default for all text data in namespace, in bytes")
set(PLUGIN_PERSISTENTSTORE_STARTUPORDER "" CACHE STRING "To configure startup order of PersistentStore plugin")

add_library(${MODULE_NAME} SHARED
PersistentStore.cpp
PersistentStoreJsonRpc.cpp
grpc/Store2.cpp
grpc/generated/validate/validate.pb.cc
grpc/generated/google/api/field_behavior.pb.cc
grpc/generated/secure_storage.pb.cc
grpc/generated/secure_storage.grpc.pb.cc
sqlite/Store2.cpp
sqlite/StoreCache.cpp
sqlite/StoreInspector.cpp
sqlite/StoreLimit.cpp
Module.cpp
)

find_package(${NAMESPACE}Plugins REQUIRED)
find_package(${NAMESPACE}Definitions REQUIRED)
target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
)

find_package(PkgConfig REQUIRED)
pkg_search_module(SQLITE REQUIRED sqlite3)
target_link_libraries(${MODULE_NAME} PRIVATE ${SQLITE_LIBRARIES})

find_library(IARMBUS_LIBRARIES NAMES IARMBus)

if (IARMBUS_LIBRARIES)
message("Building with IARMBus")
add_definitions(-DWITH_CLOCK_SYNC)
find_path(IARMBUS_INCLUDE_DIRS NAMES libIBus.h PATH_SUFFIXES rdk/iarmbus REQUIRED)
find_path(IARMSYS_INCLUDE_DIRS NAMES sysMgr.h PATH_SUFFIXES rdk/iarmmgrs/sysmgr REQUIRED)
target_include_directories(${MODULE_NAME} PRIVATE ${IARMBUS_INCLUDE_DIRS} ${IARMSYS_INCLUDE_DIRS})
target_link_libraries(${MODULE_NAME} PRIVATE ${IARMBUS_LIBRARIES})
add_definitions(-DWITH_SYSMGR)
endif ()

add_library(${MODULE_NAME} SHARED
PersistentStore.cpp
PersistentStoreJsonRpc.cpp
sqlite/Handle.cpp
Module.cpp
)

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)
find_package(Protobuf REQUIRED)
target_link_libraries(${MODULE_NAME} PUBLIC ${Protobuf_LIBRARIES})

add_definitions(${SQLITE_CFLAGS_OTHER})
link_directories(${SQLITE_LIBRARY_DIRS})

target_include_directories(${MODULE_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
${SQLITE_INCLUDE_DIRS}
${IARMBUS_INCLUDE_DIRS}
${IARMSYS_INCLUDE_DIRS}
)
find_package(gRPC CONFIG)
if (gRPC_FOUND)
set(GRPC_LIBS gRPC::grpc++)
else ()
set(GRPC_LIBS grpc++)
endif ()
target_link_libraries(${MODULE_NAME} PUBLIC ${GRPC_LIBS})

target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
${SQLITE_LIBRARIES}
${IARMBUS_LIBRARIES}
)
target_include_directories(${MODULE_NAME} PRIVATE grpc/generated)

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
Expand Down
7 changes: 7 additions & 0 deletions PersistentStore/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@
#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"

#undef EXTERNAL
#define EXTERNAL
2 changes: 1 addition & 1 deletion PersistentStore/PersistentStore.conf.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
precondition = ["Platform"]
callsign = "org.rdk.PersistentStore"
autostart = "true"
startuporder = "@PLUGIN_PERSISTENTSTORE_STARTUPORDER@"

configuration = JSON()
Expand All @@ -9,6 +8,7 @@ rootobject = JSON()
rootobject.add("mode", "@PLUGIN_PERSISTENTSTORE_MODE@")
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: 1 addition & 0 deletions PersistentStore/PersistentStore.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ end()
ans(rootobject)

map()
kv(uri ${PLUGIN_PERSISTENTSTORE_URI})
kv(path ${PLUGIN_PERSISTENTSTORE_PATH})
kv(legacypath ${PLUGIN_PERSISTENTSTORE_LEGACYPATH})
kv(key ${PLUGIN_PERSISTENTSTORE_KEY})
Expand Down
Loading

0 comments on commit 915d251

Please sign in to comment.