Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.3.0 #14

Merged
merged 13 commits into from
Aug 20, 2024
Merged
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
13 changes: 10 additions & 3 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ on:

jobs:
audit:
name: Cargo Audit
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Run cargo audit
uses: actions-rs/audit-check@v1
uses: rustsec/audit-check@v1.4.1
with:
token: ${{ secrets.GITHUB_TOKEN }}

permissions:
issues: write
issues-reason: to create issues
checks: write
checks-reason: to create check
69 changes: 24 additions & 45 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ jobs:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
uses: dtolnay/rust-toolchain@stable

- name: Run cargo check
uses: actions-rs/cargo@v1
uses: clechasseur/rs-cargo@v2
with:
command: check

Expand All @@ -33,17 +29,13 @@ jobs:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
uses: dtolnay/rust-toolchain@nightly

- name: Run cargo test
uses: actions-rs/cargo@v1
uses: clechasseur/rs-cargo@v2
with:
command: test
args: --no-default-features --features dev
Expand All @@ -56,17 +48,13 @@ jobs:
os: [ubuntu-latest, windows-latest]
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
uses: dtolnay/rust-toolchain@nightly

- name: Run cargo test
uses: actions-rs/cargo@v1
uses: clechasseur/rs-cargo@v2
with:
command: test
args: --all-features
Expand All @@ -78,17 +66,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
uses: dtolnay/rust-toolchain@nightly

- name: Run cargo doc
uses: actions-rs/cargo@v1
uses: clechasseur/rs-cargo@v2
with:
command: doc
args: --all-features
Expand All @@ -98,18 +82,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@nightly
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- name: Run cargo fmt
uses: actions-rs/cargo@v1
uses: clechasseur/rs-cargo@v2
with:
command: fmt
args: -- --check
Expand All @@ -119,39 +100,37 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@nightly
with:
toolchain: nightly
components: clippy
override: true
- uses: actions-rs/clippy-check@v1

- uses: clechasseur/rs-cargo@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
command: clippy
args: --all-features

miri:
name: Miri
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Get latest toolchain version with miri
run: echo "TOOLCHAIN=$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)" >> $GITHUB_ENV

- name: Install latest nightly toolchain with miri
uses: actions-rs/toolchain@v1
uses: dtolnay/rust-toolchain@master
with:
profile: minimal
toolchain: nightly-${{ env.TOOLCHAIN }}
override: true
components: rust-src, miri

- name: Run cargo miri test
run: cargo miri test --all-features
env:
MIRI_LOG: 1
MIRI_BACKTRACE: 1
MIRIFLAGS: -Zmiri-strict-provenance -Zmiri-check-number-validity
MIRIFLAGS: -Zmiri-strict-provenance
31 changes: 12 additions & 19 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,22 @@ name: Code Coverage
on: [push, pull_request]

jobs:
code_cov:
name: Code Coverage Tarpaulin + Codecov
test:
name: coverage
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin:develop-nightly
options: --security-opt seccomp=unconfined
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Install nightly toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true

- name: Run cargo-tarpaulin
uses: actions-rs/[email protected]
with:
args: --ignore-tests --all-features
out-type: Xml
run-types: AllTargets
env:
RUSTFLAGS: "-Ctarget-cpu=native"
- name: Generate code coverage
run: |
cargo +nightly tarpaulin --verbose --all-features --workspace --timeout 120 --out xml

- name: Upload to codecov.io
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
files: ./cobertura.xml
token: ${{secrets.CODECOV_TOKEN}}
fail_ci_if_error: true
17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ all-features = true

[features]
default = ["std"]
std = ["thiserror", "winapi/std"]
nightly_allocator_api = []
std = ["dep:thiserror", "allocator-api2/std"]
nightly_allocator_api = ["allocator-api2/nightly"]
nightly_core_intrinsics = []
# even though stabilised, still necessary for avx512
nightly_stdsimd = []
Expand All @@ -33,20 +33,23 @@ nightly = [
"nightly_strict_provenance",
]
# required features to run tests; additional features enable more tests
dev = ["std", "nightly_allocator_api"]
dev = ["std"]

[dependencies]
allocator-api2 = { version = "0.2", default-features = false }
cfg-if = "1.0"
libc = "0.2"
mirai-annotations = "1.12"
sptr = "0.3"
thiserror = {version = "1.0", optional = true}
thiserror = { version = "1.0", optional = true }

[target.'cfg(unix)'.dependencies]
rustix = { version = "0.38", features = ["mm", "param"] }

[target.'cfg(windows)'.dependencies]
winapi = {version = "0.3.9", features = ["impl-default", "memoryapi", "sysinfoapi"]}
windows = { version = "0.56.0", features = ["Win32_System_SystemInformation", "Win32_System_Memory"] }

[dev-dependencies]
criterion = "0.3"
criterion = "0.5"

[[bench]]
name = "bench_zeroizers"
Expand Down
25 changes: 3 additions & 22 deletions benches/bench_zeroizers.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
use criterion::{criterion_group, criterion_main, Criterion};
#[cfg(all(target_arch = "x86_64", target_feature = "ermsb"))]
use secmem_alloc::zeroize::AsmRepStosZeroizer;
#[cfg(all(target_arch = "x86_64", target_feature = "avx"))]
use secmem_alloc::zeroize::X86_64AvxZeroizer;
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))]
use secmem_alloc::zeroize::X86_64Sse2Zeroizer;
use secmem_alloc::zeroize::{
LibcZeroizer, MemZeroizer, VolatileMemsetZeroizer, VolatileWrite8Zeroizer,
VolatileWriteZeroizer,
MemZeroizer, MemsetAsmBarierZeroizer, VolatileMemsetZeroizer, VolatileWrite8Zeroizer,
};

fn zeroize_b127<Z: MemZeroizer>(z: Z, array: &mut [u8; 127]) {
Expand Down Expand Up @@ -50,21 +43,9 @@ macro_rules! bench_zeroizers {
$cgroup.bench_function("VolatileMemsetZeroizer", |b| {
b.iter(|| $bench_function(VolatileMemsetZeroizer, &mut $array.0))
});
$cgroup.bench_function("LibcZeroizer", |b| {
b.iter(|| $bench_function(LibcZeroizer, &mut $array.0))
$cgroup.bench_function("MemsetAsmBarierZeroizer", |b| {
b.iter(|| $bench_function(MemsetAsmBarierZeroizer, &mut $array.0))
});
$cgroup.bench_function("VolatileWriteZeroizer", |b| {
b.iter(|| $bench_function(VolatileWriteZeroizer, &mut $array.0))
});
$cgroup.bench_function("VolatileWrite8Zeroizer", |b| {
b.iter(|| $bench_function(VolatileWrite8Zeroizer, &mut $array.0))
});
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))]
{
$cgroup.bench_function("X86_64Sse2Zeroizer", |b| {
b.iter(|| $bench_function(X86_64Sse2Zeroizer, &mut $array.0))
});
}
#[cfg(all(target_arch = "x86_64", target_feature = "avx"))]
{
$cgroup.bench_function("X86_64AvxZeroizer", |b| {
Expand Down
Loading
Loading