feat: allow relative target paths for git mounts
- Remove absolute path requirement from target_path validation - Resolve relative paths against working_directory at instance startup - Fall back to /home/user if no working_directory is configured - Update frontend to allow relative target paths - Update spec to document relative path support - Update tests to allow relative paths and test path traversal rejection
This commit is contained in:
@@ -36,7 +36,6 @@ export const GitMountEditor = ({ mounts, onChange }: GitMountEditorProps) => {
|
||||
const validatePath = (path: string, isTarget: boolean): string | null => {
|
||||
if (!path) return isTarget ? "Target path is required" : null;
|
||||
if (path.includes("..")) return "Path cannot contain ..";
|
||||
if (isTarget && !path.startsWith("/")) return "Target path must be absolute";
|
||||
if (!isTarget && path.startsWith("/")) return "Source path must be relative";
|
||||
return null;
|
||||
};
|
||||
@@ -200,7 +199,7 @@ const GitMountForm = ({ mount, onSave, onCancel, validatePath, validateUrl, isNe
|
||||
placeholder="e.g., /app/config"
|
||||
className={errors.target_path ? "error" : ""}
|
||||
/>
|
||||
<span className="hint">Absolute path inside container</span>
|
||||
<span className="hint">Absolute or relative path inside container (relative resolved against working dir)</span>
|
||||
{errors.target_path && <span className="error-text">{errors.target_path}</span>}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user