feat: implement nonrepudiation and cryptographic signing#3
feat: implement nonrepudiation and cryptographic signing#3
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the integrity and trustworthiness of audit logs by introducing cryptographic signing capabilities. It allows audit events to be digitally signed using various algorithms (RSA, Ed25519) and verified, thereby providing non-repudiation. The changes include updates to data models, API interfaces, and the addition of core cryptographic utility functions, ensuring that audit trails can be reliably attributed and their authenticity confirmed. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces cryptographic signing for audit logs to provide non-repudiation. The changes are comprehensive, touching the API documentation, data models, services, and the client library. A new pkg/audit/security.go file is added with well-implemented logic for canonicalization, signing, and verification for RSA and Ed25519 keys, supported by good tests. The configuration loading for enums has also been refactored to be more robust.
My review includes a couple of suggestions: one to fix a minor bug in the new mergeUniqueStrings function in internal/config/config.go, and another to improve error handling in the new test file pkg/audit/security_test.go.
|
/gemini review |
28962bf to
f27870a
Compare
f27870a to
0faf953
Compare
0faf953 to
b219d49
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces significant enhancements by adding non-repudiation and cryptographic signing capabilities to the audit logging system. The changes include updating core audit models and DTOs to incorporate signature metadata, extending the client library with signing and verification methods, and implementing an asynchronous worker queue for event processing. New security.go and security_test.go files provide robust cryptographic functions and comprehensive tests for canonicalization, signing, and verification. The documentation (docs/API.md) has been updated to reflect these new features. Overall, the changes are well-implemented and tested, greatly improving the integrity and trustworthiness of audit events.
c499ba6 to
d7fe101
Compare
There was a problem hiding this comment.
Code Review
This pull request introduces significant new functionality for non-repudiation and cryptographic signing of audit events. The changes are extensive, including a major refactoring of the pkg/audit client to use a robust worker-queue model, the addition of new security-related fields to the data models and API, and updates to documentation. The implementation of the cryptographic functions in pkg/audit/security.go is solid and well-tested.
Overall, the changes are well-structured. I've identified a few issues: a critical one regarding a potentially breaking database schema change, a high-severity validation bug in the API handler, and a few medium-severity issues related to API documentation consistency, client library usability, and a minor performance improvement. Addressing these points will further strengthen this important new feature.
Summary
Add non-repudiation and cryptographic signing capabilities. The goal is to allow client services (such as NSW) to provide an irrefutable "Proof of Origin" for critical audit events. This is achieved by extending the
pkg/auditclient library to handle digital signatures via a secure callback mechanism and updating the backend service to persist this metadata alongside standard audit logsChanges
Core Audit Models & Persistence
AuditLogandAuditLogRequestto includesignature,signatureAlgorithm, andpublicKeyIdfieldsMessagefield to[]byteto ensure cryptographic hashes remain stable and can store larger binary payloadsBLOBorBYTEA) in both SQLite and PostgreSQL backendsClient Library (
pkg/audit)Auditorinterface now includesSignEvent,LogSignedEvent,VerifyIntegrity, andClosemethodsSignPayloadFuncto decouple the library from private key management, allowing callers to provide their own signing logic (e.g., via KMS or HSM)Clientto use a background worker queue with a configurable number of workers and automated retries (up to 3 attempts) for signing operationssecurity.go) :CanonicalizeRequestto ensure consistent JSON serialization for stable hashing.VerifyPayloadandVerifyIntegrityfor public-key based signature validationClosemethod to ensures the internal worker queue is flushed and all pending logs are transmitted before the process exitsDocumentation & Service Layer
docs/API.mdto define the new optional security fields for thePOST /api/audit-logsendpoint