Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
9 changes: 9 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: python
47 changes: 47 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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
# 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:
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
38 changes: 38 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -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 }}
39 changes: 39 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 4 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
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"
- 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 }}
42 changes: 42 additions & 0 deletions .github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<a href="LICENSE"><img src="https://img.shields.io/badge/license-CC0-blue" alt="License: CC0"></a>
<a href="https://github.com/devstreamhq/devstream/discussions"><img src="https://img.shields.io/github/discussions/devstreamhq/devstream" alt="GitHub Discussions"></a>
<a href="https://devstream.jamesconway.dev"><img src="https://img.shields.io/website?url=https%3A%2F%2Fdevstream.jamesconway.dev" alt="Website"></a>
<!-- OpenSSF badges (Scorecard, Best Practices) go here in Task 16. -->
<a href="https://scorecard.dev/viewer/?uri=github.com/devstreamhq/devstream"><img src="https://api.scorecard.dev/projects/github.com/devstreamhq/devstream/badge" alt="OpenSSF Scorecard"></a>
</p>

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.
Expand Down
47 changes: 45 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
# 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, and we'll talk it through with you in the advisory.

## What happens next

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'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, 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 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.

## 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.
54 changes: 54 additions & 0 deletions fuzz/fuzz_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
"""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, 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:
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)


def main() -> None:
atheris.Setup(sys.argv, TestOneInput)
atheris.Fuzz()


if __name__ == "__main__":
main()
Loading
Loading