Skip to content

fix: restore correct ScanResultRkyv with manual IpAddr serialization#22

Merged
doublegate merged 3 commits intodependabot/cargo/cargo-920260e05efrom
copilot/sub-pr-18
Jan 25, 2026
Merged

fix: restore correct ScanResultRkyv with manual IpAddr serialization#22
doublegate merged 3 commits intodependabot/cargo/cargo-920260e05efrom
copilot/sub-pr-18

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

PR #21's rkyv migration was incompletely merged, leaving two conflicting ScanResultRkyv definitions that broke compilation and CodeQL analysis. Initial fix removed the wrong duplicate - this PR corrects that mistake.

Changes

  • Restored correct struct definition (with manual serialization, crates/prtip-core/src/types.rs)

    • Kept manual byte serialization version with target_ip_bytes: [u8; 16] and is_ipv4: bool
    • Removed incorrect simple definition that used IpAddr directly
    • Critical: std::net::IpAddr does not implement rkyv's Archive, Serialize, and Deserialize traits
  • Fixed broken deserialization code (crates/prtip-scanner/src/output/mmap_reader.rs)

    • Consolidated duplicate length-prefix reading logic
    • Removed references to non-existent entry_bytes variable
  • Fixed dead link (docs/archive/19-PHASE4-ENHANCEMENTS.md)

    • Changed findsec.org URL (522 error) to plain text reference

Context

The correct implementation requires manual serialization because std::net::IpAddr lacks rkyv trait implementations:

// Correct implementation (restored) - works with rkyv
#[derive(Debug, Clone, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
pub struct ScanResultRkyv {
    pub target_ip_bytes: [u8; 16],  // Manual byte serialization
    pub is_ipv4: bool,               // IPv4 vs IPv6 flag
    pub state: u8,                   // PortState as u8
    // ...
}

// Incorrect version (removed) - would fail at runtime
pub struct ScanResultRkyv {
    target_ip: IpAddr,  // IpAddr doesn't implement rkyv traits
    state: PortState,   // Works, has rkyv derives
    // ...
}

The manual serialization converts IpAddr to/from byte arrays and PortState to/from u8 in the From trait implementations, enabling rkyv's zero-copy deserialization in the memory-mapped file writer/reader.

Net: +80 lines (correct implementation), resolves compilation errors and prevents runtime serialization failures.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: doublegate <6858123+doublegate@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 25, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-732d160ed1dd70ab /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-732d160ed1dd70ab types -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 be.rkyv_derive.929b5e70dd7679a2-cgu.00.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.01.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.02.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.03.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.04.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.05.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.06.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.07.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.08.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.09.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.10.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.11.rcgu.o (dns block)
    • Triggering command: /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-6bd51893e4d4a9ca /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-6bd51893e4d4a9ca --emit=dep-info,metadata,link -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 --warn=unused-results --warn=unsafe-op-in-unsafe-fn --warn=unreachable-pub --warn=clippy::undocumented-unsafe-blocks /out�� /out/lib/2f6359150364eb0d-ldblib.o /out/lib/2f6359150364eb0d-lfunc.o u/13/cc1 --gdwarf-4 artifacts,future--crate-name 53546ebb541105d4no_std_compat 53546ebb541105d4--edition=2018 (dns block)
  • nonexistent.invalid.hostname.example
    • Triggering command: /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-732d160ed1dd70ab /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-732d160ed1dd70ab types -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 be.rkyv_derive.929b5e70dd7679a2-cgu.00.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.01.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.02.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.03.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.04.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.05.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.06.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.07.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.08.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.09.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.10.rcgu.o be.rkyv_derive.929b5e70dd7679a2-cgu.11.rcgu.o (dns block)
    • Triggering command: /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-6bd51893e4d4a9ca /home/REDACTED/work/ProRT-IP/ProRT-IP/target/debug/deps/prtip_core-6bd51893e4d4a9ca --emit=dep-info,metadata,link -C opt-level=1 -C embed-bitcode=no -C debuginfo=2 --warn=unused-results --warn=unsafe-op-in-unsafe-fn --warn=unreachable-pub --warn=clippy::undocumented-unsafe-blocks /out�� /out/lib/2f6359150364eb0d-ldblib.o /out/lib/2f6359150364eb0d-lfunc.o u/13/cc1 --gdwarf-4 artifacts,future--crate-name 53546ebb541105d4no_std_compat 53546ebb541105d4--edition=2018 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Chore: Bump cargo group for rsa to 0.9.10 fix: remove duplicate ScanResultRkyv definition causing compilation failures Jan 25, 2026
Copilot AI requested a review from doublegate January 25, 2026 03:30
Copy link
Owner

@doublegate doublegate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed / Approved - changes to support PR #18 closeout -- DG 1/24

@doublegate doublegate marked this pull request as ready for review January 25, 2026 04:48
Copilot AI review requested due to automatic review settings January 25, 2026 04:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request attempts to fix compilation failures caused by duplicate ScanResultRkyv definitions left from an incomplete merge of PR #21's rkyv migration. The PR removes 128 lines of code including one complete struct definition and its conversion implementations, consolidates duplicate deserialization logic in the mmap reader, and fixes a broken documentation link.

Changes:

  • Removed duplicate ScanResultRkyv struct definition (122 lines) with manual byte serialization for IP addresses
  • Fixed duplicate length-prefix reading logic and removed references to non-existent entry_bytes variable in mmap_reader.rs
  • Changed a broken documentation URL to plain text reference

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/prtip-core/src/types.rs Removed duplicate ScanResultRkyv definition with manual IP serialization; reformatted PortState enum derives
crates/prtip-scanner/src/output/mmap_reader.rs Consolidated duplicate length-prefix reading, fixed entry_bytes reference issue
docs/archive/19-PHASE4-ENHANCEMENTS.md Fixed broken findsec.org URL reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: doublegate <6858123+doublegate@users.noreply.github.com>
Copilot AI changed the title fix: remove duplicate ScanResultRkyv definition causing compilation failures fix: restore correct ScanResultRkyv with manual IpAddr serialization Jan 25, 2026
Copilot AI requested a review from doublegate January 25, 2026 05:01
Copy link
Owner

@doublegate doublegate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed / Approved - corrected version with manual byte serialization (target_ip_bytes: [u8; 16] + is_ipv4: bool) -- DG 1/25

Copy link
Owner

@doublegate doublegate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved (No Changes) - PR was reading from older variant of code-base, ready to proceed -- DG 1/25

@doublegate doublegate merged commit 5d48440 into dependabot/cargo/cargo-920260e05e Jan 25, 2026
37 checks passed
@doublegate doublegate deleted the copilot/sub-pr-18 branch January 25, 2026 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants