Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

audit package #730

Closed
strantalis opened this issue May 2, 2024 · 0 comments · Fixed by #774
Closed

audit package #730

strantalis opened this issue May 2, 2024 · 0 comments · Fixed by #774
Assignees
Labels
comp:core Core component prod-390

Comments

@strantalis
Copy link
Member

In order to generate audit events within the platform we need an audit package that implements Leveler.

https://betterstack.com/community/guides/logging/logging-in-go/#creating-custom-log-levels

This package should be public and be something services or the sdk could easily call into. Maybe this fails under the logger package but the idea is to keep the audit centralized so in the future we could potentially look into things like tamper proof audit logs generated from the platform.

Example of how it was originally done in python.

https://github.com/opentdf/backend/blob/dbfcea7594fa72dd49d02a19aa01b36f3a32b7e6/containers/kas/kas_app/tdf3_kas_app/plugins/audit_hooks.py#L31-L77

@strantalis strantalis added the comp:core Core component label May 2, 2024
github-merge-queue bot pushed a commit that referenced this issue May 21, 2024
- Adds audit logging level to internal logger
- Closes #730 

The main changes for the PR are in `logger.go` and `audit.go` where we
add the new AUDIT log level and then add a specific method to the logger
to log rewrap requests as an example. More detailed changes for other
audit calls will be done as part of #719

Examples of rewrap success log:
```json
{
  "time": "2024-05-21T11:03:18.910724-04:00",
  "level": "AUDIT",
  "msg": "{\"id\":\"4e027444-3496-4a6d-9e95-f44be19e341c\",\"object\":{\"type\":\"data_object\",\"id\":\"a96b1e6a-177d-11ef-a5c4-06f27729b9a5\",\"attributes\":{\"attrs\":[\"https://example.com/attr/attr1/value/value1\"],\"dissem\":[],\"permissions\":[]}},\"action\":{\"type\":\"read\",\"result\":\"success\"},\"actor\":{\"id\":\"68f9d36d-e103-4518-8258-70fe7cc87c90\",\"attributes\":{\"attrs\":[],\"dissem\":[],\"permissions\":null}},\"eventMetaData\":{},\"clientInfo\":{\"userAgent\":\"\",\"platform\":\"kas\",\"requestIp\":\"\"},\"diff\":{},\"timestamp\":\"2024-05-21T11:03:18-04:00\"}",
  "namespace": "kas"
}
```

Parsed JSON string of audit log message:
```json
{
  "id": "4e027444-3496-4a6d-9e95-f44be19e341c",
  "object": {
    "type": "data_object",
    "id": "a96b1e6a-177d-11ef-a5c4-06f27729b9a5",
    "attributes": {
      "attrs": [
        "https://example.com/attr/attr1/value/value1"
      ],
      "dissem": [],
      "permissions": []
    }
  },
  "action": {
    "type": "read",
    "result": "success"
  },
  "actor": {
    "id": "68f9d36d-e103-4518-8258-70fe7cc87c90",
    "attributes": {
      "attrs": [],
      "dissem": [],
      "permissions": null
    }
  },
  "eventMetaData": {},
  "clientInfo": {
    "userAgent": "",
    "platform": "kas",
    "requestIp": ""
  },
  "diff": {},
  "timestamp": "2024-05-21T11:03:18-04:00"
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:core Core component prod-390
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants