Skip to content
Closed
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
2 changes: 0 additions & 2 deletions .github/workflows/native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ jobs:
# Build component
chmod +x build_tools_workflows/cov_docker_script/build_native.sh
./build_tools_workflows/cov_docker_script/build_native.sh ./cov_docker_script/component_config.json "$(pwd)"
env:
GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }}
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### 2.8.1
#### 2.9.0

- RDKB-67262: Remove Github token from Native build [`#112`](https://github.com/rdkcentral/advanced-security/pull/112)
- RDKB-66812 RDKB-66844 : Pause Network Intelligence while speedtest is running [`#103`](https://github.com/rdkcentral/advanced-security/pull/103)
- RDKB-66811 RDKB-66952 : Support webconfig schema for opt-in / opt-out of Network Intelligence feature [`#109`](https://github.com/rdkcentral/advanced-security/pull/109)
- RDKB-66811 RDKB-66952 : Support end user opt-in / opt-out for Network Intelligence feature [`#107`](https://github.com/rdkcentral/advanced-security/pull/107)
- RDKB-66906 : Stop Network Intelligence service in start_adv_security.sh disable logic [`#108`](https://github.com/rdkcentral/advanced-security/pull/108)
- RDKB-66906 : Make cujo-ni service restart dependent on cujo-agent restart [`#104`](https://github.com/rdkcentral/advanced-security/pull/104)
Expand Down Expand Up @@ -48,5 +51,5 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Create fossid_integration_stateless_diffscan_target_repo.yml [`#2`](https://github.com/rdkcentral/advanced-security/pull/2)
- Create CODEOWNERS file [`#1`](https://github.com/rdkcentral/advanced-security/pull/1)
- Import of source (stable2) [`55740fb`](https://github.com/rdkcentral/advanced-security/commit/55740fbcd9f7f71a3b57d286f6f9b6f919819b8b)
- Add changelog for release 2.8.1 [`198b1d0`](https://github.com/rdkcentral/advanced-security/commit/198b1d0be656ce552639f3581abb278910a65991)
- updating the changelog.md file [`c155519`](https://github.com/rdkcentral/advanced-security/commit/c1555192bbe6c2e48ac278a70b3e2a3137cd5a38)
- Add changelog for release 2.8.0 [`243972f`](https://github.com/rdkcentral/advanced-security/commit/243972f5e443e88e447b5fbd6fe8cd45b49457b0)
7 changes: 7 additions & 0 deletions config/TR181-AdvSecurity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<functions>
<func_GetParamBoolValue>NetworkIntelligence_GetParamBoolValue</func_GetParamBoolValue>
<func_SetParamBoolValue>NetworkIntelligence_SetParamBoolValue</func_SetParamBoolValue>
<func_SetParamStringValue>NetworkIntelligence_SetParamStringValue</func_SetParamStringValue>
</functions>
<parameters>
<parameter>
Expand All @@ -83,6 +84,12 @@
<syntax>bool</syntax>
<writable>true</writable>
</parameter>
<parameter>
<name>Data</name>
<type>string</type>
<syntax>string</syntax>
<writable>true</writable>
</parameter>
</parameters>
</object>
<?endif?>
Expand Down
3 changes: 2 additions & 1 deletion source/AdvSecurityDml/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ hardware_platform = i686-linux-gnu
lib_LTLIBRARIES = libdmlasecurity.la
libdmlasecurity_la_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/source/AdvSecurityDml -I$(top_srcdir)/source/AdvSecuritySsp $(CPPFLAGS) -I$(top_srcdir)/../Utopia/source/include/sysevent -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/rbus
libdmlasecurity_la_SOURCES = plugin_main.c cosa_adv_security_internal.c cosa_adv_security_dml.c cosa_adv_security_webconfig.c advsecurity_helpers.c advsecurity_param.c
libdmlasecurity_la_LDFLAGS = -lccsp_common -lsyscfg -lsysevent -lwebconfig_framework -lmsgpackc -ltrower-base64 -lsecure_wrapper -lrbus -lev -lpthread $(SSP_LDFLAGS)
libdmlasecurity_la_LDFLAGS = -lccsp_common -lsyscfg -lsysevent -lwebconfig_framework -lmsgpackc -ltrower-base64 -lsecure_wrapper -lrbus -lev -lpthread -ltelemetry_msgsender $(SSP_LDFLAGS)

if WIFI_DATA_COLLECTION
libdmlasecurity_la_CPPFLAGS += -DDML_SUPPORT -DWIFI_DATA_COLLECTION
Expand All @@ -36,5 +36,6 @@ endif

if NETWORK_INTELLIGENCE
libdmlasecurity_la_CPPFLAGS += -DDML_SUPPORT -DNETWORK_INTELLIGENCE
libdmlasecurity_la_SOURCES += cosa_network_intelligence_webconfig.c networkintelligence_param.c
libdmlasecurity_la_LDFLAGS += -lwifi_webconfig
endif
13 changes: 1 addition & 12 deletions source/AdvSecurityDml/advsecurity_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,10 @@ const char* advsecuritydoc_strerror( int errnum )
int process_advsecurityparams( advsecurityparam_t *e, msgpack_object_map *map )
{
int left = map->size;
/* Bits 0-4 are the mandatory legacy parameters. NetworkIntelligenceActivate
* is optional for backward compatibility with the older 5-parameter schema;
* when absent it retains its zeroed default. */
uint8_t objects_left = 0x1F;
msgpack_object_kv *p;
p = map->ptr;
/* Iterate every entry: optional parameters may follow the last mandatory
* one, so we must not stop early once objects_left reaches zero. */
while( 0 < left-- )
while( (0 < left--) && (0 != objects_left) )
{
if( MSGPACK_OBJECT_STR == p->key.type )
{
Expand Down Expand Up @@ -153,12 +148,6 @@ int process_advsecurityparams( advsecurityparam_t *e, msgpack_object_map *map )
e->privacy_protection_activate = p->val.via.boolean;
objects_left &= ~(1 << 4);
}
if( 0 == match(p, "NetworkIntelligenceActivate") )
{
e->network_intelligence_activate = p->val.via.boolean;
e->network_intelligence_present = true;
objects_left &= ~(1 << 5);
}
}
}
p++;
Expand Down
5 changes: 0 additions & 5 deletions source/AdvSecurityDml/advsecurity_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ typedef struct
bool safebrowsing_enable;
bool parental_control_activate;
bool privacy_protection_activate;
bool network_intelligence_activate;
/* False when the payload used the older 5-parameter schema that omits
* NetworkIntelligenceActivate. In that case network_intelligence_activate
* carries no meaning and must not be applied. */
bool network_intelligence_present;

} advsecurityparam_t;

Expand Down
244 changes: 230 additions & 14 deletions source/AdvSecurityDml/cosa_adv_security_dml.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#include "ansc_platform.h"
#include "cosa_adv_security_internal.h"
#include "cosa_adv_security_webconfig.h"
#ifdef NETWORK_INTELLIGENCE
#include "cosa_network_intelligence_webconfig.h"
#include "networkintelligence_param.h"
#endif
#include "syslog.h"
#include "ccsp_trace.h"
#include "msgpack.h"
Expand Down Expand Up @@ -573,7 +577,7 @@ AdvancedSecurity_SetParamStringValue
errno_t rc = -1;
int ind = -1;

if(ParamName == NULL)
if((ParamName == NULL) || (pString == NULL))
return FALSE;
/* check the parameter name and set the corresponding value */
rc = strcmp_s("Data", strlen("Data"), ParamName, &ind);
Expand All @@ -592,10 +596,30 @@ AdvancedSecurity_SetParamStringValue
msgpack_unpack_return unpack_ret;

decodeMsgSize = b64_get_decoded_buffer_size(strlen(pString));
if(decodeMsgSize <= 0)
{
CcspTraceError(("Invalid base64 decoded buffer size %d\n", decodeMsgSize));
return FALSE;
}

decodeMsg = (char *) AnscAllocateMemory(sizeof(char) * decodeMsgSize);
if(decodeMsg == NULL)
{
CcspTraceError(("decodeMsg AnscAllocateMemory failed\n"));
return FALSE;
}

size = b64_decode((uint8_t *) pString, strlen(pString),(uint8_t *) decodeMsg );
CcspTraceInfo(("base64 decoded data contains %d bytes\n",size));

if((size <= 0) || (size > decodeMsgSize))
{
CcspTraceError(("base64 decode failed, invalid length %d (buffer %d)\n", size, decodeMsgSize));
AnscFreeMemory(decodeMsg);
decodeMsg = NULL;
return FALSE;
}

msgpack_zone_init(&mempool, 2048);
unpack_ret = msgpack_unpack(decodeMsg, size, NULL, &mempool, &deserialized);
switch(unpack_ret)
Expand Down Expand Up @@ -629,23 +653,14 @@ AdvancedSecurity_SetParamStringValue
err = errno;
CcspTraceInfo(("errno: %s\n", advsecuritydoc_strerror(err)));

if(ad != NULL)
if(ad != NULL && ad->param != NULL && ad->subdoc_name != NULL)
{
CcspTraceInfo(("ad->subdoc_name is %s\n", ad->subdoc_name));
CcspTraceInfo(("ad->version is %lu\n", (long)ad->version));
CcspTraceInfo(("ad->transaction_id %lu\n",(long) ad->transaction_id));
if (ad->param->network_intelligence_present)
{
CcspTraceInfo(("fingerprint_enable:[%d], softflowd_enable[%d], safebrowsing_enable[%d], parental_control_activate[%d], privacy_protection_activate[%d], network_intelligence_activate[%d]\n",
ad->param->fingerprint_enable,ad->param->softflowd_enable,ad->param->safebrowsing_enable,
ad->param->parental_control_activate,ad->param->privacy_protection_activate,ad->param->network_intelligence_activate));
}
else
{
CcspTraceInfo(("fingerprint_enable:[%d], softflowd_enable[%d], safebrowsing_enable[%d], parental_control_activate[%d], privacy_protection_activate[%d]\n",
ad->param->fingerprint_enable,ad->param->softflowd_enable,ad->param->safebrowsing_enable,
ad->param->parental_control_activate,ad->param->privacy_protection_activate));
}
CcspTraceInfo(("fingerprint_enable:[%d], softflowd_enable[%d], safebrowsing_enable[%d], parental_control_activate[%d], privacy_protection_activate[%d]\n",
ad->param->fingerprint_enable,ad->param->softflowd_enable,ad->param->safebrowsing_enable,
ad->param->parental_control_activate,ad->param->privacy_protection_activate));

execData *execDataAdvsec = NULL ;
execDataAdvsec = (execData*) AnscAllocateMemory (sizeof(execData));
Expand Down Expand Up @@ -691,6 +706,17 @@ AdvancedSecurity_SetParamStringValue
ret_val = FALSE;
}
}
else if(ad != NULL)
{
CcspTraceError(("advsecuritydoc missing mandatory fields\n"));
advsecuritydoc_destroy(ad);
ret_val = FALSE;
}
else
{
CcspTraceError(("advsecuritydoc_convert failed\n"));
ret_val = FALSE;
}
}
else
{
Expand Down Expand Up @@ -4214,6 +4240,196 @@ NetworkIntelligence_RFC_SetParamUlongValue
CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName));
return FALSE;
}

/**********************************************************************

caller: owner of this object

prototype:

BOOL
NetworkIntelligence_SetParamStringValue
(
ANSC_HANDLE hInsContext,
char* ParamName,
char* pString
);

description:

This function is called to set string parameter value;

argument: ANSC_HANDLE hInsContext,
The instance handle;

char* ParamName,
The parameter name;

char* pString
The updated string value;

return: TRUE if succeeded.

**********************************************************************/
BOOL
NetworkIntelligence_SetParamStringValue
(
ANSC_HANDLE hInsContext,
char* ParamName,
char* pString
)
{
UNREFERENCED_PARAMETER(hInsContext);
errno_t rc = -1;
int ind = -1;

if(ParamName == NULL || pString == NULL)
return FALSE;

/* check the parameter name and set the corresponding value */
rc = strcmp_s("Data", strlen("Data"), ParamName, &ind);
ERR_CHK(rc);
if((rc == EOK) && (!ind))
{
networkintelligencedoc_t *nd = NULL;
int err;
char * decodeMsg = NULL;
int decodeMsgSize = 0;
int size = 0;
BOOL ret_val = TRUE;

msgpack_zone mempool;
msgpack_object deserialized;
msgpack_unpack_return unpack_ret;

decodeMsgSize = b64_get_decoded_buffer_size(strlen(pString));
if (decodeMsgSize <= 0)
{
CcspTraceError(("Invalid base64 decoded buffer size %d\n", decodeMsgSize));
return FALSE;
}

decodeMsg = (char *) AnscAllocateMemory(sizeof(char) * decodeMsgSize);
if (decodeMsg == NULL)
{
CcspTraceError(("decodeMsg AnscAllocateMemory failed\n"));
return FALSE;
}
size = b64_decode((uint8_t *) pString, strlen(pString),(uint8_t *) decodeMsg );
CcspTraceInfo(("base64 decoded data contains %d bytes\n",size));

if ((size <= 0) || (size > decodeMsgSize))
{
CcspTraceError(("base64 decode failed, invalid length %d (buffer %d)\n", size, decodeMsgSize));
AnscFreeMemory(decodeMsg);
decodeMsg = NULL;
return FALSE;
}

msgpack_zone_init(&mempool, 2048);
unpack_ret = msgpack_unpack(decodeMsg, size, NULL, &mempool, &deserialized);
switch(unpack_ret)
{
case MSGPACK_UNPACK_SUCCESS:
CcspTraceInfo(("MSGPACK_UNPACK_SUCCESS :%d\n",unpack_ret));
break;
case MSGPACK_UNPACK_EXTRA_BYTES:
CcspTraceInfo(("MSGPACK_UNPACK_EXTRA_BYTES :%d\n",unpack_ret));
break;
case MSGPACK_UNPACK_CONTINUE:
CcspTraceInfo(("MSGPACK_UNPACK_CONTINUE :%d\n",unpack_ret));
break;
case MSGPACK_UNPACK_PARSE_ERROR:
CcspTraceError(("MSGPACK_UNPACK_PARSE_ERROR :%d\n",unpack_ret));
break;
case MSGPACK_UNPACK_NOMEM_ERROR:
CcspTraceError(("MSGPACK_UNPACK_NOMEM_ERROR :%d\n",unpack_ret));
break;
default:
CcspTraceError(("Message Pack decode failed with error: %d\n", unpack_ret));
}
msgpack_zone_destroy(&mempool);

CcspTraceInfo(("---------------End of b64 decode--------------\n"));

if(unpack_ret == MSGPACK_UNPACK_SUCCESS)
{
CcspTraceInfo(("Msg unpack success\n"));
nd = networkintelligencedoc_convert(decodeMsg, size);//used to process the incoming msgobject
err = errno;
CcspTraceInfo(("errno: %s\n", networkintelligencedoc_strerror(err)));

if(nd != NULL && nd->param != NULL && nd->subdoc_name != NULL)
{
CcspTraceInfo(("nd->subdoc_name is %s\n", nd->subdoc_name));
CcspTraceInfo(("nd->version is %lu\n", (long)nd->version));
CcspTraceInfo(("nd->transaction_id %lu\n",(long) nd->transaction_id));
CcspTraceInfo(("network_intelligence_activate:[%d]\n",
nd->param->network_intelligence_activate));

execData *execDataNi = NULL ;
execDataNi = (execData*) AnscAllocateMemory (sizeof(execData));

if ( execDataNi != NULL )
{
rc = memset_s(execDataNi, sizeof(execData), 0, sizeof(execData));
ERR_CHK(rc);

execDataNi->txid = nd->transaction_id;
execDataNi->version = nd->version;
execDataNi->numOfEntries = 1;

rc = strcpy_s(execDataNi->subdoc_name, sizeof(execDataNi->subdoc_name), nd->subdoc_name);
if(rc != EOK)
{
ERR_CHK(rc);
AnscFreeMemory(execDataNi);
execDataNi = NULL;
networkintelligencedoc_destroy(nd);
AnscFreeMemory(decodeMsg);
decodeMsg = NULL;
return FALSE;
}

execDataNi->user_data = (void*) nd;
execDataNi->calcTimeout = NULL ;
execDataNi->executeBlobRequest = ni_webconfig_process_request;
execDataNi->rollbackFunc = ni_webconfig_rollback;
execDataNi->freeResources = ni_webconfig_free_resources;
PushBlobRequest(execDataNi);
CcspTraceInfo(("PushBlobRequest complete\n"));
}
else
{
CcspTraceError(("execData AnscAllocateMemory failed\n"));
networkintelligencedoc_destroy(nd);
ret_val = FALSE;
}
}
else
{
CcspTraceError(("Failed to convert networkintelligence subdoc\n"));
networkintelligencedoc_destroy(nd);
ret_val = FALSE;
}
}
else
{
CcspTraceError(("Failed to unpack msgpack\n"));
ret_val = FALSE;
}

if ( decodeMsg )
{
AnscFreeMemory (decodeMsg);
decodeMsg = NULL;
}
return ret_val;
}

CcspTraceWarning(("Unsupported parameter '%s'\n", ParamName));
return FALSE;
}
#endif // NETWORK_INTELLIGENCE

/***********************************************************************
Expand Down
Loading
Loading