wiz

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 13 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 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

View Source
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.

View Source
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.

View Source
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

func DeliveryID(body []byte) string

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

func Detect(body []byte) (string, error)

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

func NormalizeGCPName(providerID string) string

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 NewDefend

func NewDefend(o Options) *DefendHandler

NewDefend builds the Defend handler.

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.

func (*DefendHandler) ID

func (h *DefendHandler) ID() string

ID implements source.Handler.

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.

func (*IssuesHandler) Findings

func (h *IssuesHandler) Findings(_ context.Context, event string, payload []byte) ([]source.Finding, error)

Findings implements source.Handler: it normalizes one issue delivery into at most one Finding. Deliveries the pipeline does not act on return (nil, nil).

func (*IssuesHandler) ID

func (h *IssuesHandler) ID() string

ID implements source.Handler.

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.

func (*Resolver) Resolve

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

Resolve implements source.Resolver. Each alert id is a Wiz issue id; every issue folded into the finding is rejected, and one failure does not stop the rest.

Jump to

Keyboard shortcuts

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