diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 51d6ec435651afc9a9187fffed3f3addca1d8ba5..526f4918a62225a18abfaec705b23b92c2c1e823 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,11 @@ +variables: + SOURCE_FOLDER: "src" + include: - project: 'iopsys/gitlab-ci-pipeline' file: '/static-code-analysis.yml' - ref: '0.32' + ref: '1.2' stages: - static_code_analysis -variables: - DEBUG: 'TRUE' - SOURCE_FOLDER: "./src" - FLAWFINDER_OPTIONS: "-m 4 --error-level=5" - CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1" - COMPILE: "./gitlab-ci/compile.sh" - diff --git a/gitlab-ci/compile.sh b/gitlab-ci/compile.sh deleted file mode 100755 index 7e12f5f9da1f62985ae54e2aa458dc2015937696..0000000000000000000000000000000000000000 --- a/gitlab-ci/compile.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -source ./gitlab-ci/shared.sh - -install_bbfd - -exec_cmd_verbose make -C ./src diff --git a/gitlab-ci/install-dependencies.sh b/gitlab-ci/install-dependencies.sh new file mode 100755 index 0000000000000000000000000000000000000000..bb1c6a9d2d4c7ae78ec571fe5c0b3bab2f0b8898 --- /dev/null +++ b/gitlab-ci/install-dependencies.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +echo "Install dependencies for functional test" +pwd + +source ./gitlab-ci/shared.sh + +# install bbfdm +install_bbfdm + diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh index f4b3349313d06206f5061b5233ccdc3057eda6da..dc606510de3df2aea40656ed8fb4bd4c8a414169 100644 --- a/gitlab-ci/shared.sh +++ b/gitlab-ci/shared.sh @@ -11,18 +11,9 @@ function exec_cmd() fi } -function exec_cmd_verbose() +function install_bbfdm() { - echo "executing $@" - if ! $@; then - echo "Failed to execute $@" - exit 1 - fi -} - -function install_bbfd() -{ - [ -d "/opt/dev/bbfdm" ] && rm -rf /opt/dev/bbfdm + [ -d "/opt/dev/bbfdm" ] && return 0 if [ -n "${BBFDM_BRANCH}" ]; then exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm @@ -33,5 +24,4 @@ function install_bbfd() cd /opt/dev/bbfdm ./gitlab-ci/install-dependencies.sh install ./gitlab-ci/setup.sh install - cd - } diff --git a/src/packetcapture.c b/src/packetcapture.c index 3f2a43b6c203773d0076bade629e492384c8a6e9..640736bfda8d359a5216512ab08848aa9664a7dd 100644 --- a/src/packetcapture.c +++ b/src/packetcapture.c @@ -33,10 +33,11 @@ static int browsePacketCaptureResultInst(struct dmctx *dmctx, DMNODE *parent_nod static void stop_packetcapture_diagnostics(void) { - char cmd[256] = {0}; + char output[256] = {0}, cmd[256] = {0}; snprintf(cmd, sizeof(cmd), "sh %s '{\"proto\":\"both_proto\",\"cancel\":\"1\"}'", PACKET_CAPTURE_DIAGNOSTIC_PATH); - system(cmd); + + run_cmd(cmd, output, sizeof(output)); } /************************************************************* @@ -90,14 +91,14 @@ int operate_Device_packetCapture(char *refparam, struct dmctx *ctx, void *data, if (format[0] != '\0' && bbfdm_validate_string(ctx, format, -1, -1, allowed_format, NULL)) return USP_FAULT_INVALID_ARGUMENT; - char *duration = dmjson_get_value((json_object *)value, 1, "Duration"); + const char *duration = dmjson_get_value((json_object *)value, 1, "Duration"); if (duration[0] != '\0') { if (bbfdm_validate_unsignedInt(ctx, duration, RANGE_ARGS{{"1", NULL}}, 1)) return USP_FAULT_INVALID_ARGUMENT; } else duration = "1"; - char *pack_count = dmjson_get_value((json_object *)value, 1, "PacketCount"); + const char *pack_count = dmjson_get_value((json_object *)value, 1, "PacketCount"); if (pack_count[0] != '\0') { if (bbfdm_validate_unsignedInt(ctx, pack_count, RANGE_ARGS{{0, NULL}}, 1)) return USP_FAULT_INVALID_ARGUMENT; @@ -354,7 +355,7 @@ static int set_PacketCapture_Username(char *refparam, struct dmctx *ctx, void *d static int get_PacketCapture_Password(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { - *value = ""; + *value = dmstrdup(""); return 0; }