Documentation
¶
Index ¶
- func ConvertToUTF8(content []byte) ([]byte, error)
- func DecodePath(encodedRelativePath string) (string, error)
- func EncodePath(relativePath string) string
- func GetBranchName(path string) (string, error)
- func GetCommitId(path string) (string, error)
- func GetRepositoryUrl(path string) (string, error)
- func Hash(content []byte) (string, error)
- func SanitiseCredentials(rawURL string) (string, error)
- func ToAbsolutePath(baseDir string, relativePath string) string
- func ToRelativeUnixPath(baseDir string, absoluteFilePath string) (string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertToUTF8 ¶ added in v1.20.0
func DecodePath ¶ added in v0.4.0
func EncodePath ¶ added in v0.4.0
func GetBranchName ¶ added in v1.25.0
func GetCommitId ¶ added in v1.24.0
func GetRepositoryUrl ¶ added in v1.1.0
GetRepositoryUrl resolves the "origin" remote repository URL for the checkout at path.
The repository URL is what associates findings with an SCM asset/project, so a missing URL silently disables consistent-ignores. Only the "origin" remote is used: findings are never attributed to a different remote that happens to be configured. Resolution first uses go-git and, if that produces no URL, falls back to the system git binary (which resolves config forms go-git can mis-parse). The returned URL is stripped of any embedded credentials.
func SanitiseCredentials ¶ added in v1.5.4
SanitiseCredentials returns the repository URL with any embedded credentials removed. It never returns a URL that still contains a secret:
- Standard URLs (those with a "scheme://" - https, ssh, git, ...) have their entire userinfo component stripped.
- scp-style SSH remotes ("[user@]host:path", which have no scheme) are returned unchanged: the user component (e.g. "git") is not a secret, and a password cannot appear in this syntax. An "@" at or after the host:path ":" belongs to the path (e.g. an email address in the path) and is preserved, so "host:dir/a@b.com/repo.git" is not mangled.
- Input that cannot be confidently sanitized (a "scheme://" URL that fails to parse, where credentials could be present in an unknown position) fails closed with an error rather than returning the raw, credential-bearing string.
func ToAbsolutePath ¶ added in v0.4.0
Types ¶
This section is empty.