feat: add support to wire webhooks from orchestrator to emitter workflows#70
feat: add support to wire webhooks from orchestrator to emitter workflows#70
Conversation
…ectable via SNAPSHOT_STORE=memory
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0fdc2ec99
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Args: []interface{}{orchestrator.WorkflowInput{ | ||
| ResourceTypes: cfg.ResourceTypes, | ||
| ResourceTypes: cfg.ResourceTypes, | ||
| EmitterWebhookURL: cfg.EmitterWebhookURL, |
There was a problem hiding this comment.
Propagate webhook URL for existing schedules
EnsureSchedule only applies EmitterWebhookURL in the create-time action args, but the already-existing-schedule path does not compare or rewrite workflow args (it exits early when cron/jitter match, and update only touches spec/task queue). In an upgraded deployment where the schedule already exists, setting EMITTER_WEBHOOK_URL later will not reach scheduled orchestrator runs, so Stage 3 webhook notifications never fire unless the schedule is recreated manually.
Useful? React with 👍 / 👎.
|
🤖 Concern on the mock-inventory fallback in The The PR description says "Production paths always set the Wiz secrets, so this branch is dev-only" — but nothing in the code enforces that. Any prod misconfiguration (rotated secret, IRSA mis-binding, partial rollout, secret-mount race on pod start) will now silently emit fabricated 1.0.0 findings into S3 instead of failing fast. Those snapshots feed every downstream consumer, including the new emitter webhook this PR wires up. Worst case: a green compliance dashboard built on synthetic data, with no obvious signal that the underlying inventory source is broken. Suggested mitigation: gate the mock fallback on an explicit opt-in (e.g. |
|
🤖 Mock inventory Engine: resourceCfg.Type,For Aurora, Worth verifying against the adapter dispatch before claiming the e2e screenshot demonstrates a working detector→emitter path — it may be exercising the wire but not the classification. |
|
🤖 Constructor-signature inconsistency in
Pick one. Either add the URL as a positional arg to |
|
🤖 payload, err := json.Marshal(struct {
SnapshotID string `json:"snapshot_id,omitempty"`
}{SnapshotID: input.SnapshotID})In the real flow, Stage 3 only runs after Two options:
Right now it reads like defensive code for a case that can't happen, which adds confusion for future readers. |
What and Why ?
Adds the detector → emitter webhook so the OrchestratorWorkflow can
notify the downstream emitter as soon as a snapshot is persisted,
instead of waiting for the emitter's own cron.
No breaking changes. No schema changes.
This work is purely additive at every layer that other systems can observe.
Auth model: this PR is wire-only. Network isolation between detector
and emitter could be enforced as required ranging from options like no-auth to
network policies in k8s all the way till the app layer authn and authz.
What's new (production code):
{"snapshot_id": ...} to /trigger-act with an
injectable HTTPDoer so tests can swap in a fake (no live HTTP).
Default client uses a 10s timeout.
Stage 3 (NotifyEmitter), invoked only when EmitterWebhookURL is
non-empty. Failures are non-fatal: the snapshot is already durable
in S3, so a transient emitter outage just delays emission and
Temporal's retry policy handles the rest.
Activities for test injection.
emitterWebhookURL plus a WithEmitterWebhookURL functional-option
helper. WorkflowInput.EmitterWebhookURL is forwarded into the
orchestrator workflow input.
scheduled workflow input.
NotifyEmitter activity, threads the URL through the schedule and
the admin /scan trigger.
Local testability (also production-safe; defaults preserve current
behavior):
laptop dev / CI smoke tests. Selectable via SNAPSHOT_STORE=memory
(default remains s3). Lets the orchestrator's Stage 2 succeed
without AWS credentials.
branch now falls back to pkg/inventory/mock.InventorySource (one
synthetic resource per config) instead of skipping every resource
and crashing with "no resources configured". Production paths set
the Wiz secrets and remain unaffected — the misleading "using mock
inventory" log line that already existed now actually does what it
says.
(all run the Temporal CLI / curl via Docker — no
brew install temporalneeded).make devno longer hard-requiresentr;auto-reload is used when entr is on $PATH, otherwise it falls back
to plain
go run ./cmd/server.Backwards compatibility:
arg. The package is internal to this private repo and all in-repo
callers (cmd/server, cmd/cli) are updated.
zero-values reproduce the prior behavior.
defaults: empty webhook URL = Stage 3 skipped (legacy behavior);
SNAPSHOT_STORE defaults to "s3".
workflow ID changes.
Tests: full unit suite green (pkg/scan, pkg/schedule, pkg/snapshot,
pkg/workflow/orchestrator, pkg/workflow/detection). NotifyEmitter has
7 tests covering success, 4xx, 5xx, network error, missing URL,
malformed body, and successful-but-empty body.
Local e2e workflow test confirmation