MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / validateWasmFile

Method validateWasmFile

app/cli/internal/policydevel/lint.go:220–246  ·  view source on GitHub ↗

validateWasmFile validates a WASM policy file by checking that it exports the required Execute function

(file *File)

Source from the content-addressed store, hash-verified

218
219// validateWasmFile validates a WASM policy file by checking that it exports the required Execute function
220func (p *PolicyToLint) validateWasmFile(file *File) {
221 ctx := context.Background()
222
223 // Create Extism manifest
224 manifest := extism.Manifest{
225 Wasm: []extism.Wasm{
226 extism.WasmData{Data: file.Content},
227 },
228 }
229
230 cfg := extism.PluginConfig{
231 EnableWasi: true,
232 }
233
234 // Create plugin
235 plugin, err := extism.NewPlugin(ctx, manifest, cfg, []extism.HostFunction{})
236 if err != nil {
237 p.AddError(file.Path, fmt.Sprintf("failed to load WASM module: %v", err), 0)
238 return
239 }
240 defer plugin.Close(ctx)
241
242 // Check if Execute function is exported
243 if !plugin.FunctionExists("Execute") {
244 p.AddError(file.Path, "WASM module missing required 'Execute' function export", 0)
245 }
246}
247
248func (p *PolicyToLint) validateAndFormatRego(content, path string) string {
249 // 1. Optionally format

Callers 1

ValidateMethod · 0.95

Calls 2

AddErrorMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected