Skip to content

RUST-1795 Remove unstable from in-use encryption #1191

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

Merged
merged 1 commit into from
Aug 30, 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
2 changes: 1 addition & 1 deletion .evergreen/azure-kms-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ tokio = "1.28.1"

[dependencies.mongodb]
path = "../.."
features = ["in-use-encryption-unstable", "azure-kms"]
features = ["in-use-encryption", "azure-kms"]
2 changes: 1 addition & 1 deletion .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ functions:

echo "Building test ... begin"
. ${PROJECT_DIRECTORY}/.evergreen/env.sh
cargo test get_exe_name --features in-use-encryption-unstable,gcp-kms -- --ignored
cargo test get_exe_name --features in-use-encryption,gcp-kms -- --ignored
cp $(cat exe_name.txt) test-contents/test-exe
echo "Building test ... end"

Expand Down
2 changes: 1 addition & 1 deletion .evergreen/run-csfle-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -o xtrace

export CSFLE_TLS_CERT_DIR="${DRIVERS_TOOLS}/.evergreen/x509gen"

FEATURE_FLAGS+=("in-use-encryption-unstable" "aws-auth" "azure-kms")
FEATURE_FLAGS+=("in-use-encryption" "aws-auth" "azure-kms")

if [[ "$OPENSSL" = true ]]; then
FEATURE_FLAGS+=("openssl-tls")
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ zlib-compression = ["dep:flate2"]
snappy-compression = ["dep:snap"]

# Enables support for client-side field level encryption and queryable encryption.
# The In Use Encryption API is unstable and may have backwards-incompatible changes in minor version updates.
in-use-encryption-unstable = ["dep:mongocrypt", "dep:rayon", "dep:num_cpus"]
in-use-encryption = ["dep:mongocrypt", "dep:rayon", "dep:num_cpus"]
# The in-use encryption API is stable; this is for backwards compatibility.
in-use-encryption-unstable = ["in-use-encryption"]

