Add subkey cap with template-method verification chain - #147
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #147 +/- ##
============================================
+ Coverage 52.15% 59.94% +7.78%
- Complexity 69 88 +19
============================================
Files 21 27 +6
Lines 278 342 +64
Branches 32 37 +5
============================================
+ Hits 145 205 +60
- Misses 115 119 +4
Partials 18 18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bmarwell
force-pushed
the
fix/subkey-cap-verification
branch
from
May 25, 2026 21:39
3eb72a7 to
09385ae
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a structured, template-method-based verification flow for command handlers, moving add-path validation into a typed verification registry/chain and adding a dedicated exception for subkey-cap enforcement.
Changes:
- Added a template-method verification hook to
AbstractKeyServerCommandHandlerand introduced a typedCommandVerificationRegistryplus reusableVerificationStepbuilding blocks. - Refactored
/pks/addhandling to run a verification chain (KeyTextSizeValidator→KeyTextParser→KeyRingVerifier) and added aTooManySubkeysExceptionfor subkey-cap rejection. - Updated unit tests to use the new
execute(...)flow and documented the new validation architecture.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/implementation-plan.adoc | Documents the new verification hook/registry rollout plan. |
| docs/architecture.adoc | Adds a description of the new validation architecture to the verification-flow docs. |
| application/application-core/src/test/java/io/github/bmarwell/keyserver/application/core/cmdhandler/VerifyUidCommandHandlerTest.java | Updates tests to call execute(...) instead of doExecute(...). |
| application/application-core/src/test/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/KeyRingVerifierTest.java | Adds focused tests for UID/subkey cap enforcement in KeyRingVerifier. |
| application/application-core/src/test/java/io/github/bmarwell/keyserver/application/core/cmdhandler/AddKeyToVerificationQueueCommandHandlerTest.java | Updates add-handler tests to use the new execution/verification flow. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/VerifyUidCommandHandler.java | Adapts handler to template-method verification (no-op registry) and updated doExecute signature. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/VerificationStep.java | Introduces a small-step verification interface. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/NoOpCommandVerificationRegistry.java | Adds a default registry implementation for handlers without verification steps yet. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/NoCommandVerification.java | Adds a marker verification result for no-op verification. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/KeyTextSizeValidator.java | Extracts keytext-size validation into a reusable verification step. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/KeyTextParser.java | Extracts armored-key parsing into a verification step. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/KeySubmissionVerifier.java | Implements the add-path verification registry/chain. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/KeyRingVerifier.java | Adds UID/subkey verification logic and produces prepared verification output. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/verification/CommandVerificationRegistry.java | Introduces a typed command-level verification registry API. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/AddKeyToVerificationQueueCommandHandler.java | Refactors add-handler to use the verification registry and consume verified output. |
| application/application-core/src/main/java/io/github/bmarwell/keyserver/application/core/cmdhandler/AbstractKeyServerCommandHandler.java | Adds the template-method execute(...) flow: verify first, then doExecute(...). |
| application/application-api/src/main/java/io/github/bmarwell/keyserver/application/api/ex/TooManySubkeysException.java | Adds a dedicated exception type for subkey-cap violations. |
| application/application-api/src/main/java/io/github/bmarwell/keyserver/application/api/ex/KeyValidationException.java | Extends the sealed exception hierarchy to permit TooManySubkeysException. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
TooManySubkeysExceptionand reject key submissions that exceed the subkey cap/pks/addand document proxy limits #143 keytext-size guard and the new fix: add subkey count cap in AddKeyToVerificationQueueCommandHandler #136 subkey guard into a structured verification flowAbstractKeyServerCommandHandlerand a typed verification registry interfacedocs/architecture.adocanddocs/implementation-plan.adocVerification design
AbstractKeyServerCommandHandler.execute(...)now always runs a command verification registry beforedoExecute(...)CommandVerificationRegistry<T, V>is the typed registry interface for command-level pre-execution verificationVerificationStep<I, O>is the small-step interface for reusable validators/parsersKeyTextSizeValidator->KeyTextParser->KeyRingVerifierVerifyUidCommandHandleruses a no-op registry so the execution flow stays consistent across handlersCloses #136