Commit 63bdb10b41
Unsigned
Layout: unified · split
.github/workflows/pr-check.yml +18 −18
| @@ -18,9 +18,9 @@ jobs: | |||
| 18 | name: PR Compliance | 18 | name: PR Compliance |
| 19 | runs-on: ubuntu-latest | 19 | runs-on: ubuntu-latest |
| 20 | steps: | 20 | steps: |
| 21 | - uses: actions/checkout@v4 | 21 | - uses: actions/checkout@v5 |
| 22 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | 22 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} |
| 23 | - uses: actions/setup-python@v5 | 23 | - uses: actions/setup-python@v6 |
| 24 | with: | 24 | with: |
| 25 | python-version: "3.12" | 25 | python-version: "3.12" |
| 26 | - name: Check README edits | 26 | - name: Check README edits |
| @@ -38,7 +38,7 @@ jobs: | |||
| 38 | run: python lib/checks/check-pr-meta.py | 38 | run: python lib/checks/check-pr-meta.py |
| 39 | - name: Upload findings | 39 | - name: Upload findings |
| 40 | if: always() | 40 | if: always() |
| 41 | uses: actions/upload-artifact@v4 | 41 | uses: actions/upload-artifact@v5 |
| 42 | with: | 42 | with: |
| 43 | name: findings-compliance | 43 | name: findings-compliance |
| 44 | path: /tmp/findings-compliance.json | 44 | path: /tmp/findings-compliance.json |
| @@ -53,9 +53,9 @@ jobs: | |||
| 53 | outputs: | 53 | outputs: |
| 54 | yaml_changed: ${{ steps.changes.outputs.yaml_changed }} | 54 | yaml_changed: ${{ steps.changes.outputs.yaml_changed }} |
| 55 | steps: | 55 | steps: |
| 56 | - uses: actions/checkout@v4 | 56 | - uses: actions/checkout@v5 |
| 57 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} | 57 | - run: git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} |
| 58 | - uses: actions/setup-python@v5 | 58 | - uses: actions/setup-python@v6 |
| 59 | with: | 59 | with: |
| 60 | python-version: "3.12" | 60 | python-version: "3.12" |
| 61 | - name: Detect changes | 61 | - name: Detect changes |
| @@ -83,7 +83,7 @@ jobs: | |||
| 83 | run: python lib/checks/check-additions.py | 83 | run: python lib/checks/check-additions.py |
| 84 | - name: Upload diff data | 84 | - name: Upload diff data |
| 85 | if: always() | 85 | if: always() |
| 86 | uses: actions/upload-artifact@v4 | 86 | uses: actions/upload-artifact@v5 |
| 87 | with: | 87 | with: |
| 88 | name: pr-diff | 88 | name: pr-diff |
| 89 | path: | | 89 | path: | |
| @@ -92,7 +92,7 @@ jobs: | |||
| 92 | if-no-files-found: ignore | 92 | if-no-files-found: ignore |
| 93 | - name: Upload findings | 93 | - name: Upload findings |
| 94 | if: always() | 94 | if: always() |
| 95 | uses: actions/upload-artifact@v4 | 95 | uses: actions/upload-artifact@v5 |
| 96 | with: | 96 | with: |
| 97 | name: findings-data | 97 | name: findings-data |
| 98 | path: /tmp/findings-data.json | 98 | path: /tmp/findings-data.json |
| @@ -107,13 +107,13 @@ jobs: | |||
| 107 | if: "!cancelled() && needs.data-validation.outputs.yaml_changed == 'true'" | 107 | if: "!cancelled() && needs.data-validation.outputs.yaml_changed == 'true'" |
| 108 | runs-on: ubuntu-latest | 108 | runs-on: ubuntu-latest |
| 109 | steps: | 109 | steps: |
| 110 | - uses: actions/checkout@v4 | 110 | - uses: actions/checkout@v5 |
| 111 | - uses: actions/setup-python@v5 | 111 | - uses: actions/setup-python@v6 |
| 112 | with: | 112 | with: |
| 113 | python-version: "3.12" | 113 | python-version: "3.12" |
| 114 | - run: pip install -q -r lib/requirements.txt | 114 | - run: pip install -q -r lib/requirements.txt |
| 115 | - name: Download diff data | 115 | - name: Download diff data |
| 116 | uses: actions/download-artifact@v4 | 116 | uses: actions/download-artifact@v5 |
| 117 | with: | 117 | with: |
| 118 | name: pr-diff | 118 | name: pr-diff |
| 119 | path: /tmp | 119 | path: /tmp |
| @@ -131,14 +131,14 @@ jobs: | |||
| 131 | run: python lib/checks/make-info-stats.py | 131 | run: python lib/checks/make-info-stats.py |
| 132 | - name: Upload repo stats | 132 | - name: Upload repo stats |
| 133 | if: always() | 133 | if: always() |
| 134 | uses: actions/upload-artifact@v4 | 134 | uses: actions/upload-artifact@v5 |
| 135 | with: | 135 | with: |
| 136 | name: repo-stats | 136 | name: repo-stats |
| 137 | path: /tmp/repo-stats.md | 137 | path: /tmp/repo-stats.md |
| 138 | if-no-files-found: ignore | 138 | if-no-files-found: ignore |
| 139 | - name: Upload findings | 139 | - name: Upload findings |
| 140 | if: always() | 140 | if: always() |
| 141 | uses: actions/upload-artifact@v4 | 141 | uses: actions/upload-artifact@v5 |
| 142 | with: | 142 | with: |
| 143 | name: findings-project | 143 | name: findings-project |
| 144 | path: /tmp/findings-project.json | 144 | path: /tmp/findings-project.json |
| @@ -150,25 +150,25 @@ jobs: | |||
| 150 | needs: [pr-compliance, data-validation, submission-eligibility] | 150 | needs: [pr-compliance, data-validation, submission-eligibility] |
| 151 | runs-on: ubuntu-latest | 151 | runs-on: ubuntu-latest |
| 152 | steps: | 152 | steps: |
| 153 | - uses: actions/checkout@v4 | 153 | - uses: actions/checkout@v5 |
| 154 | - uses: actions/setup-python@v5 | 154 | - uses: actions/setup-python@v6 |
| 155 | with: | 155 | with: |
| 156 | python-version: "3.12" | 156 | python-version: "3.12" |
| 157 | - name: Download all findings | 157 | - name: Download all findings |
| 158 | uses: actions/download-artifact@v4 | 158 | uses: actions/download-artifact@v5 |
| 159 | with: | 159 | with: |
| 160 | pattern: findings-* | 160 | pattern: findings-* |
| 161 | path: /tmp/artifacts | 161 | path: /tmp/artifacts |
| 162 | merge-multiple: true | 162 | merge-multiple: true |
| 163 | continue-on-error: true | 163 | continue-on-error: true |
| 164 | - name: Download diff data | 164 | - name: Download diff data |
| 165 | uses: actions/download-artifact@v4 | 165 | uses: actions/download-artifact@v5 |
| 166 | with: | 166 | with: |
| 167 | name: pr-diff | 167 | name: pr-diff |
| 168 | path: /tmp/artifacts | 168 | path: /tmp/artifacts |
| 169 | continue-on-error: true | 169 | continue-on-error: true |
| 170 | - name: Download repo stats | 170 | - name: Download repo stats |
| 171 | uses: actions/download-artifact@v4 | 171 | uses: actions/download-artifact@v5 |
| 172 | with: | 172 | with: |
| 173 | name: repo-stats | 173 | name: repo-stats |
| 174 | path: /tmp/artifacts | 174 | path: /tmp/artifacts |
| @@ -181,7 +181,7 @@ jobs: | |||
| 181 | run: python lib/checks/format-comment.py | 181 | run: python lib/checks/format-comment.py |
| 182 | - name: Upload PR metadata | 182 | - name: Upload PR metadata |
| 183 | if: always() | 183 | if: always() |
| 184 | uses: actions/upload-artifact@v4 | 184 | uses: actions/upload-artifact@v5 |
| 185 | with: | 185 | with: |
| 186 | name: pr-meta | 186 | name: pr-meta |
| 187 | path: /tmp/pr-meta/ | 187 | path: /tmp/pr-meta/ |
.github/workflows/pr-comment.yml +43 −9
| @@ -20,12 +20,12 @@ jobs: | |||
| 20 | if: github.event.workflow_run.event == 'pull_request' | 20 | if: github.event.workflow_run.event == 'pull_request' |
| 21 | 21 | ||
| 22 | steps: | 22 | steps: |
| 23 | - uses: actions/checkout@v4 | 23 | - uses: actions/checkout@v5 |
| 24 | 24 | ||
| 25 | - name: Download PR metadata | 25 | - name: Download PR metadata |
| 26 | id: download | 26 | id: download |
| 27 | continue-on-error: true | 27 | continue-on-error: true |
| 28 | uses: actions/download-artifact@v4 | 28 | uses: actions/download-artifact@v5 |
| 29 | with: | 29 | with: |
| 30 | name: pr-meta | 30 | name: pr-meta |
| 31 | path: pr-meta | 31 | path: pr-meta |
| @@ -34,7 +34,7 @@ jobs: | |||
| 34 | 34 | ||
| 35 | - name: Resolve PR context | 35 | - name: Resolve PR context |
| 36 | id: context | 36 | id: context |
| 37 | uses: actions/github-script@v7 | 37 | uses: actions/github-script@v8 |
| 38 | with: | 38 | with: |
| 39 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} | 39 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} |
| 40 | script: | | 40 | script: | |
| @@ -95,7 +95,7 @@ jobs: | |||
| 95 | 95 | ||
| 96 | - name: Post or update comment | 96 | - name: Post or update comment |
| 97 | if: steps.context.outputs.pr_number | 97 | if: steps.context.outputs.pr_number |
| 98 | uses: actions/github-script@v7 | 98 | uses: actions/github-script@v8 |
| 99 | with: | 99 | with: |
| 100 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} | 100 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} |
| 101 | script: | | 101 | script: | |
| @@ -136,17 +136,38 @@ jobs: | |||
| 136 | console.log('Updated bot comment.'); | 136 | console.log('Updated bot comment.'); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | // Auto-assign Lissy93 for review when appropriate (non-critical) | ||
| 140 | try { | ||
| 141 | const readInt = (f) => fs.existsSync(f) ? parseInt(fs.readFileSync(f, 'utf8').trim()) : NaN; | ||
| 142 | const errors = readInt('pr-meta/error-count.txt'); | ||
| 143 | const total = readInt('pr-meta/findings-count.txt'); | ||
| 144 | const shouldAssign = | ||
| 145 | (action === 'create' && errors === 0 && total === 0) || | ||
| 146 | (action === 'update' && errors === 0); | ||
| 147 | if (shouldAssign) { | ||
| 148 | await github.rest.issues.addAssignees({ | ||
| 149 | owner: context.repo.owner, | ||
| 150 | repo: context.repo.repo, | ||
| 151 | issue_number: prNumber, | ||
| 152 | assignees: ['Lissy93'], | ||
| 153 | }); | ||
| 154 | console.log('Assigned Lissy93 for review.'); | ||
| 155 | } | ||
| 156 | } catch (err) { | ||
| 157 | console.log(`Failed to auto-assign: ${err.message}`); | ||
| 158 | } | ||
| 159 | |||
| 139 | review-notify: | 160 | review-notify: |
| 140 | name: Notify maintainer | 161 | name: Notify maintainer |
| 141 | runs-on: ubuntu-latest | 162 | runs-on: ubuntu-latest |
| 142 | if: github.event_name == 'pull_request_review' | 163 | if: github.event_name == 'pull_request_review' |
| 143 | 164 | ||
| 144 | steps: | 165 | steps: |
| 145 | - uses: actions/checkout@v4 | 166 | - uses: actions/checkout@v5 |
| 146 | 167 | ||
| 147 | - name: Fetch review and CI context | 168 | - name: Fetch review and CI context |
| 148 | id: context | 169 | id: context |
| 149 | uses: actions/github-script@v7 | 170 | uses: actions/github-script@v8 |
| 150 | with: | 171 | with: |
| 151 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} | 172 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} |
| 152 | script: | | 173 | script: | |
| @@ -191,7 +212,7 @@ jobs: | |||
| 191 | run: python lib/checks/check-review-ready.py | 212 | run: python lib/checks/check-review-ready.py |
| 192 | 213 | ||
| 193 | - name: Post notification | 214 | - name: Post notification |
| 194 | uses: actions/github-script@v7 | 215 | uses: actions/github-script@v8 |
| 195 | with: | 216 | with: |
| 196 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} | 217 | github-token: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }} |
| 197 | script: | | 218 | script: | |
| @@ -212,10 +233,23 @@ jobs: | |||
| 212 | '@Lissy93 - Please evaluate, and either merge or leave feedback.', | 233 | '@Lissy93 - Please evaluate, and either merge or leave feedback.', |
| 213 | ].join('\n'); | 234 | ].join('\n'); |
| 214 | 235 | ||
| 236 | const prNumber = parseInt('${{ steps.context.outputs.pr_number }}'); | ||
| 237 | |||
| 215 | await github.rest.issues.createComment({ | 238 | await github.rest.issues.createComment({ |
| 216 | owner: context.repo.owner, | 239 | owner: context.repo.owner, |
| 217 | repo: context.repo.repo, | 240 | repo: context.repo.repo, |
| 218 | issue_number: parseInt('${{ steps.context.outputs.pr_number }}'), | 241 | issue_number: prNumber, |
| 219 | body, | 242 | body, |
| 220 | }); | 243 | }); |
| 221 | console.log('Posted maintainer notification.'); | 244 | |
| 245 | // Once all checks pass, assign the PR to myself, so i get notiifcation to review | ||
| 246 | try { | ||
| 247 | await github.rest.issues.addAssignees({ | ||
| 248 | owner: context.repo.owner, | ||
| 249 | repo: context.repo.repo, | ||
| 250 | issue_number: prNumber, | ||
| 251 | assignees: ['Lissy93'], | ||
| 252 | }); | ||
| 253 | } catch (err) { | ||
| 254 | console.log(`Failed to assign Lissy93: ${err.message}`); | ||
| 255 | } | ||
lib/checks/check-project.py +96 −19
| @@ -26,7 +26,10 @@ AI_BOT_AUTHORS = [ | |||
| 26 | "copilot-swe-agent.github.com", | 26 | "copilot-swe-agent.github.com", |
| 27 | "noreply@cursor.com", | 27 | "noreply@cursor.com", |
| 28 | ] | 28 | ] |
| 29 | SPAM_PR_THRESHOLD = 5 | 29 | SPAM_AWESOME_THRESHOLD = 3 |
| 30 | SPAM_DISTINCT_REPO_THRESHOLD = 7 | ||
| 31 | SPAM_WINDOW_DAYS = 2 | ||
| 32 | NEW_ACCOUNT_DAYS = 14 | ||
| 30 | 33 | ||
| 31 | LINK_MSG = ( | 34 | LINK_MSG = ( |
| 32 | "The link(s) you included seem to be returning a 404." | 35 | "The link(s) you included seem to be returning a 404." |
| @@ -47,7 +50,8 @@ ACTIVITY_MSG = ( | |||
| 47 | ) | 50 | ) |
| 48 | MATURITY_MSG = ( | 51 | MATURITY_MSG = ( |
| 49 | "This project appears to be quite new (created less than 4 months ago)." | 52 | "This project appears to be quite new (created less than 4 months ago)." |
| 50 | " Repositories should have a proven track record before listing." | 53 | " Repositories should have a proven track record before listing," |
| 54 | " and at least 16 weeks since first stable release." | ||
| 51 | ) | 55 | ) |
| 52 | AI_CODE_MSG = ( | 56 | AI_CODE_MSG = ( |
| 53 | "This project appears to contain AI-generated code." | 57 | "This project appears to contain AI-generated code." |
| @@ -62,15 +66,27 @@ LICENSE_MSG = ( | |||
| 62 | ) | 66 | ) |
| 63 | ARCHIVED_MSG = ( | 67 | ARCHIVED_MSG = ( |
| 64 | "The GitHub project linked has been archived." | 68 | "The GitHub project linked has been archived." |
| 65 | " Additions must be actively maintained." | 69 | " Additions must be actively maintained" |
| 66 | ) | 70 | ) |
| 67 | SECURITY_MSG = ( | 71 | SECURITY_MSG = ( |
| 68 | "This project has open security vulnerabilities (critical or high severity)" | 72 | "This project has open security vulnerabilities (critical or high severity)" |
| 69 | " flagged by GitHub Dependabot. Please verify these have been addressed" | 73 | " flagged by GitHub Dependabot. Please verify these have been addressed" |
| 70 | ) | 74 | ) |
| 71 | SPAM_MSG = ( | 75 | SPAM_AWESOME_MSG = ( |
| 72 | "This user has opened up a large number of PRs to other awesome-* repos" | 76 | "You have made many similar submissions on other awesome-* repos today." |
| 73 | " in the past 24 hours, and appears to be spamming" | 77 | " Please ensure that your submission is actually a good fit for awesome-privacy" |
| 78 | ) | ||
| 79 | SPAM_MANY_MSG = ( | ||
| 80 | "The submitter of this PR appears to have been previously flagged as a spammer." | ||
| 81 | " Caution is needed when reviewing this PR" | ||
| 82 | ) | ||
| 83 | NEW_ACCOUNT_MSG = ( | ||
| 84 | "This user has only just joined GitHub." | ||
| 85 | " New accounts submitting to awesome lists can be a spam signal, careful review needed" | ||
| 86 | ) | ||
| 87 | DUPLICATE_URL_MSG = ( | ||
| 88 | "The URL for this submission already exists in another listing." | ||
| 89 | " Please check that this is not a duplicate entry" | ||
| 74 | ) | 90 | ) |
| 75 | 91 | ||
| 76 | 92 | ||
| @@ -249,37 +265,91 @@ def check_security_alerts(owner, repo, token): | |||
| 249 | 265 | ||
| 250 | 266 | ||
| 251 | def check_spam_prs(pr_user, token): | 267 | def check_spam_prs(pr_user, token): |
| 252 | """Return SPAM_MSG if the user has opened many PRs to other awesome-* repos recently.""" | 268 | """Return list of spam findings based on recent PR activity.""" |
| 253 | if not pr_user or not token: | 269 | if not pr_user or not token: |
| 254 | return None | 270 | return [] |
| 255 | try: | 271 | try: |
| 256 | since = (datetime.now(timezone.utc) - timedelta(days=1)).strftime("%Y-%m-%d") | 272 | since = (datetime.now(timezone.utc) - timedelta(days=SPAM_WINDOW_DAYS)).strftime("%Y-%m-%d") |
| 257 | headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT} | 273 | headers = { |
| 258 | headers["Authorization"] = f"token {token}" | 274 | "Accept": "application/vnd.github.v3+json", |
| 275 | "User-Agent": USER_AGENT, | ||
| 276 | "Authorization": f"token {token}", | ||
| 277 | } | ||
| 259 | resp = requests.get( | 278 | resp = requests.get( |
| 260 | "https://api.github.com/search/issues", | 279 | "https://api.github.com/search/issues", |
| 261 | headers=headers, timeout=TIMEOUT, | 280 | headers=headers, timeout=TIMEOUT, |
| 262 | params={"q": f"type:pr author:{pr_user} created:>={since}"}, | 281 | params={"q": f"type:pr author:{pr_user} created:>={since}"}, |
| 263 | ) | 282 | ) |
| 264 | if resp.status_code != 200: | 283 | if resp.status_code != 200: |
| 265 | return None | 284 | return [] |
| 266 | items = resp.json().get("items", []) | 285 | items = resp.json().get("items", []) |
| 267 | this_repo = os.environ.get("GITHUB_REPOSITORY", "Lissy93/awesome-privacy").lower() | 286 | this_repo = os.environ.get("GITHUB_REPOSITORY", "Lissy93/awesome-privacy").lower() |
| 268 | count = 0 | 287 | awesome_count = 0 |
| 288 | distinct_repos = set() | ||
| 269 | for item in items: | 289 | for item in items: |
| 270 | repo_url = item.get("repository_url", "") | 290 | repo_url = item.get("repository_url", "") |
| 271 | # repository_url looks like https://api.github.com/repos/owner/repo-name | 291 | # repository_url looks like https://api.github.com/repos/owner/repo-name |
| 272 | repo_full = "/".join(repo_url.rstrip("/").split("/")[-2:]).lower() | 292 | repo_full = "/".join(repo_url.rstrip("/").split("/")[-2:]).lower() |
| 293 | if repo_full == this_repo: | ||
| 294 | continue | ||
| 295 | distinct_repos.add(repo_full) | ||
| 273 | repo_name = repo_url.rstrip("/").split("/")[-1].lower() | 296 | repo_name = repo_url.rstrip("/").split("/")[-1].lower() |
| 274 | if repo_name.startswith("awesome-") and repo_full != this_repo: | 297 | if repo_name.startswith("awesome-"): |
| 275 | count += 1 | 298 | awesome_count += 1 |
| 276 | if count >= SPAM_PR_THRESHOLD: | 299 | findings = [] |
| 277 | return SPAM_MSG | 300 | if awesome_count >= SPAM_AWESOME_THRESHOLD: |
| 301 | findings.append(SPAM_AWESOME_MSG) | ||
| 302 | if len(distinct_repos) >= SPAM_DISTINCT_REPO_THRESHOLD: | ||
| 303 | findings.append(SPAM_MANY_MSG) | ||
| 304 | return findings | ||
| 305 | except Exception: | ||
| 306 | return [] | ||
| 307 | |||
| 308 | |||
| 309 | def check_new_account(pr_user, token): | ||
| 310 | """Return NEW_ACCOUNT_MSG if the PR author's GitHub account is very new.""" | ||
| 311 | if not pr_user or not token: | ||
| 312 | return None | ||
| 313 | try: | ||
| 314 | headers = {"Accept": "application/vnd.github.v3+json", "User-Agent": USER_AGENT} | ||
| 315 | headers["Authorization"] = f"token {token}" | ||
| 316 | resp = requests.get( | ||
| 317 | f"https://api.github.com/users/{pr_user}", | ||
| 318 | headers=headers, timeout=TIMEOUT, | ||
| 319 | ) | ||
| 320 | if resp.status_code != 200: | ||
| 321 | return None | ||
| 322 | created = resp.json().get("created_at") | ||
| 323 | if not created: | ||
| 324 | return None | ||
| 325 | created_dt = datetime.fromisoformat(created.replace("Z", "+00:00")) | ||
| 326 | if (datetime.now(timezone.utc) - created_dt).days < NEW_ACCOUNT_DAYS: | ||
| 327 | return NEW_ACCOUNT_MSG | ||
| 278 | except Exception: | 328 | except Exception: |
| 279 | pass | 329 | pass |
| 280 | return None | 330 | return None |
| 281 | 331 | ||
| 282 | 332 | ||
| 333 | def check_duplicate_urls(diff, head): | ||
| 334 | """Return DUPLICATE_URL_MSG if an added service's URL already exists in the YAML.""" | ||
| 335 | if not head: | ||
| 336 | return None | ||
| 337 | # Count how many times each URL appears in the head YAML | ||
| 338 | url_counts = {} | ||
| 339 | for cat in head.get("categories", []): | ||
| 340 | for sec in cat.get("sections", []): | ||
| 341 | for svc in sec.get("services", []): | ||
| 342 | url = svc.get("url", "").rstrip("/").lower() | ||
| 343 | if url: | ||
| 344 | url_counts[url] = url_counts.get(url, 0) + 1 | ||
| 345 | # The added service is in head already, so a count > 1 means a duplicate exists | ||
| 346 | for svc in get_services(diff, "added"): | ||
| 347 | url = svc.get("fields", {}).get("url", "").rstrip("/").lower() | ||
| 348 | if url and url_counts.get(url, 0) > 1: | ||
| 349 | return DUPLICATE_URL_MSG | ||
| 350 | return None | ||
| 351 | |||
| 352 | |||
| 283 | _DISCLOSURE_RE = re.compile( | 353 | _DISCLOSURE_RE = re.compile( |
| 284 | r"i am the author|i'm the author|my project|i created|i develop" | 354 | r"i am the author|i'm the author|my project|i created|i develop" |
| 285 | r"|i maintain|i built|my own project|i made|author of|maintainer of", | 355 | r"|i maintain|i built|my own project|i made|author of|maintainer of", |
| @@ -383,11 +453,18 @@ def main(): | |||
| 383 | pr_user = os.environ.get("PR_USER", "") | 453 | pr_user = os.environ.get("PR_USER", "") |
| 384 | pr_body = os.environ.get("PR_BODY", "") | 454 | pr_body = os.environ.get("PR_BODY", "") |
| 385 | token = os.environ.get("GITHUB_TOKEN", "") | 455 | token = os.environ.get("GITHUB_TOKEN", "") |
| 386 | findings.extend(check_repo_signals(diff, pr_user, token, pr_body)) | ||
| 387 | 456 | ||
| 388 | finding = check_spam_prs(pr_user, token) | 457 | findings.extend(check_spam_prs(pr_user, token)) |
| 458 | |||
| 459 | finding = check_new_account(pr_user, token) | ||
| 389 | if finding: | 460 | if finding: |
| 390 | findings.append(finding) | 461 | findings.append(finding) |
| 462 | |||
| 463 | finding = check_duplicate_urls(diff, head) | ||
| 464 | if finding: | ||
| 465 | findings.append(finding) | ||
| 466 | |||
| 467 | findings.extend(check_repo_signals(diff, pr_user, token, pr_body)) | ||
| 391 | except Exception: | 468 | except Exception: |
| 392 | pass | 469 | pass |
| 393 | 470 | ||
lib/checks/check-yaml-diff.py −17
| @@ -156,22 +156,6 @@ def write_diff_summary(diff_result): | |||
| 156 | f.write("\n".join(bullets) + "\n") | 156 | f.write("\n".join(bullets) + "\n") |
| 157 | 157 | ||
| 158 | 158 | ||
| 159 | def write_step_summary(diff_result): | ||
| 160 | """Write a bullet-point Markdown summary to $GITHUB_STEP_SUMMARY.""" | ||
| 161 | summary_file = os.environ.get("GITHUB_STEP_SUMMARY") | ||
| 162 | if not summary_file: | ||
| 163 | return | ||
| 164 | |||
| 165 | bullets = format_diff_bullets(diff_result) | ||
| 166 | lines = ["## YAML Diff Analysis\n"] | ||
| 167 | if bullets: | ||
| 168 | lines.extend(bullets) | ||
| 169 | else: | ||
| 170 | lines.append("No changes detected in `awesome-privacy.yml`.") | ||
| 171 | |||
| 172 | with open(summary_file, "a") as f: | ||
| 173 | f.write("\n".join(lines) + "\n") | ||
| 174 | |||
| 175 | 159 | ||
| 176 | def main(): | 160 | def main(): |
| 177 | parser = argparse.ArgumentParser() | 161 | parser = argparse.ArgumentParser() |
| @@ -227,7 +211,6 @@ def main(): | |||
| 227 | json.dump(diff_result, f, indent=2) | 211 | json.dump(diff_result, f, indent=2) |
| 228 | 212 | ||
| 229 | write_github_output("has_service_changes", str(bool(added or removed or modified)).lower()) | 213 | write_github_output("has_service_changes", str(bool(added or removed or modified)).lower()) |
| 230 | write_step_summary(diff_result) | ||
| 231 | write_diff_summary(diff_result) | 214 | write_diff_summary(diff_result) |
| 232 | 215 | ||
| 233 | added_count = len(added) | 216 | added_count = len(added) |
lib/checks/format-comment.py +5 −2
| @@ -179,7 +179,8 @@ def write_step_summary(errors, warnings, user, pr_number, run_id, changes_summar | |||
| 179 | if pr_number: | 179 | if pr_number: |
| 180 | lines.append( | 180 | lines.append( |
| 181 | f"This workflow run was triggered at {timestamp}" | 181 | f"This workflow run was triggered at {timestamp}" |
| 182 | f" for PR #{pr_number} which was opened by @{user}\n" | 182 | f" for PR [#{pr_number}](https://github.com/Lissy93/awesome-privacy/pull/{pr_number})" |
| 183 | f" which was opened by @{user}\n" | ||
| 183 | ) | 184 | ) |
| 184 | else: | 185 | else: |
| 185 | lines.append( | 186 | lines.append( |
| @@ -191,7 +192,7 @@ def write_step_summary(errors, warnings, user, pr_number, run_id, changes_summar | |||
| 191 | lines.append(f"{changes_summary}\n") | 192 | lines.append(f"{changes_summary}\n") |
| 192 | 193 | ||
| 193 | if repo_stats: | 194 | if repo_stats: |
| 194 | lines.append("#### Submission Info\n") | 195 | lines.append("### Submission Info\n") |
| 195 | lines.append(f"{repo_stats}\n") | 196 | lines.append(f"{repo_stats}\n") |
| 196 | 197 | ||
| 197 | with open(summary_file, "a") as f: | 198 | with open(summary_file, "a") as f: |
| @@ -217,6 +218,8 @@ def main(): | |||
| 217 | all_findings = errors + warnings | 218 | all_findings = errors + warnings |
| 218 | with open(os.path.join(OUTPUT_DIR, "findings-count.txt"), "w") as f: | 219 | with open(os.path.join(OUTPUT_DIR, "findings-count.txt"), "w") as f: |
| 219 | f.write(str(len(all_findings))) | 220 | f.write(str(len(all_findings))) |
| 221 | with open(os.path.join(OUTPUT_DIR, "error-count.txt"), "w") as f: | ||
| 222 | f.write(str(len(errors))) | ||
| 220 | changes_summary = load_diff_summary() | 223 | changes_summary = load_diff_summary() |
| 221 | changes_bullets = _extract_changes_bullets(changes_summary) | 224 | changes_bullets = _extract_changes_bullets(changes_summary) |
| 222 | repo_stats = load_repo_stats() | 225 | repo_stats = load_repo_stats() |
lib/checks/make-info-stats.py +10 −4
| @@ -591,11 +591,17 @@ def main(): | |||
| 591 | print(f"Failed to fetch repo data for {args['owner']}/{args['repo']}", file=sys.stderr) | 591 | print(f"Failed to fetch repo data for {args['owner']}/{args['repo']}", file=sys.stderr) |
| 592 | 592 | ||
| 593 | if args["url"]: | 593 | if args["url"]: |
| 594 | site_data = fetch_website_data(args["url"]) | 594 | parsed_url = urlparse(args["url"]) |
| 595 | has_sec_txt = check_security_txt(args["url"]) | 595 | if parsed_url.hostname and parsed_url.hostname.rstrip(".").endswith("github.com"): |
| 596 | if site_data or has_sec_txt is not None: | 596 | print(f"Skipped website checks, since github repo was specified: {args['url']}", file=sys.stderr) |
| 597 | sections.append(("Website Checks", | 597 | sections.append(("Website Checks", |
| 598 | format_markdown(grade_website_stats(site_data, args["url"], has_sec_txt)))) | 598 | f"- {ORANGE} **Skipped** web checks, since repo URL was submitted instead of a website")) |
| 599 | else: | ||
| 600 | site_data = fetch_website_data(args["url"]) | ||
| 601 | has_sec_txt = check_security_txt(args["url"]) | ||
| 602 | if site_data or has_sec_txt is not None: | ||
| 603 | sections.append(("Website Checks", | ||
| 604 | format_markdown(grade_website_stats(site_data, args["url"], has_sec_txt)))) | ||
| 599 | 605 | ||
| 600 | if args["android"]: | 606 | if args["android"]: |
| 601 | data = fetch_android_data(args["android"]) | 607 | data = fetch_android_data(args["android"]) |
lib/checks/prepare-comment.py +40 −5
| @@ -70,6 +70,35 @@ def _extract_pr_author(existing_body): | |||
| 70 | return match.group(1) if match else None | 70 | return match.group(1) if match else None |
| 71 | 71 | ||
| 72 | 72 | ||
| 73 | _SUBMISSION_INFO_RE = re.compile( | ||
| 74 | r"<details><summary>Submission Info</summary>\s*\n.*?</details>", | ||
| 75 | re.DOTALL, | ||
| 76 | ) | ||
| 77 | |||
| 78 | |||
| 79 | def _extract_submission_info(body): | ||
| 80 | """Extract the Submission Info <details> block, or None if absent.""" | ||
| 81 | match = _SUBMISSION_INFO_RE.search(body) | ||
| 82 | return match.group(0) if match else None | ||
| 83 | |||
| 84 | |||
| 85 | def _refresh_submission_info(existing_body, new_body): | ||
| 86 | """Replace or insert the Submission Info block from new_body into existing_body.""" | ||
| 87 | new_block = _extract_submission_info(new_body) | ||
| 88 | if not new_block: | ||
| 89 | return existing_body | ||
| 90 | old_block = _extract_submission_info(existing_body) | ||
| 91 | if old_block: | ||
| 92 | if old_block == new_block: | ||
| 93 | return existing_body | ||
| 94 | return existing_body.replace(old_block, new_block) | ||
| 95 | # No existing block — insert before Updates section or workflow run link | ||
| 96 | for anchor in ("---\n\n### Updates", "<sup>For full details"): | ||
| 97 | if anchor in existing_body: | ||
| 98 | return existing_body.replace(anchor, new_block + "\n\n" + anchor, 1) | ||
| 99 | return existing_body.rstrip() + "\n\n" + new_block | ||
| 100 | |||
| 101 | |||
| 73 | def build_edit_line(existing_body, findings_count, check_run_id, repo): | 102 | def build_edit_line(existing_body, findings_count, check_run_id, repo): |
| 74 | """Build the edit line to append, or None if nothing to do.""" | 103 | """Build the edit line to append, or None if nothing to do.""" |
| 75 | run_tag = f"<!-- run:{check_run_id} -->" | 104 | run_tag = f"<!-- run:{check_run_id} -->" |
| @@ -154,14 +183,20 @@ def main(): | |||
| 154 | findings_count = read_findings_count(new_body) | 183 | findings_count = read_findings_count(new_body) |
| 155 | edit_line = build_edit_line(existing_body, findings_count, check_run_id, repo) | 184 | edit_line = build_edit_line(existing_body, findings_count, check_run_id, repo) |
| 156 | 185 | ||
| 157 | if not edit_line: | 186 | # Refresh the Submission Info block even if findings haven't changed |
| 187 | refreshed_body = _refresh_submission_info(existing_body, new_body) | ||
| 188 | info_changed = refreshed_body != existing_body | ||
| 189 | |||
| 190 | if not edit_line and not info_changed: | ||
| 158 | write_output("skip") | 191 | write_output("skip") |
| 159 | return | 192 | return |
| 160 | 193 | ||
| 161 | if "### Updates" in existing_body: | 194 | updated = refreshed_body |
| 162 | updated = existing_body.rstrip() + "\n" + edit_line | 195 | if edit_line: |
| 163 | else: | 196 | if "### Updates" in updated: |
| 164 | updated = existing_body.rstrip() + "\n\n---\n\n### Updates\n\n" + edit_line | 197 | updated = updated.rstrip() + "\n" + edit_line |
| 198 | else: | ||
| 199 | updated = updated.rstrip() + "\n\n---\n\n### Updates\n\n" + edit_line | ||
| 165 | write_output("update", updated) | 200 | write_output("update", updated) |
| 166 | 201 | ||
| 167 | 202 | ||