summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2024-08-26 07:27:28 +0000
committerliuxueli <[email protected]>2024-08-26 07:27:28 +0000
commit08244ecbdabcbae6e610f47111daad7f4265d362 (patch)
treee8344a5bc6f4a645df3cd615c5df7cfc95f4ab8e
parent2963165b5e981bbfe799efe815e49ed4d0f4aff9 (diff)
Feature: add gtest case
-rw-r--r--.gitlab-ci.yml160
-rw-r--r--src/ssl_decoder.cpp34
-rw-r--r--test/ssl_decoder_test.cpp5
3 files changed, 199 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..4768065
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,160 @@
+variables:
+ GIT_STRATEGY: "clone"
+ BUILD_IMAGE_CENTOS7: "git.mesalab.cn:7443/mesa_platform/build-env:master"
+ BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
+ BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
+ INSTALL_PREFIX: "/opt/tsg/"
+ INSTALL_DEPENDENCY_LIBRARY: libMESA_handle_logger-devel libMESA_prof_load-devel libMESA_htable libMESA_jump_layer
+ sapp-devel libcjson-devel libbreakpad_mini
+ framework_env libasan stellar-on-sapp-devel libfieldstat4-devel
+ SYMBOL_TARGET: ssl_decoder
+ REPO_PREFIX: protocol
+
+stages:
+- build
+- test
+- upload
+
+.everything_before_script: &everything_before_script
+ - mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
+ - ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
+ - cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
+ - chmod +x ./ci/travis.sh
+ - yum makecache --disablerepo="*" --enablerepo="mesa-framework,platform"
+ - yum install -y $INSTALL_DEPENDENCY_LIBRARY
+ - source /etc/profile.d/framework.sh
+
+###############################################################################
+# build
+###############################################################################
+
+.build_before_script:
+ before_script: *everything_before_script
+ script:
+ - ./ci/travis.sh
+ variables:
+ BUILD_TEST: "ON"
+ BUILD_TYPE: Debug
+ tags:
+ - share
+
+.build_by_travis_for_centos8:
+ stage: build
+ image: $BUILD_IMAGE_CENTOS8
+ extends: .build_before_script
+
+develop_build_for_centos8:
+ extends: .build_by_travis_for_centos8
+ variables:
+ BUILD_TYPE: RelWithDebInfo
+ artifacts:
+ name: "$SYMBOL_TARGET-$CI_COMMIT_REF_NAME-debug"
+ paths:
+ - build/*
+ except:
+ - tags
+
+release_build_debug_for_centos8:
+ extends: .build_by_travis_for_centos8
+ variables:
+ BUILD_TYPE: Debug
+ PACKAGE: 1
+ ASAN_OPTION: "ADDRESS"
+ artifacts:
+ name: "$SYMBOL_TARGET-$CI_COMMIT_REF_NAME-release"
+ paths:
+ - build/*
+ only:
+ - tags
+
+release_build_for_centos8:
+ extends: .build_by_travis_for_centos8
+ variables:
+ BUILD_TYPE: RelWithDebInfo
+ PACKAGE: 1
+ artifacts:
+ name: "$SYMBOL_TARGET-$CI_COMMIT_REF_NAME-release"
+ paths:
+ - build/*
+ only:
+ - tags
+
+###############################################################################
+# test
+###############################################################################
+fix_env_version_test_in_centos8:
+ stage: test
+ image: $BUILD_IMAGE_CENTOS8
+ allow_failure: false
+ script:
+ - *everything_before_script
+ - cd build; make test ARGS="-V"
+ dependencies:
+ - develop_build_for_centos8
+ - release_build_for_centos8
+ tags:
+ - share
+
+
+latest_env_version_test_in_centos8:
+ stage: test
+ image: $BUILD_IMAGE_CENTOS8
+ allow_failure: false
+ script:
+ - *everything_before_script
+ - mkdir /tmp/rpm/
+ - yum install --downloadonly --downloaddir=/tmp/rpm/ sapp stellar-on-sapp -y
+ - rpm -ihv /tmp/rpm/*.rpm
+ - cd build; make test ARGS="-V"
+ dependencies:
+ - develop_build_for_centos8
+ - release_build_for_centos8
+ tags:
+ - share
+
+###############################################################################
+# upload
+###############################################################################
+# .define_before_upload_centos7:
+# stage: upload
+# image: $BUILD_IMAGE_CENTOS7
+# before_script:
+# - pwd; ls -l ; cd build ; ls -l
+# - cp /root/rpm_upload_tools.py ./
+# variables:
+# PULP3_REPO_NAME: $REPO_PREFIX-stable-x86_64.el7
+# PULP3_DIST_NAME: $REPO_PREFIX-stable-x86_64.el7
+# only:
+# - tags
+# tags:
+# - share
+
+# rpm_upload_for_centos7:
+# extends: .define_before_upload_centos7
+# dependencies:
+# - release_build_debug_for_centos7
+# - release_build_for_centos7
+# script:
+# - python3 rpm_upload_tools.py $PULP3_REPO_NAME $PULP3_DIST_NAME *.rpm
+
+.define_before_upload_centos8:
+ stage: upload
+ image: $BUILD_IMAGE_CENTOS8
+ before_script:
+ - pwd; ls -l ; cd build ; ls -l
+ - cp /root/rpm_upload_tools.py ./
+ variables:
+ PULP3_REPO_NAME: $REPO_PREFIX-stable-x86_64.el8
+ PULP3_DIST_NAME: $REPO_PREFIX-stable-x86_64.el8
+ only:
+ - tags
+ tags:
+ - share
+
+rpm_upload_for_centos8:
+ extends: .define_before_upload_centos8
+ dependencies:
+ - release_build_debug_for_centos8
+ - release_build_for_centos8
+ script:
+ - python3 rpm_upload_tools.py $PULP3_REPO_NAME $PULP3_DIST_NAME *.rpm
diff --git a/src/ssl_decoder.cpp b/src/ssl_decoder.cpp
index 059ae77..4bb6cf4 100644
--- a/src/ssl_decoder.cpp
+++ b/src/ssl_decoder.cpp
@@ -1063,6 +1063,26 @@ void ssl_message_free(struct session *sess, void *msg, void *msg_free_arg)
utarray_free(chello->extensions);
}
+ if(chello->sni!=NULL)
+ {
+ FREE(chello->sni);
+ }
+
+ if(chello->esni!=NULL)
+ {
+ FREE(chello->esni);
+ }
+
+ if(chello->ech!=NULL)
+ {
+ FREE(chello->ech);
+ }
+
+ if(chello->ja3.value!=NULL)
+ {
+ FREE(chello->ja3.value);
+ }
+
FREE(message->data);
}
break;
@@ -1074,6 +1094,11 @@ void ssl_message_free(struct session *sess, void *msg, void *msg_free_arg)
utarray_free(shello->extensions);
}
+ if(shello->ja3s.value!=NULL)
+ {
+ FREE(shello->ja3s.value);
+ }
+
FREE(message->data);
}
break;
@@ -1415,6 +1440,8 @@ int32_t ssl_decoder_config_load(const char *cfg_path, struct ssl_decoder_plugin_
plugin_env->stat.per_thread_enable=SSL_DECODER_FALSE;
fprintf(stderr, "[%s:%d] config file: %s key: [decoder.ssl.local_stat.stat_per_thread_enable] value is not yes or no", __FUNCTION__, __LINE__, cfg_path);
}
+
+ free(stat_per_thread_enable_val.u.s);
}
toml_datum_t name=toml_string_in(local_stat_tbl, "stat_name");
@@ -1426,6 +1453,7 @@ int32_t ssl_decoder_config_load(const char *cfg_path, struct ssl_decoder_plugin_
else
{
strncpy(plugin_env->stat.name, name.u.s, sizeof(plugin_env->stat.name));
+ free(name.u.s);
}
toml_datum_t output_path=toml_string_in(local_stat_tbl, "stat_output");
@@ -1437,6 +1465,7 @@ int32_t ssl_decoder_config_load(const char *cfg_path, struct ssl_decoder_plugin_
else
{
strncpy(plugin_env->stat.path, output_path.u.s, sizeof(plugin_env->stat.path));
+ free(output_path.u.s);
}
toml_free(root);
@@ -1562,5 +1591,10 @@ extern "C" void ssl_decoder_exit(void *penv)
plugin_env->tcp_stream.topic_id=-1;
}
+ if(plugin_env->net_port!=NULL)
+ {
+ FREE(plugin_env->net_port);
+ }
+
FREE(penv);
}
diff --git a/test/ssl_decoder_test.cpp b/test/ssl_decoder_test.cpp
index 3d46528..bdaf91c 100644
--- a/test/ssl_decoder_test.cpp
+++ b/test/ssl_decoder_test.cpp
@@ -367,6 +367,11 @@ int32_t ssl_decoder_test_config_load(const char *cfg_path, struct ssl_decoder_te
plugin_env->commit_result_enable=1;
fprintf(stderr, "[%s:%d] config file: %s key: [decoder.ssl.test.commit_result_enable] value is not yes or no", __FUNCTION__, __LINE__, cfg_path);
}
+
+ if(commit_result_enable_val.u.s!=NULL)
+ {
+ free(commit_result_enable_val.u.s);
+ }
}
toml_free(root);