fix(core): Add AUDIT events for improper bindings#3054
fix(core): Add AUDIT events for improper bindings#3054dmihalcik-virtru wants to merge 1 commit intomainfrom
Conversation
Summary of ChangesHello @dmihalcik-virtru, 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 improves the observability and security posture of the core service by implementing detailed audit logging for various failure scenarios encountered during key rewrapping operations. By capturing specific Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
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. When bindings fail fast, Audit logs catch every slip, Security holds strong. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds audit logging for several failure scenarios within the rewrap process, specifically for improper policy bindings. The changes correctly identify the failure points and add the necessary audit events. However, the implementation introduces significant code duplication for the audit logging logic. I've left a comment suggesting a refactoring to extract this duplicated code into a helper method to improve maintainability.
| p.Logger.Audit.RewrapFailure(ctx, audit.RewrapAuditEventParams{ | ||
| Policy: ConvertToAuditKasPolicy(*policy), | ||
| IsSuccess: false, | ||
| TDFFormat: "tdf3", | ||
| Algorithm: req.GetAlgorithm(), | ||
| PolicyBinding: "", | ||
| KeyID: kao.GetKeyAccessObject().GetKid(), | ||
| }) |
There was a problem hiding this comment.
This block for audit logging is nearly identical to two other blocks added in this function (lines 795-802 and 819-826). This duplication can make future changes more difficult.
Consider extracting this logic into a private helper method on the Provider to reduce code duplication and improve maintainability. For example:
func (p *Provider) auditRewrapFailure(ctx context.Context, policy *Policy, req *kaspb.UnsignedRewrapRequest_WithPolicyRequest, kao *kaspb.UnsignedRewrapRequest_WithKeyAccessObject, policyBinding string) {
p.Logger.Audit.RewrapFailure(ctx, audit.RewrapAuditEventParams{
Policy: ConvertToAuditKasPolicy(*policy),
IsSuccess: false,
TDFFormat: "tdf3",
Algorithm: req.GetAlgorithm(),
PolicyBinding: policyBinding,
KeyID: kao.GetKeyAccessObject().GetKid(),
})
}This new method could then be called from all three failure locations with the appropriate policyBinding value.
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
X-Test Failure Reportopentdf |
e0fb514 to
5d17897
Compare
Benchmark results, click to expandBenchmark authorization.GetDecisions Results:
Benchmark authorization.v2.GetMultiResourceDecision Results:
Benchmark Statistics
Bulk Benchmark Results
TDF3 Benchmark Results:
|
Proposed Changes
Checklist
Testing Instructions