Skip to content

Commit a107fde

Browse files
committed
Revert previous commit.
0 parents  commit a107fde

13 files changed

Lines changed: 2187 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: "Tests"
2+
on:
3+
push:
4+
branches: ["latest"]
5+
paths:
6+
- src/**
7+
- Cargo.toml
8+
- Cargo.lock
9+
- .github/workflows/test.yaml
10+
pull_request:
11+
branches: ["latest"]
12+
workflow_dispatch:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
test:
19+
name: test (${{ matrix.rust }})
20+
runs-on: ubuntu-latest
21+
strategy:
22+
matrix:
23+
rust: [stable, "1.90.0", nightly]
24+
steps:
25+
- uses: actions/checkout@v5
26+
27+
- name: Install Rust toolchain
28+
uses: actions-rust-lang/setup-rust-toolchain@v1
29+
with:
30+
toolchain: ${{ matrix.rust }}
31+
components: clippy
32+
cache-directories: |
33+
~/.cargo/registry
34+
~/.cargo/bin
35+
target
36+
37+
- name: consult Clippy
38+
run: cargo clippy --all-targets
39+
40+
- name: Install cargo-nextest and cargo-llvm-cov
41+
shell: bash
42+
run: |
43+
if [[ -z $(which cargo-nextest) ]]; then
44+
curl -sL https://get.nexte.st/latest/linux -o nextest.tgz
45+
tar xfz nextest.tgz
46+
mv cargo-nextest /home/runner/.cargo/bin
47+
fi
48+
if [[ -z $(which cargo-llvm-cov) ]]; then
49+
curl -sL https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz -o cargo-llvm-cov.tgz
50+
tar xfz cargo-llvm-cov.tgz
51+
mv cargo-llvm-cov /home/runner/.cargo/bin
52+
fi
53+
54+
- name: run the tests
55+
run: cargo nextest run
56+
57+
- name: Run doctests
58+
run: cargo test --doc
59+
60+
- name: Generate coverage (stable only)
61+
if: matrix.rust == 'stable'
62+
run: cargo llvm-cov --all-targets --workspace --lcov --output-path lcov.info
63+
64+
- name: Upload coverage to GitHub (stable only)
65+
if: matrix.rust == 'stable'
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: coverage-report
69+
path: lcov.info
70+
71+
fmt:
72+
name: formatting check
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v5
76+
77+
- name: Install nightly Rust
78+
uses: actions-rust-lang/setup-rust-toolchain@v1
79+
with:
80+
toolchain: nightly
81+
components: rustfmt
82+
83+
- name: check formatting
84+
run: cargo +nightly fmt --check --all

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Rust
2+
/target/
3+
**/*.rs.bk
4+
*.pdb
5+
6+
# Cargo
7+
Cargo.lock
8+
9+
# IDE
10+
.vscode/
11+
.idea/
12+
*.swp
13+
*.swo
14+
*~
15+
.DS_Store
16+
.ignore/

.justfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
_help:
2+
just -l
3+
4+
# Run all tests using nextest.
5+
test:
6+
cargo nextest run
7+
8+
coverage:
9+
cargo llvm-cov --all-targets --workspace --summary-only
10+
11+
# Run the nightly formatter
12+
fmt:
13+
cargo +nightly fmt
14+
15+
# Run the same checks we run in CI. Requires nightly.
16+
ci: test fmt
17+
cargo clippy --all-targets
18+
cargo test --doc
19+
20+
# Install required tools
21+
setup:
22+
brew tap ceejbot/tap
23+
brew install cargo-nextest tomato semver-bump
24+
rustup install nightly
25+
26+
# Tag a new version for release.
27+
version BUMP:
28+
#!/usr/bin/env bash
29+
set -e
30+
current=$(tomato get package.version Cargo.toml)
31+
version=$(echo "$current" | semver-bump {{BUMP}})
32+
tomato set package.version "$version" Cargo.toml &> /dev/null
33+
cargo generate-lockfile
34+
git commit Cargo.toml Cargo.lock -m "v${version}"
35+
git tag "v${version}"
36+
echo "Release tagged for version v${version}"
37+
38+
# publish to crates.io
39+
release:
40+
cargo publish

