Detect embedded IPv4 in non-canonical 6to4 addresses#110
Conversation
Greptile SummaryThis PR widens the
Confidence Score: 5/5Safe to merge — the change is a targeted, RFC-correct expansion of a detection predicate with no impact on extraction or packing logic. The only changed logic is the removal of the trailing-zeros guard in isEmbedded(). The extract() and pack() methods are untouched in behaviour. The PR correctly documents the intentional non-round-trip for non-canonical inputs, covers both new branches with dedicated test cases, and updates all relevant data providers. The darsyn/ip-doctrine consumer uses the default Mapped strategy and is unaffected. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[16-byte binary input] --> B{Starts with 0x2002?}
B -- No --> C[isEmbedded: false]
B -- Yes --> D[isEmbedded: true]
D --> E[extract: bytes 2-5 IPv4 address]
D --> F[pack IPv4 to 6to4: 2002 + IPv4 + 10x0x00 canonical form]
E --> G{Was input canonical? bytes 6-15 = 0?}
G -- Yes --> H[pack·extract = identity round-trip preserved]
G -- No --> I[pack·extract to canonical form SLA ID + interface ID zeroed not original address]
style C fill:#f88,stroke:#c00
style D fill:#8f8,stroke:#090
style I fill:#ffa,stroke:#880
Reviews (2): Last reviewed commit: "test(providers): 🚨 add non-canonical de..." | Re-trigger Greptile |
`Derived::isEmbedded()` only matched canonical 6to4 addresses with the trailing 80 bits zeroed, even though every address within `2002::/16` carries an IPv4 address in bits 16-47, as per RFC 3056. Widen detection to the whole 6to4 block; extraction keeps only the embedded IPv4 address, so an extract-pack round-trip reconstructs the canonical form (`2002:XXXX:XXXX::`) rather than the original.
Derived::isEmbedded()only matched canonical 6to4 addresses with the trailing 80 bits zeroed, even though every address within2002::/16carries an IPv4 address in bits 16-47, as per RFC 3056. Widen detection to the whole 6to4 block; extraction keeps only the embedded IPv4 address, so an extract-pack round-trip reconstructs the canonical form (2002:XXXX:XXXX::) rather than the original.