ghtasks

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const DefaultAPIURL = "https://api.github.com"

DefaultAPIURL is api.github.com; GitHub Enterprise Server is passed in.

Variables

View Source
var ErrRateLimited = errors.New("GitHub API rate limit exhausted")

ErrRateLimited is returned when GitHub refuses for quota.

Functions

func FailsAt

func FailsAt(rep *ghaudit.Report, sev ghaudit.Severity) bool

FailsAt reports whether any finding is at or above sev.

func HostForAPI

func HostForAPI(apiURL string) string

HostForAPI is the web host that pairs with an API base URL.

func LoadLocal

func LoadLocal(root string) (map[string][]byte, error)

LoadLocal reads the files the engine evaluates from a checkout: workflows, action metadata under .github/ and at the root, and CODEOWNERS.

func RepoFromRemote

func RepoFromRemote(remote, host string) string

RepoFromRemote returns owner/name for a github.com (or apiHost) remote URL.

func RuleDocs

func RuleDocs() map[string]string

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.

func WriteTable

func WriteTable(w io.Writer, rep *ghaudit.Report, s Summary, notes []string)

WriteTable renders a report for a terminal.

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

func (g *RESTGetter) Get(ctx context.Context, path string, out any) (int, error)

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.

type Summary

type Summary struct {
	BySeverity map[ghaudit.Severity]int `json:"bySeverity"`
	Total      int                      `json:"total"`
	Unknown    []string                 `json:"notEvaluated,omitempty"` // rule ids not evaluated for missing facts
	Files      int                      `json:"files"`
}

Summary counts a report for display and exit codes.

func Summarise

func Summarise(rep *ghaudit.Report, files int) Summary

Summarise counts findings and the rules that could not run.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL