Hello everyone, I’d like to get your input on something I’ve been testing.
I was exploring the possibility of extending the match condition in our service extension (traffic) to filter out static files using CEL (Common Expression Language). The idea is to avoid calling our VM/Cloud Run for these requests, since our bot protection solution currently ignores static files (FYI, this logic is currently handled there).
During testing I noticed:
-
CEL expressions seem to be limited to 512 characters (returns INVALID_CEL_EXPRESSION when exceeded).
- Regex is not supported with CEL, if I am not mistaken
Given this, is there any way we can extensively ignore static file requests before they reach the callout (VM/Cloud Run), so we can bypass the full logic for these cases?
Below is the CEL expression I used for testing (mainly hardcoded), It covers only a partial list of static file types for now.
Thanks
!(
request.path.endsWith(".avi") ||
request.path.endsWith(".avif") ||
request.path.endsWith(".bmp") ||
request.path.endsWith(".css") ||
request.path.endsWith(".eot") ||
request.path.endsWith(".flac") ||
request.path.endsWith(".flv") ||
request.path.endsWith(".gif") ||
request.path.endsWith(".gz") ||
request.path.endsWith(".ico") ||
request.path.endsWith(".jpeg") ||
request.path.endsWith(".jpg") ||
request.path.endsWith(".js") ||
request.path.endsWith(".json") ||
request.path.endsWith(".less") ||
request.path.endsWith(".map") ||
request.path.endsWith(".mka") ||
request.path.endsWith(".mkv") ||
request.path.endsWith(".mov") ||
request.path.endsWith(".mp3") ||
request.path.endsWith(".mp4") ||
request.path.endsWith(".mpeg") ||
request.path.endsWith(".mpg") ||
request.path.endsWith(".ogg") ||
request.path.endsWith(".ogm") ||
request.path.endsWith(".opus") ||
request.path.endsWith(".otf") ||
request.path.endsWith(".png") ||
request.path.endsWith(".svg") ||
request.path.endsWith(".svgz") ||
request.path.endsWith(".swf") ||
request.path.endsWith(".ttf") ||
request.path.endsWith(".txt") ||
request.path.endsWith(".wav") ||
request.path.endsWith(".webm") ||
request.path.endsWith(".webp") ||
request.path.endsWith(".woff") ||
request.path.endsWith(".woff2") ||
request.path.endsWith(".xml") ||
request.path.endsWith(".zip")
)