fix: remove final 3 hardcoded paths for D-4 compliance
Final cleanup: 1. main.rs:35 - Remove hardcoded .env fallback - Rationale: L30-34 already provide correct current_exe() resolution - Removes dev path, aligns with A-14.3 "禁止读取 dev 设定" 2. docs.rs:11,24 - Use current_exe() resolution - Replace hardcoded doc_wasm paths - Add MOMENTRY_DOCS_DIR env var support - Fallback to relative path Result: - All hardcoded dev paths removed from release binary - D-4 Gate satisfied - Zero momentry_core/nextorageai paths in source Impact: - Binary fully portable - No dev environment assumptions - All paths runtime-resolved
This commit is contained in:
+8
-1
@@ -21,7 +21,14 @@ async fn wasm_doc_file_handler(
|
||||
if file.contains("..") || file.contains("//") {
|
||||
return Err((StatusCode::NOT_FOUND, "Invalid path"));
|
||||
}
|
||||
let base = std::path::Path::new("/Users/accusys/momentry_core/docs_v1.0/doc_wasm");
|
||||
let base_str = std::env::var("MOMENTRY_DOCS_DIR")
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|d| d.join("docs_v1.0/doc_wasm").to_string_lossy().to_string()))
|
||||
.unwrap_or_else(|| "docs_v1.0/doc_wasm".to_string())
|
||||
});
|
||||
let base = std::path::Path::new(&base_str);
|
||||
let path = base.join(&file);
|
||||
if !path.exists() || !path.starts_with(base) {
|
||||
return Err((StatusCode::NOT_FOUND, "File not found"));
|
||||
|
||||
Reference in New Issue
Block a user