From cf14cef1fa75b85825a04a4bf0402c46d0e2a29e Mon Sep 17 00:00:00 2001 From: LinkTed Date: Mon, 7 Oct 2024 17:35:13 +0200 Subject: [PATCH 1/7] Updated dependencies - base64 "~0.13.0" to "0.22" - bitflags "~1.2.1" to "2" - thiserror "~1.0.23" to "1" - trust-dns-resolver "~0.20.0" to "0.20" --- Cargo.toml | 8 ++++---- src/decode.rs | 4 ++-- src/encode.rs | 8 ++++---- src/lib.rs | 2 +- tests/parse.rs | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f15332f..29b5a7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,10 +11,10 @@ keywords = ["doh", "dns", "stamps", "dnscrypt"] categories = ["parser-implementations", "encoding"] [dependencies] -base64 = "~0.13.0" -bitflags = "~1.2.1" -thiserror = "~1.0.23" -trust-dns-resolver = { version = "~0.20.0", optional = true } +base64 = "0.22" +bitflags = "2" +thiserror = "1" +trust-dns-resolver = { version = "0.20", optional = true } [features] default = [] diff --git a/src/decode.rs b/src/decode.rs index 8315ecf..e651b0a 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -3,7 +3,7 @@ use crate::{ Addr, AnonymizedDnsCryptRelay, DecodeError, DecodeResult, DnsCrypt, DnsOverHttps, DnsOverTls, DnsPlain, DnsStamp, DnsStampType, ObliviousDoHTarget, Props, }; -use base64::{decode_config, URL_SAFE_NO_PAD}; +use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine}; use std::{ convert::{TryFrom, TryInto}, mem::size_of, @@ -213,7 +213,7 @@ fn decode_props(buf: &[u8], offset: &mut usize) -> DecodeResult { /// Decode a Base64 encoded `&str` with a prefix `"sdns://"` to `std::vec::Vec`. fn decode_base64(stamp: &str) -> DecodeResult> { if let Some(base64) = stamp.strip_prefix("sdns://") { - Ok(decode_config(base64, URL_SAFE_NO_PAD)?) + Ok(BASE64_URL_SAFE_NO_PAD.decode(base64)?) } else { Err(DecodeError::InvalidInput { cause: "sdns:// prefix not present".to_string(), diff --git a/src/encode.rs b/src/encode.rs index 6480f2f..d9ae62f 100644 --- a/src/encode.rs +++ b/src/encode.rs @@ -3,7 +3,7 @@ use crate::{ Addr, AnonymizedDnsCryptRelay, DnsCrypt, DnsOverHttps, DnsOverTls, DnsPlain, DnsStamp, DnsStampType, EncodeError, EncodeResult, ObliviousDoHTarget, Props, }; -use base64::{encode_config, URL_SAFE_NO_PAD}; +use base64::{prelude::BASE64_URL_SAFE_NO_PAD, Engine}; use std::net::{IpAddr, SocketAddr}; /// Encode a `crate::DnsStampType` into a `std::vec::Vec`. @@ -21,7 +21,7 @@ fn encode_props(buffer: &mut Vec, props: &Props) { fn encode_bytes(buffer: &mut Vec, bytes: impl AsRef<[u8]>) -> EncodeResult<()> { let bytes = bytes.as_ref(); let len = bytes.len(); - if len <= std::u8::MAX as usize { + if len <= u8::MAX as usize { buffer.push(len as u8); buffer.extend(bytes); Ok(()) @@ -115,7 +115,7 @@ fn encode_pk(buffer: &mut Vec, pk: &[u8; 32]) -> EncodeResult<()> { /// [`VLP()`]: https://dnscrypt.info/stamps-specifications#common-definitions fn encode_vlp>(buffer: &mut Vec, vlp: &[T]) -> EncodeResult<()> { if vlp.is_empty() { - encode_bytes(buffer, &[]) + encode_bytes(buffer, []) } else { let len = vlp.len(); if let Some(array) = vlp.get(..(len - 1)) { @@ -157,7 +157,7 @@ fn encode_bootstrap_ipi(buffer: &mut Vec, bootstrap_ipi: &[IpAddr]) -> Encod /// Encode `[u8]` slice with Base64 and prepand `"sdns://"`. fn encode_base64(buffer: &[u8]) -> String { - format!("sdns://{}", encode_config(buffer, URL_SAFE_NO_PAD)) + format!("sdns://{}", BASE64_URL_SAFE_NO_PAD.encode(buffer)) } /// Encode a `crate::DnsPlain` into a `std::vec::Vec` as `crate::DnsStampType::Plain`. diff --git a/src/lib.rs b/src/lib.rs index ef9dd23..81dd0d0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,6 @@ non_upper_case_globals )] #![allow(clippy::cognitive_complexity)] -#![deny(broken_intra_doc_links)] #![doc(test( no_crate_inject, attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) @@ -31,6 +30,7 @@ bitflags! { /// Represent the [`props`]. /// /// [`props`]: https://dnscrypt.info/stamps-specifications#dnscrypt-stamps + #[derive(Debug, Clone, PartialEq, Eq)] pub struct Props: u64 { /// If this flag is present then the server supports [DNSSEC]. /// diff --git a/tests/parse.rs b/tests/parse.rs index 029b3de..d0ddbb7 100644 --- a/tests/parse.rs +++ b/tests/parse.rs @@ -23,7 +23,7 @@ fn parse_fail_three() { let stamp = "sdns://A"; assert_eq!( stamp.parse::(), - Err(DecodeError::Base64Error(Base64Error::InvalidLength)) + Err(DecodeError::Base64Error(Base64Error::InvalidLength(1))) ) } From a436ffff29c9f6710e11cbf9afe47055863c7855 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:20:32 +0200 Subject: [PATCH 2/7] CI: Update actions/checkout to 4 --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f951965..19cef4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: with: toolchain: stable components: rustfmt - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Run rustfmt run: cargo fmt --all -- --check @@ -27,7 +27,7 @@ jobs: name: Job audit runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Run audit uses: actions-rs/audit-check@v1 with: @@ -43,7 +43,7 @@ jobs: with: toolchain: stable components: clippy - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Run clippy uses: actions-rs/clippy-check@v1 with: @@ -64,7 +64,7 @@ jobs: uses: actions-rs/toolchain@v1 with: toolchain: ${{ matrix.rust_channel }} - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Run cargo test uses: actions-rs/cargo@v1 with: @@ -81,7 +81,7 @@ jobs: with: toolchain: nightly override: true - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Download and unpack grcov run: curl -L "$URL" | tar jxf - env: From 5e080bc36f212170e492a150e0e8087aca7b4b05 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:23:53 +0200 Subject: [PATCH 3/7] CI: Replace actions-rs with dtolnay The actions-rs/toolchain is not maintained. --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19cef4c..40a3d14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,9 +15,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Install toolchain with rustfmt - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable components: rustfmt - uses: actions/checkout@v4 - name: Run rustfmt @@ -39,9 +38,8 @@ jobs: runs-on: ubuntu-latest steps: - name: Install toolchain with clippy - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: stable components: clippy - uses: actions/checkout@v4 - name: Run clippy @@ -61,7 +59,7 @@ jobs: runs-on: ${{ matrix.os }} steps: - name: Install toolchain ${{ matrix.rust_channel }} on ${{ matrix.os }} - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust_channel }} - uses: actions/checkout@v4 From adbd0ab76e19a6fc47a36994d749927020cd5997 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:25:07 +0200 Subject: [PATCH 4/7] CI: Remove Job audit --- .github/workflows/ci.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 40a3d14..15438ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,16 +22,6 @@ jobs: - name: Run rustfmt run: cargo fmt --all -- --check - audit: - name: Job audit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Run audit - uses: actions-rs/audit-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - clippy: name: Job clippy needs: rustfmt From b51926f7e7224d3190ecbb81fef32ff665fcd3f2 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:26:50 +0200 Subject: [PATCH 5/7] CI: Replace actions-rs with giraffate The actions-rs/clippy-check is not maintained. --- .github/workflows/ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15438ce..6e1a804 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,10 +33,11 @@ jobs: components: clippy - uses: actions/checkout@v4 - name: Run clippy - uses: actions-rs/clippy-check@v1 + uses: giraffate/clippy-action@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --all-features ---all-targets -- --deny warnings -A clippy::unknown-clippy-lints + reporter: 'github-pr-check' + github_token: ${{ secrets.GITHUB_TOKEN }} + clippy_flags: --deny warnings -A clippy::unknown-clippy-lints tests: name: Job tests From b862ba7d294edc6da5bb53b03f9c6bea3b05b1a9 Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:28:20 +0200 Subject: [PATCH 6/7] CI: Update Job code coverage --- .github/workflows/ci.yml | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6e1a804..16ed836 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,27 +66,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Intall toolchain nightly on ubuntu-latest - uses: actions-rs/toolchain@v1 + uses: dtolnay/rust-toolchain@stable with: - toolchain: nightly - override: true + components: llvm-tools-preview - uses: actions/checkout@v4 - - name: Download and unpack grcov - run: curl -L "$URL" | tar jxf - - env: - URL: '/~https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2' - - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test - args: --all-features - env: - CARGO_INCREMENTAL: '0' - RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Cinline-threshold=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests' - - name: Convert gcno and gcda files into lcov - run: ./grcov --llvm target/debug -s . -t lcov -o lcov.info --ignore-not-existing --ignore "tests/*" --ignore "examples/*" --ignore "/*" --excl-line "^ *#\[" - - name: Upload coverage - uses: codecov/codecov-action@v1 + - name: cargo install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: cargo llvm-cov + run: cargo llvm-cov --all-features --lcov --output-path lcov.info + - name: Upload to codecov.io + uses: codecov/codecov-action@v4 with: - file: lcov.info + token: ${{ secrets.CODECOV_TOKEN }} + env_vars: OS,RUST From 080f2ac0a77f4c24ece4adae6a32f072ea7b815d Mon Sep 17 00:00:00 2001 From: LinkTed Date: Tue, 15 Oct 2024 18:31:34 +0200 Subject: [PATCH 7/7] CI: Replace actions-rs with run The actions-rs/cargo is not maintained. --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16ed836..3b7debb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,10 +55,7 @@ jobs: toolchain: ${{ matrix.rust_channel }} - uses: actions/checkout@v4 - name: Run cargo test - uses: actions-rs/cargo@v1 - with: - command: test - args: --no-default-features --features "${{ matrix.features }}" + run: cargo test --no-default-features --features "${{ matrix.features }}" code-coverage: name: Job code coverage