Skip to content

Commit

Permalink
feat(onion): tweet when an onion service is available for a news org
Browse files Browse the repository at this point in the history
Using dict.get(key, default) here to avoid a KeyError in case:
1. this change is deployed prior to the corresponding STN change [0] or,
2. the bot compares with a prior scan that lacks the onion_available key

[0] freedomofpress/securethenews#262
  • Loading branch information
redshiftzero committed Aug 26, 2020
1 parent efd8e2f commit 04514cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stntweets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def compare_results(old_site, new_site):

site_tweets.append("🤖 " + new_site['name'] + " is now on the HSTS preload list for major browsers, protecting user privacy. Bravo. https://securethe.news/sites")

if (new_site.get('onion_available', False) and not old_site.get('onion_available', False)):
site_tweets.append("🤖 " + new_site['name'] + " provides a @torproject onion service to protect reader privacy and enable censorship circumvention! https://securethe.news/sites")

return site_tweets

def tweet_results(tweets, twitter):
Expand Down Expand Up @@ -114,6 +117,7 @@ def main():
site['latest_scan']['defaults_to_https'],
'hsts':site['latest_scan']['hsts'],
'hsts_preloaded':site['latest_scan']['hsts_preloaded'],
'onion_available':site['latest_scan'].get('onion_available', False),
'url':'https://securethe.news/sites/' + site['slug']})

# Open existing results to compare to the new ones, if they exist.
Expand Down

0 comments on commit 04514cd

Please sign in to comment.