feat(audit): add versioned integrity format - #75
Open
P4ST4S wants to merge 1 commit into
Open
Conversation
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
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
Add Integrity v2 as an additive, versioned HMAC-SHA256 format that authenticates the complete critical audit record through RFC 8785 JSON Canonicalization Scheme.
Legacy
signaturegeneration and verification remain unchanged so existing audit logs and consumers continue to work.Context
Closes #73.
Stacked on #74, which introduces
audit_operation_idand terminaloutcomefields included in the v2 protected payload.Approach
integrityobjectsignaturefield set and add legacy verification coverageaudit.signing.key_id, defaulting todefaultThe new
github.com/gowebpki/jcsdependency is used because RFC 8785 requires ECMAScript-compatible number serialization, UTF-16 property ordering, duplicate-key rejection, and strict string handling. Reimplementing those security-sensitive rules withencoding/jsonwould not be standards-compliant. The dependency is Apache-2.0, has no runtime dependencies, and supports Go 1.15+.Test plan
go test -race ./internal/audit/... ./internal/proxy/... ./cmd/mcp-auditgo test -race ./...go build ./...go vet ./...All commands pass.
Regression coverage mutates every protected field individually, verifies object-order and whitespace invariance, rejects duplicate keys and unsupported versions, and round-trips metadata through JSONL and SQLite.
Stability impact
Adds the optional
integrityaudit object and the additiveaudit.signing.key_idconfiguration key. Existing audit fields, config keys, and legacy signature semantics are unchanged.Integrity v2 is itself contract-stable: its algorithm and protected field set are documented in
docs/AUDIT_INTEGRITY.md.Notes for reviewer
This PR intentionally does not fail startup for a missing secret. That behavior remains isolated in the next stacked PR for #67.