fix(netstat): correct dead paren check in getProcName - #969
Merged
Conversation
getProcName's second guard checked the already-validated open-paren index instead of the close-paren index. The close-paren-not-found case was only caught indirectly by the later i > j fallback, leaving misleading dead code. Use j < 0 to make the intent explicit, and add table-driven tests covering the previously-untested helper including the no-close-paren edge case.
✅ Deploy Preview for devsydev canceled.
|
✅ Deploy Preview for images-devsy-sh canceled.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
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.
TIP This summary will be updated as you push new changes.
skevetter
marked this pull request as ready for review
August 9, 2026 22:00
skevetter
enabled auto-merge (squash)
August 9, 2026 22:01
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.
Package reviewed
pkg/netstat(in thepkg-tunnel-networkscope:pkg/tunnel,pkg/http,pkg/inject,pkg/netstat,pkg/port).pkg/tunnelwas skipped because PR #646 already touches that area.Issue found
getProcNameinpkg/netstat/netstat_util.gohad dead/misleading bounds-checking code. After locating the opening paren((indexi, already validatedi >= 0), it then located the closing paren)(indexj) viabytes.LastIndex, but the follow-up guard re-checkedif i < 0instead ofif j < 0:The "no closing paren" case was only caught indirectly by the later
i > jfallback (wherej == -1), leaving the explicit guard as misleading dead code that obscured the real intent.Change
pkg/netstat/netstat_util.go: corrected the guard fromif i < 0toif j < 0, so the missing-close-paren case is checked explicitly and the dead check on the already-validatediis removed. No behavioral change — the fallback already returned""for the same inputs; this makes the intent obvious and removes dead code.pkg/netstat/netstat_util_test.go: added a table-drivenTestGetProcNamecovering the previously-untested helper, including theno closing parenandreversed parensedge cases.Verification performed
mkdir -p distgit fetch --quiet origin maintask cli:format— clean (no formatting issues)task cli:lint:ci— 0 new issuestask cli:test— passes; the only failures are the documented pre-existingpkg/gitTestRepoClone*tests (stale assertion onorigin/main, unrelated to this change which touches onlypkg/netstat)go test ./pkg/netstat/...—ok, allTestGetProcNamesubtests pass (name in parens, no opening paren, no closing paren, reversed parens, empty name, name with parens inside)task cli:build:grpcwas not required.Expected effect
Removes a dead-code footgun in a parsing helper and adds the first unit tests for it, guarding the no-close-paren edge case against future regressions.
This PR was created by an AI agent as part of an automated daily package review job.