{"record":{"id":"7b2c5d5c225ec0bb","repo":"BigPizzaV3/CodexPlusPlus","slug":"name-7b2c5d","errorCode":null,"errorMessage":"主题包路径不安全：{name}","messagePattern":"主题包路径不安全：(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_package.rs","lineNumber":819,"sourceCode":"            }\n            \"saturate\" => numeric(argument, \"\", 0.5, 2.0),\n            \"brightness\" | \"contrast\" => numeric(argument, \"\", 0.8, 1.5),\n            _ => false,\n        };\n        if !valid {\n            return false;\n        }\n    }\n    seen.contains(\"blur\")\n}\n\nfn parse_json<T: serde::de::DeserializeOwned>(bytes: &[u8], label: &str) -> anyhow::Result<T> {\n    serde_json::from_slice(bytes).with_context(|| format!(\"{label} 不是有效 JSON\"))\n}\n\nfn validate_archive_entry_name(name: &str) -> anyhow::Result<()> {\n    if name.is_empty() || name.starts_with('/') || name.contains('\\\\') {\n        bail!(\"主题包路径不安全：{name}\");\n    }\n    if name != name.trim()\n        || name.contains(['\\0', ':'])\n        || name.split('/').any(|part| part == \".\" || part == \"..\")\n        || (!name.starts_with(\"__MACOSX/\")\n            && name.split('/').filter(|part| !part.is_empty()).count() > 2)\n    {\n        bail!(\"主题包文件名不安全：{name}\");\n    }\n    Ok(())\n}\n\nfn normalize_package_entries(\n    entries: Vec<(String, Option<Vec<u8>>)>,\n) -> anyhow::Result<std::collections::BTreeMap<String, Vec<u8>>> {\n    let content_entries = entries\n        .into_iter()\n        .filter_map(|(name, content)| content.map(|content| (name, content)))","sourceCodeStart":801,"sourceCodeEnd":837,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_package.rs#L801-L837","documentation":"validate_archive_entry_name rejects unsafe entry names inside a Dream Skin .dskin zip archive before contents are read. A name that is empty, starts with '/', or contains a backslash is rejected with this message to prevent path traversal and Windows absolute/escape paths.","triggerScenarios":"validate_and_read_package encounters an archive entry whose name is \"\", \"/etc/passwd\", \"foo\\\\bar.css\", or otherwise begins with a slash or contains a backslash.","commonSituations":"Hand-crafted or tool-modified zip files with absolute paths; archives built on Windows with backslash separators; tampered packages distributed online.","solutions":["Rebuild the package so entry names are relative, use '/' separators, and start without a slash.","Repack with a standard tool (zip/7z) rather than custom archive writers.","If you are the packager, normalize names before writing entries (strip leading '/', replace '\\\\' with '/')."],"exampleFix":"// before (custom writer)\nlet entry = add_entry(\"/theme/theme.css\", data);\n// after\nlet entry = add_entry(\"theme/theme.css\", data);","handlingStrategy":"validation","validationCode":"fn entry_name_safe(name: &str) -> bool {\n    !name.is_empty() && !name.starts_with('/') && !name.contains('\\\\')\n}\n// call for every zip entry before writing","typeGuard":null,"tryCatchPattern":"match validate_and_read_package(path, platform) {\n    Ok(pkg) => install(pkg),\n    Err(e) if e.to_string().contains(\"路径不安全\") => eprintln!(\"repack archive with relative '/'-separated names\"),\n    Err(e) => return Err(e),\n}","preventionTips":["Use standard zip tooling with relative paths.","Never hand-write archive entry names.","Scan packages with zipinfo before distribution."],"tags":["security","path-traversal","zip"],"backgroundTag":"path-traversal-blocked","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}