Expand description
Git-LFS pointer recognition, shared by the scanner (oid suppression) and sources (unscanned-blob coverage gap). Git-LFS pointer recognition.
A file tracked by Git LFS is committed not as
its real bytes but as a tiny text pointer, the actual blob lives in LFS
storage and is only materialised on git lfs pull. A canonical pointer is:
version https://git-lfs.github.com/spec/v1
oid sha256:<64 lowercase hex>
size <decimal bytes>The spec fixes the version line first and then lists the remaining keys in
alphabetical order, so oid always precedes size; optional ext-* lines
may appear between version and oid.
Two consumers share this recognition, which is why it lives in core:
- the scanner suppresses the pointer’s 64-hex
oid(it is a content hash, not a leaked secret, yet matches a generic high-entropy hex shape), and - a source records a coverage gap, the pointer’s real blob (
sizebytes) was NOT scanned, so a repo of unmaterialised LFS pointers is not reported as a false-clean.
Recognition is deliberately strict (all three well-formed lines, in order): a false positive would suppress a real credential, and a whole-file pointer is unambiguous, so strictness costs no recall.
Constants§
- GIT_
LFS_ VERSION_ LINE - The exact first line of every Git-LFS pointer. Compared case-insensitively because the recognition is content-classification, not byte-exact parsing.
- SHA256_
HEX_ LEN - The number of hex characters in a
sha256object id.
Functions§
- is_
git_ lfs_ oid_ line - True if
lineis a Git-LFSoid sha256:<64 hex>line. The 64-hex body is what the scanner must NOT flag as a secret. - is_
git_ lfs_ pointer - True if
contentis a whole Git-LFS pointer file: aversionline, then anoidline, then asizeline, in that spec-mandated order. Lines that are none of the three (e.g. optionalext-*lines, or blank lines) are tolerated between the anchors, matching real pointers. - is_
git_ lfs_ size_ line - True if
lineis a Git-LFSsize <decimal>line. - is_
git_ lfs_ version_ line - True if
line(ignoring surrounding ASCII whitespace) is the Git-LFSversionline.