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

Function decodeIfBase64Wasm

pkg/policies/policies.go:1037–1053  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
1037func 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
1056func isURLPath(path string) bool {

Callers 2

loadPolicyScriptFunction · 0.85
loadLegacyPolicyScriptFunction · 0.85

Calls 1

DetectPolicyTypeFunction · 0.92

Tested by

no test coverage detected