Repository navigation
Fix device type detection for single-criterion match patterns - #408
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the device-type auto-detection update.
No open issues 🎉
What changed in this PR
Updates Device Tracking’s auto-detection logic to evaluate only the match criteria supplied by each device type.
Changes:
- Handles single-criterion types explicitly, requires both criteria when present, and skips types with neither.
- Extracts a pattern matcher that requires every non-empty wildcard token to match.
- Adds regression tests and records the detection update in the changelog.
| File | Description |
|---|---|
tests/Unit/FindScanningFunctionTest.php |
Adds coverage for criterion combinations, wildcard matching, and empty inputs. |
lib/mactrack_functions.php |
Extracts the pattern matcher and updates device-type selection logic. |
CHANGELOG.md |
Documents the device-type detection update. |
Review effort: Balanced
TheWitness
force-pushed
the
fix/mactrack-device-type-detection
branch
from
November 5, 2026 20:15
1d179d8 to
3872c2f
Compare
find_scanning_function() required a device to satisfy both the sysDescr and sysObjectID match before a device type was selected. A device type that supplied only one of the two patterns relied on the empty field being treated as an implicit match, and an empty-on-both device type acted as a catch-all that could claim devices ahead of more specific types. Match only the criteria a device type actually provides: when both patterns are set the device must satisfy both, when only one is set the device only has to satisfy that one, and a device type with neither is skipped instead of matching everything. Wildcard (*) patterns now require every token to be present rather than letting the last token win. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TheWitness
force-pushed
the
fix/mactrack-device-type-detection
branch
from
November 5, 2026 20:18
3872c2f to
03ef364
Compare
|
xmacan
approved these changes
Nov 5, 2026
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
Device type auto-detection failed when a Device Type defined only a
sysDescr match or only a sysObjectID match.
find_scanning_function()required a device to satisfy both criteria, leaning on the empty field being
treated as an implicit match. A Device Type with neither field set behaved as
a catch-all that could claim devices ahead of more specific types, and wildcard
(
*) patterns let the last token decide the result instead of requiring everytoken.
Fix
find_scanning_function()now matches only the criteria a Device Type actuallyprovides:
a device, and no longer steals devices from more specific types).
Matching was extracted into a small, testable helper,
mactrack_snmp_pattern_match(), which also fixes wildcard handling: afoo*barpattern now requires every non-empty token to be present (logical AND)
rather than letting the last token win.
Tests
tests/Unit/FindScanningFunctionTest.phpcovering only-OID, only-sysDescr,both-required, non-matching single criterion, the no-criteria/no-steal case,
wildcard AND semantics, and the empty/plain pattern helper behaviour.