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

Minor syntax edits and one alert #5

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion opencanary_correlator/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def save(self):
json.dump(self.__config, f)

except Exception, e:
print "[-] Failed to save config file %s" % e
print("[-] Failed to save config file %s" % e)
raise ConfigException("config", e)

def __repr__(self):
Expand Down
4 changes: 3 additions & 1 deletion opencanary_correlator/common/emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def mandrill_send(to=None, subject=None, message=None, reply_to=None):
if reply_to:
message["headers"] = { "Reply-To": reply_to }

# With Python 3.7 this line will fail because async is a reserved word
# The new line should be: result = mandrill_client.messages.send(message=message, asy=False, ip_pool='Main Pool')
result = mandrill_client.messages.send(message=message, async=False, ip_pool='Main Pool')

except mandrill.Error, e:
print 'A mandrill error occurred: %s - %s' % (e.__class__, e)
print('A mandrill error occurred: %s - %s' % (e.__class__, e))
2 changes: 1 addition & 1 deletion opencanary_correlator/common/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class IncidentFactory:

@classmethod
def create_incident(cls, type_, data=None):
print '{0}: {1}'.format(type_, data)
print('{0}: {1}'.format(type_, data))
logger.debug('Creating incident type: {0}'.format(type_))
if type_ == 'ftp.login_attempt':
IncidentFTPLogin(data=data, write_object=True)
Expand Down
4 changes: 4 additions & 0 deletions opencanary_correlator/common/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def emit(self, record):
# Console and correlator use different logger names. Common modules
# should still log to the logger for the process under which they're running.
# Impact of this is we don't support multiple loggers per process

# In Python 3.x this will fail as dict_keys() is no longer returns a list, but an object.
# The following will provide an iterable list (if that is still the right thing to do)
# existing_logger_names = list(logging.getLogger().manager.loggerDict.keys())
existing_logger_names = logging.getLogger().manager.loggerDict.keys()
if len(existing_logger_names) > 0:
lgr = existing_logger_names[0]
Expand Down
6 changes: 3 additions & 3 deletions opencanary_correlator/common/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ def set_console_setting(setting, value):
return redis.set(key, value)

if __name__ == "__main__":
print 'All: %r' % get_all_devices()
print 'All Incidents: %r' % get_all_incidents()
print 'All Unacknowledged Incidents: %r' % get_unacknowledged_incidents()
print('All: %r' % get_all_devices())
print('All Incidents: %r' % get_all_incidents())
print('All Unacknowledged Incidents: %r' % get_unacknowledged_incidents())
6 changes: 3 additions & 3 deletions opencanary_correlator/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def lineReceived(self, line):
event = json.loads(line)
except Exception as e:
print >> sys.stderr, "Failed to decode line"
print e
print(e)
return

process_device_report(event)
Expand All @@ -42,9 +42,9 @@ def main():
try:
config = CorrelatorOptions()
config.parseOptions()
except usage.UsageError, ue:
except usage.UsageError as ue:
print >> sys.stderr, '%s:' % sys.argv[0], ue
print config
print(config)
sys.exit(1)

common.config.config = common.config.Config(config.opts['config'])
Expand Down