Back to the room

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

Code Observatory / module

git_source

codeintel.git_source

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Contains (19)
SymbolFileResolved by
_auth_configgit_source.pysame file
_classifygit_source.pysame file
_git_envgit_source.pysame file
_is_ip_literalgit_source.pysame file
_local_refgit_source.pysame file
_rungit_source.pysame file
_sanitizegit_source.pysame file
Checkoutgit_source.pysame file
GitErrorgit_source.pysame file
local_git_dirgit_source.pysame file
open_checkoutgit_source.pysame file
parse_repo_specgit_source.pysame file
raw_file_urlgit_source.pysame file
read_file_at_commitgit_source.pysame file
RepoRefgit_source.pysame file
RepoSpecErrorgit_source.pysame file
TreeEntrygit_source.pysame file
validate_refgit_source.pysame file
web_file_urlgit_source.pysame file
Imported by (6)
SymbolFileResolved by
contextcontext.pythrough an import
indexerindexer.pythrough an import
jobsjobs.pythrough an import
runtimeruntime.pythrough an import
sourcesource.pythrough an import
routerrouter.pythrough an import
codeintel.git_sourcebackend/app/codeintel/git_source.py, lines 1–40Open source
"""Safe access to repository content via the ``git`` CLI.Design points (each closes a concrete hole in the previous pipeline):* **Content comes from git objects, never the working tree.** Remote  repositories are cloned ``--bare``, and files are read with  ``git cat-file`` at a pinned commit. A malicious repository therefore  cannot use symlinks to make the indexer read files outside the clone  (symlinks have mode 120000 and are skipped; submodules, 160000, too).* **Only tracked files at one commit are indexed**, which gives  ``.gitignore`` semantics for free and makes indexing reproducible.* **Remote URLs are validated**: https only, an allowlist of hosts, no  credentials / ports / IP literals in the URL, and HTTP redirects are not  followed, so the API cannot be turned into an SSRF probe of internal  hosts.* **Private-repo tokens never appear in argv, URLs or logs**: they are  passed as a host-scoped ``http.extraHeader`` through ``GIT_CONFIG_*``  environment variables.* Every git invocation has a timeout and never prompts for credentials."""from __future__ import annotationsimport base64import ipaddressimport loggingimport osimport reimport shutilimport subprocessimport tempfilefrom collections.abc import Iteratorfrom dataclasses import dataclassfrom pathlib import Pathfrom urllib.parse import urlsplitlogger = logging.getLogger(__name__)_SEGMENT_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$")_SHA_RE = re.compile(r"^[0-9a-f]{40}([0-9a-f]{24})?$")

Shows the first 40 of 465 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
module backend.app.codeintel.git_source
File
backend/app/codeintel/git_source.py
Lines
1–465
Parser
python-ast
Git blob
6f88470169e4935929c5f865a974bd86da564c1a
Call sites
3 named, 0 resolved, 3 left unlinked
Outside this subset
12 more edges reach code outside the graph shown here

Read it on GitHub at this commit