-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add application level Python audit logging #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Made a few suggestions / nits, but nothing blocking 👍
import collections | ||
|
||
|
||
class LeastRecentlyUsedDict(collections.OrderedDict): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this file be named least_recently_used_dict.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And in app/api/util/collections/__init__.py
we can do:
from .least_recently_used_dict import LeastRecentlyUsedDict
And to use it:
from api.util.collections import LeastRecentlyUsedDict
LeastRecentlyUsedDict(maxsize=4)
Which I think is a little cleaner than:
from api.util.collections.dict import dict_util
dict_util.LeastRecentlyUsedDict(maxsize=4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used the name dict as this could contain other dict related utilities in future. I added the import to __init__.py
.
Ticket
None
Changes
api.logging.audit
that implements Python audit logging.api.util.collections.dict
withclass LeastRecentlyUsedDict
.Context for reviewers
Python has an audit events feature. This code uses the feature to log audit events, which can be useful for security analysis.
The logs have a custom logging level
AUDIT
.Testing
A selection of logs when the server starts, include file opens, socket operations, and subprocess start: