Skip to content

Commit

Permalink
Upgrade all dependencies to their latest version
Browse files Browse the repository at this point in the history
Also fix some recent clippy errors (but not on the PKCS11 provider which
might change soon).

Signed-off-by: Hugues de Valon <[email protected]>
  • Loading branch information
hug-dev committed Feb 22, 2021
1 parent 9a700b1 commit 509c4f2
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 190 deletions.
346 changes: 206 additions & 140 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,40 @@ path = "src/bin/main.rs"

[dependencies]
parsec-interface = "0.23.0"
rand = { version = "0.8.2", features = ["small_rng"], optional = true }
rand = { version = "0.8.3", features = ["small_rng"], optional = true }
base64 = "0.13.0"
uuid = "0.8.1"
uuid = "0.8.2"
threadpool = "1.8.1"
signal-hook = "0.3.4"
sd-notify = "0.1.1"
toml = "0.5.6"
serde = { version = "1.0.115", features = ["derive"] }
env_logger = "0.8.2"
log = { version = "0.4.11", features = ["serde"] }
sd-notify = "0.2.0"
toml = "0.5.8"
serde = { version = "1.0.123", features = ["derive"] }
env_logger = "0.8.3"
log = { version = "0.4.14", features = ["serde"] }
pkcs11 = { version = "0.5.0", optional = true }
picky-asn1-der = { version = "0.2.4", optional = true }
picky-asn1 = { version = "0.3.0", optional = true }
picky-asn1 = { version = "0.3.1", optional = true }
tss-esapi = { version = "4.0.10-alpha.2", optional = true }
bincode = "1.3.1"
structopt = "0.3.17"
derivative = "2.1.1"
structopt = "0.3.21"
derivative = "2.2.0"
version = "3.0.0"
hex = { version = "0.4.2", optional = true }
psa-crypto = { version = "0.7.0", default-features = false, features = ["operations"], optional = true }
zeroize = { version = "1.1.0", features = ["zeroize_derive"] }
zeroize = { version = "1.2.0", features = ["zeroize_derive"] }
picky-asn1-x509 = { version = "0.4.0", optional = true }
users = "0.11.0"
libc = "0.2.77"
anyhow = "1.0.32"
libc = "0.2.86"
anyhow = "1.0.38"
rust-cryptoauthlib = { version = "0.1.0", optional = true }
prost = { version = "0.6.1", optional = true }
prost = { version = "0.7.0", optional = true }

[dev-dependencies]
rand = { version = "0.8.2", features = ["small_rng"] }
rand = { version = "0.8.3", features = ["small_rng"] }

[build-dependencies]
bindgen = { version = "0.56.0", optional = true }
prost-build = { version = "0.6.1", optional = true }
bindgen = { version = "0.57.0", optional = true }
prost-build = { version = "0.7.0", optional = true }

[package.metadata.docs.rs]
features = ["pkcs11-provider", "tpm-provider", "tss-esapi/docs", "mbed-crypto-provider", "cryptoauthlib-provider"]
Expand Down
5 changes: 4 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ fn generate_proto_sources(contract_dir: String) -> Result<()> {
prost_build::compile_protos(&files_slices, &[&contract_dir])
}

#[cfg(feature = "trusted-service-provider")]
fn main() -> Result<()> {
#[cfg(feature = "trusted-service-provider")]
{
generate_proto_sources(String::from("trusted-services-vendor/protocols"))?;
generate_ts_bindings(String::from("trusted-services-vendor/components"))?;
}

Ok(())
}

#[cfg(not(feature = "trusted-service-provider"))]
fn main() {}
20 changes: 10 additions & 10 deletions e2e_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ edition = "2018"
publish = false

[dependencies]
serde = { version = "1.0.115", features = ["derive"] }
parsec-client = { git = "https://github.com/parallaxsecond/parsec-client-rust.git", rev = "06c52e2348ac55f46d240d2ab61a499effccffbd", features = ["testing"] }
log = "0.4.11"
rand = "0.7.3"
env_logger = "0.7.1"
serde = { version = "1.0.123", features = ["derive"] }
parsec-client = { git = "https://github.com/parallaxsecond/parsec-client-rust.git", rev = "8c02c93b5a1d2017e24eb706002559ed160e611a", features = ["testing"] }
log = "0.4.14"
rand = "0.8.3"
env_logger = "0.8.3"

