@@ -8,6 +8,7 @@ use std::rc::Rc;
88
99use base64::Engine;
1010use chrono::{DateTime, Datelike, NaiveDate, SecondsFormat, TimeZone, Timelike, Utc};
11+ use flate2::read::GzDecoder;
1112use hmac::{Hmac, Mac};
1213use percent_encoding::{NON_ALPHANUMERIC, percent_decode_str, utf8_percent_encode};
1314use rand::Rng;
@@ -2126,6 +2127,7 @@ enum RegIntrinsic {
21262127 HmacSha256String,
21272128 GlobalConfigNew,
21282129 GlobalConfigRuleCount,
2130+ GzipDecompressBytes,
21292131 HexDecode,
21302132 HexEncode,
21312133 HexEncodeString,
@@ -4227,6 +4229,7 @@ impl RegLowerer<'_> {
42274229 return Ok(dst);
42284230 }
42294231 ("GlobalConfig", "rule_count") => RegIntrinsic::GlobalConfigRuleCount,
4232+ ("Gzip", "decompress_bytes") => RegIntrinsic::GzipDecompressBytes,
42304233 ("Hex", "decode") => RegIntrinsic::HexDecode,
42314234 ("Hex", "encode") => RegIntrinsic::HexEncode,
42324235 ("Hex", "encode_string") => RegIntrinsic::HexEncodeString,
@@ -9758,6 +9761,17 @@ impl RegVm {
97589761 let global = intrinsic_arg(&self.stack, base, args, 0)?;
97599762 Ok(VmValue::Int(expect_global_config_rule_count(global)?))
97609763 }
9764+ RegIntrinsic::GzipDecompressBytes => {
9765+ let value = expect_bytes_ref(intrinsic_arg(&self.stack, base, args, 0)?)?;
9766+ let mut decoder = GzDecoder::new(value);
9767+ let mut out = Vec::new();
9768+ Ok(json_result(
9769+ decoder
9770+ .read_to_end(&mut out)
9771+ .map(|_| VmValue::Bytes(Rc::new(out)))
9772+ .map_err(|error| decode_error_value(error.to_string())),
9773+ ))
9774+ }
97619775 RegIntrinsic::HexDecode => {
97629776 let text = expect_string_ref(intrinsic_arg(&self.stack, base, args, 0)?)?;
97639777 Ok(json_result(
0 commit comments