Documentation
¶
Overview ¶
Package wiz is the Wiz source: it turns Wiz automation-rule webhook deliveries into patchy Findings. Two feeds share one endpoint — Wiz Issues (cloud misconfigurations and toxic combinations) and Wiz Defend (threat detections) — discriminated by payload shape, not by path or header: a Wiz automation action POSTs whatever body its rule template renders and carries no event-type header.
The body template documented in docs/integrations/wiz.md is therefore the payload contract: this package decodes exactly the shapes that document tells operators to configure. There is no other spec to hold Wiz to — the payloads are operator-templated mustache, so patchy publishes the template rather than guessing at one.
Wiz findings are about cloud resources, not repository code, so they carry a source.CloudResource and no Repo. Resources on Google Cloud have their providerId normalized to the Cloud Asset Inventory name form at ingest so the asset-inventory enhancer can resolve ownership labels — and possibly a repository — without knowing which source ingested the finding.
Index ¶
Constants ¶
const ( // IssuesID identifies the Wiz Issues feed. IssuesID = "wiz-issues" // DefendID identifies the Wiz Defend threat-detection feed. DefendID = "wiz-defend" )
Source identifiers stamped into the security-source label — one per feed, so provenance and write-back dispatch can tell an issue from a detection.
const ( // EventIssue is a Wiz Issues delivery. EventIssue = "wiz.issue" // EventThreat is a Wiz Defend delivery. EventThreat = "wiz.threat" )
Event discriminators. Both feeds share one path and carry no event header, so Detect derives these from the payload shape.
const ( // KeyWebhookToken is the shared bearer token inbound deliveries carry. KeyWebhookToken = "webhookToken" // KeyClientID and KeyClientSecret are the Wiz API service-account // credentials, present only when write-back is configured. KeyClientID = "clientId" KeyClientSecret = "clientSecret" )
Credential Secret keys.
Variables ¶
This section is empty.
Functions ¶
func DeliveryID ¶
DeliveryID derives a dedup key for a delivery. Wiz sends no delivery GUID, so the honest key is the body itself: byte-identical redeliveries dedup, distinct events (which always differ in ids or timestamps) never do.
func Detect ¶
Detect reports which feed a body belongs to by its shape: EventIssue for a top-level issue object, EventThreat for a top-level threat object, "ping" for valid JSON that is neither (Wiz's test delivery). Undecodable bodies are an error — the caller answers 400, not 204.
func NormalizeGCPName ¶
NormalizeGCPName rewrites a Wiz providerId for a Google Cloud resource into the Cloud Asset Inventory name form ("//service.googleapis.com/<path>"), which is what the asset-inventory enhancer queries by. Wiz reports GCP resources by API self-link more often than by asset name, and the two differ only mechanically:
https://www.googleapis.com/compute/v1/projects/p/zones/z/instances/i https://container.googleapis.com/v1/projects/p/locations/l/clusters/c → //compute.googleapis.com/projects/p/zones/z/instances/i → //container.googleapis.com/projects/p/locations/l/clusters/c
Storage self-links use a bucket shorthand ("/storage/v1/b/<bucket>") whose asset name drops the collection segment. A name already in asset form passes through; anything unrecognized is returned unchanged — the value still works as a stable accumulation scope, it just may not resolve in Cloud Asset Inventory (the enhancer's display-name fallback covers that).
Types ¶
type DefendHandler ¶
type DefendHandler struct {
// contains filtered or unexported fields
}
DefendHandler is the Wiz Defend source plugin.
func (*DefendHandler) Findings ¶
func (h *DefendHandler) Findings(_ context.Context, event string, payload []byte) ([]source.Finding, error)
Findings implements source.Handler: one Finding per supported affected resource, so each accumulates against the resource it concerns. A threat with no resources falls back to one Finding per cloud account — coarse, but a detection with no subject at all is undeliverable and errors.
type IssueRejecter ¶
type IssueRejecter interface {
RejectIssue(ctx context.Context, issueID, reason, note string) error
}
IssueRejecter is the slice of the Wiz API the resolver needs. wizapi.Client implements it; tests substitute a fake.
type IssuesHandler ¶
type IssuesHandler struct {
// contains filtered or unexported fields
}
IssuesHandler is the Wiz Issues source plugin.
func NewIssues ¶
func NewIssues(o Options) *IssuesHandler
NewIssues builds the Issues handler. It takes no client: the documented webhook template carries everything patchy needs.
type Options ¶
type Options struct {
// MinSeverity drops findings below this level, using patchy's vocabulary
// (low/medium/high/critical). Empty admits everything above
// informational; informational is always dropped when a floor is set.
MinSeverity string
}
Options configure a handler.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is the Wiz Issues write-back: an ignore verdict rejects the originating Wiz issue with a note, the cloud analogue of dismissing a code-scanning alert. It exists only when the Integration configures spec.wiz.api; Defend threats have no write-back — a runtime detection is a record of something that happened, not a state to dismiss.
func NewResolver ¶
func NewResolver(api IssueRejecter) *Resolver
NewResolver builds the write-back over a Wiz API client.