mirror of
https://github.com/getnora-io/nora.git
synced 2026-04-12 20:50:31 +00:00
* fix: remove unwrap() from production code, improve error handling - Replace unwrap() with proper error handling in npm, mirror, validation - Add input validation to cargo registry (crate name + version) - Improve expect() messages with descriptive context in metrics, rate_limit - Remove unnecessary clone() in error.rs, docker.rs, npm.rs, dashboard_metrics - Add #![deny(clippy::unwrap_used)] to prevent future unwrap in prod code - Add let-else pattern for safer null checks in validation.rs * docs: update SECURITY.md — add 0.3.x to supported versions * security: forbid unsafe code at crate level Add #![forbid(unsafe_code)] to both lib.rs and main.rs. NORA has zero unsafe blocks — this prevents future additions without removing the forbid attribute (stronger than deny). * build: add rust-toolchain.toml, Dockerfile HEALTHCHECK - Pin toolchain to stable with clippy + rustfmt components - Add Docker HEALTHCHECK for standalone deployments (wget /health) * test: add Go proxy and Raw registry integration tests Go proxy tests: list, .info, .mod, @latest, path traversal, 404 Raw registry tests: upload/download, HEAD, 404, path traversal, overwrite, delete, binary data (10KB)
31 lines
1.2 KiB
Rust
31 lines
1.2 KiB
Rust
#![deny(clippy::unwrap_used)]
|
|
#![forbid(unsafe_code)]
|
|
//! NORA Registry — library interface for fuzzing and testing
|
|
|
|
pub mod validation;
|
|
|
|
/// Re-export Docker manifest parsing for fuzz targets
|
|
pub mod docker_fuzz {
|
|
pub fn detect_manifest_media_type(data: &[u8]) -> String {
|
|
let Ok(value) = serde_json::from_slice::<serde_json::Value>(data) else {
|
|
return "application/octet-stream".to_string();
|
|
};
|
|
if let Some(mt) = value.get("mediaType").and_then(|v| v.as_str()) {
|
|
return mt.to_string();
|
|
}
|
|
if value.get("manifests").is_some() {
|
|
return "application/vnd.oci.image.index.v1+json".to_string();
|
|
}
|
|
if value.get("schemaVersion").and_then(|v| v.as_i64()) == Some(2) {
|
|
if value.get("layers").is_some() {
|
|
return "application/vnd.oci.image.manifest.v1+json".to_string();
|
|
}
|
|
return "application/vnd.docker.distribution.manifest.v2+json".to_string();
|
|
}
|
|
if value.get("schemaVersion").and_then(|v| v.as_i64()) == Some(1) {
|
|
return "application/vnd.docker.distribution.manifest.v1+json".to_string();
|
|
}
|
|
"application/vnd.docker.distribution.manifest.v2+json".to_string()
|
|
}
|
|
}
|