fix: make cargo check happy

This commit is contained in:
bestgopher
2024-12-04 20:47:28 +08:00
committed by weisd
parent d99086c5aa
commit a2fb252330
13 changed files with 22 additions and 33 deletions
+3 -2
View File
@@ -14,7 +14,7 @@ chacha20poly1305 = { version = "0.10.1", optional = true }
jsonwebtoken = "9.3.0" jsonwebtoken = "9.3.0"
pbkdf2 = { version = "0.12.2", optional = true } pbkdf2 = { version = "0.12.2", optional = true }
rand = { workspace = true, optional = true } rand = { workspace = true, optional = true }
sha2 = "0.10.8" sha2 = { version = "0.10.8", optional = true }
thiserror.workspace = true thiserror.workspace = true
serde_json.workspace = true serde_json.workspace = true
@@ -24,6 +24,7 @@ test-case.workspace = true
time.workspace = true time.workspace = true
[features] [features]
default = ["crypto", "fips"]
fips = [] fips = []
crypto = [ crypto = [
"dep:aes-gcm", "dep:aes-gcm",
@@ -31,8 +32,8 @@ crypto = [
"dep:chacha20poly1305", "dep:chacha20poly1305",
"dep:pbkdf2", "dep:pbkdf2",
"dep:rand", "dep:rand",
"dep:sha2",
] ]
default = ["crypto", "fips"]
[lints.clippy] [lints.clippy]
unwrap_used = "deny" unwrap_used = "deny"
+1 -1
View File
@@ -37,7 +37,7 @@ fn decryp<T: aes_gcm::aead::Aead>(stream: T, nonce: &[u8], data: &[u8]) -> Resul
.map_err(Error::ErrDecryptFailed) .map_err(Error::ErrDecryptFailed)
} }
#[cfg(all(not(test), not(feature = "crypto")))] #[cfg(not(any(test, feature = "crypto")))]
pub fn decrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> { pub fn decrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> {
Ok(data.to_vec()) Ok(data.to_vec())
} }
+1 -1
View File
@@ -55,7 +55,7 @@ fn encrypt<T: aes_gcm::aead::Aead>(
Ok(ciphertext) Ok(ciphertext)
} }
#[cfg(all(not(test), not(feature = "crypto")))] #[cfg(not(any(test, feature = "crypto")))]
pub fn encrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> { pub fn encrypt_data(_password: &[u8], data: &[u8]) -> Result<Vec<u8>, crate::Error> {
Ok(data.to_vec()) Ok(data.to_vec())
} }
+2 -3
View File
@@ -1,5 +1,3 @@
use sha2::digest::InvalidLength;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum Error { pub enum Error {
#[error("unexpected header")] #[error("unexpected header")]
@@ -8,8 +6,9 @@ pub enum Error {
#[error("invalid encryption algorithm ID: {0}")] #[error("invalid encryption algorithm ID: {0}")]
ErrInvalidAlgID(u8), ErrInvalidAlgID(u8),
#[cfg(any(test, feature = "crypto"))]
#[error("{0}")] #[error("{0}")]
ErrInvalidLength(#[from] InvalidLength), ErrInvalidLength(#[from] sha2::digest::InvalidLength),
#[cfg(any(test, feature = "crypto"))] #[cfg(any(test, feature = "crypto"))]
#[error("encrypt failed")] #[error("encrypt failed")]
+1 -2
View File
@@ -2,7 +2,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{json, Value}; use serde_json::{json, Value};
use std::cell::LazyCell; use std::cell::LazyCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::env::var;
use time::format_description::BorrowedFormatItem; use time::format_description::BorrowedFormatItem;
use time::{Date, OffsetDateTime}; use time::{Date, OffsetDateTime};
@@ -103,7 +102,7 @@ impl Credentials {
Self::check_key_value(header) Self::check_key_value(header)
} }
pub fn check_key_value(header: CredentialHeader) -> crate::Result<Self> { pub fn check_key_value(_header: CredentialHeader) -> crate::Result<Self> {
todo!() todo!()
} }
+4 -4
View File
@@ -93,7 +93,7 @@ impl CacheInner {
self.users.get(user_name).or_else(|| self.sts_accounts.get(user_name)) self.users.get(user_name).or_else(|| self.sts_accounts.get(user_name))
} }
fn get_policy(&self, name: &str, groups: &[String]) -> crate::Result<Vec<Policy>> { fn get_policy(&self, _name: &str, _groups: &[String]) -> crate::Result<Vec<Policy>> {
todo!() todo!()
} }
@@ -126,13 +126,13 @@ impl CacheInner {
} }
// todo // todo
pub fn is_allowed_sts(&self, args: &Args, parent: &str) -> bool { pub fn is_allowed_sts(&self, _args: &Args, _parent: &str) -> bool {
warn!("unimplement is_allowed_sts"); warn!("unimplement is_allowed_sts");
false false
} }
// todo // todo
pub fn is_allowed_service_account(&self, args: &Args, parent: &str) -> bool { pub fn is_allowed_service_account(&self, _args: &Args, _parent: &str) -> bool {
warn!("unimplement is_allowed_sts"); warn!("unimplement is_allowed_sts");
false false
} }
@@ -141,7 +141,7 @@ impl CacheInner {
todo!() todo!()
} }
pub fn policy_db_get(&self, name: &str, groups: &[String]) -> Vec<String> { pub fn policy_db_get(&self, _name: &str, _groups: &[String]) -> Vec<String> {
todo!() todo!()
} }
} }
-2
View File
@@ -1,5 +1,3 @@
use core::error;
use crate::policy; use crate::policy;
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
+6 -7
View File
@@ -1,13 +1,12 @@
use std::{borrow::Cow, collections::HashMap, f32::NAN}; use std::{borrow::Cow, collections::HashMap};
use log::{info, warn}; use log::{info, warn};
use time::OffsetDateTime;
use crate::{ use crate::{
arn::ARN, arn::ARN,
auth::{Credentials, UserIdentity}, auth::UserIdentity,
cache::{Cache, CacheInner}, cache::CacheInner,
policy::{utils::get_values_from_claims, Args, MappedPolicy, Policy, UserType}, policy::{utils::get_values_from_claims, Args, Policy},
store::Store, store::Store,
Error, Error,
}; };
@@ -36,7 +35,7 @@ where
.or_else(|| self.cache.sts_accounts.get(user_name)) .or_else(|| self.cache.sts_accounts.get(user_name))
} }
async fn get_policy(&self, name: &str, groups: &[String]) -> crate::Result<Vec<String>> { async fn get_policy(&self, name: &str, _groups: &[String]) -> crate::Result<Vec<String>> {
if name.is_empty() { if name.is_empty() {
return Err(Error::InvalidArgument); return Err(Error::InvalidArgument);
} }
@@ -122,7 +121,7 @@ where
false false
} }
pub async fn get_combined_policy(&self, policyes: &[String]) -> Policy { pub async fn get_combined_policy(&self, _policies: &[String]) -> Policy {
todo!() todo!()
} }
-2
View File
@@ -1,5 +1,3 @@
use std::default;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use strum::{EnumString, IntoStaticStr}; use strum::{EnumString, IntoStaticStr};
+1 -2
View File
@@ -1,7 +1,6 @@
use std::{collections::HashMap, ops::Deref}; use std::{collections::HashMap, ops::Deref};
use func::Func; use func::Func;
use key::Key;
use serde::{de, Deserialize, Serialize}; use serde::{de, Deserialize, Serialize};
pub mod addr; pub mod addr;
@@ -56,7 +55,7 @@ impl<'de> Deserialize<'de> for Functions {
return Err(A::Error::custom("invalid codition")); return Err(A::Error::custom("invalid codition"));
} }
let Some(name) = name else { return Err(A::Error::custom("invalid codition")) }; let Some(_name) = name else { return Err(A::Error::custom("invalid codition")) };
let f = match qualifier { let f = match qualifier {
Some("ForAnyValues") => Func::ForAnyValues, Some("ForAnyValues") => Func::ForAnyValues,
-2
View File
@@ -1,5 +1,3 @@
use std::borrow::Cow;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use super::{action::Action, ActionSet, Args, Effect, Error, Functions, ResourceSet, Validator, ID}; use super::{action::Action, ActionSet, Args, Effect, Error, Functions, ResourceSet, Validator, ID};
-2
View File
@@ -1,5 +1,3 @@
use std::{fmt::Write, usize};
struct LazyBuf<'a> { struct LazyBuf<'a> {
s: &'a str, s: &'a str,
buf: Option<Vec<u8>>, buf: Option<Vec<u8>>,
+3 -3
View File
@@ -6,14 +6,14 @@ use ecstore::{
store_api::{HTTPRangeSpec, ObjectIO, ObjectInfo, ObjectOptions, PutObjReader}, store_api::{HTTPRangeSpec, ObjectIO, ObjectInfo, ObjectOptions, PutObjReader},
utils::path::dir, utils::path::dir,
}; };
use futures::{future::try_join_all, SinkExt}; use futures::future::try_join_all;
use log::debug; use log::debug;
use serde::{de::DeserializeOwned, Serialize}; use serde::{de::DeserializeOwned, Serialize};
use super::Store; use super::Store;
use crate::{ use crate::{
auth::UserIdentity, auth::UserIdentity,
cache::{Cache, CacheEntity, CacheInner}, cache::{Cache, CacheEntity},
policy::{utils::split_path, MappedPolicy, PolicyDoc, UserType}, policy::{utils::split_path, MappedPolicy, PolicyDoc, UserType},
Error, Error,
}; };
@@ -102,7 +102,7 @@ impl ObjectStore {
Ok(Some(user)) Ok(Some(user))
} }
async fn load_mapped_policy(&self, user_type: UserType, name: &str, is_group: bool) -> crate::Result<MappedPolicy> { async fn load_mapped_policy(&self, user_type: UserType, name: &str, _is_group: bool) -> crate::Result<MappedPolicy> {
let (p, _) = self let (p, _) = self
.load_iam_config::<MappedPolicy>(&format!("{base}{name}.json", base = user_type.prefix(), name = name)) .load_iam_config::<MappedPolicy>(&format!("{base}{name}.json", base = user_type.prefix(), name = name))
.await?; .await?;