Commit 65af207a92
65af207a928d0958b1a40065c6cdc74c7c86d786
parent: 97d3c9d804
Unsigned
Alicia Sykes <alicia@omg.lol> · 2026-10-10 15:55 UTC
Adds bus factor check in CI
Layout: unified · split
.github/CONTRIBUTING.md
+1
| @@ -305,6 +305,7 @@ Below is the full list of checks - it's basically the same as what is listed in |
| 305 | 305 | - 🟡 **Not archived** - Repo must not be archived |
| 306 | 306 | - 🟡 **No security alerts** - No open critical/high Dependabot alerts |
| 307 | 307 | - 🟡 **Minimum stars** - Repo should have ≥100 stars |
| 308 | - 🟡 **Bus factor** - Flags if ≥96% of commits come from a single contributor (bots and AI excluded) |
| 308 | 309 | - 🟡 **Spam detection** - Flags if the author opened ≥3 PRs to other awesome-* repos, or PRs across ≥7 distinct repos, in the last 2 days |
| 309 | 310 | - **Addition Info** (fyi only, no pass/fail requirements or warnings) |
| 310 | 311 | - 🔵 **Website check** (if has `url`) - Quickly checks for basic security requirements for website |
lib/checks/check-project.py
+17
| @@ -28,6 +28,7 @@ MIN_STARS = 100 |
| 28 | 28 | INACTIVE_DAYS = 90 |
| 29 | 29 | MIN_AGE_DAYS = 120 |
| 30 | 30 | AI_COMMIT_RATIO = 0.8 |
| 31 | BUS_FACTOR_RATIO = 0.96 |
| 31 | 32 | SPAM_AWESOME_THRESHOLD = 3 |
| 32 | 33 | SPAM_DISTINCT_REPO_THRESHOLD = 7 |
| 33 | 34 | SPAM_WINDOW_DAYS = 2 |
| @@ -96,6 +97,9 @@ REPO_404_MSG = ( |
| 96 | 97 | "The GitHub repository linked in this submission returns a 404." |
| 97 | 98 | " Please ensure the repo exists and is publicly accessible" |
| 98 | 99 | ) |
| 100 | BUS_FACTOR_MSG = ( |
| 101 | "This repository has a low bus factor, as maintained by a single contributor" |
| 102 | ) |
| 99 | 103 | |
| 100 | 104 | |
| 101 | 105 | def load_diff(path): |
| @@ -202,6 +206,14 @@ def check_security_alerts(owner, repo, token): |
| 202 | 206 | return None |
| 203 | 207 | |
| 204 | 208 | |
| 209 | def check_bus_factor(owner, repo, token): |
| 210 | """Return BUS_FACTOR_MSG if a single human contributor made nearly all commits.""" |
| 211 | share = utils.top_contributor_share(owner, repo, token, session=SESSION, timeout=TIMEOUT) |
| 212 | if share is not None and share >= BUS_FACTOR_RATIO: |
| 213 | return BUS_FACTOR_MSG |
| 214 | return None |
| 215 | |
| 216 | |
| 205 | 217 | def check_spam_prs(pr_user, token): |
| 206 | 218 | """Return list of spam findings based on recent PR activity.""" |
| 207 | 219 | if not pr_user: |
| @@ -376,6 +388,11 @@ def check_repo_signals(diff, pr_user, token, pr_body=""): |
| 376 | 388 | if finding: |
| 377 | 389 | findings.append(finding) |
| 378 | 390 | |
| 391 | if BUS_FACTOR_MSG not in findings: |
| 392 | finding = check_bus_factor(owner, repo, token) |
| 393 | if finding: |
| 394 | findings.append(finding) |
| 395 | |
| 379 | 396 | return findings |
| 380 | 397 | |
| 381 | 398 | |
lib/review-listings.py
+15
| @@ -18,6 +18,7 @@ Checks: |
| 18 | 18 | - github-activity: github repo was pushed recently (needs token) |
| 19 | 19 | - github-license: github repo has a license (needs token) |
| 20 | 20 | - github-fork: github repo is not a fork (needs token) |
| 21 | - github-bus-factor: no single human made 98%+ of commits, bots and AI ignored (needs token) |
| 21 | 22 | - security-advisories: no open unpatched CVEs (needs API_TOKEN) |
| 22 | 23 | - android-trackers: android app has few trackers (1 info, 2+ warn) (needs API_TOKEN) |
| 23 | 24 | - ios-app: iOS app exists, is maintained and rated (missing/stale/low-rating warn) (needs API_TOKEN) |
| @@ -73,6 +74,7 @@ except ImportError as exc: |
| 73 | 74 | MIN_DESC = 50 |
| 74 | 75 | MAX_DESC = 280 |
| 75 | 76 | MAX_DESC_HARD = 420 |
| 77 | BUS_FACTOR_RATIO = 0.98 |
| 76 | 78 | DEFAULT_WORKERS = 8 |
| 77 | 79 | DEFAULT_TIMEOUT = 10 |
| 78 | 80 | |
| @@ -421,6 +423,19 @@ def _github_license(entry: Entry, ctx: Context) -> Iterable[Finding]: |
| 421 | 423 | yield _finding(entry, "github-license", "warn", "repository has no declared license") |
| 422 | 424 | |
| 423 | 425 | |
| 426 | @check("github-bus-factor", needs_github=True) |
| 427 | def _github_bus_factor(entry: Entry, ctx: Context) -> Iterable[Finding]: |
| 428 | """No single human made 98%+ of commits (bots and AI agents ignored).""" |
| 429 | owner, repo = utils.parse_github_field(entry.service.get("github")) |
| 430 | if not owner: |
| 431 | return |
| 432 | share = utils.top_contributor_share(owner, repo, ctx.token, |
| 433 | session=ctx.session, timeout=ctx.timeout) |
| 434 | if share is not None and share >= BUS_FACTOR_RATIO: |
| 435 | yield _finding(entry, "github-bus-factor", "warn", |
| 436 | f"low bus factor, {share:.0%} of commits are by a single contributor") |
| 437 | |
| 438 | |
| 424 | 439 | @check("security-advisories", needs_api=True) |
| 425 | 440 | def _security_advisories(entry: Entry, ctx: Context) -> Iterable[Finding]: |
| 426 | 441 | """No open unpatched CVEs (low/medium warn, high/critical error).""" |
lib/utils/__init__.py
+2
| @@ -35,6 +35,7 @@ try: |
| 35 | 35 | repo_is_fork, |
| 36 | 36 | repo_pushed_days_ago, |
| 37 | 37 | repo_status, |
| 38 | top_contributor_share, |
| 38 | 39 | ) |
| 39 | 40 | from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session |
| 40 | 41 | except ImportError as exc: |
| @@ -74,6 +75,7 @@ __all__ = [ |
| 74 | 75 | "repo_status", |
| 75 | 76 | "setup_logging", |
| 76 | 77 | "slugify", |
| 78 | "top_contributor_share", |
| 77 | 79 | "tracker_count", |
| 78 | 80 | "unpatched_advisories", |
| 79 | 81 | ] |
lib/utils/github.py
+27
| @@ -1,12 +1,14 @@ |
| 1 | 1 | """GitHub API helpers and read-only accessors for repo metadata.""" |
| 2 | 2 | |
| 3 | 3 | import logging |
| 4 | import re |
| 4 | 5 | from datetime import datetime, timezone |
| 5 | 6 | |
| 6 | 7 | import requests |
| 7 | 8 | |
| 8 | 9 | from .http import DEFAULT_TIMEOUT, make_session |
| 9 | 10 | |
| 11 | # List of dirty AI users, we don't count them as real people because they have no soul |
| 10 | 12 | AI_BOT_AUTHORS = [ |
| 11 | 13 | "noreply@anthropic.com", |
| 12 | 14 | "devin-ai-integration[bot]", |
| @@ -14,6 +16,9 @@ AI_BOT_AUTHORS = [ |
| 14 | 16 | "noreply@cursor.com", |
| 15 | 17 | ] |
| 16 | 18 | |
| 19 | AI_CONTRIBUTOR_LOGINS = {"cursoragent", "openhands-agent"} |
| 20 | _BOT_LOGIN_RE = re.compile(r"[-_]bot$|\[bot\]$") |
| 21 | |
| 17 | 22 | |
| 18 | 23 | def parse_github_field(value): |
| 19 | 24 | """Parse a `github` field into (owner, repo), or (None, None) on failure.""" |
| @@ -99,6 +104,28 @@ def commit_has_bot(commit, bot_set): |
| 99 | 104 | return False |
| 100 | 105 | |
| 101 | 106 | |
| 107 | def _is_human_contributor(contributor): |
| 108 | """Return True unless a contributor is a bot, automation account or AI agent.""" |
| 109 | login = (contributor.get("login") or "").lower() |
| 110 | return (contributor.get("type") == "User" |
| 111 | and login not in AI_CONTRIBUTOR_LOGINS |
| 112 | and not _BOT_LOGIN_RE.search(login)) |
| 113 | |
| 114 | |
| 115 | def top_contributor_share(owner, repo, token, session=None, timeout=DEFAULT_TIMEOUT): |
| 116 | """Share of commits (0 to 1) by the top human contributor, ignoring bots and AI""" |
| 117 | contributors = gh_get(f"/repos/{owner}/{repo}/contributors", token, session=session, |
| 118 | params={"per_page": 100}, timeout=timeout, label="contributors") |
| 119 | if not isinstance(contributors, list) or len(contributors) >= 100: |
| 120 | return None |
| 121 | try: |
| 122 | counts = [c["contributions"] for c in contributors if _is_human_contributor(c)] |
| 123 | return max(counts) / sum(counts) if counts else None |
| 124 | except Exception as exc: |
| 125 | logging.warning("[contributors] unexpected data for %s/%s: %s", owner, repo, exc) |
| 126 | return None |
| 127 | |
| 128 | |
| 102 | 129 | def _days_since(iso_str): |
| 103 | 130 | if not iso_str: |
| 104 | 131 | return None |