Skip to content

Commit

Permalink
Merge pull request #17 from trussworks/check-empty-strings
Browse files Browse the repository at this point in the history
Everything is defaulted to empty string so check for that rather than…
  • Loading branch information
ralren authored May 14, 2020
2 parents d3beaed + 279221a commit 719c671
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sleuth/sleuth/auditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ def audit():
print_key_report(iam_users)

# lets disabled expired keys and build list of old and expired for slack
if os.environ['ENABLE_AUTO_EXPIRE'] == 'true':
if 'ENABLE_AUTO_EXPIRE' in os.environ and os.environ['ENABLE_AUTO_EXPIRE'] == 'true':
for u in iam_users:
for k in u.keys:
if k.audit_state == 'expire':
disable_key(k, u.username)

if 'SNS_TOPIC' not in os.environ and 'SLACK_URL' not in os.environ:
if ('SNS_TOPIC' not in os.environ and 'SLACK_URL' not in os.environ) or (os.environ['SNS_TOPIC'] == "" and os.environ['SLACK_URL'] == ""):
LOGGER.warn('No notification settings set, please set SNS_TOPIC or SLACK_URL envar!')

# lets assemble and send slack msg
if 'SNS_TOPIC' in os.environ:
if 'SNS_MESSAGE' not in os.environ:
if 'SNS_TOPIC' in os.environ and os.environ['SNS_TOPIC'] != "":
if 'SNS_MESSAGE' not in os.environ or os.environ['SNS_MESSAGE'] == "":
LOGGER.warn('No message set for sns topic, please set SNS_MESSAGE envar!')
LOGGER.info('Detected SNS setting so preparing and sending message via SNS')
send_to_slack, slack_msg = prepare_sns_message(iam_users)
Expand All @@ -133,8 +133,8 @@ def audit():
LOGGER.info('Nothing to report')


if 'SLACK_URL' in os.environ:
if 'SLACK_MESSAGE_TILE' not in os.environ or 'SLACK_MESSAGE_TEXT' in os.environ:
if 'SLACK_URL' in os.environ and 'SLACK_URL' != "":
if ('SLACK_MESSAGE_TITLE' not in os.environ or 'SLACK_MESSAGE_TEXT' not in os.environ) or (os.environ['SLACK_MESSAGE_TITLE'] == "" or os.environ['SLACK_MESSAGE_TEXT'] == ""):
LOGGER.warn('No message set for slack, please set SLACK_MESSAGE_TILE and SLACK_MESSAGE_TEXT envars!')
LOGGER.info('Using direct Slack API')
# lets assemble the slack message
Expand Down

0 comments on commit 719c671

Please sign in to comment.