mirror of
https://github.com/alibaba/higress.git
synced 2026-04-21 20:17:29 +08:00
Ai data masking fix (#1420)
This commit is contained in:
@@ -16,6 +16,7 @@ use fancy_regex::Regex;
|
||||
use grok::patterns;
|
||||
use higress_wasm_rust::log::Log;
|
||||
use higress_wasm_rust::plugin_wrapper::{HttpContextWrapper, RootContextWrapper};
|
||||
use higress_wasm_rust::request_wrapper::has_request_body;
|
||||
use higress_wasm_rust::rule_matcher::{on_configure, RuleMatcher, SharedRuleMatcher};
|
||||
use jieba_rs::Jieba;
|
||||
use jsonpath_rust::{JsonPath, JsonPathValue};
|
||||
@@ -519,7 +520,11 @@ impl HttpContext for AiDataMasking {
|
||||
_num_headers: usize,
|
||||
_end_of_stream: bool,
|
||||
) -> HeaderAction {
|
||||
HeaderAction::StopIteration
|
||||
if has_request_body() {
|
||||
HeaderAction::StopIteration
|
||||
} else {
|
||||
HeaderAction::Continue
|
||||
}
|
||||
}
|
||||
fn on_http_response_headers(
|
||||
&mut self,
|
||||
@@ -669,14 +674,12 @@ impl HttpContextWrapper<AiDataMaskingConfig> for AiDataMasking {
|
||||
}
|
||||
fn on_http_response_complete_body(&mut self, res_body: &Bytes) -> DataAction {
|
||||
if self.config.is_none() {
|
||||
self.reset_http_response();
|
||||
return DataAction::Continue;
|
||||
}
|
||||
let config = self.config.as_ref().unwrap();
|
||||
let mut res_body = match String::from_utf8(res_body.clone()) {
|
||||
Ok(r) => r,
|
||||
Err(_) => {
|
||||
self.reset_http_response();
|
||||
return DataAction::Continue;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user