Skip to content

Commit

Permalink
ci: clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bittermandel committed Sep 25, 2024
1 parent b815b37 commit 621664a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Setup FoundationDB
Expand Down Expand Up @@ -43,6 +44,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
checks: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Install Rust
Expand Down
4 changes: 2 additions & 2 deletions crates/valv/src/api/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::sync::Arc;

use crate::{
valv::valv::v1::{
valv::proto::v1::{
master_key_management_service_server::MasterKeyManagementService, CreateMasterKeyRequest,
CreateMasterKeyResponse, CreateMasterKeyVersionRequest, CreateMasterKeyVersionResponse,
DecryptRequest, DecryptResponse, DestroyMasterKeyVersionRequest,
Expand Down Expand Up @@ -97,7 +97,7 @@ impl MasterKeyManagementService for API {
)
.await;

let reply = crate::valv::valv::v1::EncryptResponse {
let reply = crate::valv::proto::v1::EncryptResponse {
name: request.get_ref().master_key_id.clone(),
ciphertext: encrypted_value.into(),
};
Expand Down
2 changes: 1 addition & 1 deletion crates/valv/src/cmd/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use clap::Parser;
use secrecy::{ExposeSecret, Secret};
use tonic::transport::Server;
use valv::{
api, valv::valv::v1::master_key_management_service_server::MasterKeyManagementServiceServer,
api, valv::proto::v1::master_key_management_service_server::MasterKeyManagementServiceServer,
Valv,
};

Expand Down
17 changes: 8 additions & 9 deletions crates/valv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod storage;
mod tests;

pub mod valv {
pub mod valv {
pub mod proto {
pub mod v1 {
include!("gen/valv.v1.rs");
}
Expand Down Expand Up @@ -127,10 +127,9 @@ impl ValvAPI for Valv {
nanos: chrono::Utc::now().timestamp_subsec_nanos() as i32,
}),
rotation_schedule: Some(prost_types::Duration {
seconds: chrono::TimeDelta::days(30).num_seconds() as i64,
seconds: chrono::TimeDelta::days(30).num_seconds(),
nanos: 0,
}),
..Default::default()
};

self.db
Expand Down Expand Up @@ -203,9 +202,9 @@ impl ValvAPI for Valv {
let decrypted_key_material = boring::symm::decrypt_aead(
boring::symm::Cipher::aes_256_gcm(),
self.master_key.expose_secret(),
Some(&iv),
Some(iv),
&[],
&cipher,
cipher,
tag,
)
.expect("Failed to decrypt key material");
Expand Down Expand Up @@ -270,19 +269,19 @@ impl ValvAPI for Valv {
let decrypted_key_material = boring::symm::decrypt_aead(
boring::symm::Cipher::aes_256_gcm(),
self.master_key.expose_secret(),
Some(&kv_iv),
Some(kv_iv),
&[],
&kv_cipher,
kv_cipher,
kv_tag,
)
.expect("Failed to decrypt key material");

boring::symm::decrypt_aead(
boring::symm::Cipher::aes_256_gcm(),
&decrypted_key_material,
Some(&iv),
Some(iv),
&[],
&cipher,
cipher,
tag,
)
}
Expand Down
15 changes: 6 additions & 9 deletions crates/valv/src/storage/fdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl FoundationDB {
let tenant_subspace = directory
.create_or_open(
// the transaction used to read/write the directory.
&trx,
trx,
// the path used, which can view as a UNIX path like `/app/my-app`.
&path, // do not use any custom prefix or layer
None, None,
Expand All @@ -51,8 +51,7 @@ impl FoundationDB {

let path = vec![String::from(key_id), String::from("metadata")];

let key = tenant_subspace.pack(&path).unwrap();
return key;
tenant_subspace.pack(&path).unwrap()
}

// Key structure
Expand All @@ -75,7 +74,7 @@ impl FoundationDB {
let tenant_subspace = directory
.create_or_open(
// the transaction used to read/write the directory.
&trx,
trx,
// the path used, which can view as a UNIX path like `/app/my-app`.
&path, // do not use any custom prefix or layer
None, None,
Expand All @@ -89,9 +88,7 @@ impl FoundationDB {
version.to_string(),
];

let key = tenant_subspace.pack(&path).unwrap();

return key;
tenant_subspace.pack(&path).unwrap()
}
}

Expand Down Expand Up @@ -148,7 +145,7 @@ impl ValvStorage for FoundationDB {
continue;
}

let key = internal::Key::decode(&key_value.value()[..]).expect("Failed to decode key");
let key = internal::Key::decode(key_value.value()).expect("Failed to decode key");
keys.push(key);
}

Expand Down Expand Up @@ -226,7 +223,7 @@ impl ValvStorage for FoundationDB {
let mut key_versions: Vec<internal::KeyVersion> = vec![];

for key_value in key_values.iter() {
let test: Vec<u8> = unpack(&key_value.value()).expect("Failed to unpack key value");
let test: Vec<u8> = unpack(key_value.value()).expect("Failed to unpack key value");
let version =
internal::KeyVersion::decode(&test[..]).expect("Failed to decode key version");
key_versions.push(version);
Expand Down
4 changes: 2 additions & 2 deletions crates/valv/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
mod tests {
use crate::{
api::server::API,
valv::valv::v1::{
valv::proto::v1::{
master_key_management_service_server::MasterKeyManagementServiceServer,
CreateMasterKeyRequest, DecryptRequest, EncryptRequest, MasterKey,
},
Expand All @@ -12,7 +12,7 @@ mod tests {
use std::{sync::Arc, time::Duration};
use tonic::transport::Server;

use crate::valv::valv::v1::master_key_management_service_client::MasterKeyManagementServiceClient;
use crate::valv::proto::v1::master_key_management_service_client::MasterKeyManagementServiceClient;
use tokio::time::sleep;

const SERVER_ADDR: &str = "0.0.0.0:8080";
Expand Down

0 comments on commit 621664a

Please sign in to comment.