Skip to content

Honour the Hex and Base64 obfuscator encoder on either side of AddEssentials() [patch] - #152

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/151-hex-base64-parameterized-registration
Oct 19, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/151-hex-base64-parameterized-registration

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #151

Problem

#136 made parameterized registrations take effect after AddEssentials(), but it missed AddHexObfuscationProvider(encoder) and AddBase64ObfuscationProvider(encoder). Both still used TryAddSingleton/TryAddEnumerable. As a result, once AddEssentials() had run, the caller's encoder was dropped without any error, and data was obfuscated with the default encoder.

Change

  • Essentials.ObfuscationProviders.Hex and .Base64: register through ProviderRegistration.AddOrReplaceSingleton<IObfuscationProvider, …>, and link Shared/ProviderRegistration.cs into both projects, the same as the Xor/Caesar/BitRotate fix. The doc remarks now describe the replace-in-place behaviour.
  • Essentials.All AddObfuscationProviders(): wrap Hex and Base64 in AddDefaultOrKeep<…>. Without this, an encoder registered before AddEssentials() would now be replaced by the default.

Tests

New tests in ParameterizedRegistrationTests:

  • Hex_Encoder_Takes_Effect_On_Either_Side_Of_AddEssentials
  • Base64_Encoder_Takes_Effect_On_Either_Side_Of_AddEssentials

Each covers both call orders. It checks that the concrete type and the enumerable entry obfuscate with the caller's encoder, that the provider is listed once, and that Xor is still the default IObfuscationProvider.

With the three provider/All changes reverted, both new tests fail. With them in place, the full suite passes: 1085 tests, 0 failed. All three changed projects build clean across every target framework.


Generated by Claude Code

…bfuscationProvider around AddEssentials() [patch]

Both overloads still registered through TryAddSingleton/TryAddEnumerable, so
an encoder passed after AddEssentials() was silently dropped. They now use
ProviderRegistration.AddOrReplaceSingleton like the other parameterized
providers, and AddObfuscationProviders() wraps them in AddDefaultOrKeep so an
encoder registered before AddEssentials() survives it too.

Fixes #151

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K9BPLzzCuJkUVAWjN1LtNF
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit a9a00b9 into main Oct 19, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/151-hex-base64-parameterized-registration branch October 19, 2026 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddHexObfuscationProvider(encoder) and AddBase64ObfuscationProvider(encoder) are silently ignored after AddEssentials()

2 participants