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

Function _has_symlinked_component

src/specify_cli/integrations/kimi/__init__.py:163–181  ·  view source on GitHub ↗

Return ``True`` when *path* escapes *project_root* or any component is a symlink. Walks the components strictly between *project_root* and *path* (including the final one) and reports whether any of them is a symlink. Components that do not exist yet are not symlinks, so this safely han

(path: Path, project_root: Path)

Source from the content-addressed store, hash-verified

161
162
163def _has_symlinked_component(path: Path, project_root: Path) -> bool:
164 """Return ``True`` when *path* escapes *project_root* or any component is a symlink.
165
166 Walks the components strictly between *project_root* and *path*
167 (including the final one) and reports whether any of them is a symlink.
168 Components that do not exist yet are not symlinks, so this safely handles
169 a not-yet-created destination. *project_root* itself is trusted and never
170 checked. A *path* outside *project_root* is treated as unsafe.
171 """
172 try:
173 relative = path.relative_to(project_root)
174 except ValueError:
175 return True
176 current = project_root
177 for part in relative.parts:
178 current = current / part
179 if current.is_symlink():
180 return True
181 return False
182
183
184def _is_safe_legacy_dir(path: Path, project_root: Path) -> bool:

Callers 2

setupMethod · 0.85
_is_safe_legacy_dirFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected