Skip to content

Conversation

@c-r33d
Copy link
Contributor

@c-r33d c-r33d commented Oct 31, 2025

Proposed Changes

1.) Populate kas rewrap audit message with attributes.
2.) Add keyID to eventmetadata

Example Nano failure

{
    "time": "2025-10-30T10:13:30.270403-05:00",
    "level": "AUDIT",
    "msg": "rewrap",
    "namespace": "kas",
    "audit": {
        "object": {
            "type": "key_object",
            "id": "ff1a2fe2-a942-11f0-9751-a6a754e79d24",
            "name": "",
            "attributes": {
                "assertions": [],
                "attrs": [
                    "https://test.obligations/attr/test_attr_for_triggers/value/test_valu_for_trigger"
                ],
                "permissions": []
            }
        },
        "action": {
            "type": "rewrap",
            "result": "error"
        },
        "actor": {
            "id": "031fe452-ddbb-4d36-b82f-c6b3dd4d122a",
            "attributes": []
        },
        "eventMetaData": {
            "algorithm": "ec:secp256r1",
            "keyID": "e1",
            "policyBinding": "",
            "tdfFormat": "Nano"
        },
        "clientInfo": {
            "userAgent": "connect-go/1.18.1 (go1.24.6)",
            "platform": "kas",
            "requestIP": "None"
        },
        "original": null,
        "updated": null,
        "requestID": "d56da397-3387-4a14-9955-73681e627e37",
        "timestamp": "2025-10-30T10:13:30-05:00"
    }
}

Example ztdf success

{
    "time": "2025-10-31T11:58:40.892713-05:00",
    "level": "AUDIT",
    "msg": "rewrap",
    "namespace": "kas",
    "audit": {
        "object": {
            "type": "key_object",
            "id": "cd2f0354-a942-11f0-b197-a6a754e79d24",
            "name": "",
            "attributes": {
                "assertions": [],
                "attrs": [
                    "https://test.obligations/attr/test_attr_for_triggers/value/test_valu_for_trigger"
                ],
                "permissions": []
            }
        },
        "action": {
            "type": "rewrap",
            "result": "success"
        },
        "actor": {
            "id": "031fe452-ddbb-4d36-b82f-c6b3dd4d122a",
            "attributes": []
        },
        "eventMetaData": {
            "algorithm": "rsa:2048",
            "keyID": "r1",
            "policyBinding": "YjEwNWMwZGVhMjkzYjBhZjU4MWNkOTE1MmU4N2NkNjkzNzQ2ODM5NDI0MGRjYjhmNjRiZjlhNmY0OWEzZjJlNw==",
            "tdfFormat": "tdf3"
        },
        "clientInfo": {
            "userAgent": "connect-go/1.18.1 (go1.24.6)",
            "platform": "kas",
            "requestIP": "None"
        },
        "original": null,
        "updated": null,
        "requestID": "73f131ae-cc21-490c-868d-260e58b8664d",
        "timestamp": "2025-10-31T11:58:40-05:00"
    }
}

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

@c-r33d c-r33d requested review from a team as code owners October 31, 2025 17:28
@github-actions github-actions bot added comp:kas Key Access Server size/m labels Oct 31, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @c-r33d, 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 improves the audit logging capabilities for rewrap operations within the KAS service. By populating the rewrap audit messages with specific policy attributes and the "keyID" in the "eventMetaData", it provides a more comprehensive and actionable record of key access events. This enhancement is particularly valuable for understanding the context of rewrap operations, especially for Nano TDFs where policy details are not directly visible in the audit log, thereby aiding in debugging, compliance, and security analysis.

Highlights

  • Enhanced Rewrap Audit Logging: The KAS rewrap audit messages now include detailed policy attributes and the "keyID" within the "eventMetaData" for both success and failure scenarios.
  • Improved Nano TDF Auditing: Specifically for Nano TDFs, the "KeyID" is now captured in the audit logs, which is crucial since the policy itself is encrypted in this format.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.


Logs flow, a stream of truth,KeyID now shines so bright,Audit's eye, clear and keen.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@c-r33d c-r33d changed the title Fix/populate rewrap audit log fix(kas): populate rewrap audit log Oct 31, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully enhances the rewrap audit logs by populating them with data attributes and the key ID. The changes are implemented for both TDF3 and NanoTDF formats, and the corresponding tests have been updated to validate the new log structure. The implementation is clean and correct. I have one suggestion to improve the maintainability of the tests.

@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 179.390142ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 114.042569ms

Standard Benchmark Metrics Skipped or Failed

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 362.964848ms
Throughput 275.51 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 39.9638763s
Average Latency 397.661845ms
Throughput 125.11 requests/second

NANOTDF Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 28.173442036s
Average Latency 280.86349ms
Throughput 177.47 requests/second

@github-actions
Copy link
Contributor

Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 173.909517ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 102.461439ms

Standard Benchmark Metrics Skipped or Failed

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 349.548798ms
Throughput 286.08 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 38.663492098s
Average Latency 385.011895ms
Throughput 129.32 requests/second

NANOTDF Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 27.001317328s
Average Latency 269.017906ms
Throughput 185.18 requests/second

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

EphemeralPublicKey []byte
RequiredObligations []string

// Only populated for Nano auditing, since policy is encrypted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

policy is not always encrypted. We have a option to use plain text for policy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:kas Key Access Server size/m

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants