diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6d2773d..f57cfd6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ Unless you explicitly state otherwise, any contribution intentionally submitted and [VSCode](https://code.visualstudio.com/docs/languages/rust#_formatting) 10. `cargo clippy --all --release` and fix any erorrs 11. **DON'T INCREASE THE VERSION NUMBER IN `Cargo.toml`, WE WILL DO THAN WHEN RELEASING** -12. Create a `git` `commit hook` file in `.git/hooks/pre-commit` with [this](hooks/linux-macos/pre-commit) content on `Linux` and `MacOS`, or [this](hooks/windows/pre-commit) on `Windows`. Make it executable in Linux and macO with `chmod +x .git/hooks/pre-commit` .This will run when you do `git commit` and will make the commit to be quite slow, but please give it time to complete as this helps to fix any issues locally and not relying just on running `ci` on GitHub when you create the PR +12. Create a `git` `commit hook` file in `.git/hooks/pre-commit` with [this](hooks/linux-macos/pre-commit) content on `Linux` and `MacOS`, and [this](hooks/windows/pre-commit) on `Windows`. Make it executable in Linux and macO with `chmod +x .git/hooks/pre-commit` .This will run when you do `git commit` and will make the commit to be quite slow, but please give it time to complete as this helps to fix any issues locally and not relying just on running `ci` on GitHub when you create the PR 13. Commit your changes and if there are any errors fix them before you push them 14. Push your changes and create a `PR` back to the `parent` repo targeting the `main` branch and request review from owners of the repository 15. Monitor the checks (GitHub actions runs) and fix the code if they are failing diff --git a/Cargo.lock b/Cargo.lock index 7be6dc9a..032a4fdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -454,6 +454,29 @@ dependencies = [ "piper", ] +[[package]] +name = "bon" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97493a391b4b18ee918675fb8663e53646fd09321c58b46afa04e8ce2499c869" +dependencies = [ + "bon-macros", + "rustversion", +] + +[[package]] +name = "bon-macros" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2af3eac944c12cdf4423eab70d310da0a8e5851a18ffb192c0a5e3f7ae1663" +dependencies = [ + "darling", + "ident_case", + "proc-macro2", + "quote", + "syn 2.0.77", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -664,6 +687,41 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "darling" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.77", +] + +[[package]] +name = "darling_macro" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.77", +] + [[package]] name = "deranged" version = "0.3.11" @@ -814,6 +872,12 @@ dependencies = [ "spin", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "fuse3" version = "0.7.2" @@ -1016,6 +1080,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "indexmap" version = "2.5.0" @@ -1622,6 +1692,7 @@ dependencies = [ "base64", "bincode", "blake3", + "bon", "bytes", "clap", "ctrlc", diff --git a/Cargo.toml b/Cargo.toml index f049116c..636d140c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ authors = ["Radu Marias "] homepage = "https://radumarias.github.io/rencfs" repository = "https://github.com/radumarias/rencfs" readme = "README.md" -keywords = ["filesystem", "fuse", "encryption", "system", "security"] +keywords = ["privacy", "filesystem", "encryption", "security", "cryptography"] categories = ["cryptography", "filesystem"] documentation = "https://docs.rs/rencfs" exclude = [".github/"] @@ -56,6 +56,7 @@ blake3 = "=0.1.3" thread_local = "1.1.8" subtle = "2.6.1" shush-rs = "0.1.10" +bon = "2.3.0" [target.'cfg(target_os = "linux")'.dependencies] fuse3 = { version = "0.7.2", features = ["tokio-runtime", "unprivileged"] } diff --git a/README.md b/README.md index 6747a722..535e7114 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -# rencfs +# [![](favicon.png)](https://github.com/radumarias/rencfs) rencfs [![rencfs-bin](https://img.shields.io/aur/version/rencfs-bin?color=1793d1&label=rencfs-bin&logo=arch-linux)](https://aur.archlinux.org/packages/rencfs-bin/) [![crates.io](https://img.shields.io/crates/v/rencfs.svg)](https://crates.io/crates/rencfs) [![docs.rs](https://img.shields.io/docsrs/rencfs?label=docs.rs)](https://docs.rs/rencfs/) -[![build-and-tests](https://github.com/radumarias/rencfs/actions/workflows/build_and_tests.yml/badge.svg)](https://github.com/radumarias/rencfs/actions/workflows/build_and_tests.yml) -[![release](https://github.com/radumarias/rencfs/actions/workflows/release.yml/badge.svg)](https://github.com/radumarias/rencfs/actions/workflows/release.yml) +[![build-and-tests](https://github.com/radumarias/rencfs/actions/workflows/build_and_tests.yaml/badge.svg)](https://github.com/radumarias/rencfs/actions/workflows/build_and_tests.yaml) +[![release](https://github.com/radumarias/rencfs/actions/workflows/release.yaml/badge.svg)](https://github.com/radumarias/rencfs/actions/workflows/release.yaml) [![codecov](https://codecov.io/gh/radumarias/rencfs/graph/badge.svg?token=NUQI6XGF2Y)](https://codecov.io/gh/radumarias/rencfs) [![Matrix](https://img.shields.io/matrix/rencfs%3Amatrix.org?label=Matrix)](https://matrix.to/#/#rencfs:matrix.org) @@ -42,28 +42,40 @@ There will be a [series](https://medium.com/@xorio42/list/828492b94c23) of artic It was [crate of the week](https://this-week-in-rust.org/blog/2024/08/14/this-week-in-rust-560/#crate-of-the-week) in Aug 2024. +# Talk + +[Slides](https://miro.com/app/board/uXjVLccxeCE=/?share_link_id=342563218323) from a talk, video to follow. + # Key features -- `Security` using well-known audited `AEAD` cryptography primitives -- `Data integrity`, data is written with `WAL` to ensure integrity even on crash or power loss -- Hide all data for enhanced `privacy`, all `metadata`, `content`, `file name`, `file size`, `*time` fields, `files count` are encrypted -- Safe manage of `credentials` in memory with `mlock(2)`, `mprotect`, `zeroize` and `expiry` -- `Performance`, `memory safety` and `optimized` for `concurrency` with Rust -- Simplicity -- Encryption key generated based on password -- Password saved in OS's `keyring` -- `Change password` without re-encrypting all data -- `Fast seek` on both reads and writes -- `Writes in parallel` -- Exposed with `FUSE` -- Fully `concurrent` for all operations +Some of these are still being worked on, marked with `[WIP]`. + +- `Security` using well-known audited `AEAD` cryptography primitives; +- `[WIP]` `Data integrity`, data is written with `WAL` to ensure integrity even on crash or power loss; +- `[WIP]` Hide all info for enhanced `privacy`, all `metadata`, `content`, `file name`, `file size`, `*time` fields, `files count`, directory structure are encrypted; +- `Safely` manage `credentials` in memory with `mlock(2)`, `mprotect`, `zeroize` and `expiry` to mitigate cold boot attacks; +- `Memory safety`, `performance` and `optimized` for `concurrency` with Rust; +- Simplicity; +- Encryption key generated from password; +- Password saved in OS's `keyring`; +- `Change password` without re-encrypting all data; +- `[WIP]` Generate `unique nonce` in `offline mode`; +- `Fast seek` on both reads and writes; +- `Writes in parallel`; +- Exposed with `FUSE`; +- Fully `concurrent` for all operations; +- `[WIP]` Handle `long file names`; +- `[WIP]` Abatraction layer for `Rust File` and `fs` API to use it as lib to `switch to using encrypted files` by just `changing the use statements`; +- `[WIP]` Abstraction layer to `access fhe storage` with implementation for desktop, wasm, Android, iOS and ability to write your own implementation. # Functionality +Some of these are still being worked on, marked with `[WIP]`. + - It keeps all `encrypted` data and `master encryption key` in a dedicated directory with files structured on `inodes` (with metadata info), files for binary content and directories with files/directories entries. All data, metadata and also filenames are encrypted. For new files it generates unique inodes in multi instance run and offline mode. -- The password is collected from CLI, and it's saved in OS `keyring` while app is running. This is because for safety reasons we +- The password is collected from CLI, and it's saved in OS `keyring` while app is running. This is because for security concerns we clear the password from memory on inactivity, and we derive it again from password just when needed. - Master encryption key is also encrypted with another key derived from the password. This gives the ability to change the @@ -73,10 +85,7 @@ It was [crate of the week](https://this-week-in-rust.org/blog/2024/08/14/this-we This is because we can seek to particular chunk. - Encryption key is `zeroize`d in mem on dispose and idle. Also, it's `mlock`ed while used to prevent being moved to swap. It's also `mprotect`ed while not in use. - -In progress: - -- Ensure file integrity by saving each change to WAL, so on crash or power loss on next start we apply the pending +- `[WIP]` Ensure file integrity by saving each change to WAL, so on crash or power loss on next start we apply the pending changes. This makes the write operations atomic. - Multiple writes in parallel to the same file, ideal for torrent like applications. @@ -472,7 +481,7 @@ on most CPUs via AES-NI. But where hardware acceleration is not available `ChaCh Both are good options. `AES-GCM` can be faster with **hardware support**, but **pure-software** implementations of `ChaCha20-Poly1305` are almost always **fast** and **constant-time**. -# Security +# ⚠️ Security Warning: Hazmat! - **Phantom reads**: reading older content from a file, this is not possible. Data is written with WAL and periodically flushed to file. This ensures data integrity and maintains change order. diff --git a/check-before-push-linux.sh b/check-before-push-linux.sh deleted file mode 100755 index a11878d9..00000000 --- a/check-before-push-linux.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/zsh - -set -e - -export CARGO_TERM_COLOR=always -export RUSTFLAGS="-Dwarnings" -export RUSTDOCFLAGS="-Dwarnings" - -cargo fmt --all - -cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu -cargo build --release --all-targets --all-features --target x86_64-unknown-linux-gnu -cargo clippy --release --all-targets --fix --allow-dirty --target x86_64-unknown-linux-gnu -cargo fmt --all -- --check -cargo check --all --target x86_64-unknown-linux-gnu -cargo clippy --all-targets --release --target x86_64-unknown-linux-gnu -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo test --release --all --all-features --target x86_64-unknown-linux-gnu -cargo doc --workspace --all-features --no-deps --target x86_64-unknown-linux-gnu -cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu -cargo aur -cargo generate-rpm - -cd java-bridge -cargo fmt --all -cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu -cargo build --release --all-targets --all-features --target x86_64-unknown-linux-gnu -cargo clippy --release --all-targets --fix --allow-dirty --target x86_64-unknown-linux-gnu -cargo fmt --all -- --check -cargo check --all --target x86_64-unknown-linux-gnu -cargo clippy --all-targets --release --target x86_64-unknown-linux-gnu -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo test --release --all --all-features --target x86_64-unknown-linux-gnu -cargo doc --workspace --all-features --no-deps --target x86_64-unknown-linux-gnu -cd .. diff --git a/check-before-push-macos.sh b/check-before-push-macos.sh deleted file mode 100755 index 4d1a124c..00000000 --- a/check-before-push-macos.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/zsh - -set -e - -export CARGO_TERM_COLOR=always -export RUSTFLAGS="-Dwarnings" -export RUSTDOCFLAGS="-Dwarnings" - -cargo fmt --all - -cargo build --all-targets --all-features -cargo build --release --all-targets --all-features -cargo clippy --release --all-targets --fix --allow-dirty -cargo fmt --all -- --check -cargo check --all -cargo clippy --all-targets --release -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo test --release --all --all-features -cargo doc --workspace --all-features --no-deps -cargo publish --dry-run --allow-dirty - -cd java-bridge -cargo fmt --all -cargo build --all-targets --all-features -cargo build --release --all-targets --all-features -cargo clippy --release --all-targets --fix --allow-dirty -cargo fmt --all -- --check -cargo check --all -cargo clippy --all-targets --release -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo test --release --all --all-features -cargo doc --workspace --all-features --no-deps -cd .. diff --git a/check-before-push-windows.bat b/check-before-push-windows.bat deleted file mode 100755 index 4e803bf6..00000000 --- a/check-before-push-windows.bat +++ /dev/null @@ -1,76 +0,0 @@ -@echo off -set CARGO_TERM_COLOR=always -set RUSTFLAGS=-Dwarnings -set RUSTDOCFLAGS=-Dwarnings - -cargo fmt --all -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo build --all-targets --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo build --release --all-targets --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo clippy --all-targets --release ^ - -A clippy::similar_names ^ - -A clippy::too_many_arguments ^ - -A clippy::significant_drop_tightening ^ - -A clippy::redundant_closure ^ - -A clippy::missing_errors_doc ^ - -A clippy::type_complexity -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo fmt --all -- --check -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo check --all -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo clippy --all-targets --release -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo test --release --all --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo doc --workspace --all-features --no-deps -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo publish --dry-run --allow-dirty -if %errorlevel% neq 0 exit /b %errorlevel% - -cd java-bridge -cargo fmt --all -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo build --all-targets --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo build --release --all-targets --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo clippy --release --all-targets --fix --allow-dirty -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo fmt --all -- --check -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo check --all -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo clippy --all-targets --release ^ - -A clippy::similar_names ^ - -A clippy::too_many_arguments ^ - -A clippy::significant_drop_tightening ^ - -A clippy::redundant_closure ^ - -A clippy::missing_errors_doc ^ - -A clippy::type_complexity -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo test --release --all --all-features -if %errorlevel% neq 0 exit /b %errorlevel% - -cargo doc --workspace --all-features --no-deps -if %errorlevel% neq 0 exit /b %errorlevel% - -cd .. diff --git a/check-before-push.bat b/check-before-push.bat index 9734e7b6..88773803 100755 --- a/check-before-push.bat +++ b/check-before-push.bat @@ -1,13 +1,117 @@ @echo off +setlocal + set CARGO_TERM_COLOR=always set RUSTFLAGS=-Dwarnings set RUSTDOCFLAGS=-Dwarnings +:: Filepath to the Cargo.toml file +set "CARGO_FILE=Cargo.toml" +set "BACKUP_FILE=Cargo_backup.txt" + +:: Function to add -dryRun to the version +:add_dryrun_to_version +if exist "%CARGO_FILE%" ( + findstr /r "^version\s*=\s*\"[0-9\.]*\"" "%CARGO_FILE%" >nul + if errorlevel 1 ( + echo No version found in the file. + goto :eof + ) + + copy /y "%CARGO_FILE%" "%BACKUP_FILE%" >nul + + for /f "tokens=3 delims== " %%A in ('findstr /r "^version\s*=\s*\"[0-9\.]*\"" "%CARGO_FILE%"') do ( + set "ORIGINAL_VERSION=%%~A" + set "MODIFIED_VERSION=%ORIGINAL_VERSION:~0,-1%-dryRun" + ) + + powershell -Command "(Get-Content -Raw '%CARGO_FILE%') -replace 'version = \"%ORIGINAL_VERSION%\"', 'version = \"%MODIFIED_VERSION%\"' | Set-Content '%CARGO_FILE%'" + + echo Version modified to: %MODIFIED_VERSION% +) else ( + echo Cargo.toml file not found! +) +goto :eof + +:: Function to revert the version to its original state by restoring from backup +:revert_version +if exist "%BACKUP_FILE%" ( + copy /y "%BACKUP_FILE%" "%CARGO_FILE%" >nul + del /f "%BACKUP_FILE%" + echo Cargo.toml reverted to the original version. +) else ( + echo Backup file not found! Cannot revert. +) +goto :eof + cargo fmt --all if %errorlevel% neq 0 exit /b %errorlevel% +cargo build --all-targets --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo build --release --all-targets --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + cargo clippy --release --all-targets --fix --allow-dirty --allow-staged if %errorlevel% neq 0 exit /b %errorlevel% -act --action-offline-mode -W .github/workflows/build_and_tests_reusable.yaml +cargo fmt --all -- --check +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo check --all +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo clippy --all-targets --release +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo test --release --all --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo doc --workspace --all-features --no-deps +if %errorlevel% neq 0 exit /b %errorlevel% + +call :add_dryrun_to_version +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo publish --dry-run --allow-dirty if %errorlevel% neq 0 exit /b %errorlevel% + +call :revert_version +if %errorlevel% neq 0 exit /b %errorlevel% + +cd java-bridge +cargo fmt --all +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo build --all-targets --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo build --release --all-targets --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo clippy --release --all-targets --fix --allow-dirty --allow-staged +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo fmt --all -- --check +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo check --all +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo clippy --all-targets --release ^ + -A clippy::similar_names ^ + -A clippy::too_many_arguments ^ + -A clippy::significant_drop_tightening ^ + -A clippy::redundant_closure ^ + -A clippy::missing_errors_doc ^ + -A clippy::type_complexity +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo test --release --all --all-features +if %errorlevel% neq 0 exit /b %errorlevel% + +cargo doc --workspace --all-features --no-deps +if %errorlevel% neq 0 exit /b %errorlevel% + +cd .. diff --git a/check-before-push.sh b/check-before-push.sh index 1b91f73a..c5907d62 100755 --- a/check-before-push.sh +++ b/check-before-push.sh @@ -6,37 +6,84 @@ export CARGO_TERM_COLOR=always export RUSTFLAGS="-Dwarnings" export RUSTDOCFLAGS="-Dwarnings" +# Filepath to the Cargo.toml file +CARGO_FILE="Cargo.toml" +BACKUP_FILE="Cargo_backup.txt" + +# Function to add -dryRun to the version +add_dryrun_to_version() { + if [[ -f $CARGO_FILE ]]; then + # Backup the original Cargo.toml before modification + cp "$CARGO_FILE" "$BACKUP_FILE" + + # Extract the current version from the file + ORIGINAL_VERSION=$(grep -oP '^version\s*=\s*"\K[^\"]+' "$CARGO_FILE") + + if [[ -n $ORIGINAL_VERSION ]]; then + # Modify the version and write it back to the Cargo.toml file + sed -i "s/version = \"$ORIGINAL_VERSION\"/version = \"$ORIGINAL_VERSION-dryRun\"/" "$CARGO_FILE" + echo "Version modified to: $ORIGINAL_VERSION-dryRun" + else + echo "No version found in the file." + fi + else + echo "Cargo.toml file not found!" + fi +} + +# Function to revert the version to its original state by restoring from backup +revert_version() { + if [[ -f $BACKUP_FILE ]]; then + # Restore the original Cargo.toml from the backup + mv "$BACKUP_FILE" "$CARGO_FILE" + echo "Cargo.toml reverted to the original version." + else + echo "Backup file not found! Cannot revert." + fi +} + cargo fmt --all -cargo clippy --release --all-targets --fix --allow-dirty --allow-staged -cargo build --all-targets --all-features -cargo build --release --all-targets --all-features +cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu +cargo build --release --all-targets --all-features --target x86_64-unknown-linux-gnu +cargo clippy --release --all-targets --fix --allow-dirty --allow-staged --target x86_64-unknown-linux-gnu cargo fmt --all -- --check -cargo check --all -cargo clippy --all-targets --release -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo doc --workspace --all-features --no-deps -cargo test --release --all --all-features -cargo publish --dry-run --allow-dirty +cargo check --all --target x86_64-unknown-linux-gnu +cargo clippy --all-targets --release --target x86_64-unknown-linux-gnu -- \ + -A clippy::similar_names \ + -A clippy::too_many_arguments \ + -A clippy::significant_drop_tightening \ + -A clippy::redundant_closure \ + -A clippy::missing_errors_doc \ + -A clippy::type_complexity +cargo test --release --all --all-features --target x86_64-unknown-linux-gnu +cargo doc --workspace --all-features --no-deps --target x86_64-unknown-linux-gnu + +add_dryrun_to_version +cargo publish --dry-run --allow-dirty --target x86_64-unknown-linux-gnu +revert_version + cargo aur cargo generate-rpm cd java-bridge -cargo build --all-targets --all-features -cargo build --release --all-targets --all-features +cargo fmt --all +cargo build --all-targets --all-features --target x86_64-unknown-linux-gnu +cargo build --release --all-targets --all-features --target x86_64-unknown-linux-gnu +cargo clippy --release --all-targets --fix --allow-dirty --allow-staged --target x86_64-unknown-linux-gnu cargo fmt --all -- --check -cargo check --all -cargo clippy --all-targets --release -- \ - -A clippy::similar_names \ - -A clippy::too_many_arguments \ - -A clippy::significant_drop_tightening \ - -A clippy::redundant_closure \ - -A clippy::missing_errors_doc \ - -A clippy::type_complexity -cargo doc --workspace --all-features --no-deps -cargo test --release --all --all-features +cargo check --all --target x86_64-unknown-linux-gnu +cargo clippy --all-targets --release --target x86_64-unknown-linux-gnu -- \ + -A clippy::similar_names \ + -A clippy::too_many_arguments \ + -A clippy::significant_drop_tightening \ + -A clippy::redundant_closure \ + -A clippy::missing_errors_doc \ + -A clippy::type_complexity +cargo test --release --all --all-features --target x86_64-unknown-linux-gnu +cargo doc --workspace --all-features --no-deps --target x86_64-unknown-linux-gnu +cd .. + +#cargo fmt --all +#cargo clippy --release --all-targets --fix --allow-dirty +#act --action-offline-mode -W .github/workflows/build_and_tests_reusable.yaml diff --git a/examples/magic_of_blanket_impl.rs b/examples/magic_of_blanket_impl.rs new file mode 100644 index 00000000..811a5378 --- /dev/null +++ b/examples/magic_of_blanket_impl.rs @@ -0,0 +1,58 @@ +/// This demonstrates the magic of blanket implementation. +/// +/// If we have a wrapper that wraps [Read] we don't have access to [Seek::seek] method, but +/// if we wrap [Read] + [Seek] we do. +/// We use this in [rencfs::crypto::read] and also in [rencfs::crypto::write]. +use std::io; +use std::io::{Read, Seek, SeekFrom}; + +fn main() { + // wrap only Read + let mut reader = MyRead { inner: OnlyRead {} }; + println!("we can read"); + let _ = reader.read(&mut [0; 10]).unwrap(); + // but we cannot seek + // reader.seek(SeekFrom::Start(0)).unwrap(); // compile error + + // wrap Read + Seek + let mut reader_seek = MyRead { inner: ReadSeek {} }; + println!("we can read"); + let _ = reader_seek.read(&mut [0; 10]).unwrap(); + println!("we can seek too"); + reader_seek.seek(SeekFrom::Start(0)).unwrap(); +} + +struct OnlyRead {} +impl Read for OnlyRead { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { + Ok(0) + } +} + +struct ReadSeek {} +impl Read for ReadSeek { + fn read(&mut self, _buf: &mut [u8]) -> io::Result { + Ok(0) + } +} +impl Seek for ReadSeek { + fn seek(&mut self, _pos: SeekFrom) -> io::Result { + Ok(0) + } +} + +struct MyRead { + inner: R, +} + +impl Read for MyRead { + fn read(&mut self, buf: &mut [u8]) -> io::Result { + self.inner.read(buf) + } +} + +impl Seek for MyRead { + fn seek(&mut self, pos: SeekFrom) -> io::Result { + self.inner.seek(pos) + } +} diff --git a/favicon.png b/favicon.png index 038d00c7..46001569 100644 Binary files a/favicon.png and b/favicon.png differ diff --git a/java-bridge/Cargo.lock b/java-bridge/Cargo.lock index 6c6227dd..4a5c21af 100644 --- a/java-bridge/Cargo.lock +++ b/java-bridge/Cargo.lock @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "bon" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "811d7882589e047896e5974d039dd8823a67973a63d559e6ad1e87ff5c42ed4f" +checksum = "97493a391b4b18ee918675fb8663e53646fd09321c58b46afa04e8ce2499c869" dependencies = [ "bon-macros", "rustversion", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "bon-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e745a763e579a5ce70130e66f9dd35abf77cfeb9f418f305aeab8d1ae54c43" +checksum = "2a2af3eac944c12cdf4423eab70d310da0a8e5851a18ffb192c0a5e3f7ae1663" dependencies = [ "darling", "ident_case", diff --git a/src/mount/linux.rs b/src/mount/linux.rs index eecf097b..dad86435 100644 --- a/src/mount/linux.rs +++ b/src/mount/linux.rs @@ -1084,7 +1084,10 @@ impl Filesystem for EncryptedFsFuse3 { } } - type DirEntryStream<'a> = Iter> where Self: 'a; + type DirEntryStream<'a> + = Iter> + where + Self: 'a; #[instrument(skip(self), err(level = Level::DEBUG))] async fn readdir( @@ -1175,7 +1178,10 @@ impl Filesystem for EncryptedFsFuse3 { }) } - type DirEntryPlusStream<'a> = Iter> where Self: 'a; + type DirEntryPlusStream<'a> + = Iter> + where + Self: 'a; #[instrument(skip(self), err(level = Level::DEBUG))] async fn readdirplus( diff --git a/src/run.rs b/src/run.rs index 01b7ae6c..ab84b7fb 100644 --- a/src/run.rs +++ b/src/run.rs @@ -321,9 +321,9 @@ async fn run_mount(cipher: Cipher, matches: &ArgMatches) -> Result<()> { }); } - #[allow(clippy::items_after_statements)] struct PasswordProviderImpl {} #[allow(clippy::items_after_statements)] + #[allow(static_mut_refs)] impl PasswordProvider for PasswordProviderImpl { fn get_password(&self) -> Option { unsafe { @@ -406,6 +406,7 @@ async fn run_mount(cipher: Cipher, matches: &ArgMatches) -> Result<()> { Ok(()) } +#[allow(static_mut_refs)] fn remove_pass() { unsafe { if PASS.is_none() { diff --git a/website/resources/rencfs-logo-32p.png b/website/resources/rencfs-logo-32p.png deleted file mode 100644 index 038d00c7..00000000 Binary files a/website/resources/rencfs-logo-32p.png and /dev/null differ