Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 36 additions & 2 deletions LICENSE-3rdparty.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion datadog-live-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ddcommon = { path = "../ddcommon" }
hyper = { workspace = true}
http-body-util = "0.1"

regex = "1.9.3"
regex-lite = "^0.1"
percent-encoding = "2.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion datadog-live-debugger/src/expr_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::expr_defs::{
BinaryComparison, CollectionMatch, CollectionSource, Condition, DslPart, NumberSource,
Reference, StringComparison, StringSource, Value,
};
use regex::Regex;
use regex_lite::Regex;
use std::borrow::Cow;
use std::cmp::min;
use std::fmt::{Display, Formatter};
Expand Down
2 changes: 1 addition & 1 deletion datadog-live-debugger/src/redacted_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ pub unsafe fn add_redacted_type<I: AsRef<[u8]>>(name: I) {
regex_str.push('|')
}
let name = String::from_utf8_lossy(name);
regex_str.push_str(regex::escape(&name[..name.len() - 1]).as_str());
regex_str.push_str(regex_lite::escape(&name[..name.len() - 1]).as_str());
regex_str.push_str(".*");
} else {
let added_types = &mut (*(&*ADDED_REDACTED_TYPES as *const Vec<Vec<u8>>).cast_mut());
Expand Down
2 changes: 1 addition & 1 deletion datadog-trace-obfuscation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ license.workspace = true

[dependencies]
anyhow = "1.0"
regex = "1"
regex-lite = "^0.1"
serde = { version = "1.0.145", features = ["derive"] }
serde_json = "1.0"
url = "2.4.0"
Expand Down
2 changes: 1 addition & 1 deletion datadog-trace-obfuscation/src/ip_address.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use regex::Regex;
use regex_lite::Regex;
use std::{borrow::Cow, collections::HashSet, net::Ipv6Addr, sync::LazyLock};

const ALLOWED_IP_ADDRESSES: [&str; 4] = [
Expand Down
16 changes: 8 additions & 8 deletions datadog-trace-obfuscation/src/replacer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use datadog_trace_protobuf::pb;
use regex::Regex;
use regex_lite::Regex;
use serde::Deserialize;

#[derive(Deserialize)]
Expand All @@ -27,7 +27,7 @@ pub struct ReplaceRule {
name: String,

// re holds the regex pattern for matching.
re: regex::Regex,
re: regex_lite::Regex,

// repl specifies the replacement string to be used when Pattern matches.
repl: String,
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn parse_rules_from_string(
anyhow::bail!("Obfuscator Error: Error while parsing rule: {}", err)
}
};
let no_expansion = regex::Replacer::no_expansion(&mut &raw_rule.repl).is_some();
let no_expansion = regex_lite::Replacer::no_expansion(&mut &raw_rule.repl).is_some();
vec.push(ReplaceRule {
name: raw_rule.name,
re: compiled_regex,
Expand Down Expand Up @@ -155,7 +155,7 @@ fn replace_all(
#[allow(clippy::unwrap_used)]
let m = cap.get(0).unwrap();
scratch_space.push_str(&haystack[last_match..m.start()]);
regex::Replacer::replace_append(&mut replace, &cap, scratch_space);
regex_lite::Replacer::replace_append(&mut replace, &cap, scratch_space);
last_match = m.end();
}
scratch_space.push_str(&haystack[last_match..]);
Expand Down Expand Up @@ -286,13 +286,13 @@ mod tests {
fn test_replace_rule_eq() {
let rule1 = replacer::ReplaceRule {
name: "http.url".to_string(),
re: regex::Regex::new("(token/)([^/]*)").unwrap(),
re: regex_lite::Regex::new("(token/)([^/]*)").unwrap(),
repl: "${1}?".to_string(),
no_expansion: false,
};
let rule2 = replacer::ReplaceRule {
name: "http.url".to_string(),
re: regex::Regex::new("(token/)([^/]*)").unwrap(),
re: regex_lite::Regex::new("(token/)([^/]*)").unwrap(),
repl: "${1}?".to_string(),
no_expansion: false,
};
Expand All @@ -304,13 +304,13 @@ mod tests {
fn test_replace_rule_neq() {
let rule1 = replacer::ReplaceRule {
name: "http.url".to_string(),
re: regex::Regex::new("(token/)([^/]*)").unwrap(),
re: regex_lite::Regex::new("(token/)([^/]*)").unwrap(),
repl: "${1}?".to_string(),
no_expansion: false,
};
let rule2 = replacer::ReplaceRule {
name: "http.url".to_string(),
re: regex::Regex::new("(broken/)([^/]*)").unwrap(),
re: regex_lite::Regex::new("(broken/)([^/]*)").unwrap(),
repl: "${1}?".to_string(),
no_expansion: false,
};
Expand Down
2 changes: 1 addition & 1 deletion ddcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ http-body-util = "0.1"
tower-service = "0.3"
cc = "1.1.31"
pin-project = "1"
regex = "1.5"
regex-lite = "^0.1"
rustls = { version = "0.23", default-features = false, optional = true }
rustls-native-certs = { version = "0.8.1", optional = true }
thiserror = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion ddcommon/src/azure_app_services.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use regex::Regex;
use regex_lite::Regex;
use std::env;
use std::sync::LazyLock;

Expand Down
2 changes: 1 addition & 1 deletion ddcommon/src/entity_id/unix/container_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

//! This module provides functions to parse the container id from the cgroup file
use super::CgroupFileParsingError;
use regex::Regex;
use regex_lite::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion ddcommon/src/entity_id/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub static ENTITY_ID: LazyLock<Option<&'static str>> = LazyLock::new(|| {
#[cfg(test)]
mod tests {
use super::*;
use regex::Regex;
use regex_lite::Regex;

static IN_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"in-\d+").unwrap());
static CI_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Expand Down
2 changes: 1 addition & 1 deletion tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ license.workspace = true
bench = false

[dependencies]
regex = "1"
regex-lite = "^0.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"^0.1" is equivalent to "0.1" so you don't really need to add it
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements

Also you should probably add it as a workspace dependencies, with a minimum constraint to the highest minor available ("0.1.7" right now)

Copy link
Contributor Author

@Aaalibaba42 Aaalibaba42 Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about instances where it is likely using a whole regex engine (even the lite one) is superfluous as described in this comment: #1232 (comment)

Is it worth exploring ? Would it be a separate PR ?


[[bin]]
name = "dedup_headers"
Expand Down
2 changes: 1 addition & 1 deletion tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

pub mod headers {
use regex::{Regex, RegexBuilder};
use regex_lite::{Regex, RegexBuilder};
use std::collections::HashSet;
use std::fs::{File, OpenOptions};
use std::io::{self, BufReader, BufWriter, Read, Seek, Write};
Expand Down
Loading