Skip to content

Commit 88a52c0

Browse files
authored
Merge pull request #6185 from centreon/release-20260500
Release 20260500
2 parents ca10ad3 + d49e7c4 commit 88a52c0

145 files changed

Lines changed: 9792 additions & 563 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.githooks/pre-commit.d/20_plugins.sh

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ NC='\033[0m' # No Color
77

88
# global errors counter
99
errors=0
10+
tmpfile="/tmp/check$$"
1011

1112
function info() {
1213
echo -e "${GREEN}INFO${NC}: $*"
@@ -26,19 +27,42 @@ function fatal() {
2627
exit 1
2728
}
2829

29-
function check_tabs() {
30+
function check_tabs_crlf() {
3031
local file="$1"
3132
info "--> Checking BASH indentation"
3233
grep -P '^\t' "$file" >/dev/null 2>&1 && warning "--> File $file contains leading tab character (suspected bad indentation)."
34+
info "--> Checking carriage returns"
35+
grep $'\r' "$file" >/dev/null 2>&1 && warning "--> File $file contains CRLF line terminators."
36+
}
37+
38+
function check_constants() {
39+
local file="$1"
40+
41+
info "--> Checking constants utilization"
42+
43+
grep -nH -- "-\(1\|2\|10\)[[:space:]]*=>[[:space:]]*1" "$file" > "$tmpfile"
44+
grep -nH "\<type[[:space:]]*=>[[:space:]]*[0-9]" "$file" >> "$tmpfile"
45+
if [ -s "$tmpfile" ] ; then
46+
error "It seems that some counters are not using constants defined in centreon/plugins/constants.pm."
47+
cat $tmpfile
48+
fi
49+
}
50+
51+
function check_md5() {
52+
local file="$1"
53+
54+
info "--> Checking MD5 utilization"
55+
grep -q md5_hex "$file"
56+
if [ $? -eq 0 ] ; then
57+
error "$file: It seems that md5_hexa is used. Use sha256_hex (with Digest::SHA) instead."
58+
fi
3359
}
3460

3561
jq=$(type -p jq) || fatal "Could not locate jq command"
3662
# Determining the robotidy command
37-
robotidy_path=$(type -p robocop) || robotidy_path=$(type -p robotidy) || fatal "Could not locate either robocop nor robotidy. Cannot check robot lint"
38-
robotidy_exe="${robotidy_path##*/}"
39-
info "Robot lint tool is $robotidy_exe"
40-
# Options depend on the use binary
41-
declare -A robotidy_opts=([robotidy]="-->-check --skip-keyword-call Examples:" [robocop]="check --ignore DOC02 --ignore LEN08 --ignore LEN04 --ignore DOC03 --ignore NAME07" )
63+
robocop_path=$(type -p robocop) || fatal "Could not locate robocop. Cannot check robot lint"
64+
robocop_exe="${robocop_path##*/}"
65+
4266
# Get list of committed files
4367
mapfile -t committed_files < <(git diff --cached --name-only --diff-filter=ACMR)
4468
info "Starting plugins pre-commit hooks for ${#committed_files[@]} files"
@@ -58,8 +82,15 @@ for file in "${committed_files[@]}"; do
5882
grep -- '--warning-\*\|--critical-\*' "$file" >/dev/null && error "File $file contains help that is written as --warning-* or --critical-*"
5983
# check spelling
6084
info "--> Checking that spelling in file is OK"
61-
perl .github/scripts/pod_spell_check.t "$file" ./tests/resources/spellcheck/stopwords.txt >/dev/null 2>&1 || error "Spellcheck error on file $file"
62-
check_tabs "$file"
85+
perl .github/scripts/pod_spell_check.t "$file" ./tests/resources/spellcheck/stopwords.txt >$tmpfile 2>&1
86+
rc=$?
87+
if [ $rc -ne 0 ] ; then
88+
error "Spellcheck error on file $file"
89+
tail -n 2 $tmpfile | head -n 1 | sed 's/^[^:]*:/Invalid words:/' 2>/dev/null
90+
fi
91+
check_tabs_crlf "$file"
92+
check_constants "$file"
93+
check_md5 "$file"
6394
;;
6495
txt)
6596
if [[ "${file##*/}" == "stopwords.txt" ]]; then
@@ -70,22 +101,29 @@ for file in "${committed_files[@]}"; do
70101
fi
71102
;;
72103
robot)
73-
info "--> Checking robot lint"
74-
$robotidy_path ${robotidy_opts[$robotidy_exe]} "$file" >/dev/null 2>&1 || warning "--> Robot lint errors found in $file"
75-
check_tabs "$file"
104+
info "--> Checking robot format"
105+
check_tabs_crlf "$file"
106+
cp "$file" "$tmpfile" && $robocop_path format "$tmpfile" >/dev/null 2>&1
107+
diff -q "$file" "$tmpfile" >/dev/null 2>&1
108+
rc=$?
109+
if [ $rc -ne 0 ] ; then
110+
error "$file not is properly formatted, please use 'robocop format'"
111+
fi
76112
;;
77113
sh)
78-
check_tabs "$file"
114+
check_tabs_crlf "$file"
79115
;;
80116
json)
81117
info "--> Checking JSON validity"
82118
jq '' "$file" >/dev/null 2>&1 || error "JSON file $file is not valid"
83-
check_tabs "$file"
119+
check_tabs_crlf "$file"
84120
;;
85121
*)
86122
info "File extension '.${file_extension}' has no checks"
87123
;;
88124
esac
89125
done
126+
rm -f "$tmpfile"
127+
90128
(( errors > 0 )) && fatal "$errors errors found in pre-commit checks"
91129
info "All plugins pre-commit checks passed"

