Skip to content

Fix MAC encoding, port range, data race, and ZMQ message ID bugs - #168

Merged
synfinatic merged 8 commits into
mainfrom
bug-fixes
Jun 22, 2026
Merged

Fix MAC encoding, port range, data race, and ZMQ message ID bugs#168
synfinatic merged 8 commits into
mainfrom
bug-fixes

Conversation

@synfinatic

Copy link
Copy Markdown
Owner
  • MAC addresses were encoded with PutUvarint (LEB128) instead of BigEndian, corrupting every MAC field for real hardware addresses
  • Port parsing used bitSize=16, silently rejecting ports 32768-65535
  • health check handler read collecting bool from an HTTP goroutine while main wrote it without synchronization; switched to atomic.Bool
  • jcompress format fell through to json case and logged a misleading second "Using ntopng JSON format" line; guarded with if !compress
  • ZMQ messageId started at 0, so the "Sending first ZMQ message" log fired on the second send; initialized to 1 to match the == 1 check
  • ZMQ wrap-around reset was in an else-if chain and could be skipped; made it an independent if statement

dependabot Bot added 4 commits June 19, 2026 19:59
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 5 to 6.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Commits](docker/metadata-action@v5...v6)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v6...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@v3...v4)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5 to 7.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](codecov/codecov-action@v5...v7)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.95023% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.42%. Comparing base (111d41d) to head (414e3c9).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
cmd/netflow2ng.go 80.52% 13 Missing and 2 partials ⚠️
transport/zmq.go 70.59% 2 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##            main     #168       +/-   ##
==========================================
+ Coverage   0.00%   72.42%   +72.42%     
==========================================
  Files          7        7               
  Lines        668      689       +21     
==========================================
+ Hits           0      499      +499     
+ Misses       668      161      -507     
- Partials       0       29       +29     
Files with missing lines Coverage Δ
formatter/formatter.go 94.44% <100.00%> (+94.44%) ⬆️
formatter/ntopng_json.go 96.97% <100.00%> (+96.97%) ⬆️
formatter/ntopng_tlv.go 91.19% <100.00%> (+91.19%) ⬆️
transport/transport.go 100.00% <100.00%> (+100.00%) ⬆️
transport/zmq.go 68.60% <70.59%> (+68.60%) ⬆️
cmd/netflow2ng.go 37.80% <80.52%> (+37.80%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 111d41d...414e3c9. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

synfinatic and others added 2 commits June 19, 2026 20:10
- MAC addresses were encoded with PutUvarint (LEB128) instead of
  BigEndian, corrupting every MAC field for real hardware addresses
- Port parsing used bitSize=16, silently rejecting ports 32768-65535
- health check handler read collecting bool from an HTTP goroutine while
  main wrote it without synchronization; switched to atomic.Bool
- jcompress format fell through to json case and logged a misleading
  second "Using ntopng JSON format" line; guarded with if !compress
- ZMQ messageId started at 0, so the "Sending first ZMQ message" log
  fired on the second send; initialized to 1 to match the == 1 check
- ZMQ wrap-around reset was in an else-if chain and could be skipped;
  made it an independent if statement

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- MAC encoding: TestExtractFlowData_MAC + _HighBits test BigEndian
  encoding in extractFlowData; TestNtopngJson_toJSON_MAC checks both
  src and dst; TestNtopngTlv_toTLV_MAC verifies string output in TLV
- Port range: TestAddress_Value_HighPorts confirms ports 32768–65535
  are now accepted (were rejected with bitSize=16); _OutOfRangePorts
  checks bounds enforcement at 0 and 65536
- jcompress double-log: TestSelectFormat_JCompress_SingleLog verifies
  exactly one log line is emitted and it's the compressed-format message
- atomic.Bool health handler: existing TestNewHealthHandler_* tests
  already exercise the atomic.Bool path added for the data race fix
- ZMQ messageId: existing TestZmqDriver_Send_MessageIdLogging and
  TestZmqDriver_Send_MsgIdWrap integration tests cover the off-by-one
  initialization and wrap-around fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- recover() return discarded with _ = recover() in both formatters
- w.Close() and io.Copy() in cmd tests now checked for errors
- defer r.Close() and defer sub.Close() wrapped in func() { _ = ... }()
- sub.Connect, sub.SetSubscribe, d.Init, sub.SetRcvtimeo calls in zmq
  integration tests now checked with t.Fatalf on error
- sub.RecvBytes(0) header-skip uses _, _ = to silence errcheck

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@synfinatic
synfinatic merged commit 8f19d42 into main Jun 22, 2026
6 checks passed
@synfinatic
synfinatic deleted the bug-fixes branch June 22, 2026 16:18
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.

1 participant