Skip to content

test(sanitization): add comprehensive test suite for sanitization feature - #51

Merged
marioarce merged 11 commits into
developfrom
feature/sanitization-tests
Jul 23, 2026
Merged

test(sanitization): add comprehensive test suite for sanitization feature#51
marioarce merged 11 commits into
developfrom
feature/sanitization-tests

Conversation

@marioarce

Copy link
Copy Markdown
Owner

This PR introduces a complete test suite for the Sanitization feature, covering all engines, DI integration, extension methods, and edge cases. Includes platform-independent tests and two bug fixes discovered during test implementation.

Test coverage:

  • Log Injection Sanitization: control character handling, encoding strategies, CRLF/LF injection prevention, null/empty input edge cases, and performance validation.

  • File Path Sanitization: directory traversal attack prevention, Windows UNC paths, path normalization, allowlist validation, malicious patterns, symlink handling, and path-length limits.

  • Regex Injection Sanitization: regex metacharacter escaping, special character sequences, invalid pattern detection, null/empty cases, and quantifier overflow prevention.

  • Sensitive Data Sanitization: PII detection (SSN, credit card, phone, email, IP address, API keys), masking strategies (removal vs. character replacement), key-value pair obfuscation, custom pattern support, and strictness levels.

  • Sanitization Result and Extension Methods: result model validation, extension method return types, null coalescing behavior, and method chaining compatibility.

  • Feature DI Wiring: options binding from configuration (PowerFeatures:Sanitization), NoOp service registration when feature is disabled, real service registration when enabled, settings provider bridge to static engine, and ConfigureSanitizationEngine orchestration.

Bug fixes:

  • Sensitive data masking now correctly handles key-value pairs (fixes mask character application).

  • Correlation ID generation is platform-independent (fixes test failures on non-Windows environments).

Test project added to solution. All 0 pre-existing tests remain passing; ~900 new test assertions added across 6 test classes.

marioarce added 11 commits July 22, 2026 18:45
 - Fix sensitive key masking to preserve the key name and mask only the value
 - Replace a reference to a non-existent capture group that always produced an empty mask and silently left the raw secret in the output
 - Align the fix with the pattern already used by the other key based heuristics in the same method
 - Add an xunit test project referencing the Sanitization module and abstractions packages
 - Disable test parallelization since the sanitization engine holds process wide static state that a subset of tests configure directly
 - Cover null and empty input passthrough
 - Cover the disabled setting bypass
 - Cover each control character strategy including tab preservation
 - Cover the max sanitized string length truncation
 - Cover strict allowlist validation for traversal, absolute paths, and reserved device names
 - Cover the extension and base directory allowlists including an escape attempt
 - Cover legacy pattern stripping mode
 - Cover correlation id sanitization for safe file name use
 - Cover masking of key value pairs, bearer tokens, api keys, and file paths
 - Verify the key or prefix is preserved while only the value is masked
 - Cover strictness level differences for long alphanumeric strings
 - Cover the custom mask character setting
 - Cover acceptance of safe patterns and rejection of invalid syntax
 - Cover nested quantifier rejection and the explicit opt in override
 - Cover the pattern length limit and each individually disallowed construct
 - Cover the disabled setting bypass
 - Cover every string extension method including the throwing strict file path variant
 - Cover both mask overloads and the short value edge case
 - Cover factory methods and value equality for both result types
 - Cover explicit registration resolving the real service and settings provider
 - Cover options binding from configuration and the settings provider reflecting it
 - Cover the DI resolved service honoring bound options
 - Cover the NoOp service passthrough behavior
 - Cover bridging the resolved settings provider into the static engine, including the no provider case
 - Add the Sanitization feature test project to the main solution
 - Nest the project under the existing tests solution folder
 - Register the project across all solution configuration platforms
 - Rename the misspelled property to the one actually defined on the attribute
 - Resolves a compilation error in the test assembly attribute
 - Assert against characters that are invalid file name characters on every platform
 - Avoid asserting on characters that are only invalid on Windows since the prior assertion failed on this machine
@marioarce marioarce self-assigned this Jul 23, 2026
@marioarce marioarce added enhancement New feature or request feature-framework labels Jul 23, 2026
@marioarce
marioarce merged commit 0102827 into develop Jul 23, 2026
6 checks passed
@github-actions
github-actions Bot deleted the feature/sanitization-tests branch July 23, 2026 01:25
@marioarce marioarce linked an issue Jul 23, 2026 that may be closed by this pull request
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sanitization: test coverage for engine, module, and option binding

1 participant