Commit 65af207a92
Unsigned
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 | - 🟡 **Not archived** - Repo must not be archived | 305 | - 🟡 **Not archived** - Repo must not be archived |
| 306 | - 🟡 **No security alerts** - No open critical/high Dependabot alerts | 306 | - 🟡 **No security alerts** - No open critical/high Dependabot alerts |
| 307 | - 🟡 **Minimum stars** - Repo should have ≥100 stars | 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 | - 🟡 **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 | - 🟡 **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 | - **Addition Info** (fyi only, no pass/fail requirements or warnings) | 310 | - **Addition Info** (fyi only, no pass/fail requirements or warnings) |
| 310 | - 🔵 **Website check** (if has `url`) - Quickly checks for basic security requirements for website | 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 | INACTIVE_DAYS = 90 | 28 | INACTIVE_DAYS = 90 |
| 29 | MIN_AGE_DAYS = 120 | 29 | MIN_AGE_DAYS = 120 |
| 30 | AI_COMMIT_RATIO = 0.8 | 30 | AI_COMMIT_RATIO = 0.8 |
| 31 | BUS_FACTOR_RATIO = 0.96 | ||
| 31 | SPAM_AWESOME_THRESHOLD = 3 | 32 | SPAM_AWESOME_THRESHOLD = 3 |
| 32 | SPAM_DISTINCT_REPO_THRESHOLD = 7 | 33 | SPAM_DISTINCT_REPO_THRESHOLD = 7 |
| 33 | SPAM_WINDOW_DAYS = 2 | 34 | SPAM_WINDOW_DAYS = 2 |
| @@ -96,6 +97,9 @@ REPO_404_MSG = ( | |||
| 96 | "The GitHub repository linked in this submission returns a 404." | 97 | "The GitHub repository linked in this submission returns a 404." |
| 97 | " Please ensure the repo exists and is publicly accessible" | 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 | def load_diff(path): | 105 | def load_diff(path): |
| @@ -202,6 +206,14 @@ def check_security_alerts(owner, repo, token): | |||
| 202 | return None | 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 | def check_spam_prs(pr_user, token): | 217 | def check_spam_prs(pr_user, token): |
| 206 | """Return list of spam findings based on recent PR activity.""" | 218 | """Return list of spam findings based on recent PR activity.""" |
| 207 | if not pr_user: | 219 | if not pr_user: |
| @@ -376,6 +388,11 @@ def check_repo_signals(diff, pr_user, token, pr_body=""): | |||
| 376 | if finding: | 388 | if finding: |
| 377 | findings.append(finding) | 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 | return findings | 396 | return findings |
| 380 | 397 | ||
| 381 | 398 | ||
lib/review-listings.py +15
| @@ -18,6 +18,7 @@ Checks: | |||
| 18 | - github-activity: github repo was pushed recently (needs token) | 18 | - github-activity: github repo was pushed recently (needs token) |
| 19 | - github-license: github repo has a license (needs token) | 19 | - github-license: github repo has a license (needs token) |
| 20 | - github-fork: github repo is not a fork (needs token) | 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 | - security-advisories: no open unpatched CVEs (needs API_TOKEN) | 22 | - security-advisories: no open unpatched CVEs (needs API_TOKEN) |
| 22 | - android-trackers: android app has few trackers (1 info, 2+ warn) (needs API_TOKEN) | 23 | - android-trackers: android app has few trackers (1 info, 2+ warn) (needs API_TOKEN) |
| 23 | - ios-app: iOS app exists, is maintained and rated (missing/stale/low-rating warn) (needs API_TOKEN) | 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 | MIN_DESC = 50 | 74 | MIN_DESC = 50 |
| 74 | MAX_DESC = 280 | 75 | MAX_DESC = 280 |
| 75 | MAX_DESC_HARD = 420 | 76 | MAX_DESC_HARD = 420 |
| 77 | BUS_FACTOR_RATIO = 0.98 | ||
| 76 | DEFAULT_WORKERS = 8 | 78 | DEFAULT_WORKERS = 8 |
| 77 | DEFAULT_TIMEOUT = 10 | 79 | DEFAULT_TIMEOUT = 10 |
| 78 | 80 | ||
| @@ -421,6 +423,19 @@ def _github_license(entry: Entry, ctx: Context) -> Iterable[Finding]: | |||
| 421 | yield _finding(entry, "github-license", "warn", "repository has no declared license") | 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 | @check("security-advisories", needs_api=True) | 439 | @check("security-advisories", needs_api=True) |
| 425 | def _security_advisories(entry: Entry, ctx: Context) -> Iterable[Finding]: | 440 | def _security_advisories(entry: Entry, ctx: Context) -> Iterable[Finding]: |
| 426 | """No open unpatched CVEs (low/medium warn, high/critical error).""" | 441 | """No open unpatched CVEs (low/medium warn, high/critical error).""" |
lib/utils/__init__.py +2
| @@ -35,6 +35,7 @@ try: | |||
| 35 | repo_is_fork, | 35 | repo_is_fork, |
| 36 | repo_pushed_days_ago, | 36 | repo_pushed_days_ago, |
| 37 | repo_status, | 37 | repo_status, |
| 38 | top_contributor_share, | ||
| 38 | ) | 39 | ) |
| 39 | from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session | 40 | from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session |
| 40 | except ImportError as exc: | 41 | except ImportError as exc: |
| @@ -74,6 +75,7 @@ __all__ = [ | |||
| 74 | "repo_status", | 75 | "repo_status", |
| 75 | "setup_logging", | 76 | "setup_logging", |
| 76 | "slugify", | 77 | "slugify", |
| 78 | "top_contributor_share", | ||
| 77 | "tracker_count", | 79 | "tracker_count", |
| 78 | "unpatched_advisories", | 80 | "unpatched_advisories", |
| 79 | ] | 81 | ] |
lib/utils/github.py +27
| @@ -1,12 +1,14 @@ | |||
| 1 | """GitHub API helpers and read-only accessors for repo metadata.""" | 1 | """GitHub API helpers and read-only accessors for repo metadata.""" |
| 2 | 2 | ||
| 3 | import logging | 3 | import logging |
| 4 | import re | ||
| 4 | from datetime import datetime, timezone | 5 | from datetime import datetime, timezone |
| 5 | 6 | ||
| 6 | import requests | 7 | import requests |
| 7 | 8 | ||
| 8 | from .http import DEFAULT_TIMEOUT, make_session | 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 | AI_BOT_AUTHORS = [ | 12 | AI_BOT_AUTHORS = [ |
| 11 | "noreply@anthropic.com", | 13 | "noreply@anthropic.com", |
| 12 | "devin-ai-integration[bot]", | 14 | "devin-ai-integration[bot]", |
| @@ -14,6 +16,9 @@ AI_BOT_AUTHORS = [ | |||
| 14 | "noreply@cursor.com", | 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 | def parse_github_field(value): | 23 | def parse_github_field(value): |
| 19 | """Parse a `github` field into (owner, repo), or (None, None) on failure.""" | 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 | return False | 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 | def _days_since(iso_str): | 129 | def _days_since(iso_str): |
| 103 | if not iso_str: | 130 | if not iso_str: |
| 104 | return None | 131 | return None |