diff
Everything exported by guardlink/diff, from the .d.ts files published in guardlink@2.7.1. See the entry points for the other subpaths, and use guardlink as a library for worked examples.
Interfaces
Section titled “Interfaces”DiffOptions
Section titled “DiffOptions”GuardLink Diff — exports.
Exposes
Section titled “Exposes”#diff to #cmd-injection [high] cwe:CWE-78 – “git.ts runs git with a caller-supplied ref”
Mitigates
Section titled “Mitigates”#diff against #cmd-injection using #param-commands – “git.ts runs every git call through execFileSync with an argument array and resolves the ref to a sha first (resolveCommit)”
GitRef -> #diff via parseAtRef – “Git reference input”
Properties
Section titled “Properties”StaleEntitlement
Section titled “StaleEntitlement”GuardLink Diff — exports.
Exposes
Section titled “Exposes”#diff to #cmd-injection [high] cwe:CWE-78 – “git.ts runs git with a caller-supplied ref”
Mitigates
Section titled “Mitigates”#diff against #cmd-injection using #param-commands – “git.ts runs every git call through execFileSync with an argument array and resolves the ref to a sha first (resolveCommit)”
GitRef -> #diff via parseAtRef – “Git reference input”
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
citedFile |
string |
The changed file that the entitlement’s citation points at |
entitlement |
ThreatModelEntitlement |
- |
Variables
Section titled “Variables”REF_SHAPE
Section titled “REF_SHAPE”
constREF_SHAPE:RegExp
A git ref as a person types one: a sha, branch, tag, HEAD~3, origin/main,
main@{1}. It must start with a letter or digit, so it cannot read as an
option, and it carries no whitespace, quoting or shell syntax.
Functions
Section titled “Functions”getChangedFiles()
Section titled “getChangedFiles()”getChangedFiles(
root,ref):string[]
List files that changed between ref and the working tree, repo-relative.
Feeds diffModels({ changedFiles }) so an
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root |
string |
ref |
string |
Returns
Section titled “Returns”string[]
Entitles
Section titled “Entitles”whose cited authorization code moved is reported as stale (actor-entitlement design §3.7). Returns [] on any git failure — staleness is advisory, and a diff that cannot resolve the ref should still report the rest of the delta.
Exposes
Section titled “Exposes”#diff to #cmd-injection [high] cwe:CWE-78 – “getChangedFiles passes the caller’s ref (a CLI, TUI or dashboard –since argument) to git diff –name-only”
Mitigates
Section titled “Mitigates”#diff against #cmd-injection using #input-sanitize – “resolveCommit checks the ref’s shape and resolves it to a sha first; a ref it refuses returns [] and runs nothing further”
Mitigates
Section titled “Mitigates”#diff against #cmd-injection using #param-commands – “git diff runs through execFileSync with the sha as one argument”
GitRef -> #diff via execFileSync – “Ref input to git diff –name-only”
#diff -> ChangedFileList via return – “Repo-relative paths used for entitlement staleness”
getCurrentRef()
Section titled “getCurrentRef()”getCurrentRef(
root):string
Get the current HEAD commit hash (short).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root |
string |
Returns
Section titled “Returns”string
readFileAtRef()
Section titled “readFileAtRef()”readFileAtRef(
root,ref,path,maxBytes):string|null
One file’s text as committed at ref, its path relative to root; null when that commit has no
such file. The ref goes through resolveCommit and both git calls take the sha, never the ref.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root |
string |
ref |
string |
path |
string |
maxBytes |
number |
Returns
Section titled “Returns”string | null
resolveCommit()
Section titled “resolveCommit()”resolveCommit(
root,ref):string
Resolve ref to the full sha of the commit it names, or throw.
The ref is checked against REF_SHAPE and passed after --end-of-options, and
the sha is what every later git call is given: the ref itself is used once.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
root |
string |
ref |
string |
Returns
Section titled “Returns”string
References
Section titled “References”Change
Section titled “Change”Re-exports Change
ChangeKind
Section titled “ChangeKind”Re-exports ChangeKind
diffModels
Section titled “diffModels”Re-exports diffModels
DiffSummary
Section titled “DiffSummary”Re-exports DiffSummary
formatDiff
Section titled “formatDiff”Re-exports formatDiff
formatDiffMarkdown
Section titled “formatDiffMarkdown”Re-exports formatDiffMarkdown
parseAtRef
Section titled “parseAtRef”Re-exports parseAtRef
ThreatModelDiff
Section titled “ThreatModelDiff”Re-exports ThreatModelDiff

