Skip to content
Draft
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 .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
cloudproof_rust:
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof.yml@develop
uses: Cosmian/reusable_workflows/.github/workflows/cloudproof.yml@fix/cloudproof
with:
project-name: cloudproof_rust
toolchain: stable
Expand Down
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ name: CI checks
on: push

jobs:
cargo-nursery-base:
uses: Cosmian/reusable_workflows/.github/workflows/cargo-nursery-base.yml@develop
with:
toolchain: stable
exclusions: --exclude=cloudproof_findex

cargo-doc:
uses: Cosmian/reusable_workflows/.github/workflows/cargo-doc.yml@develop
with:
Expand Down
8 changes: 2 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,9 @@ repos:
rev: v1.0.24
hooks:
# - id: dprint-toml-fix
# - id: cargo-upgrade
# - id: cargo-update
- id: stable-cargo-format
- id: cargo-upgrade
- id: cargo-update
- id: cargo-audit-deny-warnings
- id: cargo-outdated
- id: cargo-udeps
args: [--exclude=cloudproof_findex]
- id: cargo-machete
- id: docker-compose-up
- id: cargo-tests-all
Expand Down
6 changes: 3 additions & 3 deletions crates/aesgcm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// The `cloudproof_rust` subcrate `aesgcm` brings the standard AES256 GCM
/// implementation which has been audited by the NCC Group, with no significant
/// findings. Refer to <https://research.nccgroup.com/2020/02/26/public-report-rustcrypto-aes-gcm-and-chacha20poly1305-implementation-review/>
//! The `cloudproof_rust` subcrate `aesgcm` brings the standard AES256 GCM
//! implementation which has been audited by the NCC Group, with no significant
//! findings. Refer to <https://research.nccgroup.com/2020/02/26/public-report-rustcrypto-aes-gcm-and-chacha20poly1305-implementation-review/>

#[cfg(feature = "ffi")]
pub mod ffi;
Expand Down
1 change: 1 addition & 0 deletions crates/aesgcm/src/wasm_bindgen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod aesgcm;

#[allow(dead_code)]
#[cfg(test)]
mod tests;
3 changes: 3 additions & 0 deletions crates/anonymization/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ wasm = ["js-sys", "wasm-bindgen"]
[package.metadata.cargo-udeps.ignore]
normal = ["js-sys", "wasm-bindgen"]

[package.metadata.cargo-machete]
ignored = ["tiny-keccak"]

