{"record":{"id":"d216f31a1d13e1c9","repo":"Hmbown/CodeWhale","slug":"project-workspace-path-cannot-contain-compone","errorCode":null,"errorMessage":"project workspace path cannot contain '..' components","messagePattern":"project workspace path cannot contain '\\.\\.' components","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/lib.rs","lineNumber":6804,"sourceCode":"            return Err(err).with_context(|| {\n                format!(\"failed to resolve config directory {}\", parent.display())\n            });\n        }\n    };\n    let normalized = parent.join(file_name);\n    reject_path_symlink(&normalized)?;\n    Ok(normalized)\n}\n\nfn normalize_project_workspace(workspace: &Path) -> Result<PathBuf> {\n    if workspace.as_os_str().is_empty() {\n        bail!(\"project workspace path cannot be empty\");\n    }\n    if workspace\n        .components()\n        .any(|component| matches!(component, Component::ParentDir))\n    {\n        bail!(\"project workspace path cannot contain '..' components\");\n    }\n    let absolute = if workspace.is_absolute() {\n        workspace.to_path_buf()\n    } else {\n        std::env::current_dir()\n            .context(\"failed to resolve current directory for project workspace\")?\n            .join(workspace)\n    };\n    match absolute.canonicalize() {\n        Ok(path) => Ok(path),\n        Err(err) if err.kind() == std::io::ErrorKind::NotFound => {\n            Ok(normalize_path_components(&absolute))\n        }\n        Err(err) => Err(err).with_context(|| {\n            format!(\n                \"failed to resolve project workspace {}\",\n                workspace.display()\n            )","sourceCodeStart":6786,"sourceCodeEnd":6822,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/lib.rs#L6786-L6822","documentation":"normalize_project_workspace rejects workspace paths containing '..' components, mirroring the config-path rule. This blocks traversal outside the intended project root and forces unambiguous path input. Resolve the path yourself if you genuinely need parent-directory semantics.","triggerScenarios":"Passing a workspace path like \"~/project/../other\" (even though ~ was expanded), \"/srv/../home/u/proj\", or \"sub/../.\" to the workspace setting API.","commonSituations":"Shell scripts constructing workspaces from variables with ../ segments, users writing relative workspaces in config.toml, or tools templating monorepo paths with parent jumps.","solutions":["Use an absolute workspace path without '..' components","Canonicalize the path with std::fs::canonicalize (or realpath) before passing it","Rewrite the relative path so it contains no parent components"],"exampleFix":"// before\nset_workspace(PathBuf::from(\"/srv/../home/u/proj\"))\n// after\nset_workspace(PathBuf::from(\"/home/u/proj\"))","handlingStrategy":"validation","validationCode":"fn no_parent_components(p: &std::path::Path) -> bool {\n    use std::path::Component;\n    !p.components().any(|c| matches!(c, Component::ParentDir))\n}","typeGuard":"fn safe_workspace(p: &str) -> Option<std::path::PathBuf> {\n    use std::path::Component;\n    let path = std::path::PathBuf::from(p);\n    (!path.components().any(|c| matches!(c, Component::ParentDir))).then_some(path)\n}","tryCatchPattern":"match normalize_project_workspace(&workspace) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"'..' components\") => {\n        let real = std::fs::canonicalize(&workspace).ok()?;\n        normalize_project_workspace(&real)?\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Store absolute workspace paths in config.toml","Canonicalize before validating, not after","Avoid shell variables with embedded '..' segments"],"tags":["config","path","workspace","path-traversal"],"backgroundTag":"path-traversal-blocked","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}