[dev-dependencies]
ring = "0.16.15"
ring = "0.16.20"
rsa = "0.3.0"
picky-asn1-x509 = "0.3.2"
base64 = "0.12.3"
picky-asn1-x509 = "0.4.0"
base64 = "0.13.0"
num_cpus = "1.13.0"
picky-asn1-der = "0.2.4"
picky-asn1 = "0.3.0"
sha2 = "0.9.1"
picky-asn1 = "0.3.1"
sha2 = "0.9.3"

[features]
mbed-crypto-provider = []
Expand Down
5 changes: 3 additions & 2 deletions e2e_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use std::collections::HashSet;
use std::time::Duration;

const TEST_SOCKET_PATH: &str = "/tmp/parsec.sock";
const TEST_TIMEOUT: Duration = Duration::from_secs(1);
const TEST_TIMEOUT: Duration = Duration::from_secs(60);

/// Client structure automatically choosing a provider and high-level operation functions.
#[derive(Debug)]
Expand Down Expand Up @@ -60,7 +60,8 @@ impl TestClient {

let mut basic_client = BasicClient::new_naked();

let ipc_handler = unix_socket::Handler::new(TEST_SOCKET_PATH.into(), Some(TEST_TIMEOUT));
let ipc_handler =
unix_socket::Handler::new(TEST_SOCKET_PATH.into(), Some(TEST_TIMEOUT)).unwrap();
basic_client.set_ipc_handler(Box::from(ipc_handler));
basic_client.set_timeout(Some(Duration::from_secs(10)));

Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/src/raw_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const MAX_BODY_SIZE: usize = 1 << 31;
pub struct RawRequestClient;

static SOCKET_PATH: &str = "/tmp/parsec.sock";
const TIMEOUT: Duration = Duration::from_secs(5);
const TIMEOUT: Duration = Duration::from_secs(60);

#[allow(clippy::new_without_default)]
impl RawRequestClient {
Expand Down
11 changes: 5 additions & 6 deletions e2e_tests/src/stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use rand::{
thread_rng,
};
use std::convert::TryInto;
use std::iter;
use std::sync::mpsc::{channel, Receiver};
use std::thread;
use std::time::Duration;
Expand Down Expand Up @@ -39,10 +38,10 @@ pub struct StressTestConfig {
}

fn generate_string(size: usize) -> String {
let mut rng = thread_rng();
iter::repeat(())
.map(|()| rng.sample(Alphanumeric))
thread_rng()
.sample_iter(&Alphanumeric)
.take(size)
.map(char::from)
.collect()
}

Expand Down Expand Up @@ -165,7 +164,7 @@ impl StressTestWorker {

if let Some(mut interval) = self.config.req_interval {
if let Some(deviation) = self.config.req_interval_deviation_millis {
let dev = thread_rng().gen_range(0, 2 * deviation);
let dev = thread_rng().gen_range(0..2 * deviation);
interval += Duration::from_millis(dev.try_into().unwrap());
interval -= Duration::from_millis(deviation.try_into().unwrap());
}
Expand Down Expand Up @@ -376,7 +375,7 @@ impl ServiceChecker {

impl Distribution<Operation> for Standard {
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Operation {
match rng.gen_range(0, 10) {
match rng.gen_range(0..10) {
0 => Operation::CreateDestroyKey,
1 => Operation::Sign,
2 => Operation::Verify,
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/tests/all_providers/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ fn list_opcodes() {
client
.list_opcodes(ProviderID::CryptoAuthLib)
.expect("list providers failed"),
crypto_providers_cal
crypto_providers_cal
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/front/domain_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use anyhow::{Context, Result};
use listener::Listen;
use listener::{Connection, ConnectionMetadata};
use log::{error, warn};
use std::convert::TryInto;
use std::fs;
use std::fs::Permissions;
use std::io::{Error, ErrorKind};
Expand Down Expand Up @@ -74,7 +75,7 @@ impl DomainSocketListener {
let nfd = sd_notify::SD_LISTEN_FDS_START;
// Safe as listen_fds gives us the information that one file descriptor was
// received and its value starts from SD_LISTEN_FDS_START.
unsafe { UnixListener::from_raw_fd(nfd) }
unsafe { UnixListener::from_raw_fd(nfd.try_into()?) }
// Expect the socket created by systemd to be 666 on permissions.
}
n => {
Expand Down
6 changes: 3 additions & 3 deletions src/key_info_managers/on_disk_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::ffi::OsStr;
use std::fs;
use std::fs::{DirEntry, File};
use std::io::{Error, ErrorKind, Read, Write};
use std::path::PathBuf;
use std::path::{Path, PathBuf};

/// Default path where the mapping files will be stored on disk
pub const DEFAULT_MAPPINGS_PATH: &str = "/var/lib/parsec/mappings";
Expand Down Expand Up @@ -127,7 +127,7 @@ fn os_str_to_provider_id(os_str: &OsStr) -> std::io::Result<ProviderID> {
}

/// Lists all the directory paths in the given directory path.
fn list_dirs(path: &PathBuf) -> std::io::Result<Vec<PathBuf>> {
fn list_dirs(path: &Path) -> std::io::Result<Vec<PathBuf>> {
// read_dir returning an iterator over Result<DirEntry>, there is first a conversion to a path
// and then a check if the path is a directory or not.
let dir_entries: std::io::Result<Vec<DirEntry>> = path.read_dir()?.collect();
Expand All @@ -139,7 +139,7 @@ fn list_dirs(path: &PathBuf) -> std::io::Result<Vec<PathBuf>> {
}

/// Lists all the file paths in the given directory path.
fn list_files(path: &PathBuf) -> std::io::Result<Vec<PathBuf>> {
fn list_files(path: &Path) -> std::io::Result<Vec<PathBuf>> {
let dir_entries: std::io::Result<Vec<DirEntry>> = path.read_dir()?.collect();
Ok(dir_entries?
.iter()
Expand Down
13 changes: 5 additions & 8 deletions src/providers/tpm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ impl Provider {
fn new(
key_info_store: Arc<RwLock<dyn ManageKeyInfo + Send + Sync>>,
esapi_context: tss_esapi::TransientKeyContext,
) -> Option<Provider> {
Some(Provider {
) -> Provider {
Provider {
esapi_context: Mutex::new(esapi_context),
key_info_store,
})
}
}
}

Expand Down Expand Up @@ -324,7 +324,7 @@ impl ProviderBuilder {
})?;
self.tcti.zeroize();
self.owner_hierarchy_auth.zeroize();
Provider::new(
Ok(Provider::new(
self.key_info_store.ok_or_else(|| {
std::io::Error::new(ErrorKind::InvalidData, "missing key info store")
})?,
Expand All @@ -341,9 +341,6 @@ impl ProviderBuilder {
format_error!("Error creating TSS Transient Object Context", e);
std::io::Error::new(ErrorKind::InvalidData, "failed initializing TSS context")
})?,
)
.ok_or_else(|| {
std::io::Error::new(ErrorKind::InvalidData, "failed initializing TPM provider")
})
))
}
}
2 changes: 2 additions & 0 deletions src/utils/service_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ fn get_key_info_manager(config: &KeyInfoManagerConfig) -> Result<KeyInfoManager>
Ok(Arc::new(RwLock::new(manager)))
}

// Allowed to simplify the cfg blocks
#[allow(clippy::unnecessary_wraps)]
fn build_authenticators(config: &AuthenticatorConfig) -> Result<Vec<(AuthType, Authenticator)>> {
// The authenticators supported by the Parsec service.
// NOTE: order here is important. The order in which the elements are added here is the
Expand Down

0 comments on commit 509c4f2

Please sign in to comment.