Skip to content
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
60 changes: 60 additions & 0 deletions .github/workflows/publish-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Rust Crate (dbshield-core) CI & Crates.io Publish

on:
push:
branches: [main]
paths:
- "crates/dbshield-core/**"
- ".github/workflows/publish-rust.yml"
tags:
- "rust-v*"
pull_request:
branches: [main]
paths:
- "crates/dbshield-core/**"
- ".github/workflows/publish-rust.yml"
workflow_dispatch:

permissions: read-all

jobs:
test-rust:
name: Test dbshield-core Crate
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Run Cargo Tests & Package Check
working-directory: crates/dbshield-core
run: |
cargo test
cargo package --allow-dirty --list

publish-crate:
name: Publish dbshield-core to crates.io
needs: [test-rust]
if: startsWith(github.ref, 'refs/tags/rust-v') || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable

- name: Publish Crate
working-directory: crates/dbshield-core
run: |
if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
echo "CARGO_REGISTRY_TOKEN secret not set; skipping crates.io upload."
exit 1
fi
cargo publish --token "$CARGO_REGISTRY_TOKEN"
1 change: 1 addition & 0 deletions crates/dbshield-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ version = "0.2.1"
edition = "2021"
authors = ["RitualDev Studio <engineering@ritualdev.in>"]
description = "High-performance zero-GC wire protocol proxy engine, connection pooling, and virtual shadow database for DBShield."
readme = "README.md"
license = "MIT"
repository = "https://github.com/RitualDev-Lab/DBShield"
keywords = ["postgresql", "mysql", "wire-protocol", "shadow-database", "ai-agents"]
Expand Down
15 changes: 15 additions & 0 deletions crates/dbshield-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# dbshield-core 🦀

High-performance zero-GC wire protocol proxy engine, connection pooling, and virtual shadow database for **[DBShield](https://github.com/RitualDev-Lab/DBShield)**.

## Installation

```toml
[dependencies]
dbshield-core = "0.2.1"
```

## Features
- Zero-GC PostgreSQL and MySQL wire-protocol framing & inspection
- Connection pool primitives and dynamic PII data masking
- Virtual shadow database hooks for safe autonomous AI agent query execution
17 changes: 17 additions & 0 deletions crates/dbshield-core/src/masking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,20 @@ impl WirePiiMasker {
}
}
}

#[cfg(test)]
mod tests {
use super::WirePiiMasker;

#[test]
fn pseudonymizes_email_and_phone_deterministically() {
let masker = WirePiiMasker::new("test-salt");
let masked_email = masker.pseudonymize("alice@acme.io", "EMAIL");
assert!(masked_email.starts_with("user_"));
assert!(masked_email.ends_with("@acme.io"));
assert_eq!(masked_email, masker.pseudonymize("alice@acme.io", "EMAIL"));

let masked_phone = masker.pseudonymize("+1 (555) 123-9876", "PHONE");
assert_eq!(masked_phone, "+***-***-9876");
}
}