Skip to content

feat: HCL scenario schema, function allowlist, parser fuzz target - #1

Merged
tannevaled merged 2 commits into
mainfrom
scaffold-and-hcl-schema
Nov 10, 2026
Merged

tannevaled merged 2 commits into
mainfrom
scaffold-and-hcl-schema

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

First piece of the automation layer (go-webengine/engine's own plan, ~/.claude/plans/federated-nibbling-pixel.md): the HCL scenario format, before any driver/CLI wiring.

  • hclscenario/functions.go: the function allowlist (upper/lower/trim/join) — a small, fixed, reviewed set per go-wasmcontainers' own security note (the allowlist IS the attack surface): no file/exec/network/env functions, nothing unbounded, cty's own stdlib deliberately not imported wholesale.
  • hclscenario/schema.go: Parse() — read hashicorp/hcl/v2's own EvalContext/function.Spec docs before writing this (bibliography first), not reconstructed from memory.
  • FuzzParseScenario found a real panic on its first real run (go test -fuzz, ~11M execs clean after the fix): calling cty.Value.AsString() without checking the value's actual type first crashes on any non-string attribute (e.g. url = {}). Fixed with a shared evalString helper that validates known/non-null/string before ever calling AsString, used at every evaluation site. The crashing input is kept as a permanent regression entry.
  • Added a CI workflow (this repo had none): build/vet/gofmt/test/race/govulncheck.

Not yet implemented: the driver/CLI wiring and the session/dry-run/pin-enforcement/audit-log/bounds/anti-bot guardrails — tracked separately in the plan file, this PR is the scenario format only.

Test plan

  • Per-function unit tests (upper/lower/trim/join) plus a guard test asserting the allowlist has exactly these four entries
  • Scenario parsing: valid scenario end-to-end, missing/duplicate scenario block, missing required attributes, unrecognized step kind, unregistered function call, empty/truncated source
  • FuzzParseScenario: seeded, run as regular tests, then a real -fuzz pass (~11M execs, clean) — found and fixed the AsString panic above
  • go build/go vet/gofmt -l/govulncheck ./... clean
  • go test ./... green

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 10, 2026 16:53
First piece of the automation layer (go-webengine/engine's own plan at
~/.claude/plans/federated-nibbling-pixel.md): a scenario file is a
declarative sequence of click/fill/assert/submit steps, plus an
optional pinned-page identity check.

- hclscenario/functions.go: the function allowlist (upper/lower/trim/
  join) — a small, fixed, reviewed set per go-wasmcontainers' own
  security note (the allowlist IS the attack surface): no file/exec/
  network/env functions, nothing unbounded, cty's own stdlib
  deliberately NOT imported wholesale.
- hclscenario/schema.go: Parse() — hclsyntax parsing, schema
  validation, function-call evaluation. Read hashicorp/hcl/v2's own
  EvalContext/function.Spec docs before writing this (bibliography
  first), not reconstructed from memory.
- FuzzParseScenario found a real panic on its first real run
  (go test -fuzz, ~11M execs clean after the fix): calling
  cty.Value.AsString() without checking the value's actual type first
  crashes on any non-string attribute (e.g. `url = {}`). Fixed with a
  shared evalString helper that validates known/non-null/string before
  ever calling AsString, used at every evaluation site. The crashing
  input is kept as a permanent regression entry
  (testdata/fuzz/FuzzParseScenario/4941ee77dd913a51).

Not yet implemented: the driver/CLI wiring and the session/dry-run/
pin-enforcement/audit-log/bounds/anti-bot guardrails — tracked
separately, this PR is the scenario format only.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@tannevaled
tannevaled merged commit 428d1f2 into main Nov 10, 2026
1 check passed
@tannevaled
tannevaled deleted the scaffold-and-hcl-schema branch November 10, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant