Skip to content
Open
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ members = ["crates/*"]
# Update using `cargo set-version -p bitwarden <new-version>`
version = "1.0.0"
authors = ["Bitwarden Inc"]
edition = "2021"
edition = "2024"
# Note: Changing rust-version should be considered a breaking change
rust-version = "1.85"
homepage = "https://bitwarden.com"
Expand Down
12 changes: 6 additions & 6 deletions crates/bitwarden-c/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct CClient {
client: Client,
}

#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn run_command(c_str_ptr: *const c_char, client_ptr: *const CClient) -> *mut c_char {
let client = unsafe { ffi_ref!(client_ptr) };
let input_str = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr) }.to_bytes())
Expand All @@ -35,7 +35,7 @@ pub extern "C" fn run_command(c_str_ptr: *const c_char, client_ptr: *const CClie

type OnCompletedCallback = unsafe extern "C" fn(result: *mut c_char) -> ();

#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn run_command_async(
c_str_ptr: *const c_char,
client_ptr: *const CClient,
Expand Down Expand Up @@ -74,7 +74,7 @@ pub extern "C" fn run_command_async(
}

// Init client, potential leak! You need to call free_mem after this!
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut CClient {
// This will only fail if another logger was already initialized, so we can ignore the result
let _ = env_logger::try_init();
Expand All @@ -97,19 +97,19 @@ pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut CClient {
}

// Free mem
#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn free_mem(client_ptr: *mut CClient) {
std::mem::drop(unsafe { Box::from_raw(client_ptr) });
}

#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn abort_and_free_handle(join_handle_ptr: *mut tokio::task::JoinHandle<()>) {
let join_handle = unsafe { Box::from_raw(join_handle_ptr) };
join_handle.abort();
std::mem::drop(join_handle);
}

