Documentation
¶
Index ¶
- func BranchHeads(repo *gogit.Repository) (map[string]*object.Commit, error)
- func FindBranch(commit *object.Commit, repo *gogit.Repository) string
- func GenerateDiff(commit *object.Commit, fileName string) string
- type GitHubActionsPrinter
- type JSONPrinter
- type LegacyJSONCompatibleSource
- type LegacyJSONOutput
- type LegacyJSONPrinter
- type PlainPrinter
- type SarifPrinter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchHeads ¶
BranchHeads creates a map of branch names to their head commit. This can be used to find if a commit is an ancestor of a branch head.
func FindBranch ¶
func FindBranch(commit *object.Commit, repo *gogit.Repository) string
FindBranch returns the first branch a commit is a part of. Not the most accurate, but it should work similar to pre v3.0.
Types ¶
type GitHubActionsPrinter ¶ added in v3.46.0
type GitHubActionsPrinter struct {
// contains filtered or unexported fields
}
GitHubActionsPrinter is a printer that prints results in GitHub Actions format.
func (*GitHubActionsPrinter) Print ¶ added in v3.46.0
func (p *GitHubActionsPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error
type JSONPrinter ¶ added in v3.46.0
type JSONPrinter struct {
// contains filtered or unexported fields
}
JSONPrinter is a printer that prints results in JSON format.
func (*JSONPrinter) Print ¶ added in v3.46.0
func (p *JSONPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error
type LegacyJSONOutput ¶
type LegacyJSONOutput struct {
Branch string `json:"branch"`
Commit string `json:"commit"`
CommitHash string `json:"commitHash"`
Date string `json:"date"`
Diff string `json:"diff"`
Path string `json:"path"`
PrintDiff string `json:"printDiff"`
Reason string `json:"reason"`
StringsFound []string `json:"stringsFound"`
}
type LegacyJSONPrinter ¶ added in v3.46.0
type LegacyJSONPrinter struct {
// contains filtered or unexported fields
}
LegacyJSONPrinter is a printer that prints results in legacy JSON format for backwards compatibility.
func (*LegacyJSONPrinter) Print ¶ added in v3.46.0
func (p *LegacyJSONPrinter) Print(ctx context.Context, r *detectors.ResultWithMetadata) error
type PlainPrinter ¶ added in v3.46.0
type PlainPrinter struct {
// contains filtered or unexported fields
}
PlainPrinter is a printer that prints results in plain text format.
func (*PlainPrinter) Print ¶ added in v3.46.0
func (p *PlainPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error
type SarifPrinter ¶ added in v3.97.0
type SarifPrinter struct {
// contains filtered or unexported fields
}
SarifPrinter is a printer that accumulates results and, once the scan completes, emits them as a single SARIF 2.1.0 log. Unlike the other Printer implementations, SARIF results cannot be streamed one-per-line: the spec requires one JSON document containing every run and result, so Print only buffers results and Flush performs the actual marshal/write.
TODO: results are held in memory for the full scan and Flush marshals them in one pass, so peak memory grows with result count (roughly 2x at Flush, for the struct plus its marshaled JSON). Fine for typical scan sizes; if scans with very large result counts start OOMing, switch to writing results to the underlying writer incrementally as they're produced in Print.
func (*SarifPrinter) Flush ¶ added in v3.97.0
func (p *SarifPrinter) Flush(w io.Writer) error
Flush marshals every result buffered by Print into a single SARIF 2.1.0 log and writes it to w. It must be called exactly once, after all Print calls have completed (i.e. once the scan has finished), since SARIF is a single JSON document rather than a streamable format.
func (*SarifPrinter) Print ¶ added in v3.97.0
func (p *SarifPrinter) Print(_ context.Context, r *detectors.ResultWithMetadata) error
Print buffers a single result for inclusion in the SARIF document written by Flush.