Commit 965d8c5826

965d8c5826e2e875e57a638aa5f3f6635308ec73

parent: eaaccbbdd7

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-05-17 09:05 UTC

Run listing review weekly

Layout: unified · split

.github/workflows/health-check.yml +2
@@ -12,6 +12,8 @@ on:
1212 service:
1313 description: Just run for a specific entry (optional)
1414 type: string
15 schedule:
16 - cron: '0 17 * * 5' # Weekly drift check. 5PM on a Friday, in time for weekend updates
1517
1618permissions:
1719 contents: read
lib/awesome-privacy-readme-gen.py +31 −29
@@ -20,11 +20,6 @@ app_list_file_path = os.path.join(project_root, 'awesome-privacy.yml')
2020readme_path = os.path.join(project_root, '.github/README.md')
2121icon_size=14
2222
23# Read the main YAML file, where all data lives
24logger.info("Reading the awesome-privacy file...")
25with open(app_list_file_path, 'r') as file:
26 data = yaml.safe_load(file)
27
2823def iconElement(serviceUrl, serviceIcon):
2924 path = serviceIcon or f"https://icon.horse/icon/{urlparse(serviceUrl).netloc}"
3025 return f"<img src='{path}' width='{icon_size}' alt='' />"
@@ -73,7 +68,7 @@ def makeHref(text):
7368 if not text: return "#"
7469 return re.sub(r'[^\w\s-]', '', text.lower()).replace(" ", "-")
7570
76def makeContents():
71def makeContents(data):
7772 contents = "<blockquote><details open>\n"
7873 contents += "<summary>📋 <b>Contents</b></summary>\n"
7974
@@ -88,7 +83,7 @@ def makeContents():
8883 contents += "\n</details></blockquote>\n\n"
8984 return contents
9085
91def makeAwesomePrivacy():
86def makeAwesomePrivacy(data):
9287 markdown = ""
9388 for category in data.get('categories'):
9489 markdown += f"## {category.get('name')}\n\n"
@@ -145,13 +140,6 @@ def makeAwesomePrivacy():
145140 markdown += "\n---\n\n"
146141 return markdown
147142
148awesome_privacy_results = makeContents() + makeAwesomePrivacy()
149
150# Update the README.md between markers
151logger.info("Reading README.md file...")
152with open(readme_path, 'r') as file:
153 readme_content = file.read()
154
155143def update_content_between_markers(content, start_marker, end_marker, new_content):
156144 logger.info(f"Updating content between {start_marker} and {end_marker} markers...")
157145 start_index = content.find(start_marker)
@@ -166,18 +154,32 @@ def update_content_between_markers(content, start_marker, end_marker, new_conten
166154 logger.error(f"Markers {start_marker} and {end_marker} not found.")
167155 return content
168156
169# Update guides and resources in README.md
170readme_content = update_content_between_markers(
171 readme_content,
172 "<!-- awesome-privacy-start -->",
173 "<!-- awesome-privacy-end -->",
174 awesome_privacy_results
175)
176
177# Write back the updated content to README.md
178logger.info("Writing back to README.md...")
179with open(readme_path, 'w') as file:
180 file.write(readme_content)
181
182# All done. Time to go home for tea and medals.
183logger.info("Script completed successfully!")
157
158def main():
159 logger.info("Reading the awesome-privacy file...")
160 with open(app_list_file_path, 'r') as file:
161 data = yaml.safe_load(file)
162
163 awesome_privacy_results = makeContents(data) + makeAwesomePrivacy(data)
164
165 logger.info("Reading README.md file...")
166 with open(readme_path, 'r') as file:
167 readme_content = file.read()
168
169 readme_content = update_content_between_markers(
170 readme_content,
171 "<!-- awesome-privacy-start -->",
172 "<!-- awesome-privacy-end -->",
173 awesome_privacy_results,
174 )
175
176 logger.info("Writing back to README.md...")
177 with open(readme_path, 'w') as file:
178 file.write(readme_content)
179
180 # All done. Time to go home for tea and medals.
181 logger.info("Script completed successfully!")
182
183
184if __name__ == "__main__":
185 main()
lib/checks/make-info-stats.py +14 −67
@@ -25,23 +25,20 @@ import sys
2525from datetime import datetime, timezone
2626from urllib.parse import urlparse
2727
28import requests
28sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
29import utils
2930
3031DIFF_PATH = "/tmp/pr-diff.json"
3132OUTPUT_PATH = "/tmp/repo-stats.md"
3233TIMEOUT = 10
3334MAX_SUBMISSIONS = 5
3435USER_AGENT = "awesome-privacy-ci/1.0"
35AI_BOT_AUTHORS = [
36 "noreply@anthropic.com",
37 "devin-ai-integration[bot]",
38 "copilot-swe-agent.github.com",
39 "noreply@cursor.com",
40]
4136RESTRICTIVE_LICENSES = {
4237 "AGPL-3.0-only", "AGPL-3.0-or-later", "SSPL-1.0", "BSL-1.0", "BUSL-1.1",
4338}
4439
40SESSION = utils.make_session(user_agent=USER_AGENT)
41
4542SITE_INFO_URL = "https://site-info-fetch.as93.workers.dev"
4643ANDROID_API_URL = "https://android-app-privacy.as93.net"
4744IOS_API_URL = "https://ios-app-info.as93.net"
@@ -52,11 +49,8 @@ GREEN, ORANGE, RED, BLUE, WHITE = "\U0001f7e2", "\U0001f7e0", "\U0001f534", "\U0
5249
5350def _api_get(url, params=None, timeout=TIMEOUT, headers=None):
5451 """GET a URL, return parsed JSON on 200, else None."""
55 hdrs = {"User-Agent": USER_AGENT}
56 if headers:
57 hdrs.update(headers)
5852 try:
59 resp = requests.get(url, headers=hdrs, timeout=timeout, params=params)
53 resp = SESSION.get(url, headers=headers, timeout=timeout, params=params)
6054 if resp.status_code == 200:
6155 return resp.json()
6256 except Exception as e:
@@ -88,17 +82,6 @@ def relative_time(iso_str):
8882 return None
8983
9084
91def _days_since(iso_str):
92 """Return number of days since an ISO timestamp, or None."""
93 if not iso_str:
94 return None
95 try:
96 dt = datetime.fromisoformat(iso_str.replace("Z", "+00:00"))
97 return (datetime.now(timezone.utc) - dt).days
98 except Exception:
99 return None
100
101
10285def _friendly_date(iso_str):
10386 """Return relative time string with 'ago' suffix, falling back to raw string."""
10487 if not iso_str:
@@ -131,28 +114,9 @@ def format_markdown(stats):
131114 return "\n".join(f"- {emoji} **{label}:** {value}" for emoji, label, value in stats)
132115
133116
134def parse_github_field(value):
135 """Parse 'owner/repo' or full URL into (owner, repo) or (None, None)."""
136 if not value:
137 return None, None
138 if value.startswith("https://github.com/"):
139 parts = value.removeprefix("https://github.com/").strip("/").split("/")
140 if len(parts) >= 2:
141 return parts[0], parts[1]
142 return None, None
143 if "/" in value:
144 parts = value.split("/")
145 if len(parts) == 2:
146 return parts[0], parts[1]
147 return None, None
148
149
150117def gh_get(path, token, params=None):
151118 """GET a GitHub API endpoint. Returns JSON on 200, else None."""
152 headers = {"Accept": "application/vnd.github.v3+json"}
153 if token:
154 headers["Authorization"] = f"token {token}"
155 return _api_get(f"https://api.github.com{path}", params=params, headers=headers)
119 return utils.gh_get(path, token, session=SESSION, params=params, timeout=TIMEOUT, label="repos")
156120
157121
158122def fetch_all_data(owner, repo, token):
@@ -183,23 +147,9 @@ def fetch_all_data(owner, repo, token):
183147
184148 commits = gh_get(f"/repos/{owner}/{repo}/commits", token, {"per_page": 100})
185149 if commits is not None:
186 bot_set = {a.lower() for a in AI_BOT_AUTHORS}
187 ai_count = 0
188 for c in commits:
189 author = c.get("commit", {}).get("author", {})
190 email = (author.get("email") or "").lower()
191 name = (author.get("name") or "").lower()
192 if email in bot_set or name in bot_set:
193 ai_count += 1
194 continue
195 message = (c.get("commit", {}).get("message") or "").lower()
196 for line in message.splitlines():
197 if line.strip().startswith("co-authored-by:"):
198 if any(bot in line for bot in bot_set):
199 ai_count += 1
200 break
150 bot_set = {a.lower() for a in utils.AI_BOT_AUTHORS}
201151 data["commit_count"] = len(commits)
202 data["ai_commit_count"] = ai_count
152 data["ai_commit_count"] = sum(1 for c in commits if utils.commit_has_bot(c, bot_set))
203153 else:
204154 data["commit_count"] = None
205155 data["ai_commit_count"] = None
@@ -232,7 +182,7 @@ def grade_stats(data):
232182 else:
233183 stats.append((GREEN, "License", lic.get("name") or spdx or "Present"))
234184
235 age_days = _days_since(data.get("created_at"))
185 age_days = utils.repo_age_days(data)
236186 age_str = relative_time(data.get("created_at"))
237187 if age_days is None:
238188 stats.append((WHITE, "Repo Age", "Unknown"))
@@ -243,7 +193,7 @@ def grade_stats(data):
243193 else:
244194 stats.append((RED, "Repo Age", age_str))
245195
246 updated_days = _days_since(data.get("pushed_at"))
196 updated_days = utils.repo_pushed_days_ago(data)
247197 updated_str = _friendly_date(data.get("pushed_at"))
248198 if updated_days is None:
249199 stats.append((WHITE, "Last Updated", "Unknown"))
@@ -343,16 +293,13 @@ def check_security_txt(url):
343293 base = f"{parsed.scheme}://{parsed.netloc}"
344294 for path in ("/.well-known/security.txt", "/security.txt"):
345295 try:
346 resp = requests.get(
347 base + path, headers={"User-Agent": USER_AGENT},
348 timeout=TIMEOUT, allow_redirects=True,
349 )
296 resp = SESSION.get(base + path, timeout=TIMEOUT, allow_redirects=True)
350297 if resp.status_code == 200 and "contact:" in resp.text.lower():
351298 return True
352299 except Exception:
353300 continue
354301 try:
355 requests.head(base, headers={"User-Agent": USER_AGENT}, timeout=TIMEOUT)
302 SESSION.head(base, timeout=TIMEOUT)
356303 return False
357304 except Exception:
358305 return None
@@ -545,7 +492,7 @@ def _resolve_args(argv):
545492 result = {"name": None, "owner": None, "repo": None, "url": args.url,
546493 "android": args.android, "ios": args.ios, "tosdr": args.tosdr}
547494 if args.repo:
548 owner, repo = parse_github_field(args.repo)
495 owner, repo = utils.parse_github_field(args.repo)
549496 if not owner:
550497 print(f"Invalid repo format: {args.repo}", file=sys.stderr)
551498 sys.exit(1)
@@ -570,7 +517,7 @@ def _resolve_args(argv):
570517 for yaml_key, result_key in field_map.items():
571518 if fields.get(yaml_key):
572519 if yaml_key == "github":
573 result["owner"], result["repo"] = parse_github_field(fields[yaml_key])
520 result["owner"], result["repo"] = utils.parse_github_field(fields[yaml_key])
574521 else:
575522 result[result_key] = str(fields[yaml_key])
576523 if any(v for k, v in result.items() if k != "name"):
lib/review-listings.py +19 −5
@@ -20,7 +20,13 @@ Checks:
2020- github-fork: github repo is not a fork (needs token)
2121
2222Findings have three severities: error (must fix), warn (should review), info (FYI).
23HTTP 403/429 on reachability checks is demoted from error to warn (bot-blocking).
23HTTP 403/406/429 (and 404 on known bot-blocking hosts such as play.google.com) on
24reachability checks is demoted from error to warn.
25
26Exit codes:
27 1 when pass rate drops below FAIL_PASS_RATE or errors exceed FAIL_MAX_ERRORS (5)
28 2 you didn't run the script right / something else fucked up
29 0 everything is amazing
2430
2531Flags:
2632- --save-json PATH: save a JSON report to this file
@@ -49,6 +55,7 @@ from datetime import datetime, timezone
4955from threading import Lock
5056from time import monotonic
5157from typing import Callable, Iterable
58from urllib.parse import urlparse
5259
5360sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
5461try:
@@ -73,9 +80,13 @@ ACTIVITY_BANDS = (
7380SEVERITIES = ("error", "warn", "info")
7481_SEV_COLOR = {"error": "red", "warn": "yellow", "info": "cyan"}
7582_SEV_EMOJI = {"error": "🔴", "warn": "🟠", "info": "🟡"}
76_SOFT_HTTP = {403, 429}
83_SOFT_HTTP = {403, 406, 429}
84_SOFT_404_HOSTS = {"play.google.com"}
7785_PKG_RE = re.compile(r"^[a-zA-Z][a-zA-Z0-9_]*(\.[a-zA-Z][a-zA-Z0-9_]*)+$")
7886
87FAIL_PASS_RATE = 95.0
88FAIL_MAX_ERRORS = 5
89
7990
8091@dataclass
8192class Entry:
@@ -150,8 +161,10 @@ def _get_repo(entry: Entry, ctx: Context):
150161
151162
152163def _unreachable(field, url, status, default_sev):
153 """Return (severity, message). 403/429 demote error to warn."""
154 sev = "warn" if default_sev == "error" and status in _SOFT_HTTP else default_sev
164 """Return (severity, message). Bot-blocking signatures demote error to warn."""
165 host = urlparse(url).netloc.lower()
166 soft = status in _SOFT_HTTP or (status == 404 and host in _SOFT_404_HOSTS)
167 sev = "warn" if default_sev == "error" and soft else default_sev
155168 detail = f"{url} returned HTTP {status}" if status else f"{url} could not be reached"
156169 return sev, f"{field} is unreachable, {detail}"
157170
@@ -701,7 +714,8 @@ def main():
701714 except OSError as exc:
702715 logging.warning("Could not write %s: %s", path, exc)
703716
704 sys.exit(1 if any(f.severity == "error" for f in findings) else 0)
717 fail = summary["pass_rate"] < FAIL_PASS_RATE or summary["errors"] > FAIL_MAX_ERRORS
718 sys.exit(1 if fail else 0)
705719
706720
707721if __name__ == "__main__":
lib/utils/data.py +4 −3
@@ -30,6 +30,7 @@ def slugify(title):
3030 """Match the slug format used by awesome-privacy.xyz and the README generator."""
3131 if not title:
3232 return ""
33 title = re.sub(r"[+&]", "and", title.lower())
34 title = re.sub(r"\s+", "-", title)
35 return re.sub(r"[^a-z0-9-]", "", title)
33 title = title.lower()
34 title = re.sub(r"\s", "-", title)
35 title = re.sub(r"[+&]", "and", title)
36 return title.replace("?", "")
lib/utils/http.py +19 −9
@@ -1,6 +1,7 @@
11"""HTTP session and URL reachability helpers."""
22
33import logging
4import time
45
56import requests
67
@@ -8,6 +9,7 @@ DEFAULT_TIMEOUT = 10
89DEFAULT_USER_AGENT = (
910 "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
1011)
12_RETRY_BACKOFF = 1.0 # in seconds. one retry attempt on transient failures
1113
1214
1315def make_session(user_agent=DEFAULT_USER_AGENT):
@@ -19,12 +21,20 @@ def make_session(user_agent=DEFAULT_USER_AGENT):
1921def check_url(url, session=None, timeout=DEFAULT_TIMEOUT):
2022 """Return (ok, status_code). ok=True for 2xx/3xx; returns (True, None) on transport error."""
2123 session = session or make_session()
22 try:
23 resp = session.head(url, timeout=timeout, allow_redirects=True)
24 if resp.status_code >= 400:
25 resp = session.get(url, timeout=timeout, allow_redirects=True, stream=True)
26 resp.close()
27 return resp.status_code < 400, resp.status_code
28 except requests.RequestException as exc:
29 logging.debug("URL check error for %s: %s", url, exc)
30 return True, None
24 for attempt in range(2):
25 try:
26 resp = session.head(url, timeout=timeout, allow_redirects=True)
27 if resp.status_code >= 400:
28 resp = session.get(url, timeout=timeout, allow_redirects=True, stream=True)
29 resp.close()
30 status = resp.status_code
31 if 500 <= status < 600 and attempt == 0:
32 time.sleep(_RETRY_BACKOFF)
33 continue
34 return status < 400, status
35 except requests.RequestException as exc:
36 logging.debug("URL check error for %s (attempt %d): %s", url, attempt + 1, exc)
37 if attempt == 0:
38 time.sleep(_RETRY_BACKOFF)
39 continue
40 return True, None