| @@ -35,6 +35,7 @@ SPAM_WINDOW_DAYS = 2 |
| 35 | NEW_ACCOUNT_DAYS = 14 |
35 | NEW_ACCOUNT_DAYS = 14 |
| 36 | |
36 | |
| 37 | SESSION = utils.make_session(user_agent=USER_AGENT) |
37 | SESSION = utils.make_session(user_agent=USER_AGENT) |
| |
38 | API_TOKEN = os.environ.get("API_TOKEN", "") |
| 38 | |
39 | |
| 39 | LINK_MSG = ( |
40 | LINK_MSG = ( |
| 40 | "The link(s) you included seem to be returning a 404." |
41 | "The link(s) you included seem to be returning a 404." |
| @@ -74,8 +75,8 @@ ARCHIVED_MSG = ( |
| 74 | " Additions must be actively maintained" |
75 | " Additions must be actively maintained" |
| 75 | ) |
76 | ) |
| 76 | SECURITY_MSG = ( |
77 | SECURITY_MSG = ( |
| 77 | "This project has open security vulnerabilities (critical or high severity)" |
78 | "This project has published security advisories (critical or high severity)" |
| 78 | " flagged by GitHub Dependabot. Please verify these have been addressed" |
79 | " with no patched version listed. Please verify these have been addressed" |
| 79 | ) |
80 | ) |
| 80 | SPAM_AWESOME_MSG = ( |
81 | SPAM_AWESOME_MSG = ( |
| 81 | "You have made many similar submissions on other awesome-* repos today." |
82 | "You have made many similar submissions on other awesome-* repos today." |
| @@ -200,13 +201,15 @@ def check_ai_commits(owner, repo, token): |
| 200 | return None |
201 | return None |
| 201 | |
202 | |
| 202 | |
203 | |
| 203 | def check_security_alerts(owner, repo, token): |
204 | def check_security_alerts(owner, repo): |
| 204 | """Return SECURITY_MSG if the repo has open critical/high Dependabot alerts.""" |
205 | """Return SECURITY_MSG if the repo has unpatched critical/high security advisories.""" |
| 205 | alerts = _gh_get(f"/repos/{owner}/{repo}/dependabot/alerts", token, |
206 | try: |
| 206 | params={"state": "open", "severity": "critical,high", "per_page": 1}, |
207 | report = utils.fetch_security_report(owner, repo, API_TOKEN, session=SESSION, |
| 207 | label="dependabot") |
208 | timeout=TIMEOUT, label=f"{owner}/{repo}") |
| 208 | if alerts: |
209 | if utils.unpatched_advisories(report)[1]: |
| 209 | return SECURITY_MSG |
210 | return SECURITY_MSG |
| |
211 | except Exception as exc: |
| |
212 | logger.warning("check_security_alerts error for %s/%s: %s", owner, repo, exc) |
| 210 | return None |
213 | return None |
| 211 | |
214 | |
| 212 | |
215 | |
| @@ -395,7 +398,7 @@ def check_repo_signals(diff, pr_user, token, pr_body=""): |
| 395 | findings.append(finding) |
398 | findings.append(finding) |
| 396 | |
399 | |
| 397 | if SECURITY_MSG not in findings: |
400 | if SECURITY_MSG not in findings: |
| 398 | finding = check_security_alerts(owner, repo, token) |
401 | finding = check_security_alerts(owner, repo) |
| 399 | if finding: |
402 | if finding: |
| 400 | findings.append(finding) |
403 | findings.append(finding) |
| 401 | |
404 | |