Skip to content

fix(snmpagent): drop redundant snmp_priv_passphrase check in authNoPriv branch#7188

Merged
TheWitness merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/phpstan-snmpagent-develop
May 31, 2026
Merged

fix(snmpagent): drop redundant snmp_priv_passphrase check in authNoPriv branch#7188
TheWitness merged 1 commit into
Cacti:developfrom
somethingwithproof:fix/phpstan-snmpagent-develop

Conversation

@somethingwithproof
Copy link
Copy Markdown
Contributor

PHPStan level 6 (the PHP x Test job in syntax.yml) currently fails on develop HEAD:

lib/snmpagent.php  Negated boolean expression is always true.  (booleanNot.alwaysTrue)

In both SNMPv3 trap blocks the elseif is reached only when the preceding if (snmp_password && snmp_priv_passphrase) is false. With snmp_password true at the elseif, snmp_priv_passphrase is necessarily empty, so && !snmp_priv_passphrase is dead. Dropping it is behavior-identical and clears the gate. Per the repo's PHPStan policy this fixes the underlying cause rather than baselining.

Verified locally: composer run-script phpstan reports [OK] No errors. Unblocks the develop PHP test job for open develop PRs.

…iv branch

The elseif is only reached when the preceding (password && priv) is false, so
with password true the passphrase is already known empty; the extra
!snmp_priv_passphrase term is dead. PHPStan level 6 flags it as always-true.
Removing it clears the develop PHPStan gate without changing behavior.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Copilot AI review requested due to automatic review settings May 30, 2026 21:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Simplifies SNMPv3 security-level selection logic in snmpagent_notification() by removing a redundant condition.

Changes:

  • Simplified the elseif branch that assigns authNoPriv to rely solely on snmp_password after the authPriv case is handled.

@TheWitness TheWitness merged commit f73fafc into Cacti:develop May 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants