Skip to content

Test that the Composite obfuscator runs its stages in order [patch] - #175

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/issue-174-composite-stage-order
Nov 4, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
claude/issue-174-composite-stage-order

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #174

Summary

The Composite tests only checked round-trips. A Composite that ran its stages last-to-first when obfuscating, and first-to-last when deobfuscating, would still undo itself and pass every one of them. Its output bytes would differ, though, so data persisted by an earlier version would no longer deobfuscate. This PR adds the stage-order tests that consolidation spec §4 asks for. The library code is unchanged.

Changes

Essentials.Tests/ObfuscationProviderTests.cs gets seven tests built on a [Base64, Reverse] pipeline:

  • Obfuscation_Composite_ChosenStagesAreOrderSensitive checks that Reverse(Base64(x)) differs from Base64(Reverse(x)), so the chosen pair really does detect order.
  • Span, stream and async obfuscation (three tests): the output equals the stages applied one after another, B.Obfuscate(A.Obfuscate(x)).
  • Span, stream and async deobfuscation (three tests): the output equals A.Deobfuscate(B.Deobfuscate(y)).

CLAUDE.md's description of the test file now mentions the stage-order coverage.

I tried [Xor, Reverse] first, as the issue suggested. The default Xor key is a single byte, so that pair commutes, and the order-sensitivity guard caught it. [Base64, Reverse] is the other pair the issue named.

Tests

  • To check the new tests catch the bug, I temporarily made CompositeObfuscationProvider run both directions backwards:

    • all six order tests failed
    • the 54 existing obfuscation tests, including the Composite round-trips, still passed

    That confirms the gap the issue describes. The library change was then reverted.

  • Obfuscation slice: 60/60.

  • Full suite before the final pair change: 1351 passed, 1 skipped. The only failure was the order-sensitivity guard rejecting the original [Xor, Reverse] pair.


Generated by Claude Code

The Composite tests only checked round-trips, which a pipeline run
backwards in both directions would still pass while producing different
bytes from earlier versions. Compare its output with an order-sensitive
[Base64, Reverse] pair applied one stage at a time, on the span, stream
and async paths, in both directions.

Fixes #174

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

sonarqubecloud Bot commented Nov 3, 2026

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 562246c into main Nov 4, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the claude/issue-174-composite-stage-order branch November 4, 2026 00:55
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.

No test checks that CompositeObfuscationProvider applies its stages in order, so a pipeline run in the wrong order still passes (consolidation spec §4)

2 participants