From 22cf762fca345c394ee6ca6c43c767191d48414a Mon Sep 17 00:00:00 2001 From: Alec Posney Date: Tue, 7 May 2024 08:05:43 +1000 Subject: [PATCH 1/3] Replace Circular with Oval Oval is a drop in replacement for ciruclar useful fixes merged. Specificall it removes all occurences of unsound and unsafe behavior, and so will allow for Miri testing. --- Cargo.toml | 4 ++-- src/capture.rs | 2 +- src/pcap/reader.rs | 2 +- src/pcapng/reader.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c1d10aa..70e76e2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,7 +41,7 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -circular = "0.3" +oval = "2.0" cookie-factory = { version="0.3.0", optional=true } nom = "7.0" rusticata-macros = "4.0" @@ -53,5 +53,5 @@ hex-literal = "0.4" allowed_external_types = [ "nom", "nom::*", - "circular::Buffer", + "oval::Buffer", ] diff --git a/src/capture.rs b/src/capture.rs index 55ed6ed..dc16d91 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -5,7 +5,7 @@ use crate::pcap::parse_pcap_header; use crate::pcapng::parse_sectionheaderblock; use crate::traits::PcapReaderIterator; use crate::{LegacyPcapReader, PcapNGReader}; -use circular::Buffer; +use oval::Buffer; use nom::Needed; use std::io::Read; diff --git a/src/pcap/reader.rs b/src/pcap/reader.rs index 02997a3..e8c46c5 100644 --- a/src/pcap/reader.rs +++ b/src/pcap/reader.rs @@ -5,7 +5,7 @@ use crate::pcap::{ LegacyPcapBlock, PcapHeader, }; use crate::traits::PcapReaderIterator; -use circular::Buffer; +use oval::Buffer; use nom::{IResult, Needed, Offset}; use std::io::Read; diff --git a/src/pcapng/reader.rs b/src/pcapng/reader.rs index ff13a6a..af96ee2 100644 --- a/src/pcapng/reader.rs +++ b/src/pcapng/reader.rs @@ -2,7 +2,7 @@ use crate::blocks::PcapBlockOwned; use crate::error::PcapError; use crate::pcapng::*; use crate::traits::PcapReaderIterator; -use circular::Buffer; +use oval::Buffer; use nom::{Needed, Offset}; use std::io::Read; From 2b09985fde7b82efe9fb6595b273409c6d94c362 Mon Sep 17 00:00:00 2001 From: Alec Posney Date: Tue, 7 May 2024 08:07:22 +1000 Subject: [PATCH 2/3] Add Miri tests to CI Miri is the unsound/undefined behavior checker for unsafe Rust. --- .github/workflows/rust.yml | 13 +++++++++++++ src/capture.rs | 2 +- src/pcap/reader.rs | 2 +- src/pcapng/reader.rs | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fb51eda..d062c21 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -63,6 +63,19 @@ jobs: - run: cargo clippy --all-features -- -D warnings - run: cargo clippy --no-default-features -- -D warnings + miri: + name: Miri + runs-on: ubuntu-latest + env: + # Needed since the tests interact with the filesystem + MIRIFLAGS: "-Zmiri-disable-isolation" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@nightly + with: + components: miri + - run: cargo miri test --all-features + doc: name: Build documentation runs-on: ubuntu-latest diff --git a/src/capture.rs b/src/capture.rs index dc16d91..5c7aee0 100644 --- a/src/capture.rs +++ b/src/capture.rs @@ -5,8 +5,8 @@ use crate::pcap::parse_pcap_header; use crate::pcapng::parse_sectionheaderblock; use crate::traits::PcapReaderIterator; use crate::{LegacyPcapReader, PcapNGReader}; -use oval::Buffer; use nom::Needed; +use oval::Buffer; use std::io::Read; /// Generic interface for PCAP or PCAPNG file access diff --git a/src/pcap/reader.rs b/src/pcap/reader.rs index e8c46c5..a781699 100644 --- a/src/pcap/reader.rs +++ b/src/pcap/reader.rs @@ -5,8 +5,8 @@ use crate::pcap::{ LegacyPcapBlock, PcapHeader, }; use crate::traits::PcapReaderIterator; -use oval::Buffer; use nom::{IResult, Needed, Offset}; +use oval::Buffer; use std::io::Read; /// Parsing iterator over legacy pcap data (streaming version) diff --git a/src/pcapng/reader.rs b/src/pcapng/reader.rs index af96ee2..c2d1be8 100644 --- a/src/pcapng/reader.rs +++ b/src/pcapng/reader.rs @@ -2,8 +2,8 @@ use crate::blocks::PcapBlockOwned; use crate::error::PcapError; use crate::pcapng::*; use crate::traits::PcapReaderIterator; -use oval::Buffer; use nom::{Needed, Offset}; +use oval::Buffer; use std::io::Read; /// Parsing iterator over pcap-ng data (streaming version) From f4d2ef4ee90cbd163a2b88407a447ebbafd88b15 Mon Sep 17 00:00:00 2001 From: Alec Posney Date: Thu, 30 May 2024 07:21:40 +1000 Subject: [PATCH 3/3] Bump nightly ci version to match cargo-check-external-types upstream --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d062c21..efa7272 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -104,7 +104,7 @@ jobs: - name: Install rust toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: nightly-2024-02-07 + toolchain: nightly-2024-05-01 # ^ sync with https://github.com/awslabs/cargo-check-external-types/blob/main/rust-toolchain.toml - run: cargo install cargo-check-external-types - run: cargo check-external-types