Return false from the composite's Try methods when a stage fails - #42
Merged
Merged
Conversation
CompositeObfuscationProvider ran each stage through the throwing Obfuscate/Deobfuscate convenience methods, so a stage that rejects its input (Base64 or Hex fed invalid data) made the composite's Try methods throw InvalidOperationException instead of returning false. The stages now chain through their own Try methods, with each intermediate buffer sized from the stage's GetMax*Length, and the composite returns false as soon as one fails. Fixes #40 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NHprKRwyYopkJnUyhF3KSr
|
This was referenced Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #40
What changed
CompositeObfuscationProviderpassed data to each stage through the throwingObfuscate/Deobfuscateconvenience methods. If a stage rejected its input, the composite'sTry*methods threwInvalidOperationExceptioninstead of returningfalse. Base64 and Hex both reject invalid data this way.The four
Try*overloads (span and stream, obfuscate and deobfuscate) now go through two private helpers,TryRunForwardandTryRunReverse. These helpers:TryObfuscate/TryDeobfuscateGetMaxObfuscatedLength/GetMaxDeobfuscatedLengthfalseas soon as a stage failsWhen a stage fails, the stream overloads write nothing to the destination.
Tests
Obfuscation_Composite_TryDeobfuscate_Span_ReturnsFalseWhenAStageFailsObfuscation_Composite_TryDeobfuscate_Stream_ReturnsFalseWhenAStageFailsObfuscation_Composite_WithFallibleStage_Roundtrips, which checks that a successful round trip still works through the new pathReturnsFalsetests fail.🤖 Generated with Claude Code
https://claude.ai/code/session_01NHprKRwyYopkJnUyhF3KSr
Generated by Claude Code