Documentation
¶
Overview ¶
Package ghas implements the pkg/source plugin for GitHub Advanced Security code-scanning alerts (CodeQL first): it consumes code_scanning_alert webhook deliveries, fetches the full alert for rule help and location detail, and normalizes it into a source.Finding — extracting CWE identifiers from CodeQL rule tags as the advisory categorization.
Index ¶
Constants ¶
const EventType = "code_scanning_alert"
EventType is the webhook event this source consumes.
const ID = "ghas"
ID is the source identifier stamped into the security-source label.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlertDismisser ¶ added in v0.8.0
type AlertDismisser interface {
DismissAlert(ctx context.Context, repo ghclient.Repo, number int, reason, comment string) error
}
AlertDismisser closes a code-scanning alert on the forge — the write-back half of the source, exercised when the investigation returns "ignore".
type AlertGetter ¶
type AlertGetter interface {
GetAlert(ctx context.Context, repo ghclient.Repo, number int) (*ghclient.Alert, error)
}
AlertGetter fetches the full code-scanning alert; the webhook payload carries a summary, but the rule help markdown only comes from the API.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is the GHAS source plugin. It serves both directions: ingest, built with New, and the verdict write-back, built with NewResolver. The two are separate constructors because the repository is per-delivery on the way in (it comes from the payload) but per-finding on the way out.
func New ¶
func New(alerts AlertGetter) *Handler
New builds the ingest handler around an alert fetcher (typically an adapter that resolves the right installation client per repository).
func NewResolver ¶ added in v0.8.0
func NewResolver(d AlertDismisser, repo ghclient.Repo) *Handler
NewResolver builds a handler for the write-back path, dismissing alerts on repo. A zero repo means the finding has no repository, so there is nothing on GitHub to dismiss and Resolve does nothing.
func (*Handler) Findings ¶
func (h *Handler) Findings(ctx context.Context, event string, payload []byte) ([]source.Finding, error)
Findings implements source.Handler: it normalizes one delivery, fetching the full alert from the API.
func (*Handler) Resolve ¶ added in v0.8.0
Resolve implements source.Resolver: it dismisses every code-scanning alert it is handed. The caller groups alerts by source and passes only this handler's own, so a GHAS alert id is always a decimal alert number — one that is not is corrupt state worth surfacing, not another tool's identifier to step over.