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

RUST-2097 / RUST-2114 Dependency security fixes #1267

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ chrono = { version = "0.4.7", default-features = false, features = [
"clock",
"std",
] }
derivative = "2.1.1"
derive_more = "0.99.17"
derive-where = "1.2.7"
flate2 = { version = "1.0", optional = true }
futures-io = "0.3.21"
futures-core = "0.3.14"
futures-util = { version = "0.3.14", features = ["io"] }
futures-executor = "0.3.14"
hex = "0.4.0"
hickory-proto = { version = "0.24.1", optional = true }
hickory-resolver = { version = "0.24.1", optional = true }
hickory-proto = { version = "0.24.2", optional = true }
hickory-resolver = { version = "0.24.2", optional = true }
hmac = "0.12.1"
once_cell = "1.19.0"
log = { version = "0.4.17", optional = true }
Expand Down
7 changes: 3 additions & 4 deletions src/change_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::{
#[cfg(test)]
use bson::RawDocumentBuf;
use bson::{Document, Timestamp};
use derivative::Derivative;
use derive_where::derive_where;
use futures_core::{future::BoxFuture, Stream};
use serde::de::DeserializeOwned;
#[cfg(test)]
Expand Down Expand Up @@ -74,8 +74,7 @@ use crate::{
///
/// See the documentation [here](https://www.mongodb.com/docs/manual/changeStreams) for more
/// details. Also see the documentation on [usage recommendations](https://www.mongodb.com/docs/manual/administration/change-streams-production-recommendations/).
#[derive(Derivative)]
#[derivative(Debug)]
#[derive_where(Debug)]
pub struct ChangeStream<T>
where
T: DeserializeOwned,
Expand All @@ -90,7 +89,7 @@ where
data: ChangeStreamData,

/// A pending future for a resume.
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
pending_resume: Option<BoxFuture<'static, Result<ChangeStream<T>>>>,
}

Expand Down
10 changes: 4 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{

#[cfg(feature = "in-use-encryption-unstable")]
pub use self::csfle::client_builder::*;
use derivative::Derivative;
use derive_where::derive_where;
use futures_core::Future;
use futures_util::FutureExt;

Expand Down Expand Up @@ -116,8 +116,7 @@ const _: fn() = || {
assert_sync(_c);
};

#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Debug)]
struct ClientInner {
topology: Topology,
options: ClientOptions,
Expand Down Expand Up @@ -604,10 +603,9 @@ impl WeakClient {
}
}

#[derive(Derivative)]
#[derivative(Debug)]
#[derive_where(Debug)]
pub(crate) struct AsyncDropToken {
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
tx: Option<tokio::sync::oneshot::Sender<BoxFuture<'static, ()>>>,
}

Expand Down
8 changes: 4 additions & 4 deletions src/client/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod x509;
use std::{borrow::Cow, fmt::Debug, str::FromStr};

use bson::RawDocumentBuf;
use derivative::Derivative;
use derive_where::derive_where;
use hmac::{digest::KeyInit, Mac};
use rand::Rng;
use serde::Deserialize;
Expand Down Expand Up @@ -459,8 +459,8 @@ impl FromStr for AuthMechanism {
///
/// Some fields (mechanism and source) may be omitted and will either be negotiated or assigned a
/// default value, depending on the values of other fields in the credential.
#[derive(Clone, Default, Deserialize, TypedBuilder, Derivative)]
#[derivative(PartialEq)]
#[derive(Clone, Default, Deserialize, TypedBuilder)]
#[derive_where(PartialEq)]
#[builder(field_defaults(default, setter(into)))]
#[non_exhaustive]
pub struct Credential {
Expand Down Expand Up @@ -507,7 +507,7 @@ pub struct Credential {
/// }
/// ```
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
#[derive_where(skip)]
#[builder(default)]
pub oidc_callback: oidc::Callback,
}
Expand Down
11 changes: 5 additions & 6 deletions src/client/csfle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub(crate) mod state_machine;

use std::{path::Path, time::Duration};

use derivative::Derivative;
use derive_where::derive_where;
use mongocrypt::Crypt;

use crate::{
Expand All @@ -28,13 +28,12 @@ use self::state_machine::{CryptExecutor, MongocryptdOptions};

use super::WeakClient;

#[derive(Derivative)]
#[derivative(Debug)]
#[derive_where(Debug)]
pub(super) struct ClientState {
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
crypt: Crypt,
exec: CryptExecutor,
internal_client: Option<Client>,
_internal_client: Option<Client>,
opts: AutoEncryptionOptions,
}

Expand Down Expand Up @@ -79,7 +78,7 @@ impl ClientState {
Ok(Self {
crypt,
exec,
internal_client: aux_clients.internal_client,
_internal_client: aux_clients.internal_client,
opts,
})
}
Expand Down
22 changes: 11 additions & 11 deletions src/client/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::{
};

use bson::UuidRepresentation;
use derivative::Derivative;
use derive_where::derive_where;
use once_cell::sync::Lazy;
use serde::{de::Unexpected, Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
Expand Down Expand Up @@ -357,9 +357,9 @@ pub struct ServerApi {
}

/// Contains the options that can be used to create a new [`Client`](../struct.Client.html).
#[derive(Clone, Derivative, Deserialize, TypedBuilder)]
#[derive(Clone, Deserialize, TypedBuilder)]
#[builder(field_defaults(default, setter(into)))]
#[derivative(Debug, PartialEq)]
#[derive_where(Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ClientOptions {
Expand Down Expand Up @@ -393,15 +393,15 @@ pub struct ClientOptions {
pub compressors: Option<Vec<Compressor>>,

/// The handler that should process all Connection Monitoring and Pooling events.
#[derivative(Debug = "ignore", PartialEq = "ignore")]
#[derive_where(skip)]
#[builder(setter(strip_option))]
#[serde(skip)]
pub cmap_event_handler: Option<EventHandler<crate::event::cmap::CmapEvent>>,

/// The handler that should process all command-related events.
///
/// Note that monitoring command events may incur a performance penalty.
#[derivative(Debug = "ignore", PartialEq = "ignore")]
#[derive_where(skip)]
#[builder(setter(strip_option))]
#[serde(skip)]
pub command_event_handler: Option<EventHandler<crate::event::command::CommandEvent>>,
Expand Down Expand Up @@ -497,7 +497,7 @@ pub struct ClientOptions {
pub server_monitoring_mode: Option<ServerMonitoringMode>,

/// The handler that should process all Server Discovery and Monitoring events.
#[derivative(Debug = "ignore", PartialEq = "ignore")]
#[derive_where(skip)]
#[builder(setter(strip_option))]
#[serde(skip)]
pub sdam_event_handler: Option<EventHandler<crate::event::sdam::SdamEvent>>,
Expand Down Expand Up @@ -531,7 +531,7 @@ pub struct ClientOptions {
pub default_database: Option<String>,

#[builder(setter(skip))]
#[derivative(Debug = "ignore")]
#[derive_where(skip(Debug))]
pub(crate) socket_timeout: Option<Duration>,

/// The TLS configuration for the Client to use in its connections with the server.
Expand Down Expand Up @@ -561,12 +561,12 @@ pub struct ClientOptions {
/// Information from the SRV URI that generated these client options, if applicable.
#[builder(setter(skip))]
#[serde(skip)]
#[derivative(Debug = "ignore")]
#[derive_where(skip(Debug))]
pub(crate) original_srv_info: Option<OriginalSrvInfo>,

#[cfg(test)]
#[builder(setter(skip))]
#[derivative(Debug = "ignore")]
#[derive_where(skip(Debug))]
pub(crate) original_uri: Option<String>,

/// Configuration of the DNS resolver used for SRV and TXT lookups.
Expand All @@ -576,15 +576,15 @@ pub struct ClientOptions {
/// system configuration, so a custom configuration is recommended.
#[builder(setter(skip))]
#[serde(skip)]
#[derivative(Debug = "ignore")]
#[derive_where(skip(Debug))]
#[cfg(feature = "dns-resolver")]
pub(crate) resolver_config: Option<ResolverConfig>,

/// Control test behavior of the client.
#[cfg(test)]
#[builder(setter(skip))]
#[serde(skip)]
#[derivative(PartialEq = "ignore")]
#[derive_where(skip)]
pub(crate) test_options: Option<TestOptions>,
}

Expand Down
8 changes: 4 additions & 4 deletions src/client/session/cluster_time.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use derivative::Derivative;
use derive_where::derive_where;
use serde::{Deserialize, Serialize};

use crate::bson::{Document, Timestamp};
Expand All @@ -7,13 +7,13 @@ use crate::bson::{Document, Timestamp};
///
/// See [the MongoDB documentation](https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/)
/// for more information.
#[derive(Debug, Deserialize, Clone, Serialize, Derivative)]
#[derivative(PartialEq, Eq)]
#[derive(Debug, Deserialize, Clone, Serialize)]
#[derive_where(PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ClusterTime {
pub(crate) cluster_time: Timestamp,

#[derivative(PartialEq = "ignore")]
#[derive_where(skip)]
pub(crate) signature: Document,
}

Expand Down
8 changes: 4 additions & 4 deletions src/cmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod worker;

use std::time::Instant;

use derivative::Derivative;
use derive_where::derive_where;

pub use self::conn::ConnectionInfo;
pub(crate) use self::{
Expand Down Expand Up @@ -51,15 +51,15 @@ pub(crate) const DEFAULT_MAX_POOL_SIZE: u32 = 10;
/// A pool of connections implementing the CMAP spec.
/// This type is actually a handle to task that manages the connections and is cheap to clone and
/// pass around.
#[derive(Clone, Derivative)]
#[derivative(Debug)]
#[derive(Clone)]
#[derive_where(Debug)]
pub(crate) struct ConnectionPool {
address: ServerAddress,
manager: PoolManager,
connection_requester: ConnectionRequester,
generation_subscriber: PoolGenerationSubscriber,

#[derivative(Debug = "ignore")]
#[derive_where(skip)]
event_emitter: CmapEventEmitter,
}

Expand Down
9 changes: 4 additions & 5 deletions src/cmap/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
time::{Duration, Instant},
};

use derivative::Derivative;
use derive_where::derive_where;
use serde::Serialize;
use tokio::{
io::BufStream,
Expand Down Expand Up @@ -59,8 +59,7 @@ pub struct ConnectionInfo {
}

/// A wrapper around Stream that contains all the CMAP information needed to maintain a connection.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive_where(Debug)]
pub(crate) struct Connection {
/// Driver-generated ID for the connection.
pub(crate) id: u32,
Expand Down Expand Up @@ -118,11 +117,11 @@ pub(crate) struct Connection {

/// Type responsible for emitting events related to this connection. This is None for
/// monitoring connections as we do not emit events for those.
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
event_emitter: Option<CmapEventEmitter>,

/// The token callback for OIDC authentication.
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
pub(crate) oidc_token_gen_id: tokio::sync::Mutex<u32>,
}

Expand Down
8 changes: 4 additions & 4 deletions src/cmap/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::cmp::Ordering;
use std::time::Duration;

use derivative::Derivative;
use derive_where::derive_where;
#[cfg(test)]
use serde::de::{Deserializer, Error};
use serde::Deserialize;
Expand All @@ -18,16 +18,16 @@ use crate::{
};

/// Contains the options for creating a connection pool.
#[derive(Clone, Default, Deserialize, Derivative)]
#[derivative(Debug, PartialEq)]
#[derive(Clone, Default, Deserialize)]
#[derive_where(Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ConnectionPoolOptions {
/// The credential to use for authenticating connections in this pool.
#[serde(skip)]
pub(crate) credential: Option<Credential>,

/// Processes all events generated by the pool.
#[derivative(Debug = "ignore", PartialEq = "ignore")]
#[derive_where(skip)]
#[serde(skip)]
pub(crate) cmap_event_handler: Option<EventHandler<CmapEvent>>,

Expand Down
4 changes: 3 additions & 1 deletion src/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use bson::RawDocument;

#[cfg(test)]
use bson::RawDocumentBuf;
use derive_where::derive_where;
use futures_core::Stream;
use serde::{de::DeserializeOwned, Deserialize};
#[cfg(test)]
Expand Down Expand Up @@ -98,7 +99,7 @@ pub(crate) use common::{
/// If a [`Cursor`] is still open when it goes out of scope, it will automatically be closed via an
/// asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
#[derive(Debug)]
#[derive_where(Debug)]
pub struct Cursor<T> {
client: Client,
drop_token: AsyncDropToken,
Expand All @@ -108,6 +109,7 @@ pub struct Cursor<T> {
drop_address: Option<ServerAddress>,
#[cfg(test)]
kill_watcher: Option<oneshot::Sender<()>>,
#[derive_where(skip)]
_phantom: std::marker::PhantomData<fn() -> T>,
}

Expand Down
7 changes: 3 additions & 4 deletions src/cursor/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use bson::{RawDocument, RawDocumentBuf};
use derivative::Derivative;
use derive_where::derive_where;
use futures_core::{future::BoxFuture, Future};
#[cfg(test)]
use tokio::sync::oneshot;
Expand Down Expand Up @@ -35,10 +35,9 @@ pub(super) enum AdvanceResult {
}

/// An internal cursor that can be used in a variety of contexts depending on its `GetMoreProvider`.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive_where(Debug)]
pub(super) struct GenericCursor<'s, S> {
#[derivative(Debug = "ignore")]
#[derive_where(skip)]
provider: GetMoreProvider<'s, S>,
client: Client,
info: CursorInformation,
Expand Down
Loading