| Crates.io | orion-sec |
| lib.rs | orion-sec |
| version | 0.3.4 |
| created_at | 2025-09-21 15:40:22.162724+00 |
| updated_at | 2026-01-11 01:48:29.558428+00 |
| description | Secret-aware helpers for loading and masking Galaxy configuration values. |
| homepage | https://github.com/galaxy-sec/orion-sec |
| repository | https://github.com/galaxy-sec/orion-sec |
| max_upload_size | |
| id | 1848899 |
| size | 91,925 |
#orion-sec
orion-sec 提供面向 Galaxy 平台的安全配置加载与脱敏工具,帮助代理或服务在保留数据结构的同时区分明文与敏感字段。核心模块围绕 SecValue<T> 与 SecValueType 类型构建,可在读取 YAML 或环境变量后动态切换字段的明文或加密状态。
SecValue<T> 在同一结构中表示敏感与非敏感数值。orion-variate 无缝协作:支持 EnvDict、ValueType 及 UpperKey 样式。load_secfile 自动从 ~/.galaxy/sec_value.yml 或自定义路径构造安全对象。ValueGetter trait 支持点语法与数组索引(如 A[0].B)。cargo add orion-sec
或者在 Cargo.toml 中手动加入:
[dependencies]
orion-sec = "0.2"
use orion_sec::{load_sec_dict, SecValueType, ValueGetter};
fn main() -> orion_sec::SecResult<()> {
let dict = load_sec_dict()?; // 自动加载并去除 SEC_ 前缀
if let Some(SecValueType::String(db_pass)) = dict.value_get("database.credentials.password") {
println!("Password masked? {}", db_pass.is_secret());
}
Ok(())
}
如需测试不同路径,可设置 GAL_SEC_FILE_PATH=/custom/sec.yml 指向替代文件。
cargo fmt --all:统一格式化。cargo clippy --all-targets --all-features -- -D warnings:静态检查。cargo test --all-features -- --test-threads=1:运行核心测试用例。提交 PR 前请确保通过格式化、Clippy、测试与(如适用)cargo llvm-cov。详细要求见 AGENTS.md。
本项目采用 MIT License。