Skip to content
Merged
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
18 changes: 10 additions & 8 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ ref-cast,https://github.com/dtolnay/ref-cast,MIT OR Apache-2.0,David Tolnay <dto
ref-cast-impl,https://github.com/dtolnay/ref-cast,MIT OR Apache-2.0,David Tolnay <dtolnay@gmail.com>
regex,https://github.com/rust-lang/regex,MIT OR Apache-2.0,"The Rust Project Developers, Andrew Gallant <jamslam@gmail.com>"
regex-automata,https://github.com/rust-lang/regex/tree/master/regex-automata,MIT OR Apache-2.0,"The Rust Project Developers, Andrew Gallant <jamslam@gmail.com>"
regex-lite,https://github.com/rust-lang/regex,MIT OR Apache-2.0,"The Rust Project Developers, Andrew Gallant <jamslam@gmail.com>"
regex-syntax,https://github.com/rust-lang/regex/tree/master/regex-syntax,MIT OR Apache-2.0,"The Rust Project Developers, Andrew Gallant <jamslam@gmail.com>"
reqwest,https://github.com/seanmonstar/reqwest,MIT OR Apache-2.0,Sean McArthur <sean@seanmonstar.com>
resolv-conf,https://github.com/hickory-dns/resolv-conf,MIT OR Apache-2.0,The resolv-conf Authors
Expand Down
4 changes: 3 additions & 1 deletion bin_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ errno = "0.3"
nix = { version = "0.29", features = ["signal", "socket"] }
hex = "0.4"
os_info = "3.14.0"
regex = "1.0"

[dev-dependencies]
serial_test = "3.2"

[features]
regex-lite = ["libdd-common/regex-lite"]

[lib]
bench = false

