Commit 0d22adce5c

0d22adce5c40ba502bef8393dc351de3500f1be6

parent: 65af207a92

Unsigned

Alicia Sykes <alicia@omg.lol> · 2026-10-10 16:20 UTC

Adds check that security policy OR vulnerability reporting present

Layout: unified · split

.github/CONTRIBUTING.md +1
@@ -304,6 +304,7 @@ Below is the full list of checks - it's basically the same as what is listed in
304304 - 🟡 **Has license** - Repo should include a license
305305 - 🟡 **Not archived** - Repo must not be archived
306306 - 🟡 **No security alerts** - No open critical/high Dependabot alerts
307 - 🟡 **Security policy** - Repo should have a security policy (SECURITY.md) and/or private vulnerability reporting enabled
307308 - 🟡 **Minimum stars** - Repo should have ≥100 stars
308309 - 🟡 **Bus factor** - Flags if ≥96% of commits come from a single contributor (bots and AI excluded)
309310 - 🟡 **Spam detection** - Flags if the author opened ≥3 PRs to other awesome-* repos, or PRs across ≥7 distinct repos, in the last 2 days
lib/checks/check-project.py +16
@@ -100,6 +100,10 @@ REPO_404_MSG = (
100100BUS_FACTOR_MSG = (
101101 "This repository has a low bus factor, as maintained by a single contributor"
102102)
103SECURITY_POLICY_MSG = (
104 "This repository has neither a security policy nor private"
105 " vulnerability reporting enabled, so there's no clear way to report security issues"
106)
103107
104108
105109def load_diff(path):
@@ -214,6 +218,13 @@ def check_bus_factor(owner, repo, token):
214218 return None
215219
216220
221def check_security_policy(owner, repo, token):
222 """Return SECURITY_POLICY_MSG if the repo has no security policy or private reporting."""
223 if utils.has_security_contact(owner, repo, token, session=SESSION, timeout=TIMEOUT) is False:
224 return SECURITY_POLICY_MSG
225 return None
226
227
217228def check_spam_prs(pr_user, token):
218229 """Return list of spam findings based on recent PR activity."""
219230 if not pr_user:
@@ -393,6 +404,11 @@ def check_repo_signals(diff, pr_user, token, pr_body=""):
393404 if finding:
394405 findings.append(finding)
395406
407 if SECURITY_POLICY_MSG not in findings:
408 finding = check_security_policy(owner, repo, token)
409 if finding:
410 findings.append(finding)
411
396412 return findings
397413
398414
lib/utils/__init__.py +2
@@ -28,6 +28,7 @@ try:
2828 commit_has_bot,
2929 fetch_repo,
3030 gh_get,
31 has_security_contact,
3132 parse_github_field,
3233 repo_age_days,
3334 repo_has_license,
@@ -58,6 +59,7 @@ __all__ = [
5859 "fetch_repo",
5960 "fetch_security_report",
6061 "gh_get",
62 "has_security_contact",
6163 "ios_app_id",
6264 "ios_days_since_update",
6365 "ios_rating",
lib/utils/github.py +42
@@ -67,6 +67,26 @@ def gh_get(path, token, session=None, params=None, timeout=DEFAULT_TIMEOUT, labe
6767 return None
6868
6969
70def _gh_graphql(query, variables, token, session=None, timeout=DEFAULT_TIMEOUT, label=""):
71 """POST a GitHub GraphQL query. Returns the `data` dict, else None (needs a token)"""
72 if not token:
73 return None
74 session = session or make_session()
75 try:
76 resp = session.post(
77 "https://api.github.com/graphql",
78 headers={"Authorization": f"bearer {token}"},
79 json={"query": query, "variables": variables}, timeout=timeout
80 )
81 body = resp.json() if resp.status_code == 200 else {}
82 if isinstance(body.get("data"), dict) and not body.get("errors"):
83 return body["data"]
84 logging.warning("[%s] GraphQL HTTP %d: %s", label, resp.status_code, body.get("errors"))
85 except Exception as exc:
86 logging.warning("[%s] GraphQL request error: %s", label, exc)
87 return None
88
89
7090def fetch_repo(owner, repo, token, session=None):
7191 """Fetch GitHub repo metadata, returning None on any error."""
7292 return gh_get(f"/repos/{owner}/{repo}", token, session=session, label="repos")
@@ -126,6 +146,28 @@ def top_contributor_share(owner, repo, token, session=None, timeout=DEFAULT_TIME
126146 return None
127147
128148
149_SECURITY_POLICY_QUERY = (
150 "query($owner: String!, $name: String!) {"
151 " repository(owner: $owner, name: $name) { isSecurityPolicyEnabled } }"
152)
153
154
155def has_security_contact(owner, repo, token, session=None, timeout=DEFAULT_TIMEOUT):
156 """True if a repo has private vulnerability reporting or a security policy"""
157 pvr = gh_get(f"/repos/{owner}/{repo}/private-vulnerability-reporting", token,
158 session=session, timeout=timeout, label="pvr")
159 pvr = pvr.get("enabled") if isinstance(pvr, dict) else None
160 if pvr is True:
161 return True
162 data = _gh_graphql(_SECURITY_POLICY_QUERY, {"owner": owner, "name": repo}, token,
163 session=session, timeout=timeout, label="security-policy")
164 repo_data = data.get("repository") if data else None
165 policy = repo_data.get("isSecurityPolicyEnabled") if isinstance(repo_data, dict) else None
166 if policy is True:
167 return True
168 return False if pvr is False and policy is False else None
169
170
129171def _days_since(iso_str):
130172 if not iso_str:
131173 return None