ghas

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 8 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 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. CWE identifiers from CodeQL rule tags become the advisory categorization.

Index

Constants

View Source
const EventType = "code_scanning_alert"

EventType is the webhook event this source consumes.

View Source
const ID = "ghas"

ID is the source identifier stamped into the security-source label.

Variables

This section is empty.

Functions

func FindingFromAlert added in v0.10.0

func FindingFromAlert(repo ghclient.Repo, alert *ghclient.Alert) source.Finding

FindingFromAlert normalizes one code-scanning alert into the source-agnostic finding shape. Both the webhook path and the backfill lister use it.

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. It is the write-back half of the source, used when the investigation returns "ignore".

type AlertEnumerator added in v0.10.0

type AlertEnumerator interface {
	Enumerate(
		ctx context.Context, repos []string, yield func(ghclient.Repo, *ghclient.Alert) bool,
	) (complete bool, err error)
}

AlertEnumerator walks the open code-scanning alerts the credential can reach: an installation fan-out for an App, an explicit repository list for a PAT (ghclient.AppAlertEnumerator / PATAlertEnumerator). The repos it receives are only a scope hint for skipping whole installations. The Handler applies the authoritative per-repository filter.

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. New builds the ingest handler, NewResolver the verdict write-back, and NewLister the backfill listing. They are separate constructors because the repository comes from the payload on ingest, from the finding on write-back, and is the credential's whole scope for a backfill.

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 NewLister added in v0.10.0

func NewLister(e AlertEnumerator) *Handler

NewLister builds a handler for the backfill path, enumerating open alerts through e.

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) ID

func (h *Handler) ID() string

ID implements source.Handler.

func (*Handler) List added in v0.10.0

func (h *Handler) List(
	ctx context.Context, repos []string, yield func(source.Finding) bool,
) (complete bool, err error)

List implements source.Lister: it walks the enumerator's open alerts, keeps the ones matching the repository filter, and yields each as a finding. complete is false when the walk ended early: the caller's yield stopped it or the enumerator's page budget ran out.

func (*Handler) Resolve added in v0.8.0

func (h *Handler) Resolve(ctx context.Context, alerts []source.AlertRef, v source.Verdict) error

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. An id that is not is corrupt state and is reported as an error, not skipped as another tool's identifier.

Jump to

Keyboard shortcuts

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