feat(secure): surface Falco static-analyzer warnings as Terraform Diagnostics#733
Draft
ivanlysiuk-sysdig wants to merge 3 commits into
Draft
feat(secure): surface Falco static-analyzer warnings as Terraform Diagnostics#733ivanlysiuk-sysdig wants to merge 3 commits into
ivanlysiuk-sysdig wants to merge 3 commits into
Conversation
…gnostics
When the Sysdig backend processes a create/update on a Falco rule, its
validator may emit static-analyzer warnings (LOAD_NO_EVTTYPE today, per
ADR-0127) signalling rules that match too many syscall event types and
risk a measurable agent performance penalty. The backend ships these on
the v2 rule create/update response under `warnings[]`, but the provider's
internal SDK didn't deserialize them — so TF users had no way to see
them via `terraform apply`.
This change wires the warnings end-to-end:
- sysdig/internal/client/v2/model.go: add `FalcoWarning` type and a
`Warnings []FalcoWarning` field on `Rule`. JSON shape mirrors
secure-backend's `model.FalcoWarning`.
- sysdig/resource_sysdig_secure_rule_falco.go: capture `rule.Warnings`
on Create and `updatedRule.Warnings` on Update; convert each into a
`diag.Warning` Diagnostic via a small `falcoWarningsToDiagnostics`
helper. Each warning becomes a single Diagnostic with the Falco
code in Summary and the validator message + EnabledInPolicies +
AgentVersions in Detail.
Surface in `terraform apply` output:
│ Warning: Falco performance warning (LOAD_NO_EVTTYPE) on rule "<rule-name>"
│
│ with sysdig_secure_rule_falco.my_rule,
│ on main.tf line 12, in resource "sysdig_secure_rule_falco" "my_rule":
│ 12: resource "sysdig_secure_rule_falco" "my_rule" {
│
│ Rule matches too many evt.type values. This has a significant
│ performance penalty.
│
│ Enabled in policies: my-runtime-policy
│ Agent versions: linux-14.5.2
Backwards compatible: zero new required fields; rules without warnings
emit zero diagnostics (the helper returns nil on empty input). Existing
acceptance tests are unaffected since they don't inspect Diagnostics
beyond the error count.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ed helper
The first commit wired only sysdig_secure_rule_falco. All seven Sysdig rule
resources (rule_falco, rule_container, rule_filesystem, rule_network,
rule_process, rule_syscall, rule_stateful) translate to Falco rules in the
backend under the hood, so any of them can emit LOAD_NO_EVTTYPE if the
generated condition matches too many evt.type values. This extends the
Diagnostics surfacing to the other six.
Changes:
- sysdig/falco_warnings.go: new file. Extracts falcoWarningsToDiagnostics
out of resource_sysdig_secure_rule_falco.go into a package-scoped helper.
The function lives once now; all rule resources call it.
- resource_sysdig_secure_rule_falco.go: drops the local copy; relies on the
shared helper.
- resource_sysdig_secure_rule_{container,filesystem,network,process,syscall}.go:
Create captures rule.Warnings, returns Diagnostics. Update captures the
returned rule (was discarded with `_, err =`), returns Diagnostics.
- resource_sysdig_secure_rule_stateful.go: same shape; uses the stateful
rule methods (CreateStatefulRule/UpdateStatefulRule) but returns the
same Rule type carrying Warnings.
Macro + list resources are NOT wired — the backend doesn't surface warnings
on those endpoints (SSPROD-68085 / SSPROD-68086 resolved Won't Do during the
V2/V4 migration). They'll behave as before: zero diagnostics on apply.
Backwards compatible: rules whose backend response carries no warnings emit
zero diagnostics (helper short-circuits on empty input).
Build/vet: clean on ./... — same as the first commit.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…on stateful Per @ivanlysiuk: stateful-detection rules don't go through the Falco static-analyzer path in the backend, so the validator never emits LOAD_NO_EVTTYPE (or any other Falco warning code) on stateful rule mutations. The previous commit's wiring of sysdig_secure_rule_stateful was a no-op at best and misleading documentation at worst. Revert: sysdig_secure_rule_stateful Create returns to `return nil`; no Update wiring was actually applied (the sed pattern didn't match due to different surrounding whitespace). Also update the docstring in falco_warnings.go to make the exclusion explicit alongside the macro/list exclusion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Terraform Diagnostics for Falco static-analyzer warnings (today
LOAD_NO_EVTTYPE) emitted by the Sysdig backend onsysdig_secure_rule_falcocreate/update. The backend has been shipping these underwarnings[]on the v2 rule response for a few weeks — the provider's internal SDK just wasn't deserializing the field.This wires it end-to-end so TF users see warnings inline in
terraform applyoutput.Opening as draft until the deprecation cleanup in #734 lands.
What it looks like
When applying a rule whose condition causes the backend's Falco validator to emit a perf warning:
The apply still succeeds — these are advisory, not gates. (The backend supports an opt-in
performanceWarningPackGate=truequery parameter for "save anyway" semantics; not wired in this PR — leaving it as a follow-up unless there's interest. The TF UX for a gate isn't obvious.)Changes
sysdig/internal/client/v2/model.goFalcoWarningtype andWarnings []FalcoWarningfield onRule. JSON shape mirrors the backend response.sysdig/falco_warnings.gofalcoWarningsToDiagnostics(warnings)mapping each warning to adiag.Warningwith the Falco code in Summary and message + enabled-in-policies + agent-versions in Detail.sysdig/resource_sysdig_secure_rule_falco.gorule.Warningson Create andupdatedRule.Warningson Update; surface via the helper.Net: +55, -9.
Backwards compatibility
Zero new required fields. Rules whose backend response carries no warnings emit zero diagnostics (helper returns
nilon empty input). Existing acceptance tests are unaffected since they don't inspect Diagnostics beyond the error count.Out of scope (deliberately)
sysdig_secure_rule_macroandsysdig_secure_rule_list: macros + lists were de-scoped from the Falco perf warnings v1 effort on the backend side. The backend doesn't surface warnings on those endpoints, so wiring them on the TF side would be no-ops.performanceWarningPackGate=true): mentioned above; defer.End-to-end validation
Ran the matrix on a fresh Sysdig stack deployed with a backend image that includes the full warnings stack.
Matrix
sysdig_secure_rule_falco.positive_no_evttypeproc.name=ssprod_68089_tf_test(noevt.type)ssprod_68089_tf_no_evttypesysdig_secure_rule_falco.negative_cleanspawned_process and proc.name=…(evt.type filtered via macro)sysdig_secure_macro.negative_macrosysdig_secure_list.negative_listApply complete! Resources: 4 added, 0 changed, 0 destroyed.— apply succeeded; warnings are advisory.Sample Diagnostic
(
Enabled in policies:is omitted here because the test rules aren't referenced by any policy; the enrichment populates that line whenever the rule is part of an active policy — exercised via direct backend POST against the same stack.)Notes
sysdig_secure_rule_{container,filesystem,network,process,syscall}weren't exercised here — they're broken end-to-end against current backends, addressed separately in fix(secure): deprecate dead rule resources (container/filesystem/network/process/syscall) #734. This PR will rebase on top of that.sysdig_secure_rule_statefulis intentionally not wired (stateful rules don't go through the Falco static-analyzer path; backend doesn't emit warnings for them).Test plan
go build ./...— cleango vet ./sysdig/...— cleanspawned_processfilter) → no Diagnostics on that resource🤖 Generated with Claude Code