[dependencies]
argon2 = "0.5"
base64 = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/anonymization/src/core/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ impl DateAggregator {
///
/// * `time_unit`: The unit of time to round the date to.
#[must_use]
pub fn new(time_unit: TimeUnit) -> Self {
pub const fn new(time_unit: TimeUnit) -> Self {
Self { time_unit }
}

Expand Down
2 changes: 1 addition & 1 deletion crates/anonymization/src/ffi/tests.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[test]
fn ffi_anonymization() {}
const fn ffi_anonymization() {}
2 changes: 1 addition & 1 deletion crates/anonymization/src/pyo3/py_number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub struct NumberScaler(NumberScalerRust);
#[pymethods]
impl NumberScaler {
#[new]
pub fn new(mean: f64, std_dev: f64, scale: f64, translation: f64) -> Self {
pub const fn new(mean: f64, std_dev: f64, scale: f64, translation: f64) -> Self {
Self(NumberScalerRust::new(mean, std_dev, scale, translation))
}

Expand Down
4 changes: 3 additions & 1 deletion crates/anonymization/src/wasm_bindgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ macro_rules! wasm_unwrap {
mod hash;
mod noise;
mod number;
mod word;

#[allow(dead_code)]
#[cfg(test)]
mod tests;
mod word;
2 changes: 1 addition & 1 deletion crates/cloudproof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ doctest = false
[features]
findex-redis = ["cloudproof_findex/redis-interface"]
findex-sqlite = ["cloudproof_findex/sqlite-interface"]
findex-rest = ["cloudproof_findex/rest-interface"]
default = [
"cloudproof_aesgcm/default",
"cloudproof_anonymization/default",
Expand Down Expand Up @@ -59,4 +60,3 @@ cloudproof_ecies = { version = "0.1.4", optional = true }
cloudproof_findex = { version = "6.0.2", optional = true }
cloudproof_fpe = { version = "0.2.2", optional = true }
######
cosmian_crypto_core = { workspace = true, features = ["default"] }
2 changes: 1 addition & 1 deletion crates/cover_crypt/src/ffi/hybrid_cc_aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ pub unsafe extern "C" fn h_decrypt_header(
#[no_mangle]
///
/// # Safety
pub unsafe extern "C" fn h_symmetric_encryption_overhead() -> i32 {
pub const unsafe extern "C" fn h_symmetric_encryption_overhead() -> i32 {
(Aes256Gcm::NONCE_LENGTH + Aes256Gcm::MAC_LENGTH) as i32
}

Expand Down
2 changes: 1 addition & 1 deletion crates/cover_crypt/src/pyo3/py_abe_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl PolicyAxis {
///
/// Returns:
/// bool
pub fn is_hierarchical(&self) -> bool {
pub const fn is_hierarchical(&self) -> bool {
self.0.hierarchical
}

Expand Down
1 change: 1 addition & 0 deletions crates/cover_crypt/src/wasm_bindgen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ mod abe_policy;
mod generate_cc_keys;
mod hybrid_cc_aes;

#[allow(dead_code)]
#[cfg(test)]
mod tests;
2 changes: 1 addition & 1 deletion crates/ecies/src/ffi/ecies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub unsafe extern "C" fn h_ecies_salsa_seal_box_encrypt(
}

#[no_mangle]
pub unsafe extern "C" fn h_ecies_salsa_seal_box_get_encryption_overhead() -> u32 {
pub const unsafe extern "C" fn h_ecies_salsa_seal_box_get_encryption_overhead() -> u32 {
EciesSalsaSealBox::ENCRYPTION_OVERHEAD as u32
}

Expand Down
1 change: 1 addition & 0 deletions crates/ecies/src/wasm_bindgen/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod ecies;

#[allow(dead_code)]
#[cfg(test)]
mod tests;
16 changes: 8 additions & 8 deletions crates/findex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ doctest = false

[features]
# Actual user features.
default = []
default = ["rest-interface"]

# Meta features implicitly activated.
serialization = []

ffi = [
"redis-interface",
"findex-cloud",
"rest-interface",
"cosmian_ffi_utils",
"lazy_static",
Expand All @@ -37,6 +38,7 @@ ffi = [

python = [
"redis-interface",
"findex-cloud",
"rest-interface",
"sqlite-interface",
"futures",
Expand All @@ -45,6 +47,7 @@ python = [
]

wasm = [
"findex-cloud",
"rest-interface",
"js-sys",
"log",
Expand All @@ -56,12 +59,8 @@ wasm = [
]

redis-interface = ["redis"]
rest-interface = [
"base64",
"cosmian_crypto_core/ser",
"reqwest",
"serialization",
]
findex-cloud = ["base64", "cosmian_crypto_core/ser", "reqwest", "serialization"]
rest-interface = ["base64", "cosmian_crypto_core/ser", "reqwest", "serialization"]
sqlite-interface = ["rusqlite"]

[dependencies]
Expand All @@ -71,7 +70,8 @@ async-trait = { workspace = true }
base64 = { workspace = true, optional = true }
cosmian_crypto_core = { workspace = true }
cosmian_ffi_utils = { workspace = true, optional = true }
cosmian_findex = "6.0.0"
cosmian_findex = { git = "https://www.github.com/Cosmian/findex", branch = "fix/missing_some_structs_serialization" }
# cosmian_findex = { path = "../../../findex" }
futures = { version = "0.3.30", optional = true }
js-sys = { workspace = true, optional = true }
lazy_static = { version = "1.4.0", optional = true }
Expand Down
20 changes: 15 additions & 5 deletions crates/findex/python/cloudproof_findex/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ class AuthorizationToken:
class Findex:
@staticmethod
def new_with_sqlite_interface(
key: Key, label: str, entry_path: str, chain_path: Optional[str]=None
key: Key, label: str, entry_path: str, chain_path: Optional[str] = None
) -> Findex:
"""Instantiate a new Findex instance using an SQLite interface.

Expand All @@ -198,16 +198,26 @@ class Findex:
"""
@staticmethod
def new_with_redis_interface(
key: Key, label: str, entry_url: str, chain_url: Optional[str]=None
key: Key, label: str, entry_url: str, chain_url: Optional[str] = None
) -> Findex:
"""Instantiate a new Findex instance using a Redis interface.

Returns:
Findex
"""
@staticmethod
def new_with_rest_interface(label: str, token: str, entry_url: str,
chain_url: Optional[str]=None) -> Findex:
def new_with_findex_cloud_interface(
label: str, token: str, entry_url: str, chain_url: Optional[str] = None
) -> Findex:
"""Instantiate a new Findex instance using a REST interface.

Returns:
Findex
"""
@staticmethod
def new_with_rest_interface(
key: Key, label: str, entry_url: str, chain_url: Optional[str] = None
) -> Findex:
"""Instantiate a new Findex instance using a REST interface.

Returns:
Expand All @@ -218,7 +228,7 @@ class Findex:
key: Key,
label: str,
entry_callbacks: PythonCallbacks,
chain_callbacks: Optional[PythonCallbacks]=None,
chain_callbacks: Optional[PythonCallbacks] = None,
) -> Findex:
"""Instantiate a new Findex instance using a custom interface.

Expand Down
24 changes: 16 additions & 8 deletions crates/findex/python/tests/findex_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def upsert(old_values: dict, new_values: dict):
if old_value == current_value:
table[uid] = new_value
elif not current_value:
raise ValueError('The current value needs to be defined as long as the old value is defined ')
raise ValueError(
'The current value needs to be defined as long as the old value is defined '
)
else:
res[uid] = current_value
return res
Expand Down Expand Up @@ -187,7 +189,7 @@ class TestFindex(unittest.TestCase):
def setUp(self) -> None:
# Create structures needed by Findex
self.findex_key = Key.random()
self.label = "My label."
self.label = 'My label.'

self.db = {
1: ['Martin', 'Sheperd'],
Expand Down Expand Up @@ -238,11 +240,17 @@ def setUp(self) -> None:
self.label,
redis_url,
),
'rest': Findex.new_with_rest_interface(self.label,
str(token),
rest_server_url),
'findex-cloud': Findex.new_with_findex_cloud_interface(
self.label, str(token), rest_server_url
),
'rest': Findex.new_with_findex_cloud_interface(
self.label, str(token), rest_server_url
),
'custom': Findex.new_with_custom_interface(
self.findex_key, self.label, in_memory_db_interface, in_memory_db_interface
self.findex_key,
self.label,
in_memory_db_interface,
in_memory_db_interface,
),
}

Expand Down Expand Up @@ -343,9 +351,9 @@ def test_compact(self) -> None:
instance.add(indexed_values_and_keywords)

# removing 2nd db line
new_label = "My renewed label"
new_label = 'My renewed label'

filtered_locations = { Location.from_int(2) }
filtered_locations = {Location.from_int(2)}

def filter_obsolete_data(dataset: Set[Location]):
res = set()
Expand Down
2 changes: 1 addition & 1 deletion crates/findex/src/db_interfaces/custom/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ macro_rules! impl_custom_backend {
($backend_type:ident, $callback_type:ident, $value_length:ident) => {
impl $backend_type {
#[must_use]
pub fn new(backend: $callback_type) -> Self {
pub const fn new(backend: $callback_type) -> Self {
Self(backend)
}
}
Expand Down
24 changes: 17 additions & 7 deletions crates/findex/src/db_interfaces/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ use wasm_bindgen::JsCast;
#[cfg(feature = "wasm")]
use wasm_bindgen::JsValue;

#[cfg(any(feature = "rest-interface", feature = "wasm", feature = "ffi"))]
#[cfg(any(
feature = "findex-cloud",
feature = "rest-interface",
feature = "wasm",
feature = "ffi"
))]
use crate::ser_de::SerializationError;

#[derive(Debug)]
Expand All @@ -30,11 +35,11 @@ pub enum DbInterfaceError {
Ffi(String, ErrorCode),
#[cfg(feature = "python")]
Python(String),
#[cfg(feature = "rest-interface")]
#[cfg(feature = "findex-cloud")]
MalformedToken(String),
#[cfg(feature = "wasm")]
Wasm(String),
#[cfg(feature = "rest-interface")]
#[cfg(feature = "findex-cloud")]
MissingPermission(i32),
Findex(FindexCoreError),
CryptoCore(CryptoCoreError),
Expand All @@ -55,13 +60,13 @@ impl Display for DbInterfaceError {
Self::MissingCallback(err) => write!(f, "unknown callback: {err}"),
#[cfg(feature = "ffi")]
Self::Ffi(err, code) => write!(f, "{err}: {code}"),
#[cfg(feature = "rest-interface")]
#[cfg(feature = "findex-cloud")]
Self::MalformedToken(err) => write!(f, "{err}"),
#[cfg(feature = "python")]
Self::Python(err) => write!(f, "{err}"),
#[cfg(feature = "wasm")]
Self::Wasm(err) => write!(f, "wasm callback error: {err}"),
#[cfg(feature = "rest-interface")]
#[cfg(feature = "findex-cloud")]
Self::MissingPermission(err) => write!(f, "missing permission: {err}"),
Self::CryptoCore(err) => write!(f, "crypto_core: {err}"),
Self::Findex(err) => write!(f, "findex: {err}"),
Expand Down Expand Up @@ -92,7 +97,12 @@ impl From<RedisError> for DbInterfaceError {
}
}

#[cfg(any(feature = "rest-interface", feature = "wasm", feature = "ffi"))]
#[cfg(any(
feature = "findex-cloud",
feature = "rest-interface",
feature = "wasm",
feature = "ffi"
))]
impl From<SerializationError> for DbInterfaceError {
fn from(e: SerializationError) -> Self {
Self::Serialization(e.to_string())
Expand All @@ -105,7 +115,7 @@ impl From<TryFromIntError> for DbInterfaceError {
}
}

#[cfg(feature = "rest-interface")]
#[cfg(any(feature = "findex-cloud", feature = "rest-interface"))]
impl From<TryFromSliceError> for DbInterfaceError {
fn from(e: TryFromSliceError) -> Self {
Self::SliceConversion(e)
Expand Down
Loading