MCPcopy Create free account
hub / github.com/github/spec-kit / _reject_unsafe_dir

Function _reject_unsafe_dir

src/specify_cli/workflows/_commands.py:69–82  ·  view source on GitHub ↗

Refuse to proceed when *path* is a symlink or an existing non-directory. A symlinked ``.specify`` (or ``.specify/workflows``) could redirect workflow writes outside the project root, so any command that creates or writes files beneath it must bail first. Absence is tolerated — the calle

(path: Path, label: str)

Source from the content-addressed store, hash-verified

67
68
69def _reject_unsafe_dir(path: Path, label: str) -> None:
70 """Refuse to proceed when *path* is a symlink or an existing non-directory.
71
72 A symlinked ``.specify`` (or ``.specify/workflows``) could redirect
73 workflow writes outside the project root, so any command that creates or
74 writes files beneath it must bail first. Absence is tolerated — the caller
75 creates the directory — only an existing-but-wrong target is rejected.
76 """
77 if path.is_symlink():
78 err_console.print(f"[red]Error:[/red] Refusing to use symlinked {label} path")
79 raise typer.Exit(1)
80 if path.exists() and not path.is_dir():
81 err_console.print(f"[red]Error:[/red] {label} path exists but is not a directory")
82 raise typer.Exit(1)
83
84
85def _reject_unsafe_workflow_storage(project_root: Path) -> None:

Callers 3

_safe_workflow_id_dirFunction · 0.85
workflow_addFunction · 0.85

Calls 1

printMethod · 0.80

Tested by

no test coverage detected