fix(mactrack): fix 9 logic bugs in MAC address formatting, DNS resolver, and port scanning#333
Open
somethingwithproof wants to merge 3 commits into
Open
Conversation
Contributor
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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