connector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package connector delivers a finished Report to an external destination (webhook, chat, CI artifact, …). A Connector is an outbound adapter: it takes the shared Report model and pushes it somewhere. Adding an integration means implementing this one interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(ctx context.Context, r *engine.Report, conns ...Connector) []error

Dispatch sends the report to every connector, collecting (not aborting on) errors so one failing destination does not stop the others.

Types

type Connector

type Connector interface {
	Name() string
	Send(ctx context.Context, r *engine.Report) error
}

Connector delivers a report to an external system.

type GitHubCodeScanning

type GitHubCodeScanning struct {
	APIBase   string // default https://api.github.com (override for GitHub Enterprise)
	Owner     string
	Repo      string
	Token     string
	CommitSHA string
	Ref       string // e.g. "refs/heads/main"
	Client    *http.Client
}

GitHubCodeScanning uploads the report as SARIF to GitHub's code-scanning API (POST /repos/{owner}/{repo}/code-scanning/sarifs). GitHub requires the SARIF gzipped then base64-encoded, tied to a commit and ref. This surfaces findings in the repo's Security tab and on pull requests.

func NewGitHubCodeScanning

func NewGitHubCodeScanning(owner, repo, token, commitSHA, ref string) *GitHubCodeScanning

NewGitHubCodeScanning builds a code-scanning uploader with API defaults.

func (*GitHubCodeScanning) Name

func (g *GitHubCodeScanning) Name() string

func (*GitHubCodeScanning) Send

type Jira

type Jira struct {
	BaseURL    string // e.g. https://acme.atlassian.net
	ProjectKey string // e.g. "SEC"
	Email      string
	Token      string
	IssueType  string // default "Task"
	// MinSeverity suppresses issue creation unless a finding at or above this
	// level exists. SeverityUnknown means "always create".
	MinSeverity engine.Severity
	Client      *http.Client
}

Jira opens a tracking issue for a scan by calling the Jira Cloud REST API (POST /rest/api/2/issue). It creates a single summary issue describing the run, gated by MinSeverity so a clean scan does not spam the backlog. Auth is HTTP basic with an account email and an API token, per Jira Cloud.

func NewJira

func NewJira(baseURL, projectKey, email, token string) *Jira

NewJira builds a Jira connector with a default issue type and timeout.

func (*Jira) Name

func (j *Jira) Name() string

func (*Jira) Send

func (j *Jira) Send(ctx context.Context, r *engine.Report) error

type MCPPush

type MCPPush struct {
	Endpoint string // MCP HTTP endpoint, e.g. http://agent-host:7423/mcp
	// Method is the JSON-RPC notification method; defaults to
	// "notifications/scan_completed".
	Method string
	Client *http.Client
}

MCPPush notifies a Model Context Protocol endpoint that a scan completed, delivering the report as a JSON-RPC 2.0 notification. It lets an agent runtime react to fresh scan results (open a ticket, kick off triage) without polling. It is a notification, not a request: fire-and-forget fits an outbound connector, and any 2xx (including 204 No Content) counts as delivered.

func NewMCPPush

func NewMCPPush(endpoint string) *MCPPush

NewMCPPush builds an MCP push connector with defaults.

func (*MCPPush) Name

func (m *MCPPush) Name() string

func (*MCPPush) Send

func (m *MCPPush) Send(ctx context.Context, r *engine.Report) error

type SARIFFile

type SARIFFile struct {
	Path string
}

SARIFFile writes the report as a SARIF file, e.g. for upload as a CI artifact or to GitHub code scanning.

func NewSARIFFile

func NewSARIFFile(path string) *SARIFFile

NewSARIFFile builds a SARIF-file connector targeting path.

func (*SARIFFile) Name

func (f *SARIFFile) Name() string

func (*SARIFFile) Send

func (f *SARIFFile) Send(_ context.Context, r *engine.Report) error

type SIEM

type SIEM struct {
	URL    string
	APIKey string // sent as "Authorization: <APIKey>" when non-empty
	Source string // event.provider label; default "docker-security"
	Client *http.Client
}

SIEM ships each finding as a structured event to a generic HTTP collector (Splunk HEC, Elastic, a Logstash HTTP input, a custom SOC webhook). Events are newline-delimited JSON in an ECS-flavored shape, which most SIEMs ingest directly. It is intentionally vendor-neutral: point it at any endpoint that accepts a POST of NDJSON.

func NewSIEM

func NewSIEM(url string) *SIEM

NewSIEM builds a SIEM connector with a default timeout.

func (*SIEM) Name

func (s *SIEM) Name() string

func (*SIEM) Send

func (s *SIEM) Send(ctx context.Context, r *engine.Report) error

type Slack

type Slack struct {
	WebhookURL string
	Client     *http.Client
	// MaxFindings caps how many individual findings are listed (0 = summary only).
	MaxFindings int
}

Slack posts a summary message to a Slack incoming-webhook URL.

func NewSlack

func NewSlack(url string) *Slack

NewSlack builds a Slack connector.

func (*Slack) Name

func (s *Slack) Name() string

func (*Slack) Send

func (s *Slack) Send(ctx context.Context, r *engine.Report) error

type Webhook

type Webhook struct {
	URL    string
	Client *http.Client
}

Webhook POSTs the full JSON report to an arbitrary URL.

func NewWebhook

func NewWebhook(url string) *Webhook

NewWebhook builds a Webhook connector with a sane default timeout.

func (*Webhook) Name

func (h *Webhook) Name() string

func (*Webhook) Send

func (h *Webhook) Send(ctx context.Context, r *engine.Report) error

Jump to

Keyboard shortcuts

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