#[no_mangle]
#[unsafe(no_mangle)]
pub extern "C" fn free_handle(join_handle_ptr: *mut tokio::task::JoinHandle<()>) {
std::mem::drop(unsafe { Box::from_raw(join_handle_ptr) });
}
4 changes: 2 additions & 2 deletions crates/bitwarden-json/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Client {
let mut cmd_value: serde_json::Value = match serde_json::from_str(input_str) {
Ok(cmd) => cmd,
Err(e) => {
return Response::error(format!("Invalid command string: {}", e)).into_string()
return Response::error(format!("Invalid command string: {}", e)).into_string();
}
};

Expand All @@ -45,7 +45,7 @@ impl Client {
let cmd: Command = match serde_json::from_value(cmd_value) {
Ok(cmd) => cmd,
Err(e) => {
return Response::error(format!("Invalid command value: {}", e)).into_string()
return Response::error(format!("Invalid command value: {}", e)).into_string();
}
};

Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-wasm/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::rc::Rc;
use argon2::{Algorithm, Argon2, Params, Version};
use bitwarden_json::client::Client as JsonClient;
use js_sys::Promise;
use log::{set_max_level, Level};
use log::{Level, set_max_level};
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::future_to_promise;

Expand Down
4 changes: 2 additions & 2 deletions crates/bws/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{path::PathBuf, str::FromStr};
use bitwarden::auth::AccessToken;
use clap::CommandFactory;
use clap_complete::Shell;
use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};

use crate::{config, util, Cli, ProfileKey};
use crate::{Cli, ProfileKey, config, util};

pub(crate) fn completions(shell: Option<Shell>) -> Result<()> {
let Some(shell) = shell.or_else(Shell::from_env) else {
Expand Down
8 changes: 4 additions & 4 deletions crates/bws/src/command/project.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use bitwarden::{
Client,
secrets_manager::{
ClientProjectsExt,
projects::{
ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest,
ProjectsListRequest,
},
ClientProjectsExt,
},
Client,
};
use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use uuid::Uuid;

use crate::{
render::{serialize_response, OutputSettings},
ProjectCommand,
render::{OutputSettings, serialize_response},
};

pub(crate) async fn process_command(
Expand Down
13 changes: 8 additions & 5 deletions crates/bws/src/command/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ use std::{
};

use bitwarden::{
Client,
secrets_manager::{
secrets::{SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretsGetRequest},
ClientSecretsExt,
secrets::{SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretsGetRequest},
},
Client,
};
use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use itertools::Itertools;
use uuid::Uuid;
use which::which;

use crate::{
util::{is_valid_posix_name, uuid_to_posix},
ACCESS_TOKEN_KEY_VAR_NAME,
util::{is_valid_posix_name, uuid_to_posix},
};

// Essential environment variables that should be preserved even when `--no-inherit-env` is used
Expand Down Expand Up @@ -80,7 +80,10 @@ pub(crate) async fn run(

if !uuids_as_keynames {
if let Some(duplicate) = secrets.iter().map(|s| &s.key).duplicates().next() {
bail!("Multiple secrets with name: '{}'. Use --uuids-as-keynames or use unique names for secrets", duplicate);
bail!(
"Multiple secrets with name: '{}'. Use --uuids-as-keynames or use unique names for secrets",
duplicate
);
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/bws/src/command/secret.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use bitwarden::{
Client,
secrets_manager::{
ClientSecretsExt,
secrets::{
SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest,
SecretIdentifiersRequest, SecretPutRequest, SecretResponse, SecretsDeleteRequest,
SecretsGetRequest,
},
ClientSecretsExt,
},
Client,
};
use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use uuid::Uuid;

use crate::{
render::{serialize_response, OutputSettings},
SecretCommand,
render::{OutputSettings, serialize_response},
};

#[derive(Debug)]
Expand Down
4 changes: 2 additions & 2 deletions crates/bws/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use std::{
path::{Path, PathBuf},
};

use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use directories::BaseDirs;
use serde::{Deserialize, Serialize};

use crate::cli::{ProfileKey, DEFAULT_CONFIG_DIRECTORY, DEFAULT_CONFIG_FILENAME};
use crate::cli::{DEFAULT_CONFIG_DIRECTORY, DEFAULT_CONFIG_FILENAME, ProfileKey};

#[derive(Debug, Serialize, Deserialize, Default)]
pub(crate) struct Config {
Expand Down
9 changes: 6 additions & 3 deletions crates/bws/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::{path::PathBuf, str::FromStr};

use bitwarden::{
auth::{login::AccessTokenLoginRequest, AccessToken},
ClientSettings,
auth::{AccessToken, login::AccessTokenLoginRequest},
};
use bitwarden_cli::install_color_eyre;
use clap::{CommandFactory, Parser};
use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use config::Profile;
use log::error;
use render::OutputSettings;
Expand Down Expand Up @@ -94,7 +94,10 @@ async fn process_commands() -> Result<()> {
) {
Ok(state_file) => Some(state_file),
Err(e) => {
eprintln!("Warning: {}\nRetrieving the state file failed. Attempting to continue without using state. Please set \"state_dir\" in your config file to avoid authentication limits.", e);
eprintln!(
"Warning: {}\nRetrieving the state file failed. Attempting to continue without using state. Please set \"state_dir\" in your config file to avoid authentication limits.",
e
);
None
}
},
Expand Down
2 changes: 1 addition & 1 deletion crates/bws/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::path::PathBuf;

use color_eyre::eyre::{bail, Result};
use color_eyre::eyre::{Result, bail};
use directories::BaseDirs;

use crate::DEFAULT_CONFIG_DIRECTORY;
Expand Down
2 changes: 1 addition & 1 deletion crates/fake-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use axum::{
Router,
response::Json,
routing::{get, post, put},
Router,
};
use tower_http::{cors::CorsLayer, trace::TraceLayer};

Expand Down
2 changes: 1 addition & 1 deletion crates/fake-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::Result;
use fake_server::create_app;
use tokio::net::TcpListener;
use tracing::{info, level_filters::LevelFilter};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};
use tracing_subscriber::{EnvFilter, fmt, prelude::*};

#[tokio::main]
async fn main() -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions crates/fake-server/src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// This module organizes routes into separate modules by feature

use axum::{
Form,
extract::{Path, Query},
response::Json,
Form,
};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use serde_json::{Value, json};
use tracing::info;
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion crates/sdk-schemas/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{fs::File, io::Write};

use anyhow::Result;
use schemars::{schema::RootSchema, schema_for, JsonSchema};
use schemars::{JsonSchema, schema::RootSchema, schema_for};

/// Creates a json schema file for any type passed in using Schemars. The filename and path of the
/// generated schema file is derived from the namespace passed into the macro or supplied as the
Expand Down
Loading
Loading