Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

Fetch from an allowlisted host

Https only, allowlisted hosts, no redirects, a size cap and a timeout.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

_fetch_httpsbackend/app/codeintel/source.py, lines 97–118Open source
def _fetch_https(url: str, token: str | None) -> bytes:    import httpx    host = urlsplit(url).hostname    if urlsplit(url).scheme != "https" or host not in RAW_CONTENT_HOSTS:        raise PermissionError(f"refusing to fetch from {host!r}")    headers = {}    if token and host == "raw.githubusercontent.com":        headers["Authorization"] = f"token {token}"    with httpx.Client(timeout=FETCH_TIMEOUT_SECONDS, follow_redirects=False) as client:        with client.stream("GET", url, headers=headers) as resp:            if resp.status_code == 404:                raise FileNotFoundError(url)            if resp.status_code != 200:                raise ConnectionError(f"HTTP {resp.status_code}")            chunks, size = [], 0            for part in resp.iter_bytes():                size += len(part)                if size > MAX_FETCH_BYTES:                    raise OverflowError("file too large")                chunks.append(part)    return b"".join(chunks)

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/codeintel/source.py
Lines
97–118
Git blob
c9f05cf7bf871b09919d64e9fdaf8380ecc3df2c
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/codeintel/source.py
git show 975a38d:backend/app/codeintel/source.py | sed -n '97,118p'