diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cc9530..ac82515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,10 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- Nothing yet +- WASM compatibility support using `chrono` with `wasmbind` feature +- `validation_test.rs` in new `tests/` directory ### Changed -- Nothing yet +- Replaced `std::time` usage with `chrono` for WASM compatibility ### Deprecated - Nothing yet diff --git a/Cargo.toml b/Cargo.toml index fc78e41..bc453d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,6 +16,7 @@ lazy_static = "1.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" unicode-normalization = "0.1" +chrono = { version = "0.4", features = ["wasmbind", "serde"] } # Optional tracing support tracing = { version = "0.1", optional = true } diff --git a/README.md b/README.md index fb5cbbb..198957e 100644 --- a/README.md +++ b/README.md @@ -301,7 +301,7 @@ Licensed under the MIT License. See [LICENSE](LICENSE) for details. ## Security -To report security vulnerabilities, please email security@asgardtech.com. +To report security vulnerabilities, please email security@redasgard.com. **Do not** open public GitHub issues for security vulnerabilities. diff --git a/src/validation.rs b/src/validation.rs index 44ee162..897c066 100644 --- a/src/validation.rs +++ b/src/validation.rs @@ -110,10 +110,7 @@ impl ValidationEngine { issues, warnings, output_size: output.len(), - validation_timestamp: std::time::SystemTime::now() - .duration_since(std::time::UNIX_EPOCH) - .unwrap() - .as_secs(), + validation_timestamp: chrono::Utc::now().timestamp() as u64, } } @@ -253,3 +250,4 @@ impl ValidationResult { self.issues.iter().filter(|i| matches!(i.severity, ValidationSeverity::High | ValidationSeverity::Critical)).collect() } } + diff --git a/tests/validation_test.rs b/tests/validation_test.rs new file mode 100644 index 0000000..3610d3a --- /dev/null +++ b/tests/validation_test.rs @@ -0,0 +1,14 @@ +use llm_security::{ValidationEngine, LLMSecurityConfig}; + +#[test] +fn test_validation_timestamp() { + let config = LLMSecurityConfig::default(); + let engine = ValidationEngine::new(config); + let result = engine.validate_output_comprehensive("There are two r's in 'strawberry'."); + + assert!(result.validation_timestamp > 0); + // Check if timestamp is recent (within last hour) - simplified check + let now = chrono::Utc::now().timestamp() as u64; + assert!(result.validation_timestamp <= now); + assert!(result.validation_timestamp > now - 3600); +}