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

Adding audit-search.py to the utilities directory. #1117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Eising
Copy link

@Eising Eising commented Dec 19, 2016

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.

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"

Choose a reason for hiding this comment

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

SyntaxError: invalid syntax

Copy link
Member

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()

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):

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)

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():

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'))

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):

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)

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):

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)

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)

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):

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):

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):

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):

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:

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()

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants