Skip to content

fix(oui): keep vendors on partial downloads and keep the proxy with a login - #434

Merged
TheWitness merged 3 commits into
developfrom
fix/mactrack-oui-fallback-and-proxy
Nov 13, 2026
Merged

TheWitness merged 3 commits into
developfrom
fix/mactrack-oui-fallback-and-proxy

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes five defects in the OUI vendor database import (import_oui_database()):

  • Partial fallback list. The IEEE REST fallback (services13.ieee.org/...registry=MA-L&format=txt) returns at most 10,000 of the roughly 40,500 MA-L assignments. When the primary oui.txt download failed, the import still marked every vendor absent and then deleted the ones that list did not contain, so about three quarters of the vendors were removed. Vendors are now retired only when the full list was downloaded. A fallback import adds and refreshes entries and logs a NOTE.
  • Nearly empty list. A full download that parses to fewer than 1,000 records, such as an HTML error page served with a 200 status, no longer empties the table. Existing vendors are kept and a WARNING is logged.
  • Proxy login. When a proxy user was set, the stream options were replaced with only the Proxy-Authorization header. The download then bypassed the proxy and sent the proxy login to the IEEE host. The header is now added to the proxy options. The download uses its own stream context instead of changing the process-wide default, and each attempt is limited to 30 seconds.
  • Web import batching. Batched writes only ran for the CLI caller, so the import from Utilities sent every record in one REPLACE statement. The listing is now parsed first by mactrack_parse_oui_database() and written in batches of 1,000 for every caller.
  • Failed batch. If any REPLACE batch fails, for example because it exceeds max_allowed_packet, the import no longer deletes the vendors still marked absent, which would have included every vendor that batch was meant to refresh. It marks them present again and logs a WARNING.

mactrack_download_oui_database() gains two optional parameters (the URL that returned the data, and a stream context), and import_oui_database() gains an optional fallback URL so tests can use local fixtures. Existing callers are unchanged.

How Has This Been Tested?

  • New unit tests cover the fallback, nearly empty and full-list cases, web batching, a failed batch, the parser, and the proxy and timeout options. Five of them fail on the previous code.
  • Full plugin suite: 377 passed.
  • Run against the live IEEE oui.txt (40,495 records), the extracted parser returns exactly the same records as the previous inline loop. The fallback URL returned exactly 10,000 records.
  • php -l on PHP 8.1. php-cs-fixer reports no new findings in the changed code.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

… login

The IEEE REST fallback returns at most 10000 of about 40500 assignments,
but the import still marked every vendor absent and then deleted the ones
the list did not contain. Retire vendors only when the full list was
downloaded and it parsed to at least 1000 records, so an HTML error page
served with a 200 status no longer empties the table either.

Setting a proxy user replaced the whole stream context with only the
Proxy-Authorization header, so the download skipped the proxy and sent the
proxy login to the IEEE. Add the header to the proxy options instead, use
a context for this download rather than the process-wide default, and
bound each attempt to 30 seconds.

The web import only flushed batches for the CLI caller, so it sent every
record in one statement. Parse the listing first, then write in batches
of 1000 for every caller.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
A failed REPLACE batch leaves the vendors it was meant to refresh marked
absent, and the import then deleted every absent vendor. Skip the delete
when any batch fails, mark the vendors present again, and log a warning.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@sonarqubecloud

Copy link
Copy Markdown

@TheWitness
TheWitness merged commit 8c667e6 into develop Nov 13, 2026
9 checks passed
@TheWitness
TheWitness deleted the fix/mactrack-oui-fallback-and-proxy branch November 13, 2026 20:57
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.

2 participants