Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens the STUN/TURN implementation by hardening parsing/formatting paths against malformed inputs, aligning behavior with multiple RFC requirements, and adding a comprehensive suite of RFC-derived tests to lock in correct wire encoding/decoding.
Changes:
- Hardened STUN/TURN parsing and attribute stringification with bounds checks and RFC validations (magic cookie, top-bit validation, ChannelData padding).
- Corrected TURN semantics and protocol encodings (e.g., Send as Indication; REQUESTED-TRANSPORT and LIFETIME handling).
- Added extensive unit tests covering STUN/TURN/TURN-TCP/RFC test vectors and option validation.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/types_stun.go | Adds bounds checks and RFC-correct formatting for several attributes; improves ParseError safety; fixes constant typo. |
| internal/types_stun_test.go | Adds regression tests for ParseError and Attribute.String edge cases. |
| internal/stun.go | Changes TransactionID generation and MESSAGE-INTEGRITY placeholder handling during serialization. |
| internal/stun_test.go | Adds tests for GetAttribute/GetErrorString and serialize/parse round-trips (authenticated + unauthenticated). |
| internal/rfc6156_test.go | Adds RFC 6156 coverage for REQUESTED-ADDRESS-FAMILY constants and encoding rules. |
| internal/rfc6062_test.go | Adds RFC 6062 coverage for TURN-TCP method/attribute constants and ConnectionBind flows. |
| internal/rfc5769_test.go | Adds RFC 5769 test vectors for XOR address decoding and MESSAGE-INTEGRITY HMAC. |
| internal/rfc5766_test.go | Adds RFC 5766 tests for SEND indication semantics, REQUESTED-TRANSPORT, CHANNEL-NUMBER, and ChannelData padding. |
| internal/requests_turn.go | Fixes SendRequest message class to Indication per RFC 5766. |
| internal/requests_test.go | Adds tests for request factory functions across STUN/TURN/TURN-TCP. |
| internal/parsers_turn.go | Updates ChannelData parsing to tolerate RFC padding and slice to reported length. |
| internal/parsers_turn_test.go | Adds ExtractChannelData parsing tests including padding acceptance. |
| internal/parsers_stun.go | Adds STUN top-bit + magic-cookie validation and safer attribute parsing bounds checks. |
| internal/parsers_stun_test.go | Adds parseAttributes bounds/regression tests. |
| internal/helpers_turntcp.go | Improves connection cleanup on error paths; validates CONNECTION-ID size. |
| internal/helpers_turn.go | Avoids sharing MagicCookie slice backing array by cloning before appending. |
| internal/helpers_turn_test.go | Adds tests for mapped address parsing and XOR address edge cases. |
| internal/helpers_string_test.go | Adds tests for stringification helpers (methods/classes/attributes). |
| internal/helper/iphelper_test.go | Adds tests for IP iterator and private IP generation helpers. |
| internal/helper/helper.go | Adds RandomBytes helper for crypto-random byte generation. |
| internal/helper/helper_test.go | Adds tests for IsPrintable/RandomString/IsPrivateIP and updates imports. |
| internal/cmd/validate_test.go | Adds tests for CLI option validation across multiple commands. |
| internal/cmd/bruteforce.go | Ensures connection is closed; improves error parsing/logging for Allocate failures. |
| go.mod | Bumps Go language version directive. |
| CLAUDE.md | Adds repository guidance (commands, architecture notes, linting constraints). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/firefart/stunner/sessions/244cecc9-e9eb-4d79-8a2a-1f086f11fd2b Co-authored-by: firefart <105281+firefart@users.noreply.github.com>
Agent-Logs-Url: https://github.com/firefart/stunner/sessions/983372f8-aa56-46a5-9bfe-0c03242e5693 Co-authored-by: firefart <105281+firefart@users.noreply.github.com>
Agent-Logs-Url: https://github.com/firefart/stunner/sessions/983372f8-aa56-46a5-9bfe-0c03242e5693 Co-authored-by: firefart <105281+firefart@users.noreply.github.com>
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.
No description provided.