Repository navigation
Support decrypting @encryptInjectedEnv blobs in generated C# modules - #1281
Merged
theoephraim merged 4 commits intoNov 13, 2026
Merged
Conversation
The generated C# Env.Load() previously rejected encrypted __VARLOCK_ENV blobs. It now decrypts varlock:v1 blobs with AES-256-GCM using the key in _VARLOCK_ENV_KEY, matching the TypeScript runtime format.
Contributor
There was a problem hiding this comment.
Important
The generated loader now requires a .NET 8 API even for plaintext environments, and the new smoke test does not actually exercise encryption.
Reviewed changes: Reviewed the C# decryption implementation and its unit and smoke coverage.
- Encrypted loading: Generated C# modules decrypt
varlock:v1:blobs with AES-GCM and_VARLOCK_ENV_KEYbefore parsing JSON. - Coverage and fixtures: Updated emitter assertions and added a .NET 8 smoke fixture with sensitive-value checks and ignored generated artifacts.
- Release entry: Added a minor release entry for C# encrypted-blob support.
gpt-6.1-sol | 𝕏
…rypted smoke test exercise decryption The two-argument AesGcm constructor is .NET 8+, so guard it with NET8_0_OR_GREATER. The encrypted smoke test now runs with --inject blob and asserts the blob starts with varlock:v1:, so it can't pass on plaintext.
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the fixes since 4160d38.
- Preserved older target compatibility: Guarded the .NET 8 constructor and used the key-only overload on earlier targets.
- Exercised encrypted loading: Switched the smoke invocation to blob-only injection and rejected plaintext payloads in the fixture.
Validation: All 140 type-generation tests and both C# smoke tests passed. The generated fallback branch also compiled against net7.0 and decrypted successfully using runtime roll-forward.
gpt-6.1-sol | 𝕏
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.

Summary
Generated C# modules (
@generateCsharpEnv) used to rejectvarlock:v1:encrypted blobs. They now decrypt them, so@encryptInjectedEnvworks with C#, matching the TypeScript runtime format.Evidence
csharp.test.tsexpected the loader to throw__VARLOCK_ENV is encrypted.... An@encryptInjectedEnvproject failed atEnv.Load().After: the loader contains
DecryptBlob(AES-256-GCM viaAesGcm, key from_VARLOCK_ENV_KEY). Unit tests:packages/varlock/src/env-graph/test/type-generation8 files, 140 tests passing. Lint and typecheck clean.smoke-tests/smoke-test-lang-csharp-encrypted(@encryptInjectedEnv+@generateCsharpEnv) runsvarlock run -- dotnet runand printsOK. Existingsmoke-test-lang-csharpstill passes. Local run: 2 passed, 5 skipped (other languages' toolchains not installed).Merge Danger
Door: two-way. Changes are confined to the C# emitter and its tests, plus one new fixture.
Blast Radius: C# consumers of
@generateCsharpEnvonly. Non-encrypted behavior is unchanged. Encrypted blobs that previously threw now decrypt, which also means_VARLOCK_ENV_KEYmust be present in the process env for those projects. GeneratedEnv.csfiles need regenerating to pick up the change.Notes:
Convert.FromHexString) and OpenSSL on Linux forAesGcm./proc/<pid>/environreaders. The stronger option isvarlock freeze.smoke-testshit a TLSUnknownIssuererror on the local machine, so the smoke run was done with the pinned pnpm via npx.