zeph-common
Shared utility functions and security primitives for the Zeph workspace. Zero zeph-* dependencies — safe to depend on from any crate.
Overview
Provides foundational utilities used across multiple Zeph crates: Unicode-safe string truncation, network SSRF guards, sanitization primitives, and optional tree-sitter query helpers. Having these in a dedicated leaf crate prevents circular dependencies and ensures the utilities are tested in isolation.
Key modules
| Module | Description |
|---|---|
text |
Unicode-safe string truncation — truncate_chars, truncate_to_chars, truncate_to_bytes, truncate_to_bytes_ref |
net |
Network helpers — is_private_ip() for IPv4/IPv6 private range detection; used by the SSRF guard in zeph-tools and zeph-acp |
sanitize |
Low-level sanitization primitives (null byte stripping, control character removal) |
treesitter |
Tree-sitter query constants and parser helpers for Rust, Python, JavaScript, TypeScript, Go (optional, requires treesitter feature) |
Usage
[]
= { = true }
# With tree-sitter query helpers:
= { = true, = ["treesitter"] }
use ;
// Borrow a prefix slice (no allocation)
let preview = truncate_chars; // "hello"
// Owned truncated string with ellipsis appended
let owned = truncate_to_chars; // "hello…"
// Byte-level truncation for protocol buffers / network payloads
use truncate_to_bytes;
let safe = truncate_to_bytes; // "hél" (truncates at char boundary)
SSRF guard:
use IpAddr;
use is_private_ip;
let addr: IpAddr = "192.168.1.1".parse.unwrap;
assert!; // true — private range
let addr: IpAddr = "8.8.8.8".parse.unwrap;
assert!; // false — public IP
Features
| Feature | Description |
|---|---|
treesitter |
Enables tree-sitter parser helpers and ts-query constants for Rust, Python, JS, TS, Go |
Installation
Documentation
Full documentation: https://bug-ops.github.io/zeph/
License
MIT