DetectPolicyType determines the policy type from source bytes WASM files start with magic bytes: 0x00 0x61 0x73 0x6d (\0asm) as documented at https://webassembly.github.io/spec/core/binary/modules.html#binary-module
(source []byte)
| 29 | // WASM files start with magic bytes: 0x00 0x61 0x73 0x6d (\0asm) |
| 30 | // as documented at https://webassembly.github.io/spec/core/binary/modules.html#binary-module |
| 31 | func DetectPolicyType(source []byte) PolicyType { |
| 32 | // WASM files start with magic bytes: 0x00 0x61 0x73 0x6d (\0asm) |
| 33 | if len(source) >= 4 && |
| 34 | source[0] == 0x00 && |
| 35 | source[1] == 0x61 && |
| 36 | source[2] == 0x73 && |
| 37 | source[3] == 0x6d { |
| 38 | return PolicyTypeWASM |
| 39 | } |
| 40 | |
| 41 | // Default to Rego (text-based) |
| 42 | return PolicyTypeRego |
| 43 | } |
no outgoing calls