Skip to content

Commit 4de26f5

Browse files
RUST-2097 / RUST-2114 Dependency security fixes (#1267)
1 parent df4f75c commit 4de26f5

File tree

14 files changed

+66
-67
lines changed

14 files changed

+66
-67
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ chrono = { version = "0.4.7", default-features = false, features = [
7575
"clock",
7676
"std",
7777
] }
78-
derivative = "2.1.1"
7978
derive_more = "0.99.17"
79+
derive-where = "1.2.7"
8080
flate2 = { version = "1.0", optional = true }
8181
futures-io = "0.3.21"
8282
futures-core = "0.3.14"
8383
futures-util = { version = "0.3.14", features = ["io"] }
8484
futures-executor = "0.3.14"
8585
hex = "0.4.0"
86-
hickory-proto = { version = "0.24.1", optional = true }
87-
hickory-resolver = { version = "0.24.1", optional = true }
86+
hickory-proto = { version = "0.24.2", optional = true }
87+
hickory-resolver = { version = "0.24.2", optional = true }
8888
hmac = "0.12.1"
8989
once_cell = "1.19.0"
9090
log = { version = "0.4.17", optional = true }

src/change_stream.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{
1414
#[cfg(test)]
1515
use bson::RawDocumentBuf;
1616
use bson::{Document, Timestamp};
17-
use derivative::Derivative;
17+
use derive_where::derive_where;
1818
use futures_core::{future::BoxFuture, Stream};
1919
use serde::de::DeserializeOwned;
2020
#[cfg(test)]
@@ -74,8 +74,7 @@ use crate::{
7474
///
7575
/// See the documentation [here](https://www.mongodb.com/docs/manual/changeStreams) for more
7676
/// details. Also see the documentation on [usage recommendations](https://www.mongodb.com/docs/manual/administration/change-streams-production-recommendations/).
77-
#[derive(Derivative)]
78-
#[derivative(Debug)]
77+
#[derive_where(Debug)]
7978
pub struct ChangeStream<T>
8079
where
8180
T: DeserializeOwned,
@@ -90,7 +89,7 @@ where
9089
data: ChangeStreamData,
9190

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

src/client.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313

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

@@ -116,8 +116,7 @@ const _: fn() = || {
116116
assert_sync(_c);
117117
};
118118

119-
#[derive(Derivative)]
120-
#[derivative(Debug)]
119+
#[derive(Debug)]
121120
struct ClientInner {
122121
topology: Topology,
123122
options: ClientOptions,
@@ -604,10 +603,9 @@ impl WeakClient {
604603
}
605604
}
606605

607-
#[derive(Derivative)]
608-
#[derivative(Debug)]
606+
#[derive_where(Debug)]
609607
pub(crate) struct AsyncDropToken {
610-
#[derivative(Debug = "ignore")]
608+
#[derive_where(skip)]
611609
tx: Option<tokio::sync::oneshot::Sender<BoxFuture<'static, ()>>>,
612610
}
613611

src/client/auth.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod x509;
1515
use std::{borrow::Cow, fmt::Debug, str::FromStr};
1616

1717
use bson::RawDocumentBuf;
18-
use derivative::Derivative;
18+
use derive_where::derive_where;
1919
use hmac::{digest::KeyInit, Mac};
2020
use rand::Rng;
2121
use serde::Deserialize;
@@ -459,8 +459,8 @@ impl FromStr for AuthMechanism {
459459
///
460460
/// Some fields (mechanism and source) may be omitted and will either be negotiated or assigned a
461461
/// default value, depending on the values of other fields in the credential.
462-
#[derive(Clone, Default, Deserialize, TypedBuilder, Derivative)]
463-
#[derivative(PartialEq)]
462+
#[derive(Clone, Default, Deserialize, TypedBuilder)]
463+
#[derive_where(PartialEq)]
464464
#[builder(field_defaults(default, setter(into)))]
465465
#[non_exhaustive]
466466
pub struct Credential {
@@ -507,7 +507,7 @@ pub struct Credential {
507507
/// }
508508
/// ```
509509
#[serde(skip)]
510-
#[derivative(Debug = "ignore", PartialEq = "ignore")]
510+
#[derive_where(skip)]
511511
#[builder(default)]
512512
pub oidc_callback: oidc::Callback,
513513
}

src/client/csfle.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) mod state_machine;
55

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

8-
use derivative::Derivative;
8+
use derive_where::derive_where;
99
use mongocrypt::Crypt;
1010

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

2929
use super::WeakClient;
3030

31-
#[derive(Derivative)]
32-
#[derivative(Debug)]
31+
#[derive_where(Debug)]
3332
pub(super) struct ClientState {
34-
#[derivative(Debug = "ignore")]
33+
#[derive_where(skip)]
3534
crypt: Crypt,
3635
exec: CryptExecutor,
37-
internal_client: Option<Client>,
36+
_internal_client: Option<Client>,
3837
opts: AutoEncryptionOptions,
3938
}
4039

@@ -79,7 +78,7 @@ impl ClientState {
7978
Ok(Self {
8079
crypt,
8180
exec,
82-
internal_client: aux_clients.internal_client,
81+
_internal_client: aux_clients.internal_client,
8382
opts,
8483
})
8584
}

src/client/options.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
};
1818

1919
use bson::UuidRepresentation;
20-
use derivative::Derivative;
20+
use derive_where::derive_where;
2121
use once_cell::sync::Lazy;
2222
use serde::{de::Unexpected, Deserialize, Deserializer, Serialize};
2323
use serde_with::skip_serializing_none;
@@ -357,9 +357,9 @@ pub struct ServerApi {
357357
}
358358

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

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

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

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

533533
#[builder(setter(skip))]
534-
#[derivative(Debug = "ignore")]
534+
#[derive_where(skip(Debug))]
535535
pub(crate) socket_timeout: Option<Duration>,
536536

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

567567
#[cfg(test)]
568568
#[builder(setter(skip))]
569-
#[derivative(Debug = "ignore")]
569+
#[derive_where(skip(Debug))]
570570
pub(crate) original_uri: Option<String>,
571571

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

583583
/// Control test behavior of the client.
584584
#[cfg(test)]
585585
#[builder(setter(skip))]
586586
#[serde(skip)]
587-
#[derivative(PartialEq = "ignore")]
587+
#[derive_where(skip)]
588588
pub(crate) test_options: Option<TestOptions>,
589589
}
590590

src/client/session/cluster_time.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use derivative::Derivative;
1+
use derive_where::derive_where;
22
use serde::{Deserialize, Serialize};
33

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

16-
#[derivative(PartialEq = "ignore")]
16+
#[derive_where(skip)]
1717
pub(crate) signature: Document,
1818
}
1919

src/cmap.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mod worker;
1111

1212
use std::time::Instant;
1313

14-
use derivative::Derivative;
14+
use derive_where::derive_where;
1515

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

62-
#[derivative(Debug = "ignore")]
62+
#[derive_where(skip)]
6363
event_emitter: CmapEventEmitter,
6464
}
6565

src/cmap/conn.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
time::{Duration, Instant},
88
};
99

10-
use derivative::Derivative;
10+
use derive_where::derive_where;
1111
use serde::Serialize;
1212
use tokio::{
1313
io::BufStream,
@@ -59,8 +59,7 @@ pub struct ConnectionInfo {
5959
}
6060

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

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

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

src/cmap/options.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use std::cmp::Ordering;
33
use std::time::Duration;
44

5-
use derivative::Derivative;
5+
use derive_where::derive_where;
66
#[cfg(test)]
77
use serde::de::{Deserializer, Error};
88
use serde::Deserialize;
@@ -18,16 +18,16 @@ use crate::{
1818
};
1919

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

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

src/cursor.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use bson::RawDocument;
1212

1313
#[cfg(test)]
1414
use bson::RawDocumentBuf;
15+
use derive_where::derive_where;
1516
use futures_core::Stream;
1617
use serde::{de::DeserializeOwned, Deserialize};
1718
#[cfg(test)]
@@ -98,7 +99,7 @@ pub(crate) use common::{
9899
/// If a [`Cursor`] is still open when it goes out of scope, it will automatically be closed via an
99100
/// asynchronous [killCursors](https://www.mongodb.com/docs/manual/reference/command/killCursors/) command executed
100101
/// from its [`Drop`](https://doc.rust-lang.org/std/ops/trait.Drop.html) implementation.
101-
#[derive(Debug)]
102+
#[derive_where(Debug)]
102103
pub struct Cursor<T> {
103104
client: Client,
104105
drop_token: AsyncDropToken,
@@ -108,6 +109,7 @@ pub struct Cursor<T> {
108109
drop_address: Option<ServerAddress>,
109110
#[cfg(test)]
110111
kill_watcher: Option<oneshot::Sender<()>>,
112+
#[derive_where(skip)]
111113
_phantom: std::marker::PhantomData<fn() -> T>,
112114
}
113115

src/cursor/common.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
};
77

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

3737
/// An internal cursor that can be used in a variety of contexts depending on its `GetMoreProvider`.
38-
#[derive(Derivative)]
39-
#[derivative(Debug)]
38+
#[derive_where(Debug)]
4039
pub(super) struct GenericCursor<'s, S> {
41-
#[derivative(Debug = "ignore")]
40+
#[derive_where(skip)]
4241
provider: GetMoreProvider<'s, S>,
4342
client: Client,
4443
info: CursorInformation,

0 commit comments

Comments
 (0)