Skip to content

new plugin for Cambium cnMatrix Ethernet Switches with SFP#6184

Open
rmorandell-pgum wants to merge 5 commits into
centreon:developfrom
i-Vertix:network-cambium-matrix
Open

new plugin for Cambium cnMatrix Ethernet Switches with SFP#6184
rmorandell-pgum wants to merge 5 commits into
centreon:developfrom
i-Vertix:network-cambium-matrix

Conversation

@rmorandell-pgum

@rmorandell-pgum rmorandell-pgum commented May 15, 2026

Copy link
Copy Markdown
Contributor

Community contributors

Description

Modes Available:

  • arp
  • hardware
  • interfaces
  • list-interfaces
  • list-sfp-port
  • sfp-port
  • tcpcon
  • udpcon
  • uptime

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Functionality enhancement or optimization (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

How this pull request can be tested ?

CAMBIUM-NETWORKS-SYSTEM-MIB.txt
CAMBIUM-NETWORKS-TRANSCEIVER-MIB.txt

cambium-cnMatrix.snmpwalk.txt

Checklist

  • I have followed the coding style guidelines provided by Centreon
  • I have commented my code, especially hard-to-understand areas of the PR.
  • I have rebased my development branch on the base branch (develop).
  • I have provide data or shown output displaying the result of this code in the plugin area concerned.

rmorandell-pgum and others added 4 commits May 15, 2026 16:26
(cherry picked from commit 129ab769ef5398495ba82576cbbaeac7ed3a68af)
This reverts commit 129ab769ef5398495ba82576cbbaeac7ed3a68af.
@rmorandell-pgum rmorandell-pgum requested a review from a team as a code owner May 15, 2026 14:45
@rmorandell-pgum rmorandell-pgum requested review from Evan-Adam and removed request for a team May 15, 2026 14:45
}

$self->{sfp}->{$instance}->{module_temperature} = undef;
if (defined($result->{biasCurrent}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {

@aikido-pr-checks aikido-pr-checks Bot May 15, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Module temperature assignment is gated by defined($result->{biasCurrent}), which can suppress valid moduleTemperature values.

Suggested change
if (defined($result->{biasCurrent}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {
if (defined($result->{moduleTemperature}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {
Details

✨ AI Reasoning
​The control condition for storing module temperature checks a different field than the one being stored. This introduces an unintended and incorrect dependency: temperature availability is tied to bias current presence. That leads to valid module temperature values not being recorded.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

if (defined($self->{option_results}->{display_transform_src})) {
$self->{option_results}->{display_transform_dst} = '' if (!defined($self->{option_results}->{display_transform_dst}));

$self->{safe}->reval("\$assign_var =~ s{$self->{option_results}->{display_transform_src}}{$self->{option_results}->{display_transform_dst}}",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

User-controlled options (display_transform_src/dst) are interpolated into code passed to Safe->reval, enabling code/regex injection. Avoid eval by performing regex substitution without building code strings, or properly validate/escape these option values.

Details

✨ AI Reasoning
​The code dynamically constructs and evaluates Perl code using Safe->reval with patterns coming from command-line options (display_transform_src and display_transform_dst). These option values are user-controlled at runtime. Although Safe is used, reval still executes interpreted code built from potentially untrusted input and thus can allow injection of unintended code or cause unsafe regex operations. The problematic construct appears where a substitution expression is built as a string and passed to reval. This harms security by allowing arbitrary code execution or DoS via crafted regexes. Fixing by avoiding eval (use direct regex operations with proper escaping or compile-safe regex routines) would meaningfully reduce risk and is feasible in this PR scope.

🔧 How do I fix it?
Use parameterized queries with placeholders, array-based command execution (no shell interpretation), or properly escaped arguments using vetted libraries. Avoid dynamic queries/commands built with user input concatenation.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment on lines +277 to +278
my $display = defined($self->{option_results}->{add_interface_name}) ?
$instance . '-' . exists($sfp_ports->{$instance}->[1]) ? $sfp_ports->{$instance}->[1] : '' : $instance;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The my $display = ... ternary expression is precedence-ambiguous and evaluates with unintended grouping, producing incorrect display values when add_interface_name is set.

Suggested change
my $display = defined($self->{option_results}->{add_interface_name}) ?
$instance . '-' . exists($sfp_ports->{$instance}->[1]) ? $sfp_ports->{$instance}->[1] : '' : $instance;
my $display = defined($self->{option_results}->{add_interface_name}) ?
$instance . '-' . (exists($sfp_ports->{$instance}->[1]) ? $sfp_ports->{$instance}->[1] : '') : $instance;
Details

✨ AI Reasoning
​The display value construction uses a nested conditional expression whose grouping is not aligned with the intended meaning. Because of operator precedence, the condition effectively evaluates a concatenated string rather than directly selecting between full display formats. This makes the resulting display text inconsistent with the surrounding logic and can drop the port prefix unexpectedly.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Comment on lines +307 to +312
if (defined($result->{biasCurrent}) && $result->{voltage} != 0 && $result->{voltage} != -32768) {
$self->{sfp}->{$instance}->{voltage} = $result->{voltage} / 1000;
}

$self->{sfp}->{$instance}->{module_temperature} = undef;
if (defined($result->{biasCurrent}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Voltage assignment is gated by defined($result->{biasCurrent}), so voltage data can be incorrectly dropped when bias current is absent.

Show fix
Suggested change
if (defined($result->{biasCurrent}) && $result->{voltage} != 0 && $result->{voltage} != -32768) {
$self->{sfp}->{$instance}->{voltage} = $result->{voltage} / 1000;
}
$self->{sfp}->{$instance}->{module_temperature} = undef;
if (defined($result->{biasCurrent}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {
if (defined($result->{voltage}) && $result->{voltage} != 0 && $result->{voltage} != -32768) {
$self->{sfp}->{$instance}->{voltage} = $result->{voltage} / 1000;
}
$self->{sfp}->{$instance}->{module_temperature} = undef;
if (defined($result->{moduleTemperature}) && $result->{moduleTemperature} != 0 && $result->{moduleTemperature} != -32768) {
Details

✨ AI Reasoning
​A condition that controls whether voltage is stored checks a different metric variable. This creates a hard dependency between unrelated measurements. As a result, valid voltage readings can be ignored solely because bias current is missing, which is incorrect behavior from control-flow alone.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants