Skip to content

Add load-time WASM guard ABI checks and align guard unit runtime config#8779

Merged
lpcox merged 6 commits into
mainfrom
copilot/go-fan-review-tetratelabs-wazero
Jul 6, 2026
Merged

Add load-time WASM guard ABI checks and align guard unit runtime config#8779
lpcox merged 6 commits into
mainfrom
copilot/go-fan-review-tetratelabs-wazero

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

github.com/tetratelabs/wazero guards were only validated for export presence, so ABI mismatches could surface later as runtime traps. This PR adds explicit signature validation during guard load and aligns guard parse coverage tests with interpreter-mode runtime usage for deterministic unit behavior.

  • Guard initialization hardening

    • Validate required exports (label_resource, label_response, label_agent) against the expected ABI: (i32,i32,i32,i32) -> i32.
    • Return a targeted load-time error when signatures don’t match, instead of deferring failure to invocation time.
  • ABI mismatch coverage

    • Add focused test coverage for invalid exported function signatures by mutating the wasm type section and asserting the new signature error path.
  • Unit test runtime consistency

    • Update wasm_parse_coverage_test helper setup to use wazero.NewRuntimeConfigInterpreter() rather than default runtime config, matching existing guard test conventions.
if !slices.Equal(paramTypes, expectedParamTypes) || !slices.Equal(resultTypes, expectedResultTypes) {
	return fmt.Errorf(
		"WASM module function %s must have signature (i32,i32,i32,i32)->i32, got %v->%v",
		functionName, paramTypes, resultTypes,
	)
}

Copilot AI linked an issue Jul 6, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Review Go module tetratelabs/wazero for usage and compliance Add load-time WASM guard ABI checks and align guard unit runtime config Jul 6, 2026
Copilot finished work on behalf of lpcox July 6, 2026 13:03
Copilot AI requested a review from lpcox July 6, 2026 13:03
@lpcox lpcox marked this pull request as ready for review July 6, 2026 13:04
Copilot AI review requested due to automatic review settings July 6, 2026 13:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens WASM guard loading by validating exported guard function ABIs at load time, preventing signature mismatches from surfacing later as runtime traps. It also aligns a guard parsing coverage helper to use the interpreter runtime config for deterministic unit-test behavior.

Changes:

  • Validate label_resource, label_response, and label_agent exported function signatures against the expected (i32,i32,i32,i32)->i32 ABI during NewWasmGuardWithOptions.
  • Add a focused unit test that mutates the WASM type section to assert the new ABI-mismatch error path.
  • Switch wasm_parse_coverage_test runtime initialization to wazero.NewRuntimeConfigInterpreter() to match existing guard test conventions.
Show a summary per file
File Description
internal/guard/wasm_lifecycle.go Adds load-time signature validation for required exported guard functions.
internal/guard/wasm_new_options_coverage_test.go Adds test coverage for invalid exported function signatures via WASM byte mutation.
internal/guard/wasm_parse_coverage_test.go Updates helper runtime setup to use interpreter mode for deterministic tests.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread internal/guard/wasm_new_options_coverage_test.go Outdated
lpcox and others added 2 commits July 6, 2026 06:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The test copied fullGuardWasm but never actually mutated byte 14 from
i32 (0x7f) to i64 (0x7e), so the signature remained valid and no error
was produced.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lpcox lpcox merged commit 2b41d96 into main Jul 6, 2026
24 checks passed
@lpcox lpcox deleted the copilot/go-fan-review-tetratelabs-wazero branch July 6, 2026 13:17
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.

[go-fan] Go Module Review: tetratelabs/wazero

3 participants