-
Notifications
You must be signed in to change notification settings - Fork 132
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
Adding audit-search.py to the utilities directory. #1117
base: master
Are you sure you want to change the base?
Conversation
audit-search.py allows you to search through the audit log to see each change.
a = AuditLog() | ||
|
||
if len(sys.argv) == 1: | ||
print "Use with prefix to search in audit log" |
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.
SyntaxError: invalid syntax
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.
We try to use py3 syntax so that print would be print()
. If you still want to use py2 then you can do from __future__ import print_function
to just get the new print function.
|
||
|
||
|
||
a = AuditLog() |
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.
too many blank lines (3)
return output | ||
|
||
|
||
def search_log_prefix(self, prefix): |
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.
too many blank lines (2)
parsed = eval(dataset) | ||
output += "New data:\n" | ||
for k,v in parsed.items(): | ||
output += "{:<16}{:<20}: {:<32}\n".format("",k, v) |
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.
missing whitespace after ','
output += "{:<15} {}\n".format("Description:", description) | ||
parsed = eval(dataset) | ||
output += "New data:\n" | ||
for k,v in parsed.items(): |
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.
missing whitespace after ','
raise | ||
output = "{:<15} {}\n".format("Log id", data['id']) | ||
output += "{:<15} {}\n".format("Author:", data['username']) | ||
output += "{:<15} {}\n".format("Date:", data['timestamp'].strftime('%c')) |
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.
line too long (81 > 79 characters)
return _ext.INET | ||
|
||
|
||
def _format_log_prefix(self, data): |
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.
too many blank lines (2)
if not oid: | ||
oid = 869 | ||
_ext.INET = _ext.new_type((oid, ), "INET", | ||
lambda data, cursor: data and Inet(data) or None) |
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.
continuation line under-indented for visual indent
break | ||
|
||
|
||
def _register_inet(self, oid=None, conn_or_curs=None): |
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.
too many blank lines (2)
self._con_pg = psycopg2.connect(**db_args) | ||
self._curs_pg = self._con_pg.cursor(cursor_factory=psycopg2.extras.DictCursor) | ||
self._register_inet() | ||
psycopg2.extras.register_hstore(self._con_pg, globally=True, unicode=True) |
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.
line too long (90 > 79 characters)
while True: | ||
try: | ||
self._con_pg = psycopg2.connect(**db_args) | ||
self._curs_pg = self._con_pg.cursor(cursor_factory=psycopg2.extras.DictCursor) |
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.
line too long (94 > 79 characters)
|
||
|
||
|
||
def _connect_db(self): |
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.
too many blank lines (3)
|
||
|
||
|
||
def _get_afi(self, ip): |
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.
too many blank lines (3)
|
||
|
||
|
||
def _is_ipv6(self, ip): |
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.
too many blank lines (3)
self._connect_db() | ||
|
||
|
||
def _is_ipv4(self, ip): |
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.
too many blank lines (2)
import datetime | ||
import sys | ||
|
||
class AuditLog: |
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.
expected 2 blank lines, found 1
|
||
return output | ||
|
||
a = AuditLog() |
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.
expected 2 blank lines after class or function definition, found 1
I've written a little script to work with the audit log. It's nothing fancy or anything, but it works.
The audit-search.py allows you to search through the audit log to see each change performed.