Expand Down
2 changes: 1 addition & 1 deletion bin_tests/tests/crashtracker_bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ fn test_panic_hook_mode(mode: &str, expected_category: &str, expected_panic_mess

// Check for location format (file:line:column) - always present in Debug builds
// Location should end with pattern like " (path/file.rs:123:45)"
let location_regex = regex::Regex::new(r" \(.+?:\d+:\d+\)$").unwrap();
let location_regex = libdd_common::regex_engine::Regex::new(r" \(.+?:\d+:\d+\)$").unwrap();
assert!(
location_regex.is_match(message),
"Expected panic message to end with location ' (file:line:column)', got: {}",
Expand Down
3 changes: 2 additions & 1 deletion builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ library-config = []
log = []
ddsketch = []
ffe = []
regex-lite = ["libdd-common/regex-lite"]

[lib]
bench = false
Expand All @@ -44,7 +45,7 @@ tar = "0.4.45"
tools = { path = "../tools" }
toml = "0.8.19"
serde = "1.0.209"
regex = "1.10"
libdd-common = { path = "../libdd-common", default-features = false }

[[bin]]
name = "release"
Expand Down
4 changes: 2 additions & 2 deletions builder/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use anyhow::{anyhow, Result};
use regex::Regex;
use libdd_common::regex_engine::{Captures, Regex};
use std::fs::{self, OpenOptions};
use std::io::Write;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -37,7 +37,7 @@ pub(crate) fn adjust_extern_symbols(
let re = Regex::new(r#"(?m)^(\s*)extern\s+(.+;)$"#).unwrap();

// Replace function using captures
let new_content = re.replace_all(&content, |caps: &regex::Captures| {
let new_content = re.replace_all(&content, |caps: &Captures| {
let full_match = caps.get(0).unwrap().as_str();
let indent = &caps[1];
let declaration = &caps[2];
Expand Down
2 changes: 1 addition & 1 deletion datadog-ffe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ chrono = { version = "0.4.38", default-features = false, features = ["now", "ser
derive_more = { version = "2.0.0", default-features = false, features = ["from", "into"] }
log = { version = "0.4.21", default-features = false, features = ["kv", "kv_serde"] }
md5 = { version = "0.7.0", default-features = false }
regex = "1.10.4"
libdd-common = { version = "4.0.0", path = "../libdd-common", default-features = false, features = ["require-regex-full"] }
semver = "1.0"
serde-bool = { version = "0.1.3", default-features = false }
serde_with = { version = "3.11.0", default-features = false, features = ["base64", "hex", "macros"] }
Expand Down
2 changes: 1 addition & 1 deletion datadog-ffe/src/rules_based/ufc/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::{collections::HashMap, sync::Arc};

use regex::Regex;
use libdd_common::regex_engine::Regex;
use serde::{Deserialize, Serialize};

use crate::rules_based::{EvaluationError, FlagType, Str, Timestamp};
Expand Down
1 change: 1 addition & 0 deletions datadog-live-debugger-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ log = "0.4.21"
[features]
default = ["cbindgen"]
cbindgen = ["build_common/cbindgen", "libdd-common-ffi/cbindgen"]
regex-lite = ["datadog-live-debugger/regex-lite"]

[build-dependencies]
build_common = { path = "../build-common" }
5 changes: 3 additions & 2 deletions datadog-live-debugger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ http-body-util = "0.1"
"http" = "1"
bytes = "1.11.1"

regex = "1.9.3"
percent-encoding = "2.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sys-info = { version = "0.9.0" }
uuid = { version = "1.0", features = ["v4"] }
regex-automata = "0.4.5"
smallvec = "1.13.2"
constcat = "0.4.1"
tokio = "1.36.0"

[features]
regex-lite = ["libdd-common/regex-lite"]

[lib]
bench = false
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 libdd_common::regex_engine::Regex;
use std::borrow::Cow;
use std::cmp::min;
use std::fmt::{Display, Formatter};
Expand Down
6 changes: 3 additions & 3 deletions datadog-live-debugger/src/redacted_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#![allow(invalid_reference_casting)]

use regex_automata::dfa::regex::Regex;
use libdd_common::regex_engine::Regex;
use std::collections::HashSet;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::LazyLock;
Expand Down Expand Up @@ -164,7 +164,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(libdd_common::regex_engine::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 Expand Up @@ -211,7 +211,7 @@ pub fn is_redacted_type<I: AsRef<[u8]>>(name: I) -> bool {
if REDACTED_TYPES.contains(name) {
true
} else if !REDACTED_WILDCARD_TYPES_PATTERN.is_empty() {
REDACTED_TYPES_REGEX.is_match(name)
std::str::from_utf8(name).is_ok_and(|s| REDACTED_TYPES_REGEX.is_match(s))
} else {
false
}
Expand Down
2 changes: 1 addition & 1 deletion datadog-remote-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ client = [
"tracing"
]
live-debugger = ["datadog-live-debugger"]
regex-lite = ["libdd-common/regex-lite"]
ffe = ["datadog-ffe"]
test = ["hyper/server", "hyper-util"]

Expand All @@ -46,7 +47,6 @@ tracing = { version = "0.1", default-features = false, optional = true }
serde = "1.0"
serde_json = { version = "1.0", features = ["raw_value"] }
serde_with = "3"
regex = "1.0"

# Test feature
hyper-util = { workspace = true, features = ["service"], optional = true }
Expand Down
2 changes: 1 addition & 1 deletion datadog-remote-config/src/config/agent_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use serde::Deserialize;
#[cfg(feature = "test")]
use serde::Serialize;

use regex::Regex;
use libdd_common::regex_engine::Regex;
use serde::de::{self, Deserializer};

fn deserialize_case_id<'de, D>(deserializer: D) -> Result<String, D::Error>
Expand Down
1 change: 1 addition & 0 deletions libdd-common-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ bench =false
[features]
default = ["cbindgen"]
cbindgen = ["build_common/cbindgen"]
regex-lite = ["libdd-common/regex-lite"]

[build-dependencies]
build_common = { path = "../build-common" }
Expand Down
6 changes: 6 additions & 0 deletions libdd-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bytes = { version = "1.11.1" }
pin-project = "1"
rand = { version = "0.8", optional = true }
regex = "1.5"
regex-lite = { version = "0.1", optional = true }
# Use hickory-dns instead of the default system DNS resolver to avoid fork safety issues.
# The default resolver can hold locks or other global state that can cause deadlocks
# or corruption when the process forks (e.g., in PHP-FPM or other forking environments).
Expand Down Expand Up @@ -98,6 +99,11 @@ use_webpki_roots = ["hyper-rustls/webpki-roots"]
# Enable this feature to enable stubbing of cgroup
# php directly import this crate and uses functions gated by this feature for their test
cgroup_testing = []
# Use regex-lite instead of regex for smaller binary size
regex-lite = ["dep:regex-lite"]
Comment thread
Aaalibaba42 marked this conversation as resolved.
# Consumers that handle user-provided regexes can enable this feature to force
# the full `regex` crate, overriding `regex-lite` when both are active.
require-regex-full = []
# FIPS mode uses the FIPS-compliant cryptographic provider (Unix only)
fips = ["tls-core", "hyper-rustls/fips"]
# Enable reqwest client builder support with file dump debugging
Expand Down
2 changes: 1 addition & 1 deletion libdd-common/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 crate::regex_engine::Regex;
#[cfg(target_os = "linux")]
use std::collections::HashMap;
use std::sync::LazyLock;
Expand Down
2 changes: 1 addition & 1 deletion libdd-common/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 crate::regex_engine::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
Expand Down
2 changes: 1 addition & 1 deletion libdd-common/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 crate::regex_engine::Regex;

static IN_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"in-\d+").unwrap());
static CI_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Expand Down
1 change: 1 addition & 0 deletions libdd-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod connector;
#[cfg(feature = "reqwest")]
pub mod dump_server;
pub mod entity_id;
pub mod regex_engine;
#[macro_use]
pub mod cstr;
#[cfg(feature = "bench-utils")]
Expand Down
19 changes: 19 additions & 0 deletions libdd-common/src/regex_engine.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

//! Workspace-wide regex engine re-exports.
//!
//! By default this module re-exports from the full [`regex`] crate.
//! Enable the **`regex-lite`** feature to switch to [`regex_lite`] instead,
//! which trades advanced features (Unicode classes, look-around, etc.) for
//! smaller binary size and faster compile times.
//!
//! The **`require-regex-full`** feature forces the full `regex` crate even
//! when `regex-lite` is enabled, for consumers that evaluate user-provided
//! regexes requiring Unicode character class support.

#[cfg(all(feature = "regex-lite", not(feature = "require-regex-full")))]
pub use regex_lite::{escape, Captures, Regex, RegexBuilder, Replacer};

#[cfg(not(all(feature = "regex-lite", not(feature = "require-regex-full"))))]
pub use regex::{escape, Captures, Regex, RegexBuilder, Replacer};
1 change: 1 addition & 0 deletions libdd-crashtracker-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ required-features = ["collector_windows"]
[features]
default = ["cbindgen", "collector", "demangler", "receiver"]
cbindgen = ["build_common/cbindgen"]
regex-lite = ["libdd-common-ffi/regex-lite"]
# Enables the in-process collection of crash-info
collector = []
collector_windows = []
Expand Down
1 change: 1 addition & 0 deletions libdd-data-pipeline-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bench = false
default = ["cbindgen", "catch_panic"]
catch_panic = []
cbindgen = ["build_common/cbindgen", "libdd-common-ffi/cbindgen"]
regex-lite = ["libdd-data-pipeline/regex-lite"]

[build-dependencies]
build_common = { path = "../build-common" }
Expand Down
3 changes: 2 additions & 1 deletion libdd-data-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ path = "benches/trace_buffer.rs"
libdd-capabilities-impl = { version = "1.0.0", path = "../libdd-capabilities-impl" }
libdd-log = { path = "../libdd-log" }
libdd-shared-runtime = { version = "0.1.0", path = "../libdd-shared-runtime" }
regex = "1.5"
clap = { version = "4.0", features = ["derive"] }
criterion = "0.5.1"
libdd-trace-utils = { path = "../libdd-trace-utils", features = [
"test-utils",
] }
httpmock = "0.8.0-alpha.1"
rand = "0.8.5"
regex = "1.5"
tempfile = "3.3.0"
tokio = { version = "1.23", features = [
"rt",
Expand All @@ -90,3 +90,4 @@ https = [
"libdd-dogstatsd-client/https",
]
test-utils = []
regex-lite = ["libdd-common/regex-lite"]
3 changes: 3 additions & 0 deletions libdd-data-pipeline/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ mod tests {
use libdd_capabilities::HttpError;
use libdd_shared_runtime::{SharedRuntime, WorkerHandle};
use libdd_trace_utils::test_utils::poll_for_mock_hits;
// Use `regex::Regex` directly here because `httpmock`'s `body_matches`
// requires `Into<HttpMockRegex>`, which is only implemented for
// `regex::Regex`, not `regex_lite::Regex`.
Comment thread
Aaalibaba42 marked this conversation as resolved.
use regex::Regex;
use tokio::time::sleep;

Expand Down
1 change: 1 addition & 0 deletions libdd-ddsketch-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ bench = false
[features]
default = ["cbindgen"]
cbindgen = ["build_common/cbindgen", "libdd-common-ffi/cbindgen"]
regex-lite = ["libdd-common-ffi/regex-lite"]

[build-dependencies]
build_common = { path = "../build-common" }
Expand Down
Loading
Loading