.rustfmt.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
imports_granularity = "module"
2+
group_imports = "StdExternalCrate"
3+
max_width = 120
4+
wrap_comments = true
5+
style_edition = "2024"
6+
short_array_element_width_threshold = 25

CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [0.1.0] - 2025-01-20
11+
12+
### Added
13+
14+
- Initial release of `safe-debug`
15+
- `SafeDebug` derive macro for automatic sensitive field redaction
16+
- Support for named structs, tuple structs, and unit structs
17+
- Comprehensive enum support:
18+
- Unit variants (`Variant`)
19+
- Tuple variants (`Variant(T, U)`) with per-field sensitivity
20+
- Struct variants (`Variant { field: T }`) with per-field sensitivity
21+
- Mixed variant types in same enum
22+
- Full generic support:
23+
- Type parameters with auto-generated trait bounds
24+
- Lifetime parameters
25+
- Higher-ranked trait bounds (HRTB) for facet integration
26+
- Multi-generic types (`Pair<T, U>`, `Triple<T, U, V>`)
27+
- Pretty-print formatting support (`{:#?}`)
28+
- Security-first fallback behavior:
29+
- Structs: Redact all fields if metadata unavailable
30+
- Enums: Show only type name if metadata unavailable
31+
- Zero unsafe code
32+
- Minimal runtime overhead (single Shape access + per-field sensitivity check)
33+
- MIT OR Apache-2.0 dual license
34+
35+
### Security
36+
37+
- Automatic `[REDACTED]` output for fields marked `#[facet(sensitive)]`
38+
- Conservative fallback: fails safe by hiding data when metadata is unavailable
39+
- No data leakage in debug output for HIPAA-compliant and other sensitive applications
40+
41+
[Unreleased]: https://github.com/ceejbot/safe-debug/compare/v0.1.0...HEAD
42+
[0.1.0]: https://github.com/ceejbot/safe-debug/releases/tag/v0.1.0

Cargo.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[package]
2+
name = "safe-debug"
3+
version = "0.1.0"
4+
edition = "2024"
5+
rust-version = "1.90.0"
6+
authors = ["C J Silverio <ceejceej@gmail.com>"]
7+
description = "Derives std::fmt::Debug with automatic redaction for sensitive fields marked with #[facet(sensitive)]"
8+
license = "MIT OR Apache-2.0"
9+
repository = "https://github.com/ceejbot/safe-debug"
10+
homepage = "https://github.com/ceejbot/safe-debug"
11+
documentation = "https://docs.rs/safe-debug"
12+
keywords = ["debug", "redaction", "sensitive", "hipaa", "facet"]
13+
categories = ["development-tools", "encoding"]
14+
exclude = [
15+
".github/",
16+
"docs/",
17+
"*.md",
18+
"!README.md",
19+
"!CHANGELOG.md",
20+
]
21+
22+
[lib]
23+
proc-macro = true
24+
25+
[dependencies]
26+
quote = "1.0"
27+
facet-macros-parse = "0.31"
28+
29+
[dev-dependencies]
30+
facet = { version = "0.31", features = ["reflect"] }
31+
32+
[[example]]
33+
name = "enum_example"
34+
path = "examples/enum_example.rs"
35+
36+
[workspace.lints.rust]
37+
unsafe_code = { level = "deny", priority = 0 }
38+
future_incompatible = { level = "deny", priority = 1 }
39+
rust_2018_idioms = { level = "warn", priority = 2 }
40+
trivial_casts = { level = "warn", priority = 3 }
41+
trivial_numeric_casts = { level = "warn", priority = 4 }
42+
unused_lifetimes = { level = "warn", priority = 5 }
43+
unused_qualifications = { level = "warn", priority = 6 }
44+
45+
[workspace.lints.clippy]
46+
unwrap_used = "deny"

0 commit comments

Comments
 (0)