From 5b8314d99ef37ced9b05f6f0906b9b9dd8978ed6 Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:15:53 -0700 Subject: [PATCH 1/6] fix(description): accepted text could fail its own re-check Fuzzing found two descriptions that passed the filter and then failed validate_data's re-check of the stored text: - A trailing "www" became "www." once the period was added, which the link check rejects. The checks now run on the text we store. - A variation selector other than U+FE0F reset the emoji run, then got stripped, leaving four emoji in a row. All selectors now ride along. --- scripts/devstream/description.py | 4 +++- scripts/tests/test_description.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/devstream/description.py b/scripts/devstream/description.py index 540c9eb..83fc40c 100644 --- a/scripts/devstream/description.py +++ b/scripts/devstream/description.py @@ -65,7 +65,7 @@ def _emoji_run_too_long(t: str) -> bool: run += 1 if run > 2: return True - elif ch != "️": # variation selector rides along with its emoji + elif not VARIATION.match(ch): # variation selectors ride along with their emoji run = 0 return False @@ -83,6 +83,8 @@ def clean_description(text: str) -> tuple[str | None, str | None]: # would be stored at 141, and "Toolkit!!!" shrinks to an 8-character "Toolkit.". if not MIN_LEN <= len(final) <= MAX_LEN: return None, f"Descriptions need to be between {MIN_LEN} and {MAX_LEN} characters." + # Check the text we store: the added period turns a trailing "www" into "www.". + t = final if _mixed_script(t): return None, "Please use one alphabet per word." if _has_url(t): diff --git a/scripts/tests/test_description.py b/scripts/tests/test_description.py index 56ecdd8..37893b8 100644 --- a/scripts/tests/test_description.py +++ b/scripts/tests/test_description.py @@ -48,6 +48,8 @@ def test_output_is_a_fixed_point(self): "y" * 139, "z" * 140, "w" * 139 + ".", "v" * 141, "short", "abcdefghi!", "abcdefghij!", "Mixed ending?.!", "Tabs\tand\nnewlines in it", "Dots... in the middle... end...", "Questions? Yes, answered here?", "Ending with spaces and bang ! ", + # The added period turns a trailing "www" into "www.", a link on the re-check. + "A short history of the www", "Mirror of the WWW!", ] self.assertGreaterEqual(len(inputs), 30) for x in inputs: @@ -168,6 +170,8 @@ def test_invisible_characters_stripped(self): def test_emoji_run_with_variation_selector(self): bad("Stars \u2728\ufe0f\u2728\ufe0f\u2728\ufe0f everywhere here") ok("Stars \u2728\ufe0f\u2728\ufe0f everywhere here") + # Any selector, not only U+FE0F: they are all dropped before storing. + bad("Stars \u2728\u2728\ufe08\u2728\u2728 everywhere here") def test_removed_terms_allowed(self): ok("Work from home setup scripts for devs") From 9e655c314065c07f482e4b666667950367b1252c Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:15:53 -0700 Subject: [PATCH 2/6] test(fuzz): fuzz the form, description and SPDX parsers Two atheris targets, built and run on pull requests through ClusterFuzzLite with a five-minute budget. --- .clusterfuzzlite/Dockerfile | 4 +++ .clusterfuzzlite/build.sh | 9 +++++ .clusterfuzzlite/project.yaml | 1 + .github/workflows/cflite_pr.yml | 38 +++++++++++++++++++++ fuzz/fuzz_description.py | 38 +++++++++++++++++++++ fuzz/fuzz_issue_form.py | 60 +++++++++++++++++++++++++++++++++ 6 files changed, 150 insertions(+) create mode 100644 .clusterfuzzlite/Dockerfile create mode 100755 .clusterfuzzlite/build.sh create mode 100644 .clusterfuzzlite/project.yaml create mode 100644 .github/workflows/cflite_pr.yml create mode 100644 fuzz/fuzz_description.py create mode 100644 fuzz/fuzz_issue_form.py diff --git a/.clusterfuzzlite/Dockerfile b/.clusterfuzzlite/Dockerfile new file mode 100644 index 0000000..254dc25 --- /dev/null +++ b/.clusterfuzzlite/Dockerfile @@ -0,0 +1,4 @@ +FROM gcr.io/oss-fuzz-base/base-builder-python:v1@sha256:21f6fab17ace4dc76e1c56de91ee95d3d03da021df94b41056ba036f6c6f55e9 +COPY . $SRC/devstream +WORKDIR $SRC/devstream +COPY .clusterfuzzlite/build.sh $SRC/ diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh new file mode 100755 index 0000000..2a608ea --- /dev/null +++ b/.clusterfuzzlite/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu +# Standard library only, so there is nothing to pip install first. +for fuzzer in fuzz/fuzz_*.py; do + # The modules read these files at import time, relative to their own path. + compile_python_fuzzer "$fuzzer" \ + --paths "$SRC/devstream" \ + --add-data "data:data" \ + --add-data "scripts/blocklist.txt:scripts" +done diff --git a/.clusterfuzzlite/project.yaml b/.clusterfuzzlite/project.yaml new file mode 100644 index 0000000..d1ad0ae --- /dev/null +++ b/.clusterfuzzlite/project.yaml @@ -0,0 +1 @@ +language: python diff --git a/.github/workflows/cflite_pr.yml b/.github/workflows/cflite_pr.yml new file mode 100644 index 0000000..1899c20 --- /dev/null +++ b/.github/workflows/cflite_pr.yml @@ -0,0 +1,38 @@ +name: ClusterFuzzLite PR fuzzing + +on: + pull_request: + branches: [main] + paths: ["scripts/**", "fuzz/**", "data/**", ".clusterfuzzlite/**"] + +permissions: {} + +jobs: + PR: + runs-on: ubuntu-latest + permissions: + contents: read + concurrency: + group: ${{ github.workflow }}-${{ matrix.sanitizer }}-${{ github.ref }} + cancel-in-progress: true + strategy: + fail-fast: false + matrix: + sanitizer: [address] + steps: + - uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3 + with: + egress-policy: audit + - name: Build fuzzers (${{ matrix.sanitizer }}) + uses: google/clusterfuzzlite/actions/build_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + language: python + github-token: ${{ secrets.GITHUB_TOKEN }} + sanitizer: ${{ matrix.sanitizer }} + - name: Run fuzzers (${{ matrix.sanitizer }}) + uses: google/clusterfuzzlite/actions/run_fuzzers@884713a6c30a92e5e8544c39945cd7cb630abcd1 # v1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + fuzz-seconds: 300 + mode: code-change + sanitizer: ${{ matrix.sanitizer }} diff --git a/fuzz/fuzz_description.py b/fuzz/fuzz_description.py new file mode 100644 index 0000000..bd8df26 --- /dev/null +++ b/fuzz/fuzz_description.py @@ -0,0 +1,38 @@ +"""Fuzz the description filter, and the SPDX scanner on the same text. + +clean_description never raises; it returns (text, None) or (None, reason). +A result it accepts must also pass it again unchanged, because +validate_data re-checks every stored description that way. +""" + +import sys +from pathlib import Path + +import atheris + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) + +with atheris.instrument_imports(include=["scripts"]): + from scripts.devstream import license_detect + from scripts.devstream.description import FORBIDDEN, MAX_LEN, MIN_LEN, clean_description + + +def TestOneInput(data: bytes) -> None: + text = atheris.FuzzedDataProvider(data).ConsumeUnicodeNoSurrogates(len(data)) + final, why = clean_description(text) + assert (final is None) != (why is None), (final, why) + if final is not None: + assert MIN_LEN <= len(final) <= MAX_LEN, final + assert not FORBIDDEN & set(final), final + assert clean_description(final) == (final, None), final + license_detect._spdx_scan("SPDX-License-Identifier: " + text) + license_detect._readme_license("## License\n\n" + text) + + +def main() -> None: + atheris.Setup(sys.argv, TestOneInput) + atheris.Fuzz() + + +if __name__ == "__main__": + main() diff --git a/fuzz/fuzz_issue_form.py b/fuzz/fuzz_issue_form.py new file mode 100644 index 0000000..4e6d4ba --- /dev/null +++ b/fuzz/fuzz_issue_form.py @@ -0,0 +1,60 @@ +"""Fuzz the submission and report parsers, and the SPDX scanner. + +FormError is the parsers' way of saying no, so it is expected. Any other +exception is a crash: the bot would die on a hostile issue body. +""" + +import sys +from pathlib import Path + +import atheris + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) + +with atheris.instrument_imports(include=["scripts"]): + from scripts.devstream import license_detect + from scripts.devstream.entries import CATEGORIES + from scripts.devstream.issue_form import REASONS, FormError, parse_report, parse_submission + +HEADINGS = [ + "Repository", "Category", "Description", "Checklist", + "Entry", "Reason", "Replaced by (owner/name)", "Details", +] +# Real answers let the fuzzer get past the "incomplete form" checks. +ANSWERS = [ + *CATEGORIES.values(), + *REASONS, + "- [x] I read the quality bar\n- [x] This repo is open source", + "https://github.com/octo/hello", + "_No response_", +] + + +def body(fdp: atheris.FuzzedDataProvider) -> str: + if fdp.ConsumeBool(): + return fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes()) + parts = [] + for _ in range(fdp.ConsumeIntInRange(0, 8)): + answer = fdp.PickValueInList(ANSWERS) if fdp.ConsumeBool() else fdp.ConsumeUnicodeNoSurrogates(200) + parts.append(f"### {fdp.PickValueInList(HEADINGS)}\n\n{answer}") + return "\n\n".join(parts) + + +def TestOneInput(data: bytes) -> None: + text = body(atheris.FuzzedDataProvider(data)) + for parse in (parse_submission, parse_report): + try: + parse(text) + except FormError: + pass + license_detect._detect_text(text) + license_detect._spdx_scan("SPDX-License-Identifier: " + text) + + +def main() -> None: + atheris.Setup(sys.argv, TestOneInput) + atheris.Fuzz() + + +if __name__ == "__main__": + main() From 7a636b181328727d6364a41525a7eb09466203c9 Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:15:53 -0700 Subject: [PATCH 3/6] ci(security): add CodeQL, Scorecard, Dependabot and signed releases - CodeQL for Python, JS/TS and the workflows themselves, required in the ruleset once setup_repo.sh runs. - Scorecard publishes weekly and on every push to main. - Dependabot opens grouped weekly updates, each version a week old. - A v* tag builds the source and site tarballs, attests their provenance and creates the release. - Deploy only follows workflow_run builds from main, and Astro no longer sends build telemetry. --- .github/dependabot.yml | 43 ++++++++++++++++++++++++++ .github/workflows/codeql.yml | 39 ++++++++++++++++++++++++ .github/workflows/deploy.yml | 5 ++- .github/workflows/release.yml | 54 +++++++++++++++++++++++++++++++++ .github/workflows/scorecard.yml | 42 +++++++++++++++++++++++++ scripts/admin/setup_repo.sh | 6 +++- 6 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/scorecard.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..fdfa9dd --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,43 @@ +version: 2 + +# No pip entry: the bot is standard library only, so there is no manifest +# for Dependabot to read. +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + # A release has to survive a week in the wild before we take it. + cooldown: + default-days: 7 + groups: + actions: + update-types: [minor, patch] + + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + tooling: + update-types: [minor, patch] + + - package-ecosystem: npm + directory: /site + schedule: + interval: weekly + cooldown: + default-days: 7 + groups: + site: + update-types: [minor, patch] + + # The ClusterFuzzLite base image is pinned by digest. + - package-ecosystem: docker + directory: /.clusterfuzzlite + schedule: + interval: weekly + cooldown: + default-days: 7 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..f6f1892 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,39 @@ +name: CodeQL + +on: + push: + branches: [main] + pull_request: + branches: [main] + schedule: + - cron: "23 4 * * 1" + +permissions: {} + +jobs: + # The ruleset requires these by name: analyze (python), + # analyze (javascript-typescript) and analyze (actions). + analyze: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + strategy: + fail-fast: false + matrix: + language: [python, javascript-typescript, actions] + steps: + - uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: github/codeql-action/init@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + with: + languages: ${{ matrix.language }} + build-mode: none + - uses: github/codeql-action/analyze@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + with: + category: /language:${{ matrix.language }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ab5cec1..18e396f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,10 +24,13 @@ env: jobs: build: - if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' + if: github.event_name != 'workflow_run' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') runs-on: ubuntu-latest permissions: contents: read + env: + # The build otherwise reports usage to telemetry.astro.build. + ASTRO_TELEMETRY_DISABLED: 1 steps: - uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..7040a2c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Release + +on: + push: + tags: ["v*"] + +permissions: {} + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + attestations: write + env: + # The build otherwise reports usage to telemetry.astro.build. + ASTRO_TELEMETRY_DISABLED: 1 + steps: + - uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: stats + path: stats-data + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "22" + cache: npm + cache-dependency-path: site/package-lock.json + - name: Build the source tarball + run: git archive --format=tar.gz --prefix="devstream-$GITHUB_REF_NAME/" -o "devstream-$GITHUB_REF_NAME.tar.gz" "$GITHUB_SHA" + - run: npm ci --ignore-scripts + working-directory: site + - run: npm test + working-directory: site + - run: npm run build + working-directory: site + - name: Package the site + run: tar -czf "devstream-site-$GITHUB_REF_NAME.tar.gz" -C site/dist . + - uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2 + with: + subject-path: | + devstream-${{ github.ref_name }}.tar.gz + devstream-site-${{ github.ref_name }}.tar.gz + - name: Create the release + run: gh release create "$GITHUB_REF_NAME" --verify-tag --generate-notes "devstream-$GITHUB_REF_NAME.tar.gz" "devstream-site-$GITHUB_REF_NAME.tar.gz" + env: + GH_TOKEN: ${{ github.token }} diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 0000000..e25d3ea --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,42 @@ +name: Scorecard supply-chain security + +on: + # Re-score when the branch rules change, so the badge never lags them. + branch_protection_rule: + schedule: + - cron: "41 5 * * 2" + push: + branches: [main] + +permissions: {} + +jobs: + # publish_results makes the Scorecard API check this job: no env, no + # containers, and only its approved actions as steps. + analysis: + runs-on: ubuntu-latest + permissions: + # Upload the results to code scanning. + security-events: write + # Sign the published results for the badge and the API. + id-token: write + steps: + - uses: step-security/harden-runner@46b06cea07f9e64621fdf066ba77ac6915163d43 # v2.22.3 + with: + egress-policy: audit + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: ossf/scorecard-action@fa7117db83c52d787ae5a89f350999701505d78e # v2.5.0 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + - uses: github/codeql-action/upload-sarif@9b3254085494b55a0f7c4c2b3d2d52cc712ce370 # v4.39.1 + with: + sarif_file: results.sarif diff --git a/scripts/admin/setup_repo.sh b/scripts/admin/setup_repo.sh index 61bf3eb..bd97d1e 100755 --- a/scripts/admin/setup_repo.sh +++ b/scripts/admin/setup_repo.sh @@ -32,6 +32,7 @@ gh label create needs-review -R "$REPO" --color fbca04 --description "Needs a ma gh label create report -R "$REPO" --color d93f0b --description "Entry reported" --force >/dev/null gh label create superseded -R "$REPO" --color c5def5 --description "Reported as replaced by another repo" --force >/dev/null +# The analyze (...) contexts are CodeQL's matrix jobs. Scorecard isn't listed: it never runs on PRs. RULESET=$(cat <<'J' { "name": "main-protection", @@ -60,7 +61,10 @@ RULESET=$(cat <<'J' "required_status_checks": [ { "context": "validate", "integration_id": 15368 }, { "context": "test", "integration_id": 15368 }, - { "context": "lint", "integration_id": 15368 } + { "context": "lint", "integration_id": 15368 }, + { "context": "analyze (python)", "integration_id": 15368 }, + { "context": "analyze (javascript-typescript)", "integration_id": 15368 }, + { "context": "analyze (actions)", "integration_id": 15368 } ] } }, From f23714e41f9487c4b2ff2ee8b885f0bc55df9278 Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:15:53 -0700 Subject: [PATCH 4/6] docs(security): publish response times, scope and safe harbour Also adds the Scorecard badge to the README, now that it ships. --- README.md | 2 +- SECURITY.md | 49 ++++++++++++++++++++++++++++++++++++-- scripts/tests/test_docs.py | 2 +- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6435e35..220fb56 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ License: CC0 GitHub Discussions Website - + OpenSSF Scorecard

Awesome lists rot. That link someone merged in 2019 is still sitting there, long after the repo's last commit, and the star count beside it only tells you who got excited once. DevStream checks a repo before it lands and again every week. Then it ranks what survives by Likes, one per account. diff --git a/SECURITY.md b/SECURITY.md index 3bc4e69..2dba026 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,9 +1,54 @@ # Security policy -Found a vulnerability in DevStream? Please report it privately, not in a public issue, discussion or pull request. +Found a way to break DevStream, or to bend its rankings? Tell us privately first. A public issue hands the trick to everyone before we can close it. + +## Supported versions + +We fix security problems on `main` and in the latest release. Older releases don't get patches; the fix lands in the next one. + +| Version | Supported | +| -------------- | --------- | +| `main` | Yes | +| Latest release | Yes | +| Anything older | No | + +## Reporting a vulnerability + +We use GitHub's private vulnerability reporting, so there's no email address to hunt for. 1. Open the [Security tab](https://github.com/devstreamhq/devstream/security) of this repo. 2. Select **Report a vulnerability**. 3. Tell us what you found, how to reproduce it and what an attacker could do with it. -Only the maintainers can see your report. We'll reply in the advisory and keep you posted while we work on a fix. +Only you and the maintainers can see the report. We talk it through in the advisory, and you can watch the fix take shape there. + +## What happens next + +- **Within 48 hours**, we acknowledge your report. +- **Within 7 days**, you get our first assessment: whether we can reproduce it, how serious we think it is and what we plan to do. +- **Within 90 days**, we fix it and publish the advisory together. If a fix needs longer, we'll say why and agree a new date with you rather than go quiet. + +We credit you in the advisory unless you'd rather we didn't. + +## What's in scope + +- **The bot and its workflows.** Anything in `scripts/` or `.github/workflows/` that lets someone run code, read secrets, write to the repo or push the bot into a decision it shouldn't make. +- **The site.** Script injection, broken escaping of entry data, or anything that turns the leaderboard against the people reading it. +- **Data integrity.** Ranking manipulation counts. If you can get an entry listed past the quality bar, keep one alive that should be removed, or remove someone else's, we want to hear about it. +- **Likes gaming.** A way to inflate Likes that slips past the burst check and the trust rule is a vulnerability, even when no code misbehaves. + +## What's out of scope + +The repos listed on DevStream belong to their own maintainers. If you find a hole in one of them, report it to that project through its own security policy. If a listed repo is malicious, use the report form on its entry and we'll pull it. + +Denial of service by flooding the issue tracker, and findings that need a compromised maintainer account, are out of scope too. + +## Safe harbour + +Research in good faith is welcome here. If you follow this policy, we won't pursue legal action or ask anyone else to, and we'll treat your work as authorised. Good faith means you: + +- test against your own accounts and test repos, not other people's entries or Likes, +- stop as soon as you've shown the problem, and don't keep or share data that isn't yours, +- give us the time above before going public. + +Not sure whether something is covered? Ask in the advisory before you try it. We'd much rather answer a question than read about it later. diff --git a/scripts/tests/test_docs.py b/scripts/tests/test_docs.py index f9a8e76..81ff0b2 100644 --- a/scripts/tests/test_docs.py +++ b/scripts/tests/test_docs.py @@ -15,7 +15,7 @@ "realm", "navigate", "landscape", "in today's fast-paced world", "in an era of", ] # Not shipped yet, so no page may claim them. -UNSHIPPED = re.compile(r"\bsponsor|\bopenssf\b|\bscorecard\b|\bbest practices badge\b", re.I) +UNSHIPPED = re.compile(r"\bsponsor|\bbest practices badge\b", re.I) NOT_JUST = re.compile(r"\b(?:it|this|that)(?:'s|’s| is) not just\b", re.I) LINK = re.compile(r"\]\(([^)\s]+)\)|(?:src|srcset|href)=\"([^\"]+)\"") COMMENT = re.compile(r"", re.S) From e57b9f71a5357e73982fd3872741da4cc05cc1a9 Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:32:18 -0700 Subject: [PATCH 5/6] fix(description): strip every default-ignorable and Hangul filler Only Cf characters were stripped, so a blocked word split by U+180B, U+3164, U+115F or a tag variation selector got through. Strip an explicit Default_Ignorable_Code_Point table on both sides of NFKC, which maps U+3164 and U+FFA0 onto U+1160. A bare "www" is a word again: only "www." followed by a name is a link. --- fuzz/fuzz_description.py | 20 ++++++++++++++++++-- scripts/devstream/description.py | 21 ++++++++++++++++----- scripts/tests/test_description.py | 14 +++++++++++++- 3 files changed, 47 insertions(+), 8 deletions(-) diff --git a/fuzz/fuzz_description.py b/fuzz/fuzz_description.py index bd8df26..74cdfe5 100644 --- a/fuzz/fuzz_description.py +++ b/fuzz/fuzz_description.py @@ -14,16 +14,32 @@ with atheris.instrument_imports(include=["scripts"]): from scripts.devstream import license_detect - from scripts.devstream.description import FORBIDDEN, MAX_LEN, MIN_LEN, clean_description + from scripts.devstream.description import FORBIDDEN, IGNORABLE, MAX_LEN, MIN_LEN, VARIATION, clean_description + + +# Invisible characters people use to slip a blocked word past the filter. +SNEAKY = [ + "\u00ad", "\u034f", "\u061c", "\u115f", "\u1160", "\u17b4", "\u180b", "\u180e", "\u200b", + "\u200d", "\u202e", "\u2060", "\u2062", "\u3164", "\ufe08", "\ufe0f", "\ufeff", "\uffa0", + "\ufff0", "\U0001bca0", "\U0001d173", "\U000e0001", "\U000e0100", "\u2728", +] def TestOneInput(data: bytes) -> None: - text = atheris.FuzzedDataProvider(data).ConsumeUnicodeNoSurrogates(len(data)) + fdp = atheris.FuzzedDataProvider(data) + if fdp.ConsumeBool(): + text = fdp.ConsumeUnicodeNoSurrogates(fdp.remaining_bytes()) + else: + text = "".join( + fdp.PickValueInList(SNEAKY) if fdp.ConsumeBool() else fdp.ConsumeUnicodeNoSurrogates(8) + for _ in range(fdp.ConsumeIntInRange(0, 40)) + ) final, why = clean_description(text) assert (final is None) != (why is None), (final, why) if final is not None: assert MIN_LEN <= len(final) <= MAX_LEN, final assert not FORBIDDEN & set(final), final + assert not IGNORABLE.search(final) and not VARIATION.search(final), final assert clean_description(final) == (final, None), final license_detect._spdx_scan("SPDX-License-Identifier: " + text) license_detect._readme_license("## License\n\n" + text) diff --git a/scripts/devstream/description.py b/scripts/devstream/description.py index 83fc40c..dd5aae2 100644 --- a/scripts/devstream/description.py +++ b/scripts/devstream/description.py @@ -14,9 +14,19 @@ ADDRESS_TAIL = re.compile(r"/|[:?]\S") +# Default_Ignorable_Code_Point plus the Hangul fillers. The stdlib has no property +# regex, so this is the table. U+FE00-FE0F is left to VARIATION: the emoji-run +# check needs to see them first. +IGNORABLE = re.compile( + "[\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180f\u200b-\u200f\u202a-\u202e" + "\u2060-\u206f\u3164\ufeff\uffa0\ufff0-\ufff8\U0001bca0-\U0001bca3\U0001d173-\U0001d17a" + "\U000e0000-\U000e0fff]" +) + + def _strip_invisible(s: str) -> str: - # Cf covers zero-width, soft hyphen, invisible operators and U+180E; U+034F is Mn. - return "".join(c for c in s if unicodedata.category(c) != "Cf" and c != "\u034f") + # Cf also covers format characters outside the table, such as U+0600-0605. + return IGNORABLE.sub("", "".join(c for c in s if unicodedata.category(c) != "Cf")) def _load_blocklist() -> list[str]: @@ -48,7 +58,7 @@ def _mixed_script(t: str) -> bool: def _has_url(t: str) -> bool: t = t.replace("。", ".") - if re.search(r"https?://|www\.", t, re.I): + if re.search(r"https?://|www\.(?=\w)", t, re.I): return True if IPV4.search(t): return True @@ -72,7 +82,8 @@ def _emoji_run_too_long(t: str) -> bool: def clean_description(text: str) -> tuple[str | None, str | None]: # U+FE0F is kept through the emoji check, then dropped before matching. - t = " ".join(_strip_invisible(unicodedata.normalize("NFKC", text)).split()) + # Strip on both sides of NFKC: it maps U+3164 and U+FFA0 onto the U+1160 filler. + t = " ".join(_strip_invisible(unicodedata.normalize("NFKC", _strip_invisible(text))).split()) if len(t) < MIN_LEN: return None, f"Descriptions need to be between {MIN_LEN} and {MAX_LEN} characters." if _emoji_run_too_long(t): @@ -83,7 +94,7 @@ def clean_description(text: str) -> tuple[str | None, str | None]: # would be stored at 141, and "Toolkit!!!" shrinks to an 8-character "Toolkit.". if not MIN_LEN <= len(final) <= MAX_LEN: return None, f"Descriptions need to be between {MIN_LEN} and {MAX_LEN} characters." - # Check the text we store: the added period turns a trailing "www" into "www.". + # Check the text we store, so validate_data's re-check reaches the same answer. t = final if _mixed_script(t): return None, "Please use one alphabet per word." diff --git a/scripts/tests/test_description.py b/scripts/tests/test_description.py index 37893b8..475bcd7 100644 --- a/scripts/tests/test_description.py +++ b/scripts/tests/test_description.py @@ -48,7 +48,7 @@ def test_output_is_a_fixed_point(self): "y" * 139, "z" * 140, "w" * 139 + ".", "v" * 141, "short", "abcdefghi!", "abcdefghij!", "Mixed ending?.!", "Tabs\tand\nnewlines in it", "Dots... in the middle... end...", "Questions? Yes, answered here?", "Ending with spaces and bang ! ", - # The added period turns a trailing "www" into "www.", a link on the re-check. + # The added period turns a trailing "www" into "www.", which must not read as a link. "A short history of the www", "Mirror of the WWW!", ] self.assertGreaterEqual(len(inputs), 30) @@ -167,6 +167,18 @@ def test_invisible_characters_stripped(self): for ch in ("\u00ad", "\u2062", "\u034f", "\u180e", "\ufe0f"): bad(f"Free po{ch}rn tool for the web") + def test_default_ignorables_and_hangul_fillers_stripped(self): + # Not all of these are Cf, and NFKC turns U+3164 and U+FFA0 into U+1160. + for ch in ("\U000e0100", "\u180b", "\u3164", "\u115f", "\u1160", "\uffa0", "\u061c", + "\u17b4", "\U0001bca0", "\U0001d173", "\ufff0", "\U000e0001"): + with self.subTest(ch=hex(ord(ch))): + bad(f"Free po{ch}rn tool for the web") + + def test_bare_www_is_a_word_not_a_link(self): + self.assertEqual(ok("A short history of the www"), "A short history of the www.") + self.assertEqual(ok("Mirror of the WWW!"), "Mirror of the WWW.") + bad("Docs live at www.example for now") + def test_emoji_run_with_variation_selector(self): bad("Stars \u2728\ufe0f\u2728\ufe0f\u2728\ufe0f everywhere here") ok("Stars \u2728\ufe0f\u2728\ufe0f everywhere here") From 852eab16d0a07c47395ced1f5674438ee657f36b Mon Sep 17 00:00:00 2001 From: jamesconwaydev <148910373+jamesconwaydev@users.noreply.github.com> Date: Thu, 5 Nov 2026 18:32:18 -0700 Subject: [PATCH 6/6] ci(security): guard release tags and require clean CodeQL results - release-tags ruleset: only admins create, move or delete v* tags. - main-protection blocks merges on CodeQL errors or high alerts. - Release builds skip the npm cache; Dependabot leaves wrangler alone. - SECURITY.md promises only what the process does. --- .github/dependabot.yml | 4 ++++ .github/workflows/release.yml | 2 -- SECURITY.md | 18 +++++++------- scripts/admin/setup_repo.sh | 44 ++++++++++++++++++++++++++++++----- 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fdfa9dd..7db416d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,6 +28,10 @@ updates: directory: /site schedule: interval: weekly + # Wrangler is pinned in three places (site/package.json, its lockfile and + # WRANGLER_VERSION in deploy.yml), so we bump it by hand to keep them in step. + ignore: + - dependency-name: wrangler cooldown: default-days: 7 groups: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7040a2c..6e9be67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,8 +31,6 @@ jobs: - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: "22" - cache: npm - cache-dependency-path: site/package-lock.json - name: Build the source tarball run: git archive --format=tar.gz --prefix="devstream-$GITHUB_REF_NAME/" -o "devstream-$GITHUB_REF_NAME.tar.gz" "$GITHUB_SHA" - run: npm ci --ignore-scripts diff --git a/SECURITY.md b/SECURITY.md index 2dba026..0f037b6 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -20,26 +20,24 @@ We use GitHub's private vulnerability reporting, so there's no email address to 2. Select **Report a vulnerability**. 3. Tell us what you found, how to reproduce it and what an attacker could do with it. -Only you and the maintainers can see the report. We talk it through in the advisory, and you can watch the fix take shape there. +Only you and the maintainers can see the report, and we'll talk it through with you in the advisory. ## What happens next -- **Within 48 hours**, we acknowledge your report. -- **Within 7 days**, you get our first assessment: whether we can reproduce it, how serious we think it is and what we plan to do. -- **Within 90 days**, we fix it and publish the advisory together. If a fix needs longer, we'll say why and agree a new date with you rather than go quiet. +We acknowledge every report within 48 hours. Within 7 days you get our first assessment: whether we can reproduce it, how serious we think it is and what we plan to do. Disclosure is coordinated with you and happens within 90 days of your report. -We credit you in the advisory unless you'd rather we didn't. +We'll credit you in the advisory if you'd like. ## What's in scope -- **The bot and its workflows.** Anything in `scripts/` or `.github/workflows/` that lets someone run code, read secrets, write to the repo or push the bot into a decision it shouldn't make. -- **The site.** Script injection, broken escaping of entry data, or anything that turns the leaderboard against the people reading it. -- **Data integrity.** Ranking manipulation counts. If you can get an entry listed past the quality bar, keep one alive that should be removed, or remove someone else's, we want to hear about it. -- **Likes gaming.** A way to inflate Likes that slips past the burst check and the trust rule is a vulnerability, even when no code misbehaves. +- The bot and its workflows: anything in `scripts/` or `.github/workflows/` that lets someone run code, read secrets, write to the repo or push the bot into a decision it shouldn't make. +- The site: script injection, broken escaping of entry data, or anything that turns the leaderboard against the people reading it. +- Data integrity, because ranking manipulation counts. If you can get an entry listed past the quality bar, keep one alive that should be removed, or remove someone else's, we want to hear about it. +- Likes gaming. A way to inflate Likes that slips past the burst check and the trust rule is a vulnerability, even when no code misbehaves. ## What's out of scope -The repos listed on DevStream belong to their own maintainers. If you find a hole in one of them, report it to that project through its own security policy. If a listed repo is malicious, use the report form on its entry and we'll pull it. +The repos listed on DevStream belong to their own maintainers. If you find a hole in one of them, report it to that project through its own security policy. If a listed repo is malicious, use the [Report an entry](https://github.com/devstreamhq/devstream/issues/new?template=report-entry.yml) form and pick "Malicious". A report from an established account hides the entry while we look. Denial of service by flooding the issue tracker, and findings that need a compromised maintainer account, are out of scope too. diff --git a/scripts/admin/setup_repo.sh b/scripts/admin/setup_repo.sh index bd97d1e..0c88697 100755 --- a/scripts/admin/setup_repo.sh +++ b/scripts/admin/setup_repo.sh @@ -68,6 +68,14 @@ RULESET=$(cat <<'J' ] } }, + { + "type": "code_scanning", + "parameters": { + "code_scanning_tools": [ + { "tool": "CodeQL", "alerts_threshold": "errors", "security_alerts_threshold": "high_or_higher" } + ] + } + }, { "type": "required_linear_history" }, { "type": "non_fast_forward" }, { "type": "deletion" } @@ -76,12 +84,36 @@ RULESET=$(cat <<'J' J ) -ID=$(gh api "repos/$REPO/rulesets" --jq '.[] | select(.name=="main-protection") | .id') -if [ -n "$ID" ]; then - echo "$RULESET" | gh api -X PUT "repos/$REPO/rulesets/$ID" --input - >/dev/null -else - echo "$RULESET" | gh api -X POST "repos/$REPO/rulesets" --input - >/dev/null -fi +# A v* tag triggers release.yml, so only admins may create, move or delete one. +TAG_RULESET=$(cat <<'J' +{ + "name": "release-tags", + "target": "tag", + "enforcement": "active", + "conditions": { "ref_name": { "include": ["refs/tags/v*"], "exclude": [] } }, + "bypass_actors": [ + { "actor_id": 5, "actor_type": "RepositoryRole", "bypass_mode": "always" } + ], + "rules": [ + { "type": "creation" }, + { "type": "update" }, + { "type": "deletion" } + ] +} +J +) + +upsert_ruleset() { + local id + id=$(gh api "repos/$REPO/rulesets" --jq ".[] | select(.name==\"$1\") | .id") + if [ -n "$id" ]; then + echo "$2" | gh api -X PUT "repos/$REPO/rulesets/$id" --input - >/dev/null + else + echo "$2" | gh api -X POST "repos/$REPO/rulesets" --input - >/dev/null + fi +} +upsert_ruleset main-protection "$RULESET" +upsert_ruleset release-tags "$TAG_RULESET" # Last: fails while the org forbids Actions approving PRs (org setting). gh api -X PUT "repos/$REPO/actions/permissions/workflow" \ -f default_workflow_permissions=read \