source

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 source is patchy's public plugin seam for security-finding sources. A source turns tool-specific webhook deliveries (GitHub Advanced Security code-scanning alerts, other SAST tools, agentic findings) into normalized Findings; the source-controller owns everything downstream — issue creation, accumulation, and labels — so a new source implements Handler and registers it, nothing more.

Implementations may live outside this repository; the exported API is deliberately self-contained and depends on nothing under internal/. Dependencies a handler needs to enrich a delivery (an API client to fetch the full alert, say) are injected at construction, not passed per call.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Finding

type Finding struct {
	// Source is the emitting Handler's ID, e.g. "ghas".
	Source string
	Repo   Repo
	// AlertNumber is the source-native unique finding number (the
	// code-scanning alert number for GHAS).
	AlertNumber int
	// Advisories are the categorization identifiers (CWE/CVE/GHSA numbers),
	// most authoritative first: Advisories[0] is the accumulation key
	// (GHSA over CVE over CWE, per the source's judgement).
	Advisories []string
	// RuleID is the tool's rule identifier, e.g. a CodeQL query id.
	RuleID string
	// Title is a one-line human summary.
	Title string
	// Description is the full markdown help/description for the rule.
	Description string
	// Severity is the tool-reported severity, normalized by the handler to
	// low, medium, high, or critical.
	Severity string
	// HTMLURL links back to the finding in the source tool.
	HTMLURL string
	// Locations are the places the finding was raised, when available.
	Locations []Location
}

Finding is a source-agnostic security finding. The source-controller keys accumulation on (Repo, Source, primary advisory) and stamps the labels and issue content from these fields alone.

type Handler

type Handler interface {
	// ID names the source; it becomes the security-source label value.
	ID() string
	// Events lists the GitHub webhook event types the handler consumes,
	// e.g. ["code_scanning_alert"]. The source-controller routes matching
	// deliveries to Findings.
	Events() []string
	// Findings normalizes one webhook delivery into zero or more Findings.
	// A delivery the handler chooses to skip (an action it does not act on,
	// say) returns (nil, nil).
	Findings(ctx context.Context, eventType string, payload []byte) ([]Finding, error)
}

Handler is the interface a finding source implements.

type Location

type Location struct {
	// Path is repository-relative.
	Path      string `json:"path"`
	StartLine int    `json:"start_line,omitempty"`
	EndLine   int    `json:"end_line,omitempty"`
	// Snippet is the offending source excerpt, when the tool provides one.
	Snippet string `json:"snippet,omitempty"`
}

Location is one place in the repository a finding points at. The json tags are part of the public contract: locations are embedded verbatim in issue manifests and agent handoff files.

type Repo

type Repo struct {
	Owner string
	Name  string
}

Repo identifies a GitHub repository.

func (Repo) String

func (r Repo) String() string

String returns "owner/name".

Jump to

Keyboard shortcuts

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