Skip to content

Commit 3af63ae

Browse files
committed
fix: raise default rust pii text limit
Signed-off-by: lucarlig <luca.carlig@ibm.com>
1 parent a604cad commit 3af63ae

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

plugins/pii_filter/pii_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class PIIFilterConfig(BaseModel):
130130
include_detection_details: bool = Field(default=True, description="Include detection details in metadata")
131131

132132
# Resource limits for the Rust implementation
133-
max_text_bytes: int = Field(default=256 * 1024, gt=0, le=100 * 1024 * 1024, description="Maximum text payload size accepted by the Rust detector (max 100MB)")
133+
max_text_bytes: int = Field(default=10 * 1024 * 1024, gt=0, le=100 * 1024 * 1024, description="Maximum text payload size accepted by the Rust detector (max 100MB)")
134134
max_nested_depth: int = Field(default=32, gt=0, le=1000, description="Maximum nested depth accepted by the Rust detector (max 1000)")
135135
max_collection_items: int = Field(default=4096, gt=0, le=1_000_000, description="Maximum list or mapping size accepted by the Rust detector (max 1M)")
136136

plugins_rust/pii_filter/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ impl Default for PIIConfig {
147147
include_detection_details: true,
148148

149149
// Default resource limits
150-
max_text_bytes: 256 * 1024,
150+
max_text_bytes: 10 * 1024 * 1024,
151151
max_nested_depth: 32,
152152
max_collection_items: 4096,
153153

@@ -342,7 +342,7 @@ mod tests {
342342
assert!(config.detect_email);
343343
assert_eq!(config.redaction_text, "[REDACTED]");
344344
assert_eq!(config.default_mask_strategy, MaskingStrategy::Redact);
345-
assert_eq!(config.max_text_bytes, 256 * 1024);
345+
assert_eq!(config.max_text_bytes, 10 * 1024 * 1024);
346346
assert_eq!(config.max_nested_depth, 32);
347347
assert_eq!(config.max_collection_items, 4096);
348348
}

plugins_rust/pii_filter/src/detector.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,34 @@ mod tests {
11031103
});
11041104
}
11051105

1106+
#[test]
1107+
fn test_default_detector_accepts_inputs_larger_than_256k() {
1108+
Python::initialize();
1109+
Python::attach(|_| {
1110+
let config = PIIConfig {
1111+
detect_ssn: true,
1112+
detect_bsn: false,
1113+
detect_credit_card: false,
1114+
detect_email: false,
1115+
detect_phone: false,
1116+
detect_ip_address: false,
1117+
detect_date_of_birth: false,
1118+
detect_passport: false,
1119+
detect_driver_license: false,
1120+
detect_bank_account: false,
1121+
detect_medical_record: false,
1122+
detect_aws_keys: false,
1123+
detect_api_keys: false,
1124+
..Default::default()
1125+
};
1126+
let patterns = compile_patterns(&config).unwrap();
1127+
let detector = PIIDetectorRust { patterns, config };
1128+
let text = format!("{} SSN: 123-45-6789", "x".repeat(300 * 1024));
1129+
1130+
assert!(detector.detect(&text).is_ok());
1131+
});
1132+
}
1133+
11061134
#[test]
11071135
fn test_longer_overlap_wins_over_registration_order() {
11081136
let mut config = PIIConfig {

0 commit comments

Comments
 (0)