ghas

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 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 — extracting CWE identifiers from CodeQL rule tags as 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 — the single mapping both the webhook path and the backfill lister go through.

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 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 credential's reachable open code-scanning alerts — an installation fan-out for an App, an explicit repository list for a PAT (ghclient.AppAlertEnumerator / PATAlertEnumerator). The repos entries it receives are only a scope hint (skipping whole installations); the authoritative per-repository filter is the Handler's.

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 three directions: ingest, built with New; the verdict write-back, built with NewResolver; and the backfill listing, built with NewLister. They are separate constructors because the repository is per-delivery on the way in (it comes from the payload), per-finding on the way out, and 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 — one that is not is corrupt state worth surfacing, not another tool's identifier to step over.

Jump to

Keyboard shortcuts

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