Adding audit-search.py to the utilities directory.#1117
Open
Eising wants to merge 3 commits intoSpriteLink:masterfrom
Open
Adding audit-search.py to the utilities directory.#1117Eising wants to merge 3 commits intoSpriteLink:masterfrom
Eising wants to merge 3 commits intoSpriteLink:masterfrom
Conversation
audit-search.py allows you to search through the audit log to see each change.
houndci-bot
reviewed
Dec 19, 2016
| a = AuditLog() | ||
|
|
||
| if len(sys.argv) == 1: | ||
| print "Use with prefix to search in audit log" |
Member
There was a problem hiding this comment.
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.
houndci-bot
reviewed
Dec 19, 2016
|
|
||
|
|
||
|
|
||
| a = AuditLog() |
houndci-bot
reviewed
Dec 19, 2016
| return output | ||
|
|
||
|
|
||
| def search_log_prefix(self, prefix): |
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| parsed = eval(dataset) | ||
| output += "New data:\n" | ||
| for k,v in parsed.items(): | ||
| output += "{:<16}{:<20}: {:<32}\n".format("",k, v) |
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| output += "{:<15} {}\n".format("Description:", description) | ||
| parsed = eval(dataset) | ||
| output += "New data:\n" | ||
| for k,v in parsed.items(): |
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| 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.
line too long (81 > 79 characters)
houndci-bot
reviewed
Dec 19, 2016
| return _ext.INET | ||
|
|
||
|
|
||
| def _format_log_prefix(self, data): |
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| 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.
continuation line under-indented for visual indent
houndci-bot
reviewed
Dec 19, 2016
| break | ||
|
|
||
|
|
||
| def _register_inet(self, oid=None, conn_or_curs=None): |
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| 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.
line too long (90 > 79 characters)
houndci-bot
reviewed
Dec 19, 2016
utilities/audit-search.py
Outdated
| 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.
line too long (94 > 79 characters)
houndci-bot
reviewed
Dec 19, 2016
|
|
||
|
|
||
|
|
||
| def _connect_db(self): |
houndci-bot
reviewed
Dec 19, 2016
|
|
||
|
|
||
|
|
||
| def _get_afi(self, ip): |
houndci-bot
reviewed
Dec 19, 2016
|
|
||
|
|
||
|
|
||
| def _is_ipv6(self, ip): |
houndci-bot
reviewed
Dec 19, 2016
| self._connect_db() | ||
|
|
||
|
|
||
| def _is_ipv4(self, ip): |
houndci-bot
reviewed
Dec 19, 2016
| import datetime | ||
| import sys | ||
|
|
||
| class AuditLog: |
houndci-bot
reviewed
Dec 19, 2016
|
|
||
| return output | ||
|
|
||
| a = AuditLog() |
There was a problem hiding this comment.
expected 2 blank lines after class or function definition, found 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.