Repository navigation
feat(core): add alter ego model, keyed digests and token registry - #3
Merged
Merged
Conversation
Alter egos carry a mandatory placement and a decoy class (generic or unique), with severity defaults derived from the class. The constructor validates every field, so an invalid alter ego cannot exist. Decoy values are registered only as HMAC-SHA256 digests, with one subkey per trigger domain derived through HKDF from a key of at least 32 bytes. Reading the configuration therefore does not reveal which values are decoys, and the same value has a different digest in each domain. The registry is immutable, validates the whole set at once and reports every problem without echoing digests or values. Lookups by identifier and by raw value do not allocate.
Measures lookups with and without a match, in a domain without triggers and by identifier, with the memory diagnoser on.
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.
What changed
WalterEgo):HoneyTokenwith a mandatory placement,HoneyTokenId(lowercase slug, stable across restarts),HoneyTokenKind,DecoyClass(generic or unique),SeverityandTriggerDomain. The constructor validates every field, so an invalid alter ego cannot exist. Tags are copied into a frozen dictionary and validated after the copy.ISecretHasherandSecretDigest. A digest is HMAC-SHA256 with one subkey per trigger domain, derived with HKDF-SHA256 from a key of at least 32 bytes, so the same value has a different digest in each domain. The canonical text form is 43 base64url characters without padding. Digest equality runs in constant time, and the buffer that held the hashed value is cleared after use.ITokenRegistryfinds alter egos by identifier or by raw value (hashed internally, so sensors never handle keys or digests).HasTriggerslets a sensor skip a domain that has no decoys. The internal builder validates the whole set at once (identifiers, kind and trigger domain rules, duplicates, triggers shared between alter egos, text and tag limits) and reports every problem without echoing digests or values. Defaults: unique class for every kind except endpoints and users, which must state their class; low severity for generic decoys and high for unique ones.There is no entry point yet: dependency injection and configuration binding come in a later change, so no sample is affected (
no-sample-impact).How it was tested
dotnet build -c Release: 0 warnings, 0 errors, AOT analyzers included.dotnet test: 259 passed, 152 of them inWalterEgo.Core.Tests. The digest construction is pinned by known-answer vectors computed outside .NET with an independent HKDF and HMAC implementation, including a non-ASCII value and a lone surrogate. An allocation test checks that lookups allocate nothing; adding a deliberate allocation to the lookup made it fail.dotnet format --verify-no-changes: clean.dotnet list package --vulnerable --include-transitive: no vulnerable packages.TryMatchwithout a matchTryMatchwith a matchTryMatchin a domain without triggersTryGetby identifierPublic API impact
New public types in
WalterEgo.Core:HoneyToken,HoneyTokenId,HoneyTokenKind,DecoyClass,Severity,TriggerDomain,SecretDigest,ISecretHasherandITokenRegistry. No existing API changed.