Skip to content
Generated from the .d.ts files published in guardlink@2.7.1. Report problems against guardlink, not this page.

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.

GuardLink Diff — exports.

#diff to #cmd-injection [high] cwe:CWE-78 – “git.ts runs git with a caller-supplied ref”

#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”

Property Type Description
changedFiles? Iterable<string, any, any> Files that changed between the two revisions, repo-relative (e.g. from git diff --name-only <ref>). Used only to compute staleEntitlements.

GuardLink Diff — exports.

#diff to #cmd-injection [high] cwe:CWE-78 – “git.ts runs git with a caller-supplied ref”

#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”

Property Type Description
citedFile string The changed file that the entitlement’s citation points at
entitlement ThreatModelEntitlement -

const REF_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.

getChangedFiles(root, ref): string[]

List files that changed between ref and the working tree, repo-relative.

Feeds diffModels({ changedFiles }) so an

Parameter Type
root string
ref string

string[]

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.

#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”

#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”

#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(root): string

Get the current HEAD commit hash (short).

Parameter Type
root string

string


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.

Parameter Type
root string
ref string
path string
maxBytes number

string | null


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.

Parameter Type
root string
ref string

string

Re-exports Change


Re-exports ChangeKind


Re-exports diffModels


Re-exports DiffSummary


Re-exports formatDiff


Re-exports formatDiffMarkdown


Re-exports parseAtRef


Re-exports ThreatModelDiff