Documentation
¶
Overview ¶
Package ghtasks runs the Vulnetix GitHub posture engine (vdb-sca-match ghaudit) for the `vulnesis gha` analysis tasks: workflows, actions, settings, org and audit. It owns everything the engine leaves to its callers: reading local workflow files, talking to the GitHub REST API, and rendering a report.
Index ¶
- Constants
- Variables
- func FailsAt(rep *ghaudit.Report, sev ghaudit.Severity) bool
- func HostForAPI(apiURL string) string
- func LoadLocal(root string) (map[string][]byte, error)
- func RepoFromRemote(remote, host string) string
- func RuleDocs() map[string]string
- func WriteTable(w io.Writer, rep *ghaudit.Report, s Summary, notes []string)
- type Advisories
- type AdvisoryLookup
- type RESTGetter
- type Summary
Constants ¶
const DefaultAPIURL = "https://api.github.com"
DefaultAPIURL is api.github.com; GitHub Enterprise Server is passed in.
Variables ¶
var ErrRateLimited = errors.New("GitHub API rate limit exhausted")
ErrRateLimited is returned when GitHub refuses for quota.
Functions ¶
func HostForAPI ¶
HostForAPI is the web host that pairs with an API base URL.
func LoadLocal ¶
LoadLocal reads the files the engine evaluates from a checkout: workflows, action metadata under .github/ and at the root, and CODEOWNERS.
func RepoFromRemote ¶
RepoFromRemote returns owner/name for a github.com (or apiHost) remote URL.
func RuleDocs ¶
RuleDocs renders the pages for the GitHub posture rules: docs/generated/github-rules/_index.md and one page per rule. They are not published from this repository: vdb-sca-match is private, so the platform docs (docs.vulnetix.com, Vulnetix/platform-docs) cannot run this renderer and instead read the committed pages from a git ref of this repository with migration/generators/github-rules.mjs.
Types ¶
type Advisories ¶
type Advisories struct {
Lookup AdvisoryLookup
Failed bool
Asked int
// contains filtered or unexported fields
}
Advisories adapts a lookup to ghaudit.CollectOptions.Advisories, asking once per action@ref. Failed reports whether any lookup failed, so the caller can say the known-vulnerable rule was not fully evaluated.
func (*Advisories) Func ¶
func (a *Advisories) Func() func(ctx context.Context, action, ref, sha string) []ghaudit.ActionAdvisory
Func returns the callback for CollectOptions.Advisories.
type AdvisoryLookup ¶
type AdvisoryLookup func(ctx context.Context, action, ref string) (ids []ghaudit.ActionAdvisory, ok bool)
AdvisoryLookup answers one action reference: the advisories that affect the version its ref names. ok=false means the lookup failed.
type RESTGetter ¶
type RESTGetter struct {
BaseURL string
Token string
Client *http.Client
// Calls counts requests, for the report.
Calls int
// MaxWait caps the total time Get spends waiting out rate limits for one
// request. A limit that resets later than that fails at once with
// ErrRateLimited instead of stalling the run.
MaxWait time.Duration
// RetryBase is the first backoff when GitHub refuses for quota without
// saying when to come back; it doubles on each retry.
RetryBase time.Duration
}
RESTGetter is a ghaudit.Getter over net/http with a token.
func NewRESTGetter ¶
func NewRESTGetter(baseURL, token string) *RESTGetter
NewRESTGetter returns a getter for baseURL ("" for github.com).
func (*RESTGetter) Get ¶
Get implements ghaudit.Getter. A refusal for quota (403 or 429 with no requests remaining, or with Retry-After) is retried after the wait GitHub asks for, Retry-After first and then X-RateLimit-Reset, or after an exponential backoff when it names none, as long as the waits fit in MaxWait. Past that it returns ErrRateLimited.