fix(mactrack): fix 9 logic bugs in MAC address formatting, DNS resolver, and port scanning - #333
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a collection of independent logic bugs across the mactrack plugin: a typo'd variable in MAC address normalization, an argument-count mismatch in a prepared UPDATE, inverted/swapped DNS resolver initialization, wrong WHERE column in a bulk device update, an inverted comparison in the macauth email scheduler, scalar-increment misuse on array variables in six vendor scan modules, missing strict !== false checks on strpos(), and a reversed array index in the hp_ng ifAlias lookup.
Changes:
- Correct variable references and comparison/condition operators in MAC formatting, ARP UPDATE, DNS resolver branch, macauth timing, ignorePorts bulk update, and hp_ng ifAlias lookup.
- Remove erroneous
$active_vlans++scalar-increment on array variables across HP/Extreme/Juniper/Foundry collectors. - Add
!== falsetostrpos($parameter, '=')checks in the three CLI entry scripts.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| poller_mactrack.php | Fix strpos truthiness check, split concatenated device_id/mac_address parameter, invert macauth scheduling comparison |
| mactrack_scanner.php | Add !== false to strpos arg parser check |
| mactrack_resolver.php | Add !== false to strpos check; swap branches so Net_DNS2_Resolver is initialized when nameservers are configured |
| mactrack_devices.php | Change ignorePorts UPDATE WHERE clause from id to device_id |
| lib/mactrack_functions.php | Use correct $mac_address instead of typo $max_address in xform_mac_address() |
| lib/mactrack_hp.php, hp_ng.php, hp_ngi.php, extreme.php, juniper.php, foundry.php | Remove invalid $active_vlans++ increment on array variable |
| lib/mactrack_hp_ng.php | Correct ifAlias lookup to $ifInterfaces[$ifIndex]['ifAlias'] |
…rt scanning Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Confirmed != 0 is correct: when device responds to AT-MIB probe (ifIntcount > 0), use newer ipNetToMedia OIDs for collection. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
e4d876b to
961ea1c
Compare
Normalize all xform_mac_address branches into one variable, persist mt_last_macauth_time after scheduled reports, and drop remaining array ++ typos in vendor port scanners. Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
|
Closing as superseded. The logic fixes here now live in #342 as a focused PR. The Net/DNS2 portion bundled the library under |
Summary
xform_mac_address()read$max_address(typo) instead of$mac_address— all MAC addresses returned as empty string or raw inputpoller_mactrack.phpUPDATE concatenateddevice_id . mac_addressinto one parameter —mac_track_temp_portsIP updates never matched any rowmactrack_resolver.phpDNS resolver initialized only when$nameserversis empty; branches swapped — configured DNS servers were always ignoredmactrack_devices.phpignorePorts bulk UPDATE usedWHERE id = ?instead ofWHERE device_id = ?— batch updates silently wrote zero rows (confirmed: all other queries in same file usedevice_id)> time()instead of< time()— report fired continuously before scheduled time, never after$active_vlans++incremented an array as scalar in 6 vendor files (hp, hp_ng, hp_ngi, extreme, juniper, foundry) — clobbered VLAN array, port scanning never executedstrpos($parameter, '=')used as boolean without!== falsein 3 files — parameters starting with=misclassifiedmactrack_hp_ng.phpifName lookup used$ifInterfaces['ifAlias'][$ifIndex]instead of$ifInterfaces[$ifIndex]['ifAlias']— all port names always emptyNote: ARP MIB condition (
$ifIntcount != 0selecting ipNetToMedia OIDs) was reviewed and confirmed correct — device responsiveness to AT-MIB probe gates use of the newer ipNetToMedia table.Test plan
xform_mac_address()mac_track_temp_portsIP column is updated during ARP resolutionmac_track_devices🤖 Generated with Claude Code