Documentation
¶
Index ¶
- Constants
- func ChangedLineRanges(logger *zap.Logger, repoPath, baseRef, headRef string) (map[string][]LineRange, error)
- func CheckoutRef(logger *zap.Logger, repoPath, ref string) error
- func CloneTemp(ctx context.Context, logger *zap.Logger, repoURL, ref string) (string, error)
- func FindRepoRoot(logger *zap.Logger, path string) (string, error)
- func HeadCommit(ctx context.Context, logger *zap.Logger, path string) string
- func MaterializeLocalRef(ctx context.Context, logger *zap.Logger, sourceRepoPath, ref string) (string, error)
- func MaterializeRemoteRef(ctx context.Context, logger *zap.Logger, sourceRepoPath, ref string) (string, error)
- func PublicURL(raw string) string
- func VerifyRef(logger *zap.Logger, repoPath, ref string) error
- type LineRange
Constants ¶
const ( // RemoteOperationTimeout bounds one constrained remote materialization flow. // Git does not expose a reliable byte quota, so elapsed time is the // enforceable in-process boundary before checkout validation. RemoteOperationTimeout = 10 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ChangedLineRanges ¶ added in v0.14.17
func ChangedLineRanges(logger *zap.Logger, repoPath, baseRef, headRef string) (map[string][]LineRange, error)
ChangedLineRanges returns added/changed head-side line ranges from a git diff. Deleted-only hunks are omitted because there is no head line for SARIF to annotate.
func CheckoutRef ¶
CheckoutRef checks out ref in repoPath.
func CloneTemp ¶
CloneTemp clones repoURL into a temporary directory and optionally checks out ref. The caller owns cleanup of the returned directory.
func FindRepoRoot ¶
FindRepoRoot resolves the git repository root for path.
func HeadCommit ¶ added in v0.27.0
HeadCommit returns the commit path's checkout is at, or "" when path is not inside a git repository, git is not available, or HEAD does not resolve -- a scan of a plain directory has no commit to record, and that is not an error. The value is what a scan record names as the commit it ran against: for a clone, the commit CloneTemp checked out; for a local path, whatever the working tree is at, which is the best a scan can say.
func MaterializeLocalRef ¶
func MaterializeLocalRef(ctx context.Context, logger *zap.Logger, sourceRepoPath, ref string) (string, error)
MaterializeLocalRef clones sourceRepoPath into a temporary directory and checks out ref. Local repositories are trusted inputs, so repository symlinks are preserved even when they point outside the checkout. The caller owns cleanup of the returned directory.
func MaterializeRemoteRef ¶ added in v0.21.0
func MaterializeRemoteRef(ctx context.Context, logger *zap.Logger, sourceRepoPath, ref string) (string, error)
MaterializeRemoteRef clones an already-fetched remote repository into a temporary directory, checks out ref, and validates the resulting tree. The caller owns cleanup of the returned directory.
func PublicURL ¶ added in v0.27.0
PublicURL returns a repository URL as a public identity: without the userinfo, the query and the fragment it may carry. A token or password in the userinfo, or in a query parameter, is what git needs to fetch and is never what a scan record, a plugin request or a log should repeat, and neither a query nor a fragment names a repository. A value that does not parse as a URL with a scheme -- the scp-like git@host:org/repo form, a bare path -- is returned as it was; net/url owns what a URL is and how it re-serializes.