Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

project CI refresh #33

Merged
merged 19 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: cargo
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
groups:
crates-io:
patterns:
- "*"
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
12 changes: 0 additions & 12 deletions .github/workflows/clippy-check.yml

This file was deleted.

95 changes: 47 additions & 48 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
on: [push, pull_request]

name: Continuous integration

on:
push:
pull_request:
merge_group:
schedule:
- cron: '0 18 * * *'

jobs:
check:
name: Check
Expand All @@ -10,80 +15,74 @@ jobs:
matrix:
rust:
- stable
- 1.53.0
- 1.63.0
- nightly
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Cargo update
run: cargo update
- uses: actions-rs/cargo@v1
with:
command: check
- run: RUSTFLAGS="-D warnings" cargo check

test:
name: Test Suite
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test

fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add clippy
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
command: clippy
args: -- -D warnings
components: clippy
- run: cargo clippy -- -D warnings

doc:
name: Build documentation
runs-on: ubuntu-latest
env:
RUSTDOCFLAGS: --cfg docsrs
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo doc --workspace --no-deps --all-features

semver:
name: Check semver compatibility
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2

check-external-types:
name: Validate external types appearing in public API
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
command: doc
args: --workspace --no-deps --all-features
toolchain: nightly-2024-02-07
# ^ 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
15 changes: 15 additions & 0 deletions .github/workflows/security-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Security audit
on:
schedule:
- cron: "0 8 * * *"
push:
paths:
- "**/Cargo.*"
jobs:
security_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: rustsec/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/target/
**/*.rs.bk
Cargo.lock
/.idea
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ authors = ["Pierre Chifflier <[email protected]>"]
readme = "README.md"
categories = ["network-programming", "parser-implementations"]
edition = "2018"
rust-version = "1.63"

include = [
"CHANGELOG.md",
Expand Down Expand Up @@ -50,3 +51,10 @@ hex-literal = "0.4"

[badges]
travis-ci = { repository = "rusticata/pcap-parser" }

[package.metadata.cargo_check_external_types]
allowed_external_types = [
"nom",
"nom::*",
"circular::Buffer",
cpu marked this conversation as resolved.
Show resolved Hide resolved
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Crates.io Version](https://img.shields.io/crates/v/pcap-parser.svg)](https://crates.io/crates/pcap-parser)
[![docs.rs](https://docs.rs/pcap-parser/badge.svg)](https://docs.rs/pcap-parser)
[![Github CI](https://github.com/rusticata/pcap-parser/workflows/Continuous%20integration/badge.svg)](https://github.com/rusticata/pcap-parser/actions)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.53.0+-lightgray.svg)](#rust-version-requirements)
[![Minimum rustc version](https://img.shields.io/badge/rustc-1.63.0+-lightgray.svg)](#rust-version-requirements)

# PCAP and PCAPNG parsers

Expand Down
1 change: 0 additions & 1 deletion src/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::pcap::{LegacyPcapBlock, PcapHeader};
use crate::pcapng::Block;
use std::convert::From;

/// A block from a Pcap or PcapNG file
pub enum PcapBlockOwned<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/capture_pcap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::traits::PcapReaderIterator;
use circular::Buffer;
use nom::combinator::complete;
use nom::multi::many0;
use nom::{self, IResult, Needed, Offset};
use nom::{IResult, Needed, Offset};
use std::fmt;
use std::io::Read;

Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<I> ParseError<I> for PcapError<I> {

impl<I> fmt::Display for PcapError<I>
where
I: std::fmt::Debug,
I: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Expand All @@ -82,4 +82,4 @@ where
}
}

impl<I> std::error::Error for PcapError<I> where I: std::fmt::Debug {}
impl<I> std::error::Error for PcapError<I> where I: fmt::Debug {}
8 changes: 4 additions & 4 deletions src/pcapng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ impl<'a, En: PcapEndianness> PcapNGBlockParser<'a, En, EnhancedPacketBlock<'a>>
let origlen = En::u32_from_bytes(*array_ref4(b_hdr, 16));
// read packet data
// align32 can overflow
if caplen >= ::std::u32::MAX - 4 {
if caplen >= u32::MAX - 4 {
return Err(Err::Error(E::from_error_kind(i, ErrorKind::Verify)));
}
let padded_length = align32!(caplen);
Expand Down Expand Up @@ -817,7 +817,7 @@ impl<'a, En: PcapEndianness> PcapNGBlockParser<'a, En, DecryptionSecretsBlock<'a
let (i, secrets_len) = En::parse_u32(i)?;
// read packet data
// align32 can overflow
if secrets_len >= ::std::u32::MAX - 4 {
if secrets_len >= u32::MAX - 4 {
return Err(Err::Error(E::from_error_kind(i, ErrorKind::Verify)));
}
let padded_length = align32!(secrets_len);
Expand Down Expand Up @@ -1076,7 +1076,7 @@ where
// read generic block layout
//
if i.len() < P::HDR_SZ {
return Err(nom::Err::Incomplete(nom::Needed::new(P::HDR_SZ - i.len())));
return Err(Err::Incomplete(nom::Needed::new(P::HDR_SZ - i.len())));
}
let (i, block_type) = le_u32(i)?;
let (i, block_len1) = En::parse_u32(i)?;
Expand Down Expand Up @@ -1154,7 +1154,7 @@ pub fn parse_sectionheaderblock_be(
/// Parse a SectionHeaderBlock (little or big endian)
pub fn parse_sectionheaderblock(i: &[u8]) -> IResult<&[u8], SectionHeaderBlock, PcapError<&[u8]>> {
if i.len() < 12 {
return Err(nom::Err::Incomplete(nom::Needed::new(12 - i.len())));
return Err(Err::Incomplete(nom::Needed::new(12 - i.len())));
}
let bom = u32::from_le_bytes(*array_ref4(i, 8));
if bom == BOM_MAGIC {
Expand Down
1 change: 0 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::convert::{AsMut, AsRef};
use std::ops;
use std::ops::{Deref, DerefMut};

Expand Down