decodeIfBase64Wasm checks if content is base64-encoded WASM and decodes it. Returns the original content if it's not base64 or not WASM after decoding.
(content []byte)
| 1035 | // decodeIfBase64Wasm checks if content is base64-encoded WASM and decodes it. |
| 1036 | // Returns the original content if it's not base64 or not WASM after decoding. |
| 1037 | func decodeIfBase64Wasm(content []byte) []byte { |
| 1038 | // Try to decode as base64 |
| 1039 | decoded, err := base64.StdEncoding.DecodeString(string(content)) |
| 1040 | if err != nil { |
| 1041 | // Not base64, return original content |
| 1042 | return content |
| 1043 | } |
| 1044 | |
| 1045 | // Check if decoded content is WASM |
| 1046 | if engine.DetectPolicyType(decoded) == engine.PolicyTypeWASM { |
| 1047 | // It's base64-encoded WASM, return decoded bytes |
| 1048 | return decoded |
| 1049 | } |
| 1050 | |
| 1051 | // Decoded but not WASM, return original content |
| 1052 | return content |
| 1053 | } |
| 1054 | |
| 1055 | // isURLPath checks if a path is an HTTP or HTTPS URL |
| 1056 | func isURLPath(path string) bool { |
no test coverage detected