# Enables support for emitting tracing events.
# The tracing API is unstable and may have backwards-incompatible changes in minor version updates.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ features = ["sync"]
| `zlib-compression` | Enable support for compressing messages with [`zlib`](https://zlib.net/). |
| `zstd-compression` | Enable support for compressing messages with [`zstd`](http://facebook.github.io/zstd/). |
| `snappy-compression` | Enable support for compressing messages with [`snappy`](http://google.github.io/snappy/). |
| `in-use-encryption-unstable` | Enable support for client-side field level encryption and queryable encryption. This API is unstable and may be subject to breaking changes in minor releases. |
| `in-use-encryption` | Enable support for client-side field level encryption and queryable encryption. |
| `tracing-unstable` | Enable support for emitting [`tracing`](https://docs.rs/tracing/latest/tracing/) events. This API is unstable and may be subject to breaking changes in minor releases. |
| `compat-3-0-0` | Required for future compatibility if default features are disabled. |

Expand Down
2 changes: 1 addition & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod client_options;
mod count;
mod create_collection;
mod create_index;
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub mod csfle;
mod delete;
mod distinct;
Expand Down
2 changes: 1 addition & 1 deletion src/action/bulk_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ where
}

async fn execute_inner(mut self) -> Result<R> {
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
if self.client.should_auto_encrypt().await {
use mongocrypt::error::{Error as EncryptionError, ErrorKind as EncryptionErrorKind};

Expand Down
2 changes: 1 addition & 1 deletion src/action/create_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<'a> CreateCollection<'a> {
change_stream_pre_and_post_images: crate::db::options::ChangeStreamPreAndPostImages,
clustered_index: crate::db::options::ClusteredIndex,
comment: bson::Bson,
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
encrypted_fields: Document,
);

Expand Down
2 changes: 1 addition & 1 deletion src/action/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub struct DropCollection<'a> {
impl<'a> DropCollection<'a> {
option_setters!(options: DropCollectionOptions;
write_concern: WriteConcern,
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
encrypted_fields: bson::Document,
);

Expand Down
22 changes: 11 additions & 11 deletions src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod action;
pub mod auth;
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) mod csfle;
mod executor;
pub mod options;
Expand All @@ -11,7 +11,7 @@ use std::{
time::{Duration, Instant},
};

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub use self::csfle::client_builder::*;
use derivative::Derivative;
use futures_core::Future;
Expand Down Expand Up @@ -123,7 +123,7 @@ struct ClientInner {
options: ClientOptions,
session_pool: ServerSessionPool,
shutdown: Shutdown,
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
csfle: tokio::sync::RwLock<Option<csfle::ClientState>>,
#[cfg(test)]
disable_command_events: AtomicBool,
Expand Down Expand Up @@ -159,7 +159,7 @@ impl Client {
pending_drops: SyncMutex::new(IdSet::new()),
executed: AtomicBool::new(false),
},
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
csfle: Default::default(),
#[cfg(test)]
disable_command_events: AtomicBool::new(false),
Expand Down Expand Up @@ -190,7 +190,7 @@ impl Client {
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub fn encrypted_builder(
client_options: ClientOptions,
key_vault_namespace: crate::Namespace,
Expand All @@ -213,7 +213,7 @@ impl Client {

/// Whether commands sent via this client should be auto-encrypted.
pub(crate) async fn should_auto_encrypt(&self) -> bool {
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
{
let csfle = self.inner.csfle.read().await;
match *csfle {
Expand All @@ -225,13 +225,13 @@ impl Client {
None => false,
}
}
#[cfg(not(feature = "in-use-encryption-unstable"))]
#[cfg(not(feature = "in-use-encryption"))]
{
false
}
}

#[cfg(all(test, feature = "in-use-encryption-unstable"))]
#[cfg(all(test, feature = "in-use-encryption"))]
pub(crate) async fn mongocryptd_spawned(&self) -> bool {
self.inner
.csfle
Expand All @@ -241,7 +241,7 @@ impl Client {
.map_or(false, |cs| cs.exec().mongocryptd_spawned())
}

#[cfg(all(test, feature = "in-use-encryption-unstable"))]
#[cfg(all(test, feature = "in-use-encryption"))]
pub(crate) async fn has_mongocryptd_client(&self) -> bool {
self.inner
.csfle
Expand Down Expand Up @@ -549,7 +549,7 @@ impl Client {
&self.inner.topology
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) async fn primary_description(&self) -> Option<crate::sdam::ServerDescription> {
let start_time = Instant::now();
let timeout = self
Expand Down Expand Up @@ -578,7 +578,7 @@ impl Client {
}
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) async fn auto_encryption_opts(
&self,
) -> Option<tokio::sync::RwLockReadGuard<'_, csfle::options::AutoEncryptionOptions>> {
Expand Down
6 changes: 3 additions & 3 deletions src/client/auth/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,17 +456,17 @@ impl AwsCredential {
Ok(auth_header)
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) fn access_key(&self) -> &str {
&self.access_key_id
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) fn secret_key(&self) -> &str {
&self.secret_access_key
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) fn session_token(&self) -> Option<&str> {
self.session_token.as_deref()
}
Expand Down
12 changes: 6 additions & 6 deletions src/client/executor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
use bson::RawDocumentBuf;
use bson::{doc, RawBsonRef, RawDocument, Timestamp};
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
use futures_core::future::BoxFuture;
use once_cell::sync::Lazy;
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -621,7 +621,7 @@ impl Client {

#[allow(unused_mut)]
let mut message = Message::from_command(cmd, Some(request_id))?;
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
{
let guard = self.inner.csfle.read().await;
if let Some(ref csfle) = *guard {
Expand Down Expand Up @@ -781,7 +781,7 @@ impl Client {
})
.await;

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
let response = {
let guard = self.inner.csfle.read().await;
if let Some(ref csfle) = *guard {
Expand Down Expand Up @@ -812,7 +812,7 @@ impl Client {
}
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
fn auto_encrypt<'a>(
&'a self,
csfle: &'a super::csfle::ClientState,
Expand All @@ -828,7 +828,7 @@ impl Client {
})
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
fn auto_decrypt<'a>(
&'a self,
csfle: &'a super::csfle::ClientState,
Expand Down
4 changes: 2 additions & 2 deletions src/coll/action/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl<'a> Action for DropCollection<'a> {
async fn execute(mut self) -> Result<()> {
resolve_options!(self.cr, self.options, [write_concern]);

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
self.cr
.drop_aux_collections(self.options.as_ref(), self.session.as_deref_mut())
.await?;
Expand All @@ -24,7 +24,7 @@ impl<'a> Action for DropCollection<'a> {
}
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
impl<T> crate::Collection<T>
where
T: Send + Sync,
Expand Down
2 changes: 1 addition & 1 deletion src/coll/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ pub struct DropCollectionOptions {
/// Map of encrypted fields for the collection.
// Serialization is skipped because the server doesn't accept this option; it's needed for
// preprocessing. Deserialization needs to remain because it's used in test files.
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
#[serde(skip_serializing)]
pub encrypted_fields: Option<Document>,
}
Expand Down
8 changes: 4 additions & 4 deletions src/db/action/create_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<'a> Action for CreateCollection<'a> {
coll: self.name,
};

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
let has_encrypted_fields = {
self.db
.resolve_encrypted_fields(&ns, &mut self.options)
Expand All @@ -38,7 +38,7 @@ impl<'a> Action for CreateCollection<'a> {
.execute_operation(create, self.session.as_deref_mut())
.await?;

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
if has_encrypted_fields {
use crate::action::Action;
use bson::{doc, Document};
Expand All @@ -56,7 +56,7 @@ impl<'a> Action for CreateCollection<'a> {
}

impl Database {
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
async fn resolve_encrypted_fields(
&self,
base_ns: &Namespace,
Expand All @@ -82,7 +82,7 @@ impl Database {
}
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
#[allow(clippy::needless_option_as_deref)]
async fn create_aux_collections(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/db/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ pub struct CreateCollectionOptions {
pub comment: Option<Bson>,

/// Map of encrypted fields for the created collection.
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub encrypted_fields: Option<Document>,
}

Expand Down
10 changes: 5 additions & 5 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl Error {
)
}

#[cfg(all(test, feature = "in-use-encryption-unstable"))]
#[cfg(all(test, feature = "in-use-encryption"))]
pub(crate) fn is_csfle_error(&self) -> bool {
matches!(self.kind.as_ref(), ErrorKind::Encryption(..))
}
Expand Down Expand Up @@ -372,7 +372,7 @@ impl Error {
ErrorKind::Transaction { message } => Some(message.clone()),
ErrorKind::IncompatibleServer { message } => Some(message.clone()),
ErrorKind::InvalidArgument { message } => Some(message.clone()),
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
ErrorKind::Encryption(err) => err.message.clone(),
_ => None,
}
Expand Down Expand Up @@ -533,7 +533,7 @@ impl Error {
| ErrorKind::Custom(_)
| ErrorKind::Shutdown
| ErrorKind::GridFs(_) => {}
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
ErrorKind::Encryption(_) => {}
}
}
Expand Down Expand Up @@ -580,7 +580,7 @@ impl From<std::io::ErrorKind> for ErrorKind {
}
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
impl From<mongocrypt::error::Error> for ErrorKind {
fn from(err: mongocrypt::error::Error) -> Self {
Self::Encryption(err)
Expand Down Expand Up @@ -693,7 +693,7 @@ pub enum ErrorKind {
MissingResumeToken,

/// An error occurred during encryption or decryption.
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
#[error("An error occurred during client-side encryption: {0}")]
Encryption(mongocrypt::error::Error),

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
pub mod options;

pub use ::bson;
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub use ::mongocrypt;

pub mod action;
Expand Down Expand Up @@ -55,7 +55,7 @@ mod test;
mod trace;
pub(crate) mod tracking_arc;

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub use crate::client::csfle::client_encryption;
pub use crate::{
client::{session::ClientSession, Client},
Expand Down
2 changes: 1 addition & 1 deletion src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub(crate) use find_and_modify::FindAndModify;
pub(crate) use get_more::GetMore;
pub(crate) use insert::Insert;
pub(crate) use list_indexes::ListIndexes;
#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) use raw_output::RawOutput;
pub(crate) use search_index::{CreateSearchIndexes, DropSearchIndex, UpdateSearchIndex};
pub(crate) use update::{Update, UpdateOrReplace};
Expand Down
2 changes: 1 addition & 1 deletion src/operation/run_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'conn> RunCommand<'conn> {
})
}

#[cfg(feature = "in-use-encryption-unstable")]
#[cfg(feature = "in-use-encryption")]
pub(crate) fn new_raw(
db: String,
command: RawDocumentBuf,
Expand Down
Loading