Skip to content

test(netstat): cover parseAddr edge cases - #1045

Merged
skevetter merged 2 commits into
mainfrom
pkg-tunnel-network/netstat-parseaddr-tests
Aug 18, 2026
Merged

skevetter merged 2 commits into
mainfrom
pkg-tunnel-network/netstat-parseaddr-tests

Conversation

@devsy-app

@devsy-app devsy-app Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Package reviewed

pkg/netstat (tunneling/networking category)

Issue found

parseAddr — the lower-level socket-address parser that splits /proc/net/tcp* IP:port hex fields into a SockAddr — was only exercised indirectly through the full doNetstat path. That path couples parsing with file I/O and /proc process-info extraction, so the parser's own edge cases (port-conflict parsing: missing port, malformed IP length, invalid hex) had no focused regression coverage. A regression in parseAddr (e.g. a change to the field-split or length switch) would only surface as a broad doNetstat failure rather than a precise, localized test failure.

Change

Add TestParseAddr table tests to pkg/netstat/netstat_util_test.go covering:

  • IPv4 loopback (0100007F:0050 → 127.0.0.1:80)
  • IPv6 any (0000...0000:0016 → :::22)
  • Missing port (single field, no :) → error
  • Bad IP length (ZZ:0050) → error
  • Invalid IPv4 hex (0100007G:0050) → error
  • Invalid port hex (0100007F:zzzz) → error

Pure test addition — no behavioral or production code changes.

Verification

  • task cli:format — clean.
  • task cli:lint:ci — 0 issues.
  • task cli:test — passes. The only failing suite is pkg/git (TestRepoCloneArgsThroughRunner, TestRepoCloneFromInfoBranch, TestRepoCloneFromInfoHelper), the documented known pre-existing failure on origin/main; this change does not touch pkg/git.
  • No gRPC/proto files changed; task cli:build:grpc not required.

This PR was created by an AI agent as part of an automated daily package review job.

Add table tests for parseAddr covering IPv4/IPv6 parsing and edge cases (missing port, bad IP length, invalid hex). The lower-level parser was only exercised indirectly through the full doNetstat file/proc path, leaving port-conflict edge cases without focused regression coverage.
@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit e7bafa3
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a82a2595582e30008d6b9a8

@netlify

netlify Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit e7bafa3
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a82a25974e9be0008585873

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 0 duplication

Metric Results
Complexity 5
Duplication 0

View in Codacy

AI Reviewer: run a review on demand. To trigger the first review automatically, go to your organization or repository integration settings. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@skevetter
skevetter marked this pull request as ready for review August 18, 2026 00:12
@skevetter
skevetter merged commit f934a7a into main Aug 18, 2026
76 checks passed
@skevetter
skevetter deleted the pkg-tunnel-network/netstat-parseaddr-tests branch August 18, 2026 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant