2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
4
use datadog_trace_protobuf:: pb;
5
- use regex :: Regex ;
5
+ use regex_lite :: Regex ;
6
6
use serde:: Deserialize ;
7
7
8
8
#[ derive( Deserialize ) ]
@@ -27,7 +27,7 @@ pub struct ReplaceRule {
27
27
name : String ,
28
28
29
29
// re holds the regex pattern for matching.
30
- re : regex :: Regex ,
30
+ re : regex_lite :: Regex ,
31
31
32
32
// repl specifies the replacement string to be used when Pattern matches.
33
33
repl : String ,
@@ -97,7 +97,7 @@ pub fn parse_rules_from_string(
97
97
anyhow:: bail!( "Obfuscator Error: Error while parsing rule: {}" , err)
98
98
}
99
99
} ;
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 ( ) ;
101
101
vec. push ( ReplaceRule {
102
102
name : raw_rule. name ,
103
103
re : compiled_regex,
@@ -155,7 +155,7 @@ fn replace_all(
155
155
#[ allow( clippy:: unwrap_used) ]
156
156
let m = cap. get ( 0 ) . unwrap ( ) ;
157
157
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) ;
159
159
last_match = m. end ( ) ;
160
160
}
161
161
scratch_space. push_str ( & haystack[ last_match..] ) ;
@@ -286,13 +286,13 @@ mod tests {
286
286
fn test_replace_rule_eq ( ) {
287
287
let rule1 = replacer:: ReplaceRule {
288
288
name : "http.url" . to_string ( ) ,
289
- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
289
+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
290
290
repl : "${1}?" . to_string ( ) ,
291
291
no_expansion : false ,
292
292
} ;
293
293
let rule2 = replacer:: ReplaceRule {
294
294
name : "http.url" . to_string ( ) ,
295
- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
295
+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
296
296
repl : "${1}?" . to_string ( ) ,
297
297
no_expansion : false ,
298
298
} ;
@@ -304,13 +304,13 @@ mod tests {
304
304
fn test_replace_rule_neq ( ) {
305
305
let rule1 = replacer:: ReplaceRule {
306
306
name : "http.url" . to_string ( ) ,
307
- re : regex :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
307
+ re : regex_lite :: Regex :: new ( "(token/)([^/]*)" ) . unwrap ( ) ,
308
308
repl : "${1}?" . to_string ( ) ,
309
309
no_expansion : false ,
310
310
} ;
311
311
let rule2 = replacer:: ReplaceRule {
312
312
name : "http.url" . to_string ( ) ,
313
- re : regex :: Regex :: new ( "(broken/)([^/]*)" ) . unwrap ( ) ,
313
+ re : regex_lite :: Regex :: new ( "(broken/)([^/]*)" ) . unwrap ( ) ,
314
314
repl : "${1}?" . to_string ( ) ,
315
315
no_expansion : false ,
316
316
} ;
0 commit comments