Merge branch 'Branch_v1.0.4' into develop-20.05.01

# Conflicts:
#	src/tsg_entry.cpp
安全事件日志中填写“设备编号”字段(https://jira.geedge.net/browse/TSG-1722)
This commit is contained in:
liuxueli
2020-05-25 15:02:59 +08:00
3 changed files with 47 additions and 5 deletions

View File

@@ -41,7 +41,7 @@ static __attribute__((__used__)) const char * GIT_VERSION_UNKNOWN = NULL;
#endif
char TSG_MASTER_VERSION_20200514=0;
char TSG_MASTER_VERSION_20200522=0;
const char *tsg_conffile="tsgconf/main.conf";
g_tsg_para_t g_tsg_para;
@@ -54,7 +54,39 @@ id2field_t g_tsg_fs2_field[TSG_FS2_MAX]={{TLD_TYPE_UNKNOWN, TSG_FS2_LINKS, "link
{TLD_TYPE_UNKNOWN, TSG_FS2_DENY, "deny"}
};
#define DECCRYPTION_EXCLUSION_ALLOW_POLICY_ID 1
static int tsg_get_sn(char *filename, char *device_sn, int device_sn_len)
{
int ret=0,flags=0;
char buff[4096]={0};
cJSON *object=NULL;
FILE *fp=fopen(filename, "rb");
if(fp)
{
ret=fread(buff, sizeof(buff), 1, fp);
if(ret<(int)sizeof(buff))
{
object=cJSON_Parse(buff);
if(object)
{
cJSON *item=cJSON_GetObjectItem(object, "sn");
if(item && device_sn_len>(int)strlen(item->valuestring))
{
flags=1;
memcpy(device_sn, item->valuestring, strlen(item->valuestring));
}
cJSON_Delete(object);
object=NULL;
}
}
fclose(fp);
fp=NULL;
}
return flags;
}
static void free_policy_label(int thread_seq, void *project_req_value)
{
@@ -843,7 +875,8 @@ extern "C" int TSG_MASTER_INIT()
char label_buff[MAX_STRING_LEN*4]={0};
char fs_server_ip[MAX_IPV4_LEN]={0};
char fs_output_path[MAX_STRING_LEN*4]={0};
char device_sn_filename[MAX_STRING_LEN]={0};
memset(&g_tsg_para, 0, sizeof(g_tsg_para));
MESA_load_profile_int_def(tsg_conffile, "SYSTEM","LOG_LEVEL", &level, 30);
@@ -858,7 +891,14 @@ extern "C" int TSG_MASTER_INIT()
MESA_load_profile_int_def(tsg_conffile, "SYSTEM", "DEVICE_ID", &g_tsg_para.device_id, 0);
MESA_load_profile_short_def(tsg_conffile, "SYSTEM", "TIMEOUT", (short *)&g_tsg_para.timeout, 300);
MESA_load_profile_string_def(tsg_conffile, "SYSTEM", "DEVICE_SN_FILENAME", device_sn_filename, sizeof(device_sn_filename), "/opt/tsg/etc/tsg_sn.json");
ret=tsg_get_sn(device_sn_filename, g_tsg_para.device_sn, sizeof(g_tsg_para.device_sn));
if(ret==0)
{
MESA_handle_runtime_log(g_tsg_para.logger, RLOG_LV_FATAL, "GET_DEVICE_SN", "Get device SN failed; please check :%s", device_sn_filename);
}
MESA_load_profile_string_def(tsg_conffile, "SYSTEM", "POLICY_PRIORITY_LABEL", label_buff, sizeof(label_buff), "POLICY_PRIORITY");
g_tsg_para.priority_project_id=project_producer_register(label_buff, PROJECT_VAL_TYPE_STRUCT, free_policy_label);
if(g_tsg_para.priority_project_id<0)

View File

@@ -70,6 +70,7 @@ typedef struct _tsg_para
int priority_project_id;
int establish_latency_project_id;
int fs2_field_id[TSG_FS2_MAX];
char device_sn[MAX_DOAMIN_LEN/8];
char table_name[TABLE_MAX][_MAX_TABLE_NAME_LEN];
void *logger;
screen_stat_handle_t fs2_handle;

View File

@@ -19,7 +19,7 @@
#include "tsg_send_log.h"
#include "tsg_send_log_internal.h"
char TSG_SEND_LOG_VERSION_20200427=0;
char TSG_SEND_LOG_VERSION_20200522=0;
struct tsg_log_instance_t *g_tsg_log_instance;
@@ -487,6 +487,7 @@ int tsg_send_log(struct tsg_log_instance_t *instance, struct TLD_handle_t *handl
TLD_append_streaminfo(instance, handle, log_msg->a_stream);
TLD_append(_handle, _instance->id2field[LOG_COMMON_SLED_IP].name, (void *)(_instance->local_ip_str), TLD_TYPE_STRING);
TLD_append(_handle, _instance->id2field[LOG_COMMON_DEVICE_ID].name, (void *)(g_tsg_para.device_sn), TLD_TYPE_STRING);
for(i=0;i<log_msg->result_num; i++)
{