Files
cacti/tests/Unit/Core
d66752117c fix(cli): add --security-level and SNMPv3 help to change_device.php (#8579)
* fix(cli): add --security-level and SNMPv3 help to change_device.php

change_device.php merges overrides onto the stored device, so a device
that was authPriv stayed authPriv when only auth settings were given.
Add --security-level to set noAuthNoPriv, authNoPriv or authPriv
explicitly, clearing protocols and secrets the level does not use.
Only require an SNMPv3 password when an auth protocol is set, validate
protocol names with the list of valid values, report the SNMPv3 user
and level instead of the community, and add SNMPv3 help examples.

* fix(cli): collapse SNMPv3 help prints to clear SonarQube duplication

The new SNMPv3 "security level" explanation and "Examples" sections in
change_device.php's display_help() were written as a run of ~20 consecutive
`print '...' . PHP_EOL;` statements. SonarCloud's token-based duplication
detector normalizes string literals, so this run matched the equally long
run of help prints in cli/structure_rra_paths.php, tripping the Quality
Gate (11.7% duplicated lines on new code, 1 block / 19 lines).

Collapse those two sections into a single concatenated `print` each. The
emitted help text is byte-for-byte identical; only the statement grouping
changes, which breaks the duplicated token run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* fix(cli): declare SNMPv3 protocol globals in change_device.php

The SNMPv3 validation block references the $snmp_auth_protocols and
$snmp_priv_protocols arrays (defined in include/global_arrays.php) without a
`global` declaration, so PHPStan (level 8, the Commit Audit "PHP 8.3 locked
integration" job) reports "Variable $snmp_auth_protocols might not be defined"
and the same for $snmp_priv_protocols.

Declare both arrays global at the top of the SNMPv3 branch, matching how every
other consumer of these arrays (managers.php, automation_snmp.php, lib/snmp.php)
brings them into scope. No behavioural change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: TheWitness <copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 16:01:33 -05:00
..