Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(engine): semicolon is no more considered as a beginning of commen… #1120

Merged
merged 3 commits into from
Feb 7, 2024
Merged
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: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma8
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dnf install -y cmake \

dnf update libarchive

pip3 install conan==1.57.0 --prefix=/usr --upgrade
pip3 install conan==1.62.0 --prefix=/usr --upgrade
rm -rf ~/.conan/profiles/default

EOF
Expand Down
2 changes: 1 addition & 1 deletion .github/docker/Dockerfile.centreon-collect-alma9
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dnf --best install -y cmake \
# TEMPORARY PYTHON UPGRADE TO 3.18 TO HELP WITH DATA_FILTER ISSUE
dnf upgrade -y python3

pip3 install conan==1.57.0 --prefix=/usr --upgrade
pip3 install conan==1.62.0 --prefix=/usr --upgrade
rm -rf ~/.conan/profiles/default

EOF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
pip3 install conan==1.57.0
pip3 install conan==1.62.0
ln -s /usr/local/bin/conan /usr/bin/conan
rm -rf ~/.conan/profiles/default

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/veracode-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
mkdir build
cd build

sudo pip3 install conan==1.57.0 --prefix=/usr --upgrade
sudo pip3 install conan==1.62.0 --prefix=/usr --upgrade
sudo conan install .. -s compiler.cppstd=14 -s compiler.libcxx=libstdc++11 --build=missing

sudo cmake \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ apt install conan
If it does not work, conan can be installed with pip3:

```shell
pip3 install conan==1.57.0
pip3 install conan==1.62.0
```

> All the dependencies pulled by conan are located in conanfile.txt. If
Expand Down
12 changes: 9 additions & 3 deletions cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ This program build Centreon-broker
-fcr|--force-conan-rebuild : rebuild conan data
-ng : C++17 standard
-clang : Compilation with clang++
-mold : Link with mold instead of ld
-h|--help : help
EOF
}
Expand All @@ -33,6 +34,7 @@ CXX=g++
LIBCXX=libstdc++11
WITH_CLANG=OFF
EE=
MOLD=

for i in "$@"
do
Expand All @@ -55,6 +57,10 @@ do
CXX=clang++
shift
;;
-mold)
MOLD="-fuse-ld=mold"
shift
;;
-fcr|--force-conan-rebuild)
echo "Forced conan rebuild"
CONAN_REBUILD="1"
Expand Down Expand Up @@ -311,9 +317,9 @@ echo "$conan install .. --build=missing"
$conan install .. --build=missing

if [[ "$maj" == "Raspbian" ]] ; then
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF $* ..
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF $* ..
elif [[ "$maj" == "Debian" ]] ; then
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_PREFIX_LIB_CLIB=/usr/lib64/ -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* ..
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_PREFIX_LIB_CLIB=/usr/lib64/ -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* ..
else
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* ..
CC=$CC CXX=$CXX CXXFLAGS="-Wall -Wextra $MOLD" $cmake -DWITH_CLANG=$WITH_CLANG -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DWITH_USER_BROKER=centreon-broker -DWITH_USER_ENGINE=centreon-engine -DWITH_GROUP_BROKER=centreon-broker -DWITH_GROUP_ENGINE=centreon-engine -DWITH_TESTING=On -DWITH_MODULE_SIMU=On -DWITH_BENCH=On -DWITH_CREATE_FILES=OFF -DWITH_CONF=OFF $* ..
fi
64 changes: 30 additions & 34 deletions engine/precomp_inc/precomp.hh
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
/*
** Copyright 2022 Centreon
**
** This file is part of Centreon Engine.
**
** Centreon Engine is free software: you can redistribute it and/or
** modify it under the terms of the GNU General Public License version 2
** as published by the Free Software Foundation.
**
** Centreon Engine is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Centreon Engine. If not, see
** <http://www.gnu.org/licenses/>.
*/
/**
* Copyright 2022-2024 Centreon
*
* This file is part of Centreon Engine.
*
* Centreon Engine is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* Centreon Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Centreon Engine. If not, see
* <http://www.gnu.org/licenses/>.
*/

#ifndef CCE_PRECOMP_HH
#define CCE_PRECOMP_HH

#include <absl/strings/numbers.h>
#include <absl/strings/str_split.h>
#include <absl/strings/string_view.h>
#include <spdlog/fmt/ostr.h>
#include <spdlog/spdlog.h>
#include <unistd.h>

#include <algorithm>
#include <array>
#include <asio.hpp>
#include <atomic>
#include <boost/algorithm/string/trim.hpp>
#include <boost/circular_buffer.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/optional.hpp>
#include <cassert>
#include <cerrno>
#include <cmath>
#include <condition_variable>
#include <cstddef>
#include <cstdint>

#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
Expand All @@ -57,19 +66,6 @@
#include <utility>
#include <vector>

#include <spdlog/fmt/ostr.h>
#include <spdlog/spdlog.h>

#include <absl/strings/numbers.h>
#include <absl/strings/str_split.h>
#include <absl/strings/string_view.h>

#include <boost/circular_buffer.hpp>
#include <boost/container/flat_map.hpp>
#include <boost/optional.hpp>

#include <asio.hpp>

#include "com/centreon/engine/namespace.hh"

namespace fmt {
Expand Down
38 changes: 19 additions & 19 deletions engine/src/configuration/object.cc
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
** Copyright 2011-2014 Merethis
**
** This file is part of Centreon Engine.
**
** Centreon Engine is free software: you can redistribute it and/or
** modify it under the terms of the GNU General Public License version 2
** as published by the Free Software Foundation.
**
** Centreon Engine is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with Centreon Engine. If not, see
** <http://www.gnu.org/licenses/>.
*/
/**
* Copyright 2011-2014,2024 Merethis
*
* This file is part of Centreon Engine.
*
* Centreon Engine is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* Centreon Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Centreon Engine. If not, see
* <http://www.gnu.org/licenses/>.
*/

#include "com/centreon/engine/configuration/object.hh"
#include "com/centreon/engine/configuration/anomalydetection.hh"
Expand Down Expand Up @@ -204,7 +204,7 @@ bool object::parse(std::string const& line) {
key.assign(line, 0, pos);
value.assign(line, pos + 1, std::string::npos);
}
string::trim(value);
boost::algorithm::trim(value);
if (!parse(key.c_str(), value.c_str()))
return object::parse(key.c_str(), value.c_str());
return true;
Expand Down
2 changes: 1 addition & 1 deletion engine/src/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool string::get_next_line(std::ifstream& stream,
unsigned int& pos) {
while (std::getline(stream, line, '\n')) {
++pos;
string::trim(line);
boost::algorithm::trim(line);
if (!line.empty()) {
char c(line[0]);
if (c != '#' && c != ';' && c != '\x0')
Expand Down
2 changes: 1 addition & 1 deletion packaging/rpm/centreon-collect.spec
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ SELinux context for centreon-broker
%setup -q -n %{name}-%{version}

%build
pip3 install conan==1.57.0 --upgrade
pip3 install conan==1.62.0 --upgrade
conan install . -s compiler.cppstd=14 -s compiler.libcxx=libstdc++11 --build=missing

cmake3 \
Expand Down
37 changes: 37 additions & 0 deletions tests/engine/forced_checks.robot
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,40 @@ EMACROS_NOTIF

Stop Engine
Kindly Stop Broker


EMACROS_SEMICOLON
[Documentation] Macros with a semicolon are used even if they contain a semicolon
[Tags] engine external_cmd macros
Config Engine ${1}
Config Broker central
Config Broker rrd
Config Broker module ${1}
Engine Config Set Value ${0} log_legacy_enabled ${0}
Engine Config Set Value ${0} log_v2_enabled ${1}
Engine Config Set Value 0 log_level_checks trace True
Engine Config Set Value In Hosts 0 host_1 _KEY2 VAL1;val3;
Engine Config Change Command
... 0
... \\d+
... /bin/echo "KEY2=$_HOSTKEY2$"
Clear Retention
${start} Get Current Date
Start Engine
Start Broker

${content} Create List INITIAL HOST STATE: host_1;
${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60
Should Be True
... ${result}
... An Initial host state on host_1 should be raised before we can start our external commands.
Schedule Forced Svc Check host_1 service_1
Sleep 5s

${content} Create List KEY2=VAL1;val3;
${result} Find In Log With Timeout ${engineLog0} ${start} ${content} 60
Should Be True ${result} VAL1;val3; not found in log.

Stop Engine
Kindly Stop Broker

Loading