.githooks/pre-commit.d/80_gitleaks.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ if ! command -v gitleaks >/dev/null 2>&1; then
99
fi
1010

1111
# scan for secrets before commit
12-
gitleaks detect --no-git --verbose
12+
gitleaks protect -v --staged
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# Build arg to select vmware Perl source: false=use .deb (production), true=use local repo (dev/test)
2+
ARG USE_SOURCE_VMWARE=false
3+
# Build arg to include VMware Perl SDK (requires proprietary files in sdks-vmware/ — see sdks-vmware/README.md)
4+
ARG WITH_SDK=false
5+
6+
#############################################
7+
# Stage 1: Extract files from .deb packages
8+
#############################################
9+
FROM debian:12-slim AS extractor
10+
11+
RUN apt-get update && apt-get install -y --no-install-recommends \
12+
dpkg \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Extract .deb package (mounted via --mount during build)
16+
RUN --mount=type=bind,source=packages-centreon,target=/packages \
17+
mkdir -p /extracted && \
18+
cd /packages && \
19+
for deb in centreon-plugin-Virtualization-VMWare-daemon*.deb; do \
20+
echo "Extracting $deb..."; \
21+
dpkg-deb -x "$deb" /extracted/; \
22+
done && \
23+
echo "=== Extracted Perl modules ===" && \
24+
ls -lah /extracted/usr/share/perl5/centreon/ || true && \
25+
echo "=== Extracted binaries ===" && \
26+
ls -lah /extracted/usr/bin/ || true
27+
28+
#############################################
29+
# Stage 1b/1c: Perl modules source selector
30+
# USE_SOURCE_VMWARE=false → extract from .deb (production default)
31+
# USE_SOURCE_VMWARE=true → copy from local repo source (dev/testing)
32+
#############################################
33+
FROM scratch AS vmware-perl-false
34+
COPY --from=extractor /extracted/usr/share/perl5/centreon /centreon-modules/
35+
36+
FROM scratch AS vmware-perl-true
37+
COPY connectors/vmware/src/centreon/ /centreon-modules/
38+
39+
ARG USE_SOURCE_VMWARE=false
40+
# hadolint ignore=DL3006
41+
FROM vmware-perl-${USE_SOURCE_VMWARE} AS vmware-perl-selected
42+
43+
#############################################
44+
# Stage 1d/1e: Binary source selector
45+
#############################################
46+
FROM scratch AS vmware-bin-false
47+
COPY --from=extractor /extracted/usr/bin/centreon_vmware.pl /centreon_vmware.pl
48+
COPY --from=extractor /extracted/usr/bin/centreon_vmware_convert_config_file /centreon_vmware_convert_config_file
49+
50+
FROM scratch AS vmware-bin-true
51+
COPY connectors/vmware/src/centreon_vmware.pl /centreon_vmware.pl
52+
COPY connectors/vmware/src/centreon/script/centreon_vmware_convert_config_file /centreon_vmware_convert_config_file
53+
54+
ARG USE_SOURCE_VMWARE=false
55+
# hadolint ignore=DL3006
56+
FROM vmware-bin-${USE_SOURCE_VMWARE} AS vmware-bin-selected
57+
58+
#############################################
59+
# Stage 2a: VMware SDK — with SDK (WITH_SDK=true)
60+
# Requires SDK archives in sdks-vmware/ (gitignored — proprietary Broadcom license):
61+
# - VMware-vSphere-Perl-SDK-7.0.0-17698549.x86_64.tar.gz (download from https://developer.broadcom.com)
62+
# - vsan-sdk-perl.zip (download from https://developer.broadcom.com)
63+
# Build with: docker build --build-arg WITH_SDK=true .
64+
#############################################
65+
FROM debian:12-slim AS sdk-true
66+
67+
RUN apt-get update && apt-get install -y --no-install-recommends \
68+
perl \
69+
make \
70+
patch \
71+
unzip \
72+
&& rm -rf /var/lib/apt/lists/*
73+
74+
COPY .github/docker/connector/VICommon.patch /tmp/VICommon.patch
75+
76+
RUN --mount=type=bind,source=sdks-vmware,target=/sdks \
77+
set -e && \
78+
cd /tmp && \
79+
tar zxf /sdks/VMware-vSphere-Perl-SDK-7.0.0-17698549.x86_64.tar.gz && \
80+
cd vmware-vsphere-cli-distrib && \
81+
patch --backup lib/VMware/share/VMware/VICommon.pm /tmp/VICommon.patch && \
82+
perl Makefile.PL && \
83+
make pure_install && \
84+
echo "=== vSphere SDK installed ===" && \
85+
ls -lah /usr/local/share/perl/
86+
87+
RUN --mount=type=bind,source=sdks-vmware,target=/sdks \
88+
set -e && \
89+
cd /tmp && \
90+
unzip /sdks/vsan-sdk-perl.zip && \
91+
mkdir -p /usr/local/share/perl5/VMware && \
92+
cp ./vsan-sdk-perl/bindings/VIM25Vsanmgmt* /usr/local/share/perl5/VMware/ && \
93+
echo "=== vSAN SDK installed ===" && \
94+
ls -lah /usr/local/share/perl5/VMware/
95+
96+
#############################################
97+
# Stage 2b: VMware SDK — without SDK (WITH_SDK=false, default)
98+
# Used by CI and public image builds. The daemon starts but encrypted::
99+
# credentials won't be decryptable without the SDK.
100+
#############################################
101+
FROM debian:12-slim AS sdk-false
102+
103+
RUN mkdir -p /usr/local/share/perl/5.36.0/VMware /usr/local/share/perl5/VMware
104+
105+
# hadolint ignore=DL3006
106+
FROM sdk-${WITH_SDK} AS sdk-installer
107+
108+
#############################################
109+
# Stage 3: Runtime - Debian 12 slim image
110+
#############################################
111+
FROM debian:12-slim AS centreon-vmware
112+
113+
ARG VERSION
114+
ARG STABILITY
115+
116+
# Create users and groups
117+
RUN groupadd -g 33 www-data 2>/dev/null || true && \
118+
groupadd -g 900 centreon && \
119+
useradd -u 900 -g centreon -m -r -d /var/spool/centreon -s /bin/bash centreon && \
120+
groupadd -g 901 centreon-engine && \
121+
useradd -u 901 -g centreon-engine -m -r -d /var/lib/centreon-engine -s /bin/bash centreon-engine && \
122+
groupadd -g 903 centreon-gorgone && \
123+
useradd -u 903 -g centreon-gorgone -m -r -d /var/lib/centreon-gorgone -s /bin/bash centreon-gorgone && \
124+
usermod -aG centreon-engine centreon && \
125+
usermod -aG centreon-gorgone centreon
126+
127+
# Add Centreon plugins-stable repository (needed for libnet-curl-perl on amd64)
128+
RUN apt-get update && apt-get install -y --no-install-recommends gnupg wget ca-certificates && \
129+
echo "deb [arch=amd64] https://packages.centreon.com/apt-plugins-stable/ bookworm main" \
130+
> /etc/apt/sources.list.d/centreon-plugins.list && \
131+
wget -O- https://apt-key.centreon.com | gpg --dearmor \
132+
| tee /etc/apt/trusted.gpg.d/centreon.gpg > /dev/null 2>&1 && \
133+
rm -rf /var/lib/apt/lists/*
134+
135+
# Install runtime dependencies
136+
RUN apt-get update && apt-get install -y --no-install-recommends \
137+
perl \
138+
libclass-methodmaker-perl \
139+
libcrypt-openssl-aes-perl \
140+
libcrypt-ssleay-perl \
141+
libio-socket-inet6-perl \
142+
libjson-xs-perl \
143+
liblwp-protocol-https-perl \
144+
libsoap-lite-perl \
145+
libtext-template-perl \
146+
libuuid-perl \
147+
libzmq-constants-perl \
148+
libzmq-libzmq4-perl \
149+
libxml-libxml-perl \
150+
libjson-perl \
151+
libzmq5 \
152+
&& rm -rf /var/lib/apt/lists/*
153+
154+
# Install libnet-curl-perl (only available in Centreon plugins repo for amd64, cpanm fallback for arm64)
155+
RUN ARCH=$(dpkg --print-architecture) && \
156+
if [ "$ARCH" = "amd64" ]; then \
157+
apt-get update && apt-get install -y --no-install-recommends \
158+
libnet-curl-perl && \
159+
rm -rf /var/lib/apt/lists/*; \
160+
else \
161+
apt-get update && apt-get install -y --no-install-recommends \
162+
cpanminus \
163+
build-essential \
164+
libcurl4-openssl-dev \
165+
libssl-dev && \
166+
rm -rf /var/lib/apt/lists/* && \
167+
cpanm --notest Net::Curl; \
168+
fi
169+
170+
# Create directory structure
171+
RUN mkdir -p \
172+
/etc/centreon \
173+
/tmp/centreon_vmware && \
174+
chown -R centreon-gorgone:centreon /etc/centreon && \
175+
chmod -R 775 /etc/centreon && \
176+
chown centreon:centreon /tmp/centreon_vmware && \
177+
chmod 775 /tmp/centreon_vmware
178+
179+
# Copy VMware SDK from installer stage
180+
# vSphere SDK: make pure_install puts modules in the versioned site path
181+
COPY --from=sdk-installer /usr/local/share/perl/ /usr/local/share/perl/
182+
# vSAN SDK: copied directly to /usr/local/share/perl5/VMware/
183+
COPY --from=sdk-installer /usr/local/share/perl5/VMware/ /usr/local/share/perl5/VMware/
184+
185+
# Copy Perl modules from selector (centreon vmware modules + script modules)
186+
COPY --from=vmware-perl-selected /centreon-modules/ /usr/share/perl5/centreon/
187+
188+
# Copy executables from selector
189+
COPY --from=vmware-bin-selected --chmod=755 /centreon_vmware.pl /usr/bin/centreon_vmware.pl
190+
COPY --from=vmware-bin-selected --chmod=755 /centreon_vmware_convert_config_file /usr/bin/centreon_vmware_convert_config_file
191+
192+
# Copy default configuration (template with placeholder vCenter URLs)
193+
COPY --chown=centreon-gorgone:centreon --chmod=660 \
194+
connectors/vmware/packaging/config/centreon_vmware-conf.json \
195+
/etc/centreon/centreon_vmware.json
196+
197+
# Verify critical files exist
198+
RUN echo "=== Verification ===" && \
199+
ls -lah /usr/bin/centreon_vmware.pl && \
200+
ls -lah /usr/bin/centreon_vmware_convert_config_file && \
201+
ls -lah /usr/share/perl5/centreon/ && \
202+
ls -lah /usr/local/share/perl5/VMware/ && \
203+
ls -lah /etc/centreon/ && \
204+
echo "=== Files verified ==="
205+
206+
ENV PERL5LIB=/usr/local/share/perl5:/usr/share/perl5:/usr/lib/perl5
207+
208+
WORKDIR /etc/centreon
209+
210+
USER centreon
211+
212+
CMD ["/usr/bin/perl", "/usr/bin/centreon_vmware.pl", \
213+
"--config-extra=/etc/centreon/centreon_vmware.json", \
214+
"--logfile=/dev/stdout", \
215+
"--severity=error"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- lib/VMware/share/VMware/VICommon.pm 2025-04-24 17:18:24.938290503 +0200
2+
+++ VICommon.pm 2025-04-24 17:18:18.690399614 +0200
3+
@@ -2319,6 +2319,8 @@
4+
my $user_agent = $self->{user_agent};
5+
$user_agent->cookie_jar->as_string
6+
=~ m/(.*)vmware_soap_session=\"\\\"([0-9a-zA-Z-](.*)+)\\\"\"(.*)/;
7+
+ $user_agent->cookie_jar->as_string
8+
+ =~ m/(.*)vmware_soap_session=[\\\"]*([0-9a-zA-Z-]+)/ unless $2;
9+
return $2;
10+
}

.github/docker/packaging/Dockerfile.packaging-plugins-java-alma10

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ dnf install -y \
1111
zstd
1212

1313
cd /usr/local/src
14-
wget https://dlcdn.apache.org/maven/maven-3/3.8.9/binaries/apache-maven-3.8.9-bin.tar.gz
15-
tar zxf apache-maven-3.8.9-bin.tar.gz
16-
ln -s /usr/local/src/apache-maven-3.8.9/bin/mvn /usr/bin/mvn
17-
rm -f apache-maven-3.8.9-bin.tar.gz
14+
wget https://dlcdn.apache.org/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.tar.gz
15+
tar zxf apache-maven-3.9.16-bin.tar.gz
16+
ln -s /usr/local/src/apache-maven-3.9.16/bin/mvn /usr/bin/mvn
17+
rm -f apache-maven-3.9.16-bin.tar.gz
1818

1919
echo '[goreleaser]
2020
name=GoReleaser
@@ -26,4 +26,4 @@ dnf clean all
2626

2727
EOF
2828

29-
WORKDIR /src
29+
WORKDIR /src

.github/docker/packaging/Dockerfile.packaging-plugins-java-alma8

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ dnf install -y \
1111
zstd
1212

1313
cd /usr/local/src
14-
wget https://dlcdn.apache.org/maven/maven-3/3.8.9/binaries/apache-maven-3.8.9-bin.tar.gz
15-
tar zxf apache-maven-3.8.9-bin.tar.gz
16-
ln -s /usr/local/src/apache-maven-3.8.9/bin/mvn /usr/bin/mvn
17-
rm -f apache-maven-3.8.9-bin.tar.gz
14+
wget https://dlcdn.apache.org/maven/maven-3/3.9.16/binaries/apache-maven-3.9.16-bin.tar.gz
15+
tar zxf apache-maven-3.9.16-bin.tar.gz
16+
ln -s /usr/local/src/apache-maven-3.9.16/bin/mvn /usr/bin/mvn
17+
rm -f apache-maven-3.9.16-bin.tar.gz
1818

1919
echo '[goreleaser]
2020
name=GoReleaser
@@ -26,4 +26,4 @@ dnf clean all
2626

2727
EOF
2828

29-
WORKDIR /src
29+
WORKDIR /src

0 commit comments

Comments
 (0)