Linux環境における netstat -an 出力形式に対応したポート検出正規表現を追加#43
Merged
harakeishi merged 2 commits intoharakeishi:mainfrom Mar 2, 2026
Merged
Conversation
OS別パーサ選択を追加し、netstatテスト拡張とREADMEのプラットフォーム検証状況を追記
exit_codeだけの検証では本来落ちるべきLinux環境の失敗を検知できなかったため、Port Conflicts出力を明示検証しcleanupもtrapで安定化
Owner
|
@all-contributors please add @aaaaninja for code |
Contributor
|
I've put up a pull request to add @aaaaninja! 🎉 |
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.
概要
Linux/WSL2環境の
netstat -an出力形式(0.0.0.0:11211,:::11211)を正しく解釈できず、システムポート衝突を見逃す問題を修正しました。あわせて、CLI E2Eの検証を
exit_code == 0のみから、衝突表示の実アサート付きに強化し、Linuxで本来検知すべき不具合を見逃しにくくしました。変更内容
internal/scanner/netstat.gohost:port)と BSD/macOS形式(host.port)を明確に分離internal/scanner/netstat_test.goREADME.mdmacOS / Linux: Tested,Windows: Not testedを明記testdata/gopose/gopose_e2e_test.ymlexit_codeだけでなく、Port Conflicts:などの出力内容をアサートtrapによるクリーンアップで後始末を安定化期待すること
exit code 0だけでは拾えない回帰(衝突表示欠落)を検知できること動作確認
go test ./internal/scanner -run TestParseNetstatOutput -vgo test ./...補足
本PRでは正規表現方針を維持したまま最小差分でLinux対応しています。
Windowsは現時点で未検証のため、READMEに明記しています。
最小の変更で済むようにruntime.GOOSを使うようにしましたが、依存を外したいなら将来的にはnetstatを直接使うのではなく必要ポートだけを直接チェックするのもありだと思います。