Skip to content

Commit cf6bb9e

Browse files
authored
Merge pull request #7 from freedomofpress/guardian
Adds ruleset for www.guardian.com SecureDrop instance
2 parents b001ca3 + 48bb8bb commit cf6bb9e

7 files changed

+20
-10
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ which will create `test-key.jwk` in your current working directory.
2424

2525
1. Ensure they are in the official SecureDrop directory. If they are not, go through the IVF process with the organization.
2626

27-
2. Add their domain to `onboarded.txt` via PR into this repository. We match the domain based on the landing page of the organization, comparing the `netloc` in a URL with structure `scheme://netloc/path;parameters?query#fragment`.
27+
2. Add their domain name and the requested URL to the `onboarded.txt` via PR into this repository. We match the domain based on the landing page of the organization, comparing the `netloc` in a URL with structure `scheme://netloc/path;parameters?query#fragment`.
2828

2929
3. Next, perform a ruleset release as described below.
3030

default.rulesets.1593528236.gz

332 Bytes
Binary file not shown.

latest-rulesets-timestamp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1588004096
1+
1593528236

onboarded.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
lucyparsonslabs.com
2-
theintercept.com
1+
primary_domain,sd_rewrite_rule
2+
lucyparsonslabs.com,lucyparsonslabs.securedrop.tor.onion
3+
theintercept.com,theintercept.securedrop.tor.onion
4+
www.theguardian.com,theguardian.securedrop.tor.onion

rulesets-signature.1593528236.sha256

512 Bytes
Binary file not shown.
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ruleset name="The Guardian">
2+
<target host="theguardian.securedrop.tor.onion" />
3+
<rule from="^http[s]?://theguardian.securedrop.tor.onion"
4+
to="http://33y6fjyhs3phzfjj.onion" />
5+
</ruleset>

sddir.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import re
22
import requests
33
import os
4+
import csv
45
import urllib
56

67
from typing import Dict, List
@@ -40,13 +41,13 @@ def get_securedrop_directory() -> Dict:
4041
return directory_entry_map
4142

4243

43-
def write_custom_ruleset(onboarded_org: str, directory_entries: Dict) -> None:
44+
def write_custom_ruleset(onboarded_org: str, sd_rewrite_rule: str, directory_entries: Dict) -> None:
4445
directory_entry = directory_entries[onboarded_org]
4546

4647
ruleset = """<ruleset name="{org_name}">\n\t<target host="{securedrop_redirect_url}" />\n\t<rule from="^http[s]?://{securedrop_redirect_url}"
4748
to="{onion_addr_with_protocol}" />\n</ruleset>\n""".format(
4849
org_name=directory_entry["title"],
49-
securedrop_redirect_url=directory_entry["securedrop_redirect_url"],
50+
securedrop_redirect_url=sd_rewrite_rule,
5051
onion_addr_with_protocol=directory_entry["onion_addr_with_protocol"],
5152
securedrop_tld=SECUREDROP_ONION_PSEUDO_TLD,
5253
)
@@ -64,9 +65,11 @@ def write_custom_ruleset(onboarded_org: str, directory_entries: Dict) -> None:
6465
# do so on an opt-in basis. The following text file contains the homepages
6566
# of the organizations that have opted in.
6667
with open('onboarded.txt', 'r') as f:
67-
onboarded_orgs = f.readlines()
68-
directory_entries = get_securedrop_directory()
69-
for org in onboarded_orgs:
70-
write_custom_ruleset(org.strip(), directory_entries)
68+
reader = csv.DictReader(f)
69+
directory_entries = get_securedrop_directory()
70+
for row in reader:
71+
#write_custom_ruleset(org.strip(), directory_entries)
72+
write_custom_ruleset(row["primary_domain"], row["sd_rewrite_rule"], directory_entries)
73+
7174

7275
print("✔️ Custom rulesets written to directory: ./{}".format(RULESET_DIR))

0 commit comments

Comments
 (0)