commit 86f35c132bdd2ea196f2245f031c55bdeefb8bee
parent c81379221edd2af4ddbf910c1b3970fd1bae50ce
Author: Zack Newman <zack@philomathiclife.com>
Date: Mon, 19 May 2025 15:00:52 -0600
update deps
Diffstat:
5 files changed, 67 insertions(+), 117 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
@@ -9,22 +9,63 @@ license = "MIT OR Apache-2.0"
name = "rpz"
readme = "README.md"
repository = "https://git.philomathiclife.com/repos/rpz/"
-version = "1.2.0"
+version = "1.3.0"
+
+[lints.rust]
+unknown_lints = { level = "deny", priority = -1 }
+future_incompatible = { level = "deny", priority = -1 }
+let_underscore = { level = "deny", priority = -1 }
+missing_docs = { level = "deny", priority = -1 }
+nonstandard_style = { level = "deny", priority = -1 }
+refining_impl_trait = { level = "deny", priority = -1 }
+rust_2018_compatibility = { level = "deny", priority = -1 }
+rust_2018_idioms = { level = "deny", priority = -1 }
+rust_2021_compatibility = { level = "deny", priority = -1 }
+rust_2024_compatibility = { level = "deny", priority = -1 }
+unsafe_code = { level = "deny", priority = -1 }
+unused = { level = "deny", priority = -1 }
+warnings = { level = "deny", priority = -1 }
+
+[lints.clippy]
+all = { level = "deny", priority = -1 }
+cargo = { level = "deny", priority = -1 }
+complexity = { level = "deny", priority = -1 }
+correctness = { level = "deny", priority = -1 }
+nursery = { level = "deny", priority = -1 }
+pedantic = { level = "deny", priority = -1 }
+perf = { level = "deny", priority = -1 }
+restriction = { level = "deny", priority = -1 }
+style = { level = "deny", priority = -1 }
+suspicious = { level = "deny", priority = -1 }
+# Noisy, opinionated, and likely don't prevent bugs or improve APIs.
+arbitrary_source_item_ordering = "allow"
+blanket_clippy_restriction_lints = "allow"
+exhaustive_enums = "allow"
+exhaustive_structs = "allow"
+implicit_return = "allow"
+min_ident_chars = "allow"
+missing_trait_methods = "allow"
+multiple_crate_versions = "allow"
+pub_use = "allow"
+question_mark_used = "allow"
+ref_patterns = "allow"
+return_and_then = "allow"
+single_call_fn = "allow"
+single_char_lifetime_names = "allow"
+unseparated_literal_suffix = "allow"
[dependencies]
ascii_domain = { version = "0.6.4", default-features = false }
num-bigint = { version = "0.4.6", default-features = false }
+priv_sep = { version = "3.0.0-alpha.1", default-features = false, optional = true }
reqwest = { version = "0.12.15", default-features = false, features = ["brotli", "deflate", "gzip", "rustls-tls-native-roots", "trust-dns"] }
serde = { version = "1.0.219", default-features = false }
superset_map = { version = "0.3.1", default-features = false }
-tokio = { version = "1.44.1", default-features = false, features = ["rt", "time"] }
-toml = { version = "0.8.20", default-features = false, features = ["parse"] }
+tokio = { version = "1.45.0", default-features = false, features = ["rt", "time"] }
+toml = { version = "0.8.22", default-features = false, features = ["parse"] }
url = { version = "2.5.4", default-features = false, features = ["serde"] }
zfc = { version = "0.4.1", default-features = false }
-[target.'cfg(target_os = "openbsd")'.dependencies]
-priv_sep = { version = "2.2.0", default-features = false, features = ["openbsd"], optional = true }
-
### FEATURES #################################################################
diff --git a/src/dom.rs b/src/dom.rs
@@ -20,6 +20,8 @@ use std::{
};
use superset_map::SetOrd;
use zfc::{BoundedCardinality, Cardinality, Set};
+/// One.
+const ONE: NonZeroU8 = NonZeroU8::new(1).unwrap();
/// Error returned when an invalid string is passed to [`Adblock::parse_value`], [`DomainOnly::parse_value`],
/// [`Hosts::parse_value`], [`Wildcard::parse_value`], or [`RpzDomain::parse_value`].
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
@@ -755,13 +757,10 @@ impl DomainOnly<'_> {
/// Same as [`DomainOnly::cardinality`] except that a `NonZeroU8` is returned.
///
/// The value is always 1.
- #[expect(unsafe_code, reason = "trivial use of NonZeroU8::new_unchecked")]
#[inline]
#[must_use]
pub const fn domain_count(&self) -> NonZeroU8 {
- // SAFETY:
- // 0 < 1 < 256.
- unsafe { NonZeroU8::new_unchecked(1) }
+ ONE
}
}
impl PartialEq<DomainOnly<'_>> for DomainOnly<'_> {
@@ -1010,13 +1009,10 @@ impl Hosts<'_> {
/// Same as [`Hosts::cardinality`] except that a `NonZeroU8` is returned.
///
/// The value is always 1.
- #[expect(unsafe_code, reason = "trivial use of NonZeroU8::new_unchecked")]
#[inline]
#[must_use]
pub const fn domain_count(&self) -> NonZeroU8 {
- // SAFETY:
- // 0 < 1 < 256.
- unsafe { NonZeroU8::new_unchecked(1) }
+ ONE
}
}
impl PartialEq<Hosts<'_>> for Hosts<'_> {
diff --git a/src/lib.rs b/src/lib.rs
@@ -17,48 +17,6 @@
//! file easier.
#![feature(btree_cursors)]
#![feature(io_error_more)]
-#![deny(
- future_incompatible,
- let_underscore,
- missing_docs,
- nonstandard_style,
- rust_2018_compatibility,
- rust_2018_idioms,
- rust_2021_compatibility,
- rust_2024_compatibility,
- unsafe_code,
- unused,
- warnings,
- clippy::all,
- clippy::cargo,
- clippy::complexity,
- clippy::correctness,
- clippy::nursery,
- clippy::pedantic,
- clippy::perf,
- clippy::restriction,
- clippy::style,
- clippy::suspicious
-)]
-#![allow(
- unknown_lints,
- reason = "OpenBSD does not recognize clippy::return_and_then"
-)]
-#![expect(
- clippy::arbitrary_source_item_ordering,
- clippy::blanket_clippy_restriction_lints,
- clippy::exhaustive_enums,
- clippy::exhaustive_structs,
- clippy::implicit_return,
- clippy::min_ident_chars,
- clippy::missing_trait_methods,
- clippy::multiple_crate_versions,
- clippy::question_mark_used,
- clippy::ref_patterns,
- clippy::return_and_then,
- clippy::single_char_lifetime_names,
- reason = "never want to use these lints"
-)]
/// Module for hostname-like domains including parsing [`str`]s
/// from a variety of formats.
pub mod dom;
diff --git a/src/main.rs b/src/main.rs
@@ -3,49 +3,6 @@
//! Consult [`README.md`](https://crates.io/crates/rpz).
#![feature(never_type)]
#![cfg_attr(doc, feature(doc_auto_cfg))]
-#![deny(
- future_incompatible,
- let_underscore,
- missing_docs,
- nonstandard_style,
- rust_2018_compatibility,
- rust_2018_idioms,
- rust_2021_compatibility,
- rust_2024_compatibility,
- unsafe_code,
- unused,
- warnings,
- clippy::all,
- clippy::cargo,
- clippy::complexity,
- clippy::correctness,
- clippy::nursery,
- clippy::pedantic,
- clippy::perf,
- clippy::restriction,
- clippy::style,
- clippy::suspicious
-)]
-#![allow(
- unknown_lints,
- reason = "OpenBSD does not recognize clippy::return_and_then"
-)]
-#![allow(clippy::pub_use, reason = "when priv_sep is used, we export UnveilErr")]
-#![expect(
- clippy::arbitrary_source_item_ordering,
- clippy::blanket_clippy_restriction_lints,
- clippy::implicit_return,
- clippy::min_ident_chars,
- clippy::missing_trait_methods,
- clippy::multiple_crate_versions,
- clippy::question_mark_used,
- clippy::ref_patterns,
- clippy::return_and_then,
- clippy::single_call_fn,
- clippy::single_char_lifetime_names,
- clippy::unseparated_literal_suffix,
- reason = "never want to use these lints"
-)]
/// Contains a wrapper of block and unblock `RpzDomain`s
/// which can be used to write to a `File` or `stdout`.
mod app;
@@ -67,7 +24,7 @@ use core::{
time::Duration,
};
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-use priv_sep::UnveilErr;
+use priv_sep::NulOrIoErr;
use reqwest::Client;
use rpz::{
dom::FirefoxDomainErr,
@@ -109,7 +66,7 @@ enum E {
Config(de::Error),
/// Variant for errors due to calls to `unveil`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
- Unveil(UnveilErr),
+ Unveil(NulOrIoErr),
/// Variant for IO errors.
Io(io::Error),
/// Variant for errors due to downloading external HTTP(S) block files.
@@ -164,8 +121,8 @@ impl From<ExtFileErr> for E {
}
}
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-impl From<UnveilErr> for E {
- fn from(value: UnveilErr) -> Self {
+impl From<NulOrIoErr> for E {
+ fn from(value: NulOrIoErr) -> Self {
Self::Unveil(value)
}
}
diff --git a/src/priv_sep.rs b/src/priv_sep.rs
@@ -1,7 +1,7 @@
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub use priv_sep::UnveilErr;
+pub use priv_sep::NulOrIoErr;
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-use priv_sep::{self, Permission, Permissions, Promise, Promises};
+use priv_sep::{self, Permissions, Promise, Promises};
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
use std::env;
#[cfg(not(all(feature = "priv_sep", target_os = "openbsd")))]
@@ -90,7 +90,7 @@ pub const fn pledge_away_all_but_stdio(_: &mut Zst) -> Result<(), !> {
}
/// Calls `unveil`_on `path` with no `Permissions`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_none<P: AsRef<Path>>(path: P) -> Result<(), UnveilErr> {
+pub fn unveil_none<P: AsRef<Path>>(path: P) -> Result<(), NulOrIoErr> {
Permissions::NONE.unveil(path)
}
/// No-op that always returns `Ok`.
@@ -101,7 +101,7 @@ pub fn unveil_none<P: AsRef<Path>>(_: P) -> Result<(), !> {
}
/// Calls `unveil_none` on `/`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn veil_all() -> Result<(), UnveilErr> {
+pub fn veil_all() -> Result<(), NulOrIoErr> {
unveil_none("/")
}
/// No-op that always returns `Ok`.
@@ -112,7 +112,7 @@ pub const fn veil_all() -> Result<(), !> {
}
/// Calls `unveil`_on `path` with `Permissions::CREATE`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_create<P: AsRef<Path>>(path: P) -> Result<(), UnveilErr> {
+pub fn unveil_create<P: AsRef<Path>>(path: P) -> Result<(), NulOrIoErr> {
Permissions::CREATE.unveil(path)
}
/// No-op that always returns `Ok`.
@@ -128,14 +128,14 @@ pub fn unveil_create<P: AsRef<Path>>(_: P) -> Result<(), !> {
reason = "ErrorKind is non_exhaustive"
)]
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_read_dir<P: AsRef<Path>>(path: P) -> Result<bool, UnveilErr> {
+pub fn unveil_read_dir<P: AsRef<Path>>(path: P) -> Result<bool, NulOrIoErr> {
Permissions::READ.unveil(path).map_or_else(
|err| match err {
- UnveilErr::Io(ref err2) => match err2.kind() {
+ NulOrIoErr::Io(ref err2) => match err2.kind() {
ErrorKind::NotFound => Ok(false),
_ => Err(err),
},
- UnveilErr::Nul(_) => Err(err),
+ NulOrIoErr::Nul(_) => Err(err),
},
|()| Ok(true),
)
@@ -157,7 +157,7 @@ pub fn unveil_read_dir<P: AsRef<Path>>(path: P) -> Result<bool, Error> {
}
/// Calls `unveil`_on `path` with `Permissions::READ`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_read_file<P: AsRef<Path>>(path: P) -> Result<(), UnveilErr> {
+pub fn unveil_read_file<P: AsRef<Path>>(path: P) -> Result<(), NulOrIoErr> {
Permissions::READ.unveil(path)
}
/// No-op that always returns `Ok`.
@@ -172,7 +172,7 @@ pub fn unveil_read_file<P: AsRef<Path>>(_: P) -> Result<(), !> {
/// instead of `/etc/ssl/`.
#[expect(unsafe_code, reason = "safety comment justifies its correctness")]
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_https() -> Result<(), UnveilErr> {
+pub fn unveil_https() -> Result<(), NulOrIoErr> {
/// The path to the root certificate store.
const CERTS: &str = "/etc/ssl/cert.pem";
unveil_read_file(CERTS).map(|()| {
@@ -190,10 +190,8 @@ pub const fn unveil_https() -> Result<(), !> {
}
/// Calls `unveil`_on `path` with create, read, and write `Permissions`.
#[cfg(all(feature = "priv_sep", target_os = "openbsd"))]
-pub fn unveil_create_read_write<P: AsRef<Path>>(path: P) -> Result<(), UnveilErr> {
- let mut perms = Permissions::ALL;
- perms.disable(Permission::Execute);
- perms.unveil(path)
+pub fn unveil_create_read_write<P: AsRef<Path>>(path: P) -> Result<(), NulOrIoErr> {
+ (!Permissions::EXECUTE).unveil(path)
}
/// No-op that always returns `Ok`.
#[cfg(not(all(feature = "priv_sep", target_os = "openbsd")))]