MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / _safe_static_file

Function _safe_static_file

src/codegraphcontext/viz/server.py:47–53  ·  view source on GitHub ↗

Resolve *relative_path* under the static root; reject traversal.

(relative_path: str)

Source from the content-addressed store, hash-verified

45
46
47def _safe_static_file(relative_path: str) -> Path:
48 """Resolve *relative_path* under the static root; reject traversal."""
49 root = _static_root()
50 candidate = (root / relative_path).resolve()
51 if not is_path_under_static(candidate, root):
52 raise HTTPException(status_code=403, detail="Access denied")
53 return candidate
54
55
56def is_path_under_static(path: Path, root: Path) -> bool:

Callers 1

spa_fallbackFunction · 0.85

Calls 3

_static_rootFunction · 0.85
is_path_under_staticFunction · 0.85
resolveMethod · 0.45

Tested by

no test coverage detected