22// SPDX-License-Identifier: Apache-2.0
33
44use datadog_trace_protobuf:: pb;
5- use regex :: Regex ;
5+ use regex_lite :: Regex ;
66use serde:: Deserialize ;
77
88#[ derive( Deserialize ) ]
@@ -27,7 +27,7 @@ pub struct ReplaceRule {
2727 name : String ,
2828
2929 // re holds the regex pattern for matching.
30- re : regex :: Regex ,
30+ re : regex_lite :: Regex ,
3131
3232 // repl specifies the replacement string to be used when Pattern matches.
3333 repl : String ,
@@ -97,7 +97,7 @@ pub fn parse_rules_from_string(
9797 anyhow:: bail!( "Obfuscator Error: Error while parsing rule: {}" , err)
9898 }
9999 } ;
100- let no_expansion = regex :: Replacer :: no_expansion ( & mut & raw_rule. repl ) . is_some ( ) ;
100+ let no_expansion = regex_lite :: Replacer :: no_expansion ( & mut & raw_rule. repl ) . is_some ( ) ;
101101 vec. push ( ReplaceRule {
102102 name : raw_rule. name ,
103103 re : compiled_regex,
@@ -155,7 +155,7 @@ fn replace_all(
155155 #[ allow( clippy:: unwrap_used) ]
156156 let m = cap. get ( 0 ) . unwrap ( ) ;
157157 scratch_space. push_str ( & haystack[ last_match..m. start ( ) ] ) ;
158- regex :: Replacer :: replace_append ( & mut replace, & cap, scratch_space) ;
158+ regex_lite :: Replacer :: replace_append ( & mut replace, & cap, scratch_space) ;
159159 last_match = m. end ( ) ;
160160 }
161161 scratch_space. push_str ( & haystack[ last_match..] ) ;
@@ -286,13 +286,13 @@ mod tests {
286286 fn test_replace_rule_eq ( ) {
287287 let rule1 = replacer:: ReplaceRule {
288288 name : "http.url" . to_string ( ) ,
289- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
289+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
290290 repl : "${1}?" . to_string ( ) ,
291291 no_expansion : false ,
292292 } ;
293293 let rule2 = replacer:: ReplaceRule {
294294 name : "http.url" . to_string ( ) ,
295- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
295+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
296296 repl : "${1}?" . to_string ( ) ,
297297 no_expansion : false ,
298298 } ;
@@ -304,13 +304,13 @@ mod tests {
304304 fn test_replace_rule_neq ( ) {
305305 let rule1 = replacer:: ReplaceRule {
306306 name : "http.url" . to_string ( ) ,
307- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
307+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
308308 repl : "${1}?" . to_string ( ) ,
309309 no_expansion : false ,
310310 } ;
311311 let rule2 = replacer:: ReplaceRule {
312312 name : "http.url" . to_string ( ) ,
313- re : regex :: Regex :: new ( "(broken/)([^/]*)" ) . unwrap ( ) ,
313+ re : regex_lite :: Regex :: new ( "(broken/)([^/]*)" ) . unwrap ( ) ,
314314 repl : "${1}?" . to_string ( ) ,
315315 no_expansion : false ,
316316 } ;
0 commit comments