diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba6db64..c5c1cc0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,9 +29,10 @@ on: pull_request: push: branches: [main] - # Lets quarantine.yml run the required checks on the PR it opens: a PR - # created with GITHUB_TOKEN triggers no `pull_request` workflows, but a - # `workflow_dispatch` is the documented exception (docs/12 §4). + # Lets quarantine.yml and vt-recheck.yml run the required checks on the PRs + # they open. A PR created with GITHUB_TOKEN gets `pull_request` runs that + # wait for a maintainer's approval (GitHub, since 2026-06-11); a + # `workflow_dispatch` always runs (docs/12 §4). workflow_dispatch: # Explicit least privilege. This repository's default workflow token is diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index eef1e98..47cacfc 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -14,8 +14,9 @@ on: pull_request: schedule: - cron: '31 3 * * 1' - # quarantine.yml dispatches this on the PR it opens (GITHUB_TOKEN-created PRs - # trigger no pull_request runs, so the required check would never appear). + # quarantine.yml and vt-recheck.yml dispatch this on the PRs they open: a + # GITHUB_TOKEN-created PR's pull_request runs wait for approval (GitHub, + # since 2026-06-11), so the required check would not appear on its own. workflow_dispatch: # Required matrix — security-events: write is what lets results upload. diff --git a/.github/workflows/quarantine.yml b/.github/workflows/quarantine.yml index b6175c7..8958d29 100644 --- a/.github/workflows/quarantine.yml +++ b/.github/workflows/quarantine.yml @@ -6,10 +6,12 @@ # checks still apply. # # Fixed 2026-10-21 (audit): -# - A PR opened with GITHUB_TOKEN triggers no `pull_request` workflows, so its -# required checks (build, gates, codeql) never ran and it could not merge. -# The job now dispatches ci.yml and codeql.yml on the PR branch — -# `workflow_dispatch` is the documented exception to that rule. +# - A PR opened with GITHUB_TOKEN triggered no `pull_request` workflows, so +# its required checks (build, gates, codeql) never ran and it could not +# merge. The job dispatches ci.yml and codeql.yml on the PR branch — +# `workflow_dispatch` always runs. (Since GitHub's 2026-06-11 change such +# a PR does get `pull_request` runs, but they wait for a maintainer's +# approval, so the dispatch is still what makes the checks appear.) # - The ruleset requires signed commits: create-pull-request now signs via the # API (`sign-commits`). # - Every nightly run re-opened `[quarantine] ` issues while the PR was diff --git a/.github/workflows/vt-recheck.yml b/.github/workflows/vt-recheck.yml new file mode 100644 index 0000000..ef33c9f --- /dev/null +++ b/.github/workflows/vt-recheck.yml @@ -0,0 +1,200 @@ +# docs/12 §4b — VirusTotal re-check (docs/09 §6 step 5, assisted). +# +# Daily on main: scripts/vt-recheck.mjs re-scans the entries whose check is +# due and the bot opens — or updates — ONE pull request, `vt/recheck`. While +# that PR is open, each run first carries its results over, so the next day +# continues with the next entries instead of re-scanning the same stalest +# ones (main still shows them as stale until the PR merges). A detection +# never flags anything: a `clean` entry becomes `unverified` and gets a +# tracking issue, and the maintainer decides (quarantine stays a reviewed +# `pnpm quarantine`, hard rule 5). +# +# Dispatched on any other branch it is a PREVIEW: it scans only the listed +# slugs — or, with none, the entries that were never scanned, i.e. a data +# PR's new apps — and uploads the patched files as the `vt-preview` artifact +# for the maintainer to review and commit. No PR, no issues. +# +# VirusTotal's Public API allows 4 requests a minute and 500 a day (reset at +# 00:00 UTC, hence the schedule). The script paces itself, spends at most the +# `budget`, and stops cleanly at the quota; the next run continues. The +# concurrency group keeps two runs from sharing the key's per-minute limit. +name: vt-recheck + +on: + schedule: + - cron: '41 0 * * *' + workflow_dispatch: + inputs: + slugs: + description: 'Slugs to scan first, space or comma separated (on a branch other than main: only these, or the never-scanned when empty)' + required: false + default: '' + promote: + description: "Slugs to move unverified → clean IF their scan comes back clean — the maintainer's docs/09 §6 call" + required: false + default: '' + max_age: + description: 'Re-scan checks older than this many days' + required: false + default: '90' + budget: + description: 'VirusTotal requests this run may spend (500/day; each URL costs at least 2)' + required: false + default: '440' + +permissions: + contents: read + +concurrency: + group: vt-recheck + cancel-in-progress: false + +jobs: + recheck: + runs-on: ubuntu-latest + # 440 requests at 15.5 s each is about two hours. + timeout-minutes: 150 + permissions: + contents: write # create-pull-request commits to vt/recheck + pull-requests: write # …and opens or updates the PR + issues: write # one tracking issue per detection + actions: write # dispatch the required checks onto the PR branch + steps: + # No persisted token while repository code runs; create-pull-request + # authenticates with its own `token` input. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version-file: .nvmrc + + # Only an OPEN pull request's results are carried: the repository + # deletes merged branches, and a PR closed without merging was a + # rejection, never to be re-adopted. + - name: Carry the open re-check PR + id: carry + if: github.ref == 'refs/heads/main' + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + open=$(gh pr list --repo "$GITHUB_REPOSITORY" --head vt/recheck --state open --json number --jq 'length') + if [ "$open" = "0" ]; then + echo "No open re-check PR — nothing to carry." + exit 0 + fi + git fetch --no-tags --depth=1 origin vt/recheck + mkdir -p "$RUNNER_TEMP/carry" + git archive FETCH_HEAD src/data/apps | tar -x -C "$RUNNER_TEMP/carry" + echo "dir=$RUNNER_TEMP/carry/src/data/apps" >> "$GITHUB_OUTPUT" + + # Everything reaches the script through env (never `${{ }}` inside + # `run:`); it validates slugs and numbers itself. + - name: Re-check on VirusTotal + id: scan + env: + VT_API_KEY: ${{ secrets.VT_API_KEY }} + VT_SLUGS: ${{ inputs.slugs }} + VT_PROMOTE: ${{ inputs.promote }} + VT_MAX_AGE: ${{ inputs.max_age }} + VT_BUDGET: ${{ inputs.budget }} + VT_ONLY_LISTED: ${{ github.ref != 'refs/heads/main' && '1' || '' }} + VT_CARRY: ${{ steps.carry.outputs.dir }} + VT_SUMMARY: ${{ runner.temp }}/vt-summary.md + VT_REVIEW_JSON: ${{ runner.temp }}/vt-review.json + run: node scripts/vt-recheck.mjs + + - name: Job summary + if: always() + run: | + if [ -f "$RUNNER_TEMP/vt-summary.md" ]; then + cat "$RUNNER_TEMP/vt-summary.md" >> "$GITHUB_STEP_SUMMARY" + fi + + # ── preview (any branch but main) ───────────────────────────────────── + - name: Collect the preview + if: github.ref != 'refs/heads/main' && steps.scan.outputs.changed != '0' + run: | + set -euo pipefail + mkdir -p "$RUNNER_TEMP/vt-preview" + git diff --name-only -- src/data/apps | while read -r f; do + cp --parents "$f" "$RUNNER_TEMP/vt-preview/" + done + cp "$RUNNER_TEMP/vt-summary.md" "$RUNNER_TEMP/vt-preview/" + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + if: github.ref != 'refs/heads/main' && steps.scan.outputs.changed != '0' + with: + name: vt-preview + path: ${{ runner.temp }}/vt-preview/ + retention-days: 7 + + # ── main: one accumulating PR ───────────────────────────────────────── + # NOTE: requires Settings → Actions → General → "Allow GitHub Actions to + # create and approve pull requests" (H10 — enabled for quarantine.yml). + - id: cpr + if: github.ref == 'refs/heads/main' && steps.scan.outputs.changed != '0' + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 + with: + branch: vt/recheck + add-paths: src/data/apps + sign-commits: true + title: 'data: VirusTotal re-check' + commit-message: 'data: refresh VirusTotal scans' + labels: security + body-path: ${{ runner.temp }}/vt-summary.md + + # A PR opened with GITHUB_TOKEN gets `pull_request` runs that wait for a + # maintainer's approval; `workflow_dispatch` always runs. Dispatch only + # when the branch actually moved. + - name: Run the required checks on the PR branch + if: steps.cpr.outputs.pull-request-operation == 'created' || steps.cpr.outputs.pull-request-operation == 'updated' + env: + GH_TOKEN: ${{ github.token }} + BRANCH: ${{ steps.cpr.outputs.pull-request-branch }} + run: | + set -euo pipefail + gh workflow run ci.yml --repo "$GITHUB_REPOSITORY" --ref "$BRANCH" + gh workflow run codeql.yml --repo "$GITHUB_REPOSITORY" --ref "$BRANCH" + + - name: Open one tracking issue per entry with detections + if: github.ref == 'refs/heads/main' && steps.scan.outputs.review != '' + env: + GH_TOKEN: ${{ github.token }} + REVIEW_JSON: ${{ runner.temp }}/vt-review.json + run: | + set -euo pipefail + jq -c '.[]' "$REVIEW_JSON" | while read -r row; do + slug=$(jq -r '.slug' <<<"$row") + # Same shape validate:data enforces on filenames; anything else is + # not ours and must not reach a command or an issue title. + if ! [[ "$slug" =~ ^[a-z0-9]+(-[a-z0-9]+)*$ ]]; then + echo "::warning::skipping unexpected slug '$slug'" + continue + fi + title="[vt] $slug" + # " }`. You do not need a VirusTotal key: the maintainer +dispatches `vt-recheck.yml` on the PR branch, which scans the new entry's +download page and records the permalink, and only the maintainer moves an +entry to `clean` (docs/09 §6). If you change an existing entry's +`links.download`, the old scan no longer describes it — say so in the PR. + If you are unsure whether something is wanted, open a discussion first. A short question costs everyone less than a large rejected PR. diff --git a/docs/03_DATA_FLOW.md b/docs/03_DATA_FLOW.md index 762636e..dd01104 100644 --- a/docs/03_DATA_FLOW.md +++ b/docs/03_DATA_FLOW.md @@ -80,9 +80,12 @@ of 2026-10-21; `pnpm build` then checks the output — docs/02 §4): ## 4. Update & re-verification flow - Editing an app = PR touching its one file; bump `updatedAt`. -- Monthly batch (docs/13 §6): oldest `security.checkedAt` entries get - re-vetted; refresh `checkedAt` even when nothing changed — the dated - status is the product's honesty mechanism. +- Re-checks are automated since 2026-10-23 (docs/12 §4b): `vt-recheck.yml` + re-scans every entry whose `checkedAt` is older than 90 days, a few + hundred requests a day within VirusTotal's Public API limits, into one + accumulating PR. It refreshes `checkedAt` even when nothing changed — the + dated status is the product's honesty mechanism — and turns any detection + into `unverified` plus an issue, never into a flag. ## 5. Quarantine state machine (hard rules 4–5) diff --git a/docs/04_DATA_SCHEMA.md b/docs/04_DATA_SCHEMA.md index 556afea..4f672fe 100644 --- a/docs/04_DATA_SCHEMA.md +++ b/docs/04_DATA_SCHEMA.md @@ -104,7 +104,7 @@ duplicates, link provenance, invisible characters, quarantine) are L2, | `links.download` | https URL | Official download page (page, not direct binary, when both exist). | | `security.status` | enum | `unverified` (default at entry) · `clean` (vetting checklist passed, docs/09 §6) · `flagged` (blocks listing → quarantine, docs/03 §5). | | `security.evidence` | https URL \| null | VirusTotal scan of the download page/file, or vendor advisory. **Required by the schema when `clean` or `flagged`** (since v1.1); optional for `unverified`, though held entries carry theirs too. Linked from the detail page ("View scan", docs/06 §5). | -| `security.checkedAt` | date | Date the status was last verified — rendered on the card ("checked 30 Jul 2026"). A real date, not in the future; `validate:data` warns once it is older than 180 days. | +| `security.checkedAt` | date | Date of the latest scan behind the status — rendered on the card ("checked 30 Jul 2026"). The full docs/09 §6 checklist runs when an entry is first marked `clean` and whenever its links change; `vt-recheck.yml` re-scans at least every 90 days and moves this date (never `addedAt`/`updatedAt`). A real date, not in the future; `validate:data` warns once it is older than 180 days. | | `addedAt` / `updatedAt` | date | Drive RSS, the "Newest" sort and category-page order. Real dates, not in the future; `updatedAt` ≥ `addedAt`. | ## 3. Pricing semantics (rulings) diff --git a/docs/09_SECURITY_PRIVACY.md b/docs/09_SECURITY_PRIVACY.md index 69f0ef1..a3413c9 100644 --- a/docs/09_SECURITY_PRIVACY.md +++ b/docs/09_SECURITY_PRIVACY.md @@ -289,8 +289,11 @@ apps themselves* → report to their vendors, but tell us too so we can flag. ## 6. Data-vetting checklist (before `security.status: "clean"`) -Run all steps; record date in `checkedAt`; link scan in `evidence` when -available. This checklist is the *definition* of "clean". +Run all steps before an entry is first marked `clean`, and again whenever +its links change; link the scan in `evidence`. This checklist is the +*definition* of "clean". Since 2026-10-23 `checkedAt` is the date of the +**latest scan** (step 5): `vt-recheck.yml` re-runs that step at least every 90 +days and moves the date, while steps 1–4 stay with the maintainer (D30). 1. **Domain authenticity** — homepage/download domain matches the vendor's known official domain (cross-check the project's repo, Wikipedia infobox, @@ -303,10 +306,18 @@ available. This checklist is the *definition* of "clean". 4. **Installer hygiene** — release notes/installer page shows no bundled third-party offers; if the vendor publishes checksums/signatures, note that on the entry's `tags` (`signed-releases`) — optional. -5. **VirusTotal (when feasible)** — scan the download-page URL; for - directly-linked binaries of less-known apps, scan the file. Paste the - permalink into `evidence` — **required**: since v1.1 the schema refuses - `clean` (and `flagged`) without an `evidence` URL (docs/04 §2). +5. **VirusTotal** — scan the download-page URL; for directly-linked + binaries of less-known apps, scan the file. The permalink goes into + `evidence` — **required**: since v1.1 the schema refuses `clean` (and + `flagged`) without an `evidence` URL (docs/04 §2). **Assisted since + 2026-10-23** (docs/12 §4b): `scripts/vt-recheck.mjs` submits + `links.download` through the VirusTotal API and writes the permalink and + date; dispatched on a data branch it scans a PR's new entries before + merge, and daily on `main` it re-scans every check older than 90 days. It + never decides `clean` or `flagged`: zero detections keep the status, any + detection drops `clean` to `unverified` and opens a `[vt] ` issue, + and a promotion to `clean` happens only for slugs the maintainer lists + (`promote`). 6. **Judgment call** — anything uneasy ⇒ leave `unverified` (listable) or `flagged` (quarantine) — never "clean by default". diff --git a/docs/12_CI_CD.md b/docs/12_CI_CD.md index 847dccf..499e500 100644 --- a/docs/12_CI_CD.md +++ b/docs/12_CI_CD.md @@ -318,7 +318,7 @@ jobs: labels: security, quarantine - if: steps.cpr.outputs.pull-request-branch != '' env: { GH_TOKEN: '${{ github.token }}', BRANCH: '${{ steps.cpr.outputs.pull-request-branch }}' } - run: | # a GITHUB_TOKEN PR triggers no workflows + run: | # a GITHUB_TOKEN PR's own runs wait for approval gh workflow run ci.yml --ref "$BRANCH" gh workflow run codeql.yml --ref "$BRANCH" - if: steps.sweep.outputs.moved != '' @@ -340,10 +340,13 @@ cron guarantees a flagged entry never survives more than 24 h even if a PR reviewer missed it. Normally it never fires: `validate:data` fails a PR that flags an entry without moving it. -Hardened 2026-10-21: a PR opened with `GITHUB_TOKEN` triggers no +Hardened 2026-10-21: a PR opened with `GITHUB_TOKEN` triggered no `pull_request` workflows, so its required checks never ran and it could not merge — the job now dispatches `ci.yml` and `codeql.yml` on the PR branch -(`workflow_dispatch` is the documented exception). The commit is **signed** +(`workflow_dispatch` always runs). *Corrected 2026-10-23:* since GitHub's +2026-06-11 change such a PR **does** get `pull_request` runs, but they wait +for a maintainer's approval — the dispatch stays, and approving those runs +would only duplicate CI. The commit is **signed** via the API (`sign-commits`). Issues are created only when none is open (every nightly run used to re-open them). Step outputs reach shell bodies only through `env:`, never `${{ }}` inside `run:` (expression injection). @@ -354,6 +357,59 @@ only through `env:`, never `${{ }}` inside `run:` (expression injection). Actions to create and approve pull requests*** is enabled. Without it the nightly sweep silently cannot open its PR, which defeats hard rule 5. +## 4b. VirusTotal re-check (repo-local) + +`.github/workflows/vt-recheck.yml` + `scripts/vt-recheck.mjs` (added +2026-10-23, D30) — docs/09 §6 step 5 made assisted, so no dated security +claim can go stale unnoticed. Every check in the v1.0 catalogue was dated +2026-07-30, so all 326 would have crossed `validate:data`'s 180-day warning +together on 2027-01-27. + +- **What it scans:** each entry's `links.download` page — the URL every + recorded scan was of (318 of 326 evidence ids equal the SHA-256 of that + link's canonical form; 8 had drifted to a newer link). `POST /urls` + submits it, a second pass reads `GET /analyses/{id}`, and the permalink is + `https://www.virustotal.com/gui/url/`. +- **What it writes:** only the three `security` lines, patched in place so + Prettier's layout survives; never `addedAt`/`updatedAt` — the feed orders + by `addedAt`, and notify.py announces anything it has not seen. +- **The rules:** zero malicious/suspicious ⇒ fresh `evidence` + `checkedAt`, + status unchanged; any detection ⇒ `clean` becomes `unverified` and a + `[vt] ` issue (label `security`) asks the maintainer to decide; + `promote` slugs go `unverified` → `clean` only on a clean scan. It never + sets `flagged` — quarantine stays a human `pnpm quarantine` (§4). An + analysis in which no engine answered is "not checked", not clean. +- **Who is due:** the `slugs` input first, then never-scanned entries, then + drifted evidence (at most weekly), then checks older than `max_age` + (default 90 days), oldest first. +- **Limits:** the Public API allows 4 requests a minute and 500 a day, and + counts every call. The script paces at 15.5 s, spends at most `budget` + (default 440, capped at 500) with no more than half of it on submissions, + backs off 60 s once on a 429 and treats a second as the day's quota — + keeping what it finished. A refused key fails the step; a missing key + (forks, Dependabot) is a no-op that says so. `concurrency: vt-recheck` + keeps two runs off one key. The schedule, 00:41 UTC, follows the daily + quota reset. +- **On `main` (daily cron, or dispatch):** one PR, `vt/recheck`, opened by + `peter-evans/create-pull-request` with `add-paths: src/data/apps` and + API-signed commits. While it is open, each run first **carries** its + results (`git archive` of the branch into `$RUNNER_TEMP`; a block is + adopted only if its download link is unchanged and its check is newer), so + the PR accumulates day by day instead of re-scanning the same entries. The + repository deletes merged branches, and a PR closed unmerged is never + carried. CI is dispatched on the branch when the action created or updated + the PR (same reason as §4). +- **On any other branch (preview):** dispatch `vt-recheck.yml --ref + ` and it scans only the `slugs` given — or, with none, the entries + without a scan, i.e. a data PR's new apps — then uploads the patched files + and the report as the `vt-preview` artifact (7 days). No PR, no issues: the + maintainer reviews and commits them into the data PR before it merges. +- **Terms:** VirusTotal offers the Public API to sites "free to consumers"; + it "must not be used in business workflows that do not contribute new + files" and "can not be used as a substitute for antivirus products". + SoftHarbor is free, carries no ads and only submits public download URLs; + the site copy keeps making no safety claim (hard rule 4). + ## 5. Link check (repo-local) `.github/workflows/link-check.yml`: diff --git a/docs/13_RELEASE.md b/docs/13_RELEASE.md index 6c9e144..7233e2e 100644 --- a/docs/13_RELEASE.md +++ b/docs/13_RELEASE.md @@ -221,7 +221,7 @@ shape or the 50-item window's order without meaning to announce. | daily (auto) | quarantine sweep (docs/12 §4) | | weekly (auto) | link-check triage — the one `link-rot` issue is refreshed or closed (docs/12 §5); fix, replace with official mirror, or flag | | weekly (auto, Monday) | Dependabot PRs (npm + actions, 2-day cooldown) — merge when CI is green; osv/audit findings fail CI on their own | -| monthly (manual, ~30 min) | re-verify the 10 oldest `checkedAt` entries; refresh dates (`validate:data` warns once a check is older than 180 days) | +| daily (auto, 00:41 UTC) | VirusTotal re-check (docs/12 §4b): checks older than 90 days are re-scanned into the one `vt/recheck` PR — review and merge it; triage any `[vt] ` issue (false positive → back to `clean` with a note; confirmed → `flagged` + `pnpm quarantine`). GitHub disables a public repo's schedules after 60 days without activity — re-enable the workflow if it ever goes quiet | | monthly (manual, ~10 min) | GSC review: Coverage, Core Web Vitals, hreflang errors; skim DMARC reports (docs/16 §6/§8) | | **annually (manual, ~2 min)** | **Roll `Expires` in `public/.well-known/security.txt` forward one year** (docs/09 §5). An expired `security.txt` is treated as invalid by scanners and researchers — and nothing else in this repo would notice. | | once, post-launch | HSTS phase transitions P1 → P2 (+2 weeks) → optional P3/preload (H9) — docs/16 §5. Observed 2026-10-21: already at P3 (`preload` in the header) — docs/15 §5 | diff --git a/docs/14_LEGAL.md b/docs/14_LEGAL.md index 24cf6eb..25dc120 100644 --- a/docs/14_LEGAL.md +++ b/docs/14_LEGAL.md @@ -348,18 +348,18 @@ can only carry CC BY-SA 4.0 because the summaries are the project's own words Must name **each model whose work lands, its version identifier, and its developer** — currently Claude models by Anthropic, used through Claude Code: **Claude Opus 5** (`claude-opus-5`) for the site and catalogue -through v1.0, and **Claude Opus 5.5** (`claude-opus-5-5`) for the v1.1 work -of October 2026; no other AI system contributed. Every claim on the page +through v1.0, and **Claude Opus 5.5** (`claude-opus-5-5`) for the v1.1 and +v1.2 work of October 2026; no other AI system contributed. Every claim on the page must stay literally true — update it when a process changes (two false claims were corrected on 2026-10-21). -| Area | Position (as shipped, v1.1) | +| Area | Position (as shipped, v1.2) | |---|---| | Source code | AI-assisted, reviewed and run by the maintainer; the same automated gates as any change — lint, type-check, unit and browser tests, schema validation, EN/VI parity, a build, a CSP guard | | Tests | Drafted with AI assistance, reviewed against the behaviour they describe; run on every change, and nothing merges while one fails | | Finding the software | Candidate list AI-assisted; **inclusion is a human decision** against docs/00 §3; links machine-checked per PR (changed entries) and weekly (whole catalogue), with "forbidden"/"too many requests" counted as reachable | | Summaries | Written from scratch in both locales, never pasted; VI reviewed by a native speaker, not machine-translated | -| Security status | **Not AI-decided** — maintainer runs docs/09 §6, and the scan is linked from the app page; where a link changed after its scan, the linked scan is of the earlier link until the next re-check | +| Security status | **Not AI-decided** — "no known warnings" only after the maintainer ran docs/09 §6; from then on `vt-recheck.yml` re-scans every download page on VirusTotal at least every 90 days and moves the date (a fixed rule, not a model: any warning drops the entry to "unverified" and opens an issue; only the maintainer marks clean, flags or removes). The scan is linked from the app page; where a link changed after its scan, the linked scan is of the earlier link until the next re-check. Updated 2026-10-23 (`LEGAL_UPDATED.aiDisclosure`; not an accepted document, so `LEGAL_VERSION` and the gate are unchanged) | Closes with the limits being unchanged: AI assistance is neither a warranty nor an excuse, and a mistake here belongs to the maintainer, not a tool. diff --git a/docs/15_ROADMAP.md b/docs/15_ROADMAP.md index b8c253d..bf9bee8 100644 --- a/docs/15_ROADMAP.md +++ b/docs/15_ROADMAP.md @@ -46,16 +46,16 @@ them (item 9 especially), so new work is appended, never renumbered. Errors) only if abuse or 403/429 UX ever becomes real (docs/16 §9); plus a `SearchAction` JSON-LD node (docs/16 §7) — its prerequisite, the `/apps?q=` deep link, **shipped in v1.1** (`src/lib/urlstate.ts`). -2. **VirusTotal automation — deadline 2027-01-26.** Every entry was - checked on 2026-07-30, so all 326 cross the 180-day staleness line - (`validate-data.mjs` warns) together around 2027-01-26. A scheduled - workflow re-scans each entry's official links through the VT API in - batches inside the public limits (4/min, 500/day), refreshes - `checkedAt` + `evidence`, and opens a signed-commit PR — dispatching - `ci.yml`/`codeql.yml` itself, as quarantine.yml does — plus flag issues - on detections (docs/09 §6.5 from manual to assisted; a confirmed - detection goes through `pnpm quarantine`, never deletion). Also re-scan - the ~11 entries whose evidence is a scan of an earlier link. +2. ~~**VirusTotal automation — deadline 2027-01-26.**~~ **Done 2026-10-23 + (D30, docs/12 §4b):** `vt-recheck.yml` re-scans every check older than + 90 days daily, inside the Public API limits, into one accumulating + signed-commit PR that dispatches `ci.yml`/`codeql.yml`; a detection drops + `clean` to `unverified` and opens an issue (a confirmed one goes through + `pnpm quarantine`, never deletion); dispatched on a data branch it scans a + PR's new entries first. The drifted scans turned out to be 8, not ~11 + (dosbox-staging, forklift, netbird, nomacs, unity scanned an earlier + link; beeper, spyder, nextcloud-desktop a trailing-slash variant) — the + other six suspected ones were `#fragment` links, which VirusTotal drops. 3. **Install-command snippets** — optional `install.winget` / `install.brew` fields rendered as copy buttons. 4. **Favorites** — localStorage star + "my list" view (stays static). @@ -269,6 +269,7 @@ rule 8) · ads/affiliate links (conflicts with the trust proposition). | 2026-10-21 | **Suite v2.0** (site v1.1) — a MAJOR bump by §6's rule, because D25/D26 amend hard rules 1 and 7: docs/00–16 brought in line with the code — D25–D27, the rows above, superseded statuses marked; claims that could not be checked from the repository or a live probe are marked "⚠ verify" | ✅ | | 2026-10-23 | **D28 — Node 26, and TypeScript 6 and 7 side by side** (amends D7, D21). `.nvmrc` `26`, engines `>=26 <27`, `@types/node` 26 — five days before Node 26's LTS promotion (2026-10-28), at the owner's request; Node 24 had entered maintenance on 2026-10-20. TypeScript follows Microsoft's documented pair: `typescript` → `npm:@typescript/typescript6` (re-exports TS 6.0.3: the API `astro check`'s language server asserts, typescript-eslint's project service and svelte2tsx load) and `@typescript/native` → `npm:typescript@7` (bin `tsc`). `pnpm check` is now `astro check && tsc --noEmit` — and that second half is the first type-check `.ts` files ever had: astro check reports `.astro` diagnostics only. Node 25+ ships no Corepack, so laptops reinstall it (`npm i -g corepack`) and Workers Builds downloads Node 26 per build (`PNPM_VERSION` is the fallback) | ✅ (owner, 2026-10-23) | | 2026-10-23 | **D29 — SonarQube Cloud: CI-based analysis with coverage**, replacing Automatic Analysis (which cannot import coverage and must stay off). `ci.yml` job `sonar`, not a required check; `sonar-project.properties` replaces `.sonarcloud.properties`; `sonarqube-scan-action` 8.3 with the newest CLI (8.2); `sonar.projectVersion` from `package.json` so the "previous version" new-code period finally has a baseline (every analysis until now was "not provided"). Coverage now measures what Sonar analyses instead of excluding it: the build scripts through Vitest 5's `autoAttachSubprocess` (their child-process runs count), the head scripts, the endpoints and the schema through new tests — ratchet 93/78/90/93 → **96/85/95/97**. The schema tests caught a real bug: an impossible or malformed date made `toISOString()` throw, crashing `astro build` with a bare RangeError instead of naming the field | ✅ | +| 2026-10-23 | **D30 — VirusTotal re-check, assisted not decided** (docs/09 §6 step 5; docs/12 §4b). `scripts/vt-recheck.mjs` + `vt-recheck.yml`: daily on `main`, checks older than 90 days are re-scanned (download page, VT API v3, 4/min, ≤ 440 of 500 requests a day) and only the three `security` lines change; `checkedAt` now means "latest scan" (docs/04, docs/09 §6). The bot never flags and never promotes on its own: a detection turns `clean` into `unverified` plus a `[vt] ` issue, and `unverified` → `clean` happens only for slugs the maintainer passes as `promote`. Dispatched on a data branch it previews a PR's new entries as an artifact. Terms fit: the Public API is offered to sites free to consumers; SoftHarbor is free and ad-free and submits only public URLs. The site's own copy moved with it — the "no known warnings" note and the AI Disclosure now describe the re-scan (`LEGAL_UPDATED.aiDisclosure` 2026-10-23; `LEGAL_VERSION` unchanged) | ✅ (owner, 2026-10-23) | ## 5. Open questions for Kokone diff --git a/package.json b/package.json index f1c571a..80f33e4 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,8 @@ "quarantine": "node scripts/quarantine.mjs", "test": "vitest run", "test:watch": "vitest", - "validate:data": "node scripts/validate-data.mjs" + "validate:data": "node scripts/validate-data.mjs", + "vt:recheck": "node scripts/vt-recheck.mjs" }, "dependencies": { "@astrojs/rss": "^4.0.19", diff --git a/scripts/vt-recheck.mjs b/scripts/vt-recheck.mjs new file mode 100644 index 0000000..ce54f8e --- /dev/null +++ b/scripts/vt-recheck.mjs @@ -0,0 +1,499 @@ +// SPDX-License-Identifier: GPL-3.0-only +// Copyright (C) 2026 poli0981 (SkullMute) +/** + * VirusTotal re-check — docs/09 §6 step 5 made assisted, docs/12 §4b. + * + * Every entry's security line is a DATED claim ("no known warnings as of + * ", hard rule 4), so it is only honest while the date is recent. + * This re-scans each entry's `links.download` page on VirusTotal and rewrites + * ONLY its three security lines: + * + * - no engine reports it malicious or suspicious → fresh `evidence` and + * `checkedAt`, status unchanged. A slug the maintainer lists in + * VT_PROMOTE goes `unverified` → `clean`: that is their docs/09 §6 call, + * never the script's; + * - any detection → a `clean` entry drops to `unverified` (it no longer has + * "no known warnings") and is reported for a tracking issue; an + * `unverified` entry just gets the fresh scan. + * + * It never sets `flagged` — quarantine stays a human `pnpm quarantine` + * (hard rule 5) — and never touches `addedAt`/`updatedAt`: the feed orders by + * addedAt and notify.py announces whatever it has not seen (docs/13 §5). + * Files are patched line by line, not re-serialised, so Prettier's layout + * survives byte for byte. + * + * Callers: .github/workflows/vt-recheck.yml — daily on main (a PR accumulates + * the results), or dispatched on a data branch as a preview — and a + * maintainer with VT_API_KEY set. Options come from the environment so a + * workflow never interpolates input into a command line: + * + * VT_API_KEY required; without it the run is a no-op that says so + * VT_SLUGS scan these first (space or comma separated) + * VT_PROMOTE move these unverified → clean if their scan is clean + * VT_ONLY_LISTED "1": scan only VT_SLUGS — or, if empty, the entries that + * have never been scanned (a data PR's new apps) + * VT_MAX_AGE re-scan checks older than this many days (default 90) + * VT_BUDGET requests this run may spend (default 440, at most 500) + * VT_CARRY data dir of the still-open re-check PR (see carry()) + * VT_SUMMARY write the markdown report here (the PR body) + * VT_REVIEW_JSON write the detections here, for the issue step + * VT_INTERVAL_MS pacing between requests (default 15 500 — tests set 0) + * + * Public API limits: 4 requests a minute and 500 a day, and VirusTotal counts + * every call. One URL costs a submission plus at least one read, so at most + * half the budget is spent on submissions — the reads must always fit. + */ +import { createHash } from 'node:crypto'; +import { appendFileSync, existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; + +const API = 'https://www.virustotal.com/api/v3'; +const GUI = 'https://www.virustotal.com/gui/url/'; +const SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/; +const EVIDENCE_RE = /^https:\/\/www\.virustotal\.com\/gui\/url\/([0-9a-f]{64})$/; +const DAY_MS = 86_400_000; +/** A drifted scan is re-run at most weekly, so a canonicalisation miss costs ≤ 2 requests a week. */ +const DRIFT_GRACE_DAYS = 7; +const MAX_POLLS = 3; +const QUOTA_BACKOFF_MS = 60_000; +const DEFAULTS = { maxAge: 90, budget: 440, intervalMs: 15_500 }; + +/** The API key was refused: nothing else this run does can succeed. */ +export class AuthError extends Error {} + +/** + * VirusTotal's URL identifier is the SHA-256 of its canonical form. WHATWG + * parsing does what the catalogue's 326 recorded scans show it does: + * lowercase scheme and host, an empty path becomes "/", the query is kept — + * and the fragment, which a browser never sends, is dropped. + */ +export function canonicalUrl(raw) { + const url = new URL(raw); + url.hash = ''; + return url.href; +} + +export const urlId = (raw) => createHash('sha256').update(canonicalUrl(raw)).digest('hex'); + +const daysBetween = (from, to) => Math.round((Date.parse(to) - Date.parse(from)) / DAY_MS); + +/** Slugs from "a b,c" — invalid ones are reported, never passed on. */ +export function parseSlugs(value, log = () => {}) { + const slugs = []; + for (const s of String(value ?? '').split(/[\s,]+/)) { + if (!s) continue; + if (SLUG_RE.test(s)) slugs.push(s); + else log(`vt-recheck: ignoring "${s}" — not a valid slug`); + } + return [...new Set(slugs)]; +} + +/** + * Rewrites the three lines of the `security` object and nothing else. The + * object holds no nested braces (docs/04 §2), so `[^}]*` cannot overrun it. + */ +export function patchSecurity(text, security) { + return text.replace(/("security":\s*\{)([^}]*)(\})/, (_, open, body, close) => { + const next = body + .replace(/("status":\s*)"[^"]*"/, `$1"${security.status}"`) + .replace(/("evidence":\s*)(?:null|"[^"]*")/, `$1${JSON.stringify(security.evidence)}`) + .replace(/("checkedAt":\s*)"[^"]*"/, `$1"${security.checkedAt}"`); + return open + next + close; + }); +} + +/** Everything but `security`, for proving a patch touched nothing else. */ +const rest = (app) => JSON.stringify({ ...app, security: undefined }); + +function loadEntries(appsDir, log) { + if (!existsSync(appsDir)) return []; + const entries = []; + for (const file of readdirSync(appsDir).filter((f) => f.endsWith('.json'))) { + const slug = file.slice(0, -'.json'.length); + const path = join(appsDir, file); + const text = readFileSync(path, 'utf8'); + try { + const app = JSON.parse(text); + if (SLUG_RE.test(slug) && app?.security && app?.links?.download) { + entries.push({ slug, path, text, app }); + } else log(`vt-recheck: skipping ${file} — not a catalogue entry`); + } catch (e) { + log(`vt-recheck: skipping unparseable ${file}: ${e.message}`); + } + } + return entries.sort((a, b) => (a.slug < b.slug ? -1 : 1)); +} + +/** + * The daily run lands in ONE pull request that stays open until merged. Its + * branch holds the earlier days' results; without this, every run would + * re-scan the same stalest entries, because main still shows them as stale. + * A carried security block is adopted only when the download link it scanned + * is still the one on main and its check is newer than main's. + */ +export function carry(entries, carryDir) { + const carried = []; + if (!carryDir || !existsSync(carryDir)) return carried; + for (const entry of entries) { + const path = join(carryDir, `${entry.slug}.json`); + if (!existsSync(path)) continue; + let theirs; + try { + theirs = JSON.parse(readFileSync(path, 'utf8')); + } catch { + continue; + } + const sec = theirs?.security; + if ( + theirs?.links?.download !== entry.app.links.download || + typeof sec?.checkedAt !== 'string' || + !(sec.checkedAt > entry.app.security.checkedAt) || + sec.status === 'flagged' + ) { + continue; + } + const security = { + status: sec.status, + evidence: sec.evidence ?? null, + checkedAt: sec.checkedAt, + }; + entry.text = patchSecurity(entry.text, security); + entry.app = { ...entry.app, security }; + entry.dirty = true; + carried.push(entry.slug); + } + return carried; +} + +/** True when the linked scan is of some other URL than today's download link. */ +function drifted(entry) { + const id = EVIDENCE_RE.exec(entry.app.security.evidence ?? '')?.[1]; + return id !== undefined && id !== urlId(entry.app.links.download); +} + +/** Who gets scanned this run, in priority order. */ +export function select(entries, { slugs, onlyListed, maxAge, today }) { + const bySlug = new Map(entries.map((e) => [e.slug, e])); + const listed = slugs.map((s) => bySlug.get(s)).filter(Boolean); + const scannable = entries.filter((e) => e.app.security.status !== 'flagged'); + const neverScanned = scannable.filter((e) => e.app.security.evidence === null); + if (onlyListed) return listed.length > 0 ? listed : neverScanned; + + const age = (e) => daysBetween(e.app.security.checkedAt, today); + const due = [ + ...listed, + ...neverScanned, + ...scannable.filter((e) => drifted(e) && age(e) >= DRIFT_GRACE_DAYS), + // Oldest check first; Array#sort is stable, so equal dates keep slug order. + ...scannable.filter((e) => age(e) > maxAge).sort((a, b) => age(b) - age(a)), + ]; + return [...new Set(due)]; +} + +/** The VirusTotal client: pacing, the request budget, and the quota rules. */ +function client({ apiKey, fetch, sleep, now, intervalMs, budget }) { + let spent = 0; + let last = -Infinity; + const state = { quotaHit: false }; + + async function once(method, path, body) { + const wait = last + intervalMs - now(); + if (wait > 0) await sleep(wait); + last = now(); + spent++; + return fetch(`${API}${path}`, { + method, + headers: { + 'x-apikey': apiKey, + accept: 'application/json', + ...(body ? { 'content-type': 'application/x-www-form-urlencoded' } : {}), + }, + ...(body ? { body } : {}), + }); + } + + /** One API call, with a single back-off on 429 (the per-minute limit). */ + async function call(method, path, body) { + let res = await once(method, path, body); + if (res.status === 429 && spent < budget) { + await sleep(QUOTA_BACKOFF_MS); + res = await once(method, path, body); + } + if (res.status === 429) { + state.quotaHit = true; + throw new Error('quota exceeded'); + } + if (res.status === 401 || res.status === 403) { + throw new AuthError(`VirusTotal refused the API key (HTTP ${res.status})`); + } + if (!res.ok) throw new Error(`HTTP ${res.status}`); + return res.json(); + } + + return { + state, + left: () => budget - spent, + spent: () => spent, + /** POST /urls → the analysis id. */ + submit: async (url) => + (await call('POST', '/urls', `url=${encodeURIComponent(url)}`))?.data?.id, + /** GET /analyses/{id} → `{ data: { attributes }, meta: { url_info } }`. */ + read: async (id) => call('GET', `/analyses/${encodeURIComponent(id)}`), + }; +} + +const why = (vt, e) => (vt.state.quotaHit ? 'daily quota' : e.message); + +/** Pass 1: submit the queue, keeping half the budget for the reads. */ +async function submitAll(vt, queue, outcome) { + const pending = []; + const most = Math.floor(vt.left() / 2); + for (const entry of queue) { + if (vt.state.quotaHit || pending.length >= most) { + outcome(entry, { kind: 'skipped', reason: vt.state.quotaHit ? 'daily quota' : 'budget' }); + continue; + } + try { + const id = await vt.submit(entry.app.links.download); + if (typeof id !== 'string') throw new Error('no analysis id'); + pending.push({ entry, id, polls: 0 }); + } catch (e) { + if (e instanceof AuthError) throw e; + outcome(entry, { kind: 'error', reason: why(vt, e) }); + } + } + return pending; +} + +/** Pass 2: read each analysis; one still queued goes to the back of the line. */ +async function readAll(vt, pending, outcome) { + while (pending.length > 0) { + const item = pending.shift(); + if (vt.state.quotaHit || vt.left() < 1) { + outcome(item.entry, { + kind: 'skipped', + reason: vt.state.quotaHit ? 'daily quota' : 'budget', + }); + continue; + } + try { + const body = await vt.read(item.id); + const attributes = body?.data?.attributes; + if (attributes?.status !== 'completed') { + item.polls++; + if (item.polls < MAX_POLLS) pending.push(item); + else outcome(item.entry, { kind: 'error', reason: 'analysis still queued' }); + continue; + } + // The URL's id rides along in `meta`; the analysis id ("u--") + // carries it too, should `meta` ever be missing. + const id = body?.meta?.url_info?.id ?? /^u-([0-9a-f]{64})-\d+$/.exec(item.id)?.[1]; + if (typeof id !== 'string' || !/^[0-9a-f]{64}$/.test(id)) throw new Error('no URL id'); + const stats = attributes.stats ?? {}; + const verdicts = ['harmless', 'undetected', 'malicious', 'suspicious']; + // Every engine timing out is not "no detections" — it is no answer. + if (verdicts.every((k) => !stats[k])) throw new Error('no engine returned a verdict'); + outcome(item.entry, { kind: 'scanned', id, stats }); + } catch (e) { + if (e instanceof AuthError) throw e; + outcome(item.entry, { kind: 'error', reason: why(vt, e) }); + } + } +} + +/** The status rules from the header, as one decision. */ +export function decide(status, stats, promote) { + const detections = (stats.malicious ?? 0) + (stats.suspicious ?? 0); + if (detections > 0) return { status: status === 'clean' ? 'unverified' : status, review: true }; + if (promote && status === 'unverified') return { status: 'clean', review: false }; + return { status, review: false }; +} + +function apply(entry, result, { today, promote }) { + const before = entry.app.security; + const { status, review } = decide(before.status, result.stats, promote.has(entry.slug)); + const security = { status, evidence: `${GUI}${result.id}`, checkedAt: today }; + const text = patchSecurity(entry.text, security); + const app = JSON.parse(text); + if (rest(app) !== rest(entry.app) || JSON.stringify(app.security) !== JSON.stringify(security)) { + throw new Error(`patch of ${entry.slug} did not apply cleanly`); + } + entry.text = text; + entry.app = app; + entry.dirty = true; + return { was: before.status, status, review }; +} + +/** + * Re-checks the catalogue in `appsDir`. Pure apart from the files it + * rewrites and the `fetch` it is given, so tests drive it in-process. + */ +export async function recheck(options) { + const { + appsDir, + apiKey, + fetch = globalThis.fetch, + sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), + now = Date.now, + today = new Date().toISOString().slice(0, 10), + slugs = [], + promote = [], + onlyListed = false, + maxAge = DEFAULTS.maxAge, + budget = DEFAULTS.budget, + intervalMs = DEFAULTS.intervalMs, + carryDir, + log = () => {}, + } = options; + + const entries = loadEntries(appsDir, log); + const carried = carry(entries, carryDir); + const promoted = new Set(promote); + const queue = select(entries, { + slugs: [...new Set([...slugs, ...promote])], + onlyListed, + maxAge, + today, + }); + const vt = client({ + apiKey, + fetch, + sleep, + now, + intervalMs, + budget: Math.min(Math.max(budget, 0), 500), + }); + + const rows = []; + const outcome = (entry, result) => { + if (result.kind !== 'scanned') { + rows.push({ slug: entry.slug, ...result }); + return; + } + const detections = { + malicious: result.stats.malicious ?? 0, + suspicious: result.stats.suspicious ?? 0, + }; + const change = apply(entry, result, { today, promote: promoted }); + const mismatch = result.id !== urlId(entry.app.links.download); + if (mismatch) log(`vt-recheck: ${entry.slug}: VirusTotal's URL id differs from the local hash`); + rows.push({ + slug: entry.slug, + kind: 'scanned', + evidence: `${GUI}${result.id}`, + ...detections, + ...change, + mismatch, + }); + }; + + const pending = await submitAll(vt, queue, outcome); + await readAll(vt, pending, outcome); + + for (const entry of entries.filter((e) => e.dirty)) writeFileSync(entry.path, entry.text); + return { + rows, + carried, + changed: entries.filter((e) => e.dirty).length, + review: rows.filter((r) => r.review), + spent: vt.spent(), + quotaHit: vt.state.quotaHit, + selected: queue.length, + }; +} + +function resultCell(r) { + if (r.kind !== 'scanned') return `not checked (${r.reason})`; + const found = r.malicious + r.suspicious > 0; + const text = found ? `⚠ ${r.malicious} malicious, ${r.suspicious} suspicious` : 'no detections'; + return r.mismatch ? `${text} · id ≠ local hash` : text; +} + +function statusCell(r) { + if (!r.status) return '—'; + return r.was !== r.status ? `${r.was} → **${r.status}**` : r.status; +} + +/** The PR body / job summary. */ +export function summary(report, { today }) { + const lines = [ + `VirusTotal re-check, ${today} (docs/12 §4b). Each row re-scanned the entry's`, + '`links.download` page; only the three `security` lines change.', + '', + `- scanned: ${report.rows.filter((r) => r.kind === 'scanned').length} of ${report.selected} due · requests: ${report.spent}` + + (report.quotaHit ? ' · **stopped at the daily quota** — the next run continues' : ''), + `- needs review (detections): ${report.review.length}` + + (report.review.length ? ` — ${report.review.map((r) => `\`${r.slug}\``).join(', ')}` : ''), + ]; + if (report.carried.length) { + lines.push( + `- carried from the open re-check PR: ${report.carried.length} (${report.carried.join(', ')})`, + ); + } + lines.push('', '| entry | result | status | scan |', '|---|---|---|---|'); + for (const r of report.rows) { + const scan = r.evidence ? `[scan](${r.evidence})` : '—'; + lines.push(`| \`${r.slug}\` | ${resultCell(r)} | ${statusCell(r)} | ${scan} |`); + } + lines.push( + '', + 'A detection never flags or removes anything: `clean` becomes `unverified` and an', + 'issue asks the maintainer to decide (docs/09 §6; a confirmed one goes through', + "`pnpm quarantine`). This reports what VirusTotal's engines said on the day —", + 'not a safety guarantee (hard rule 4).', + ); + return lines.join('\n') + '\n'; +} + +function int(value, fallback) { + const n = Number.parseInt(String(value ?? ''), 10); + return Number.isFinite(n) && n >= 0 ? n : fallback; +} + +export async function main(env = process.env, cwd = process.cwd()) { + const out = (key, value) => { + if (env['GITHUB_OUTPUT']) appendFileSync(env['GITHUB_OUTPUT'], `${key}=${value}\n`); + }; + const today = new Date().toISOString().slice(0, 10); + const apiKey = env['VT_API_KEY']; + if (!apiKey) { + console.log( + 'vt-recheck: VT_API_KEY is not set — nothing scanned (forks and Dependabot have no secrets)', + ); + out('changed', 0); + out('review', ''); + return 0; + } + try { + const report = await recheck({ + appsDir: join(cwd, 'src/data/apps'), + apiKey, + today, + slugs: parseSlugs(env['VT_SLUGS'], console.error), + promote: parseSlugs(env['VT_PROMOTE'], console.error), + onlyListed: env['VT_ONLY_LISTED'] === '1', + maxAge: int(env['VT_MAX_AGE'], DEFAULTS.maxAge), + budget: int(env['VT_BUDGET'], DEFAULTS.budget), + intervalMs: int(env['VT_INTERVAL_MS'], DEFAULTS.intervalMs), + carryDir: env['VT_CARRY'] || undefined, + log: console.error, + }); + const text = summary(report, { today }); + if (env['VT_SUMMARY']) writeFileSync(env['VT_SUMMARY'], text); + if (env['VT_REVIEW_JSON']) + writeFileSync(env['VT_REVIEW_JSON'], JSON.stringify(report.review, null, 2)); + console.log(text); + if (report.quotaHit) + console.log('::warning::VirusTotal quota reached — the next run continues'); + out('changed', report.changed); + out('review', report.review.map((r) => r.slug).join(' ')); + return 0; + } catch (e) { + console.error(`vt-recheck: ${e.message}`); + out('changed', 0); + out('review', ''); + return 1; + } +} + +if (import.meta.main) process.exitCode = await main(); diff --git a/scripts/vt-recheck.test.ts b/scripts/vt-recheck.test.ts new file mode 100644 index 0000000..dbdafcd --- /dev/null +++ b/scripts/vt-recheck.test.ts @@ -0,0 +1,614 @@ +// SPDX-License-Identifier: GPL-3.0-only +// Copyright (C) 2026 poli0981 (SkullMute) +// +// vt-recheck.mjs, driven in-process against a fake VirusTotal (the script +// takes `fetch` as a dependency, like worker/verify.ts), plus one real child +// run for the CLI path. That run gets NODE_V8_COVERAGE='' and VT_API_KEY='': +// Vitest merges a child's coverage of a file it also imported wrongly, and a +// developer's own key must never reach the real API from a test. + +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { project, run } from './fixture'; +import { + AuthError, + canonicalUrl, + decide, + main, + parseSlugs, + patchSecurity, + recheck, + select, + summary, + urlId, +} from './vt-recheck.mjs'; + +const TODAY = '2026-10-23'; +/** A check more than 90 days before TODAY: due by age alone. */ +const STALE = '2026-06-01'; +const GUI = 'https://www.virustotal.com/gui/url/'; +const SEVEN_ZIP = readFileSync(join(process.cwd(), 'src/data/apps/7-zip.json'), 'utf8'); + +interface Security { + status: 'clean' | 'unverified' | 'flagged'; + evidence: string | null; + checkedAt: string; +} + +/** An entry in the catalogue's own layout (Prettier: inline arrays). */ +function entry(download: string, security: Partial = {}): string { + const sec: Security = { + status: 'clean', + evidence: `${GUI}${urlId(download)}`, + checkedAt: STALE, + ...security, + }; + return `{ + "name": "App", + "developer": "Dev", + "logo": "monogram", + "summary": { "en": "An app used by tests to exercise the script.", "vi": "Ứng dụng dùng cho kiểm thử." }, + "categories": ["utilities"], + "tags": ["portable"], + "platforms": ["windows"], + "pricing": "free", + "license": null, + "links": { + "homepage": "https://example.test", + "repo": null, + "download": "${download}" + }, + "security": { + "status": "${sec.status}", + "evidence": ${JSON.stringify(sec.evidence)}, + "checkedAt": "${sec.checkedAt}" + }, + "addedAt": "2026-07-28" +} +`; +} + +const dl = (slug: string) => `https://${slug}.example.test/download`; + +function tree(files: Record): { root: string; appsDir: string } { + const prefixed = Object.fromEntries( + Object.entries(files).map(([slug, text]) => [`src/data/apps/${slug}.json`, text]), + ); + const root = project(prefixed); + return { root, appsDir: join(root, 'src/data/apps') }; +} + +const read = (appsDir: string, slug: string) => + JSON.parse(readFileSync(join(appsDir, `${slug}.json`), 'utf8')) as { security: Security }; + +interface Verdict { + malicious?: number; + suspicious?: number; + queued?: number; // reads that answer "queued" before "completed" + submitStatus?: number; // HTTP status of the POST + readStatus?: number; + empty?: boolean; // every engine timed out + noMeta?: boolean; + id?: string; // URL id VirusTotal reports, if not the local hash +} + +/** A fake VirusTotal v3: POST /urls and GET /analyses/{id}. */ +function fakeVt(verdicts: Record = {}, opts: { status429?: number[] } = {}) { + const calls: Array<{ method: string; path: string; key: string | null }> = []; + const byAnalysis = new Map(); + let n = 0; + const fetch = vi.fn(async (input: string, init: RequestInit = {}) => { + n++; + const url = new URL(input); + const headers = new Headers(init.headers); + calls.push({ method: init.method ?? 'GET', path: url.pathname, key: headers.get('x-apikey') }); + if (opts.status429?.includes(n)) + return Response.json({ error: { code: 'QuotaExceededError' } }, { status: 429 }); + + if (init.method === 'POST' && url.pathname === '/api/v3/urls') { + const target = new URLSearchParams(String(init.body)).get('url') ?? ''; + const v = verdicts[target] ?? {}; + if (v.submitStatus) return new Response('nope', { status: v.submitStatus }); + const id = `u-${urlId(target)}-1761177600`; + byAnalysis.set(id, { url: target, reads: 0 }); + return Response.json({ data: { type: 'analysis', id } }); + } + const match = /^\/api\/v3\/analyses\/(.+)$/.exec(url.pathname); + const analysis = match ? byAnalysis.get(decodeURIComponent(match[1] ?? '')) : undefined; + if (!analysis) return new Response('not found', { status: 404 }); + const v = verdicts[analysis.url] ?? {}; + if (v.readStatus) return new Response('nope', { status: v.readStatus }); + analysis.reads++; + if (analysis.reads <= (v.queued ?? 0)) { + return Response.json({ data: { attributes: { status: 'queued', stats: {} } } }); + } + const stats = v.empty + ? { harmless: 0, undetected: 0, malicious: 0, suspicious: 0, timeout: 90 } + : { + harmless: 60, + undetected: 25, + malicious: v.malicious ?? 0, + suspicious: v.suspicious ?? 0, + }; + return Response.json({ + data: { attributes: { status: 'completed', stats } }, + ...(v.noMeta + ? {} + : { meta: { url_info: { id: v.id ?? urlId(analysis.url), url: analysis.url } } }), + }); + }); + return { fetch, calls }; +} + +function opts(appsDir: string, fetch: unknown, extra: Record = {}) { + return { + appsDir, + apiKey: 'test-key', + fetch, + sleep: vi.fn(async () => {}), + now: () => 0, + today: TODAY, + intervalMs: 0, + maxAge: 90, + ...extra, + }; +} + +afterEach(() => { + vi.unstubAllGlobals(); + vi.restoreAllMocks(); +}); + +describe('canonicalUrl / urlId — VirusTotal URL identifiers', () => { + it('reproduces the ids recorded in the catalogue', () => { + // Three real entries: a plain page, a bare origin and a #fragment link. + for (const slug of ['7-zip', 'homebrew', 'vlc']) { + const app = JSON.parse( + readFileSync(join(process.cwd(), `src/data/apps/${slug}.json`), 'utf8'), + ); + expect(app.security.evidence, slug).toBe(`${GUI}${urlId(app.links.download)}`); + } + }); + + it('lowercases the host, adds the root path, drops the fragment and keeps the query', () => { + expect(canonicalUrl('HTTPS://Brew.SH')).toBe('https://brew.sh/'); + expect(canonicalUrl('https://www.videolan.org/vlc/#download')).toBe( + 'https://www.videolan.org/vlc/', + ); + expect(canonicalUrl('https://x.test/get?os=win')).toBe('https://x.test/get?os=win'); + expect(canonicalUrl('https://x.test/download/')).not.toBe( + canonicalUrl('https://x.test/download'), + ); + }); +}); + +describe('parseSlugs', () => { + it('splits on spaces and commas, de-duplicates, and refuses non-slugs', () => { + const log = vi.fn(); + expect(parseSlugs(' 7-zip,vlc 7-zip\nNot_A_Slug ; ', log)).toEqual(['7-zip', 'vlc']); + expect(log).toHaveBeenCalledWith(expect.stringContaining('"Not_A_Slug"')); + expect(log).toHaveBeenCalledWith(expect.stringContaining('";"')); + expect(parseSlugs(undefined)).toEqual([]); + }); +}); + +describe('patchSecurity', () => { + it('changes the three security lines of a real entry and not one byte more', () => { + const security = { + status: 'unverified', + evidence: `${GUI}${'f'.repeat(64)}`, + checkedAt: TODAY, + }; + const before = SEVEN_ZIP.split('\n'); + const after = patchSecurity(SEVEN_ZIP, security).split('\n'); + expect(after).toHaveLength(before.length); + const changed = before.flatMap((line, i) => (line === after[i] ? [] : [after[i]])); + expect(changed).toEqual([ + ' "status": "unverified",', + ` "evidence": "${GUI}${'f'.repeat(64)}",`, + ` "checkedAt": "${TODAY}"`, + ]); + }); + + it('fills a never-scanned entry', () => { + const text = entry(dl('a'), { status: 'unverified', evidence: null }); + const patched = patchSecurity(text, { + status: 'unverified', + evidence: `${GUI}abc`, + checkedAt: TODAY, + }); + expect(JSON.parse(patched).security).toEqual({ + status: 'unverified', + evidence: `${GUI}abc`, + checkedAt: TODAY, + }); + }); +}); + +describe('decide — the status rules', () => { + it('keeps the status on a clean scan, and promotes only when asked', () => { + expect(decide('clean', { malicious: 0 }, false)).toEqual({ status: 'clean', review: false }); + expect(decide('unverified', {}, false)).toEqual({ status: 'unverified', review: false }); + expect(decide('unverified', {}, true)).toEqual({ status: 'clean', review: false }); + }); + + it('drops clean to unverified on any detection, and never flags', () => { + expect(decide('clean', { suspicious: 1 }, false)).toEqual({ + status: 'unverified', + review: true, + }); + expect(decide('clean', { malicious: 3 }, true)).toEqual({ status: 'unverified', review: true }); + expect(decide('unverified', { malicious: 1 }, true)).toEqual({ + status: 'unverified', + review: true, + }); + }); +}); + +describe('select — who is due, in order', () => { + const make = (slug: string, security: Partial, download = dl(slug)) => ({ + slug, + app: JSON.parse(entry(download, security)), + }); + + it('puts listed slugs first, then never-scanned, drifted and stale (oldest first)', () => { + const entries = [ + make('fresh', { checkedAt: '2026-10-01' }), + make('listed', { checkedAt: '2026-10-20' }), + make('new-app', { status: 'unverified', evidence: null, checkedAt: TODAY }), + make('drifted', { evidence: `${GUI}${urlId(dl('old-link'))}`, checkedAt: '2026-10-01' }), + make('drift-recent', { evidence: `${GUI}${urlId(dl('old-link'))}`, checkedAt: '2026-10-20' }), + make('stale-older', { checkedAt: '2026-06-01' }), + make('stale', { checkedAt: '2026-07-01' }), + make('advisory', { + status: 'clean', + evidence: 'https://vendor.test/advisory', + checkedAt: '2026-10-01', + }), + make('flagged', { status: 'flagged', checkedAt: '2026-01-01' }), + ]; + const order = select(entries, { + slugs: ['listed', 'missing'], + onlyListed: false, + maxAge: 90, + today: TODAY, + }); + expect(order.map((e: { slug: string }) => e.slug)).toEqual([ + 'listed', + 'new-app', + 'drifted', + 'stale-older', + 'stale', + ]); + }); + + it('in preview, scans only the listed slugs — or the never-scanned when none are listed', () => { + const entries = [make('a', {}), make('b', { status: 'unverified', evidence: null })]; + const pick = (slugs: string[]) => + select(entries, { slugs, onlyListed: true, maxAge: 0, today: TODAY }).map( + (e: { slug: string }) => e.slug, + ); + expect(pick(['a'])).toEqual(['a']); + expect(pick([])).toEqual(['b']); + }); +}); + +describe('recheck — end to end against a fake VirusTotal', () => { + it('refreshes evidence and checkedAt on a clean scan, sending the key', async () => { + const { appsDir } = tree({ stale: entry(dl('stale')) }); + const vt = fakeVt(); + const report = await recheck(opts(appsDir, vt.fetch)); + + expect(read(appsDir, 'stale').security).toEqual({ + status: 'clean', + evidence: `${GUI}${urlId(dl('stale'))}`, + checkedAt: TODAY, + }); + expect(report).toMatchObject({ changed: 1, spent: 2, quotaHit: false, selected: 1 }); + expect(report.rows[0]).toMatchObject({ + slug: 'stale', + kind: 'scanned', + malicious: 0, + mismatch: false, + }); + expect(vt.calls.map((c) => `${c.method} ${c.path.replace(/[0-9a-f]{64}/, 'ID')}`)).toEqual([ + 'POST /api/v3/urls', + 'GET /api/v3/analyses/u-ID-1761177600', + ]); + expect(vt.calls.every((c) => c.key === 'test-key')).toBe(true); + }); + + it('leaves entries that are not due untouched', async () => { + const fresh = entry(dl('fresh'), { checkedAt: '2026-10-01' }); + const { appsDir } = tree({ fresh }); + const vt = fakeVt(); + const report = await recheck(opts(appsDir, vt.fetch)); + expect(report.changed).toBe(0); + expect(vt.fetch).not.toHaveBeenCalled(); + expect(readFileSync(join(appsDir, 'fresh.json'), 'utf8')).toBe(fresh); + }); + + it('drops clean to unverified on a detection and reports it for review', async () => { + const { appsDir } = tree({ + hit: entry(dl('hit')), + held: entry(dl('held'), { status: 'unverified' }), + }); + const vt = fakeVt({ [dl('hit')]: { malicious: 1 }, [dl('held')]: { suspicious: 2 } }); + const report = await recheck(opts(appsDir, vt.fetch)); + + expect(read(appsDir, 'hit').security.status).toBe('unverified'); + expect(read(appsDir, 'held').security.status).toBe('unverified'); + expect(report.review.map((r: { slug: string }) => r.slug)).toEqual(['held', 'hit']); + expect(report.review[1]).toMatchObject({ was: 'clean', status: 'unverified', malicious: 1 }); + }); + + it('promotes only the listed unverified entries whose scan is clean', async () => { + const { appsDir } = tree({ + 'new-a': entry(dl('new-a'), { status: 'unverified', evidence: null, checkedAt: TODAY }), + 'new-b': entry(dl('new-b'), { status: 'unverified', evidence: null, checkedAt: TODAY }), + 'new-c': entry(dl('new-c'), { status: 'unverified', evidence: null, checkedAt: TODAY }), + }); + const vt = fakeVt({ [dl('new-b')]: { malicious: 1 } }); + await recheck(opts(appsDir, vt.fetch, { promote: ['new-a', 'new-b'] })); + expect(read(appsDir, 'new-a').security.status).toBe('clean'); + expect(read(appsDir, 'new-b').security.status).toBe('unverified'); + expect(read(appsDir, 'new-c').security).toMatchObject({ + status: 'unverified', + evidence: `${GUI}${urlId(dl('new-c'))}`, + }); + }); + + it('spends at most half the budget on submissions', async () => { + const { appsDir } = tree({ a: entry(dl('a')), b: entry(dl('b')), c: entry(dl('c')) }); + const vt = fakeVt(); + const report = await recheck(opts(appsDir, vt.fetch, { budget: 4 })); + expect(report.spent).toBe(4); + expect(report.rows.find((r: { slug: string }) => r.slug === 'c')).toMatchObject({ + kind: 'skipped', + reason: 'budget', + }); + expect(read(appsDir, 'c').security.checkedAt).toBe(STALE); + }); + + it('re-reads an analysis that is still queued, up to three times', async () => { + const { appsDir } = tree({ slow: entry(dl('slow')), stuck: entry(dl('stuck')) }); + const vt = fakeVt({ [dl('slow')]: { queued: 2 }, [dl('stuck')]: { queued: 9 } }); + const report = await recheck(opts(appsDir, vt.fetch)); + expect(read(appsDir, 'slow').security.checkedAt).toBe(TODAY); + expect(report.rows.find((r: { slug: string }) => r.slug === 'stuck')).toMatchObject({ + kind: 'error', + reason: 'analysis still queued', + }); + expect(read(appsDir, 'stuck').security.checkedAt).toBe(STALE); + }); + + it('backs off once on 429, then treats a second 429 as the spent daily quota', async () => { + const { appsDir } = tree({ a: entry(dl('a')), b: entry(dl('b')), c: entry(dl('c')) }); + // Request 1 (submit a) is limited once and retried; request 4 (submit c) + // and its retry are both refused — the day's quota is gone. + const vt = fakeVt({}, { status429: [1, 4, 5] }); + const o = opts(appsDir, vt.fetch); + const report = await recheck(o); + + expect(o.sleep).toHaveBeenCalledWith(60_000); + expect(report.quotaHit).toBe(true); + expect(report.rows.find((r: { slug: string }) => r.slug === 'c')).toMatchObject({ + kind: 'error', + reason: 'daily quota', + }); + // a and b were submitted before the quota ran out, but their reads come + // after it: nothing is guessed, nothing is written for them. + expect(report.rows.filter((r: { kind: string }) => r.kind === 'skipped')).toHaveLength(2); + expect(report.changed).toBe(0); + }); + + it('stops everything on a refused API key, writing nothing', async () => { + const text = entry(dl('a')); + const { appsDir } = tree({ a: text }); + const fetch = vi.fn(async () => new Response('denied', { status: 401 })); + await expect(recheck(opts(appsDir, fetch))).rejects.toBeInstanceOf(AuthError); + expect(readFileSync(join(appsDir, 'a.json'), 'utf8')).toBe(text); + }); + + it('records a failed URL as not checked and carries on', async () => { + const { appsDir } = tree({ + bad: entry(dl('bad')), + good: entry(dl('good')), + odd: entry(dl('odd')), + }); + const vt = fakeVt({ [dl('bad')]: { submitStatus: 400 }, [dl('odd')]: { readStatus: 500 } }); + const report = await recheck(opts(appsDir, vt.fetch)); + expect(report.rows.find((r: { slug: string }) => r.slug === 'bad')).toMatchObject({ + kind: 'error', + reason: 'HTTP 400', + }); + expect(report.rows.find((r: { slug: string }) => r.slug === 'odd')).toMatchObject({ + kind: 'error', + reason: 'HTTP 500', + }); + expect(read(appsDir, 'good').security.checkedAt).toBe(TODAY); + expect(report.changed).toBe(1); + }); + + it('refuses an analysis in which no engine answered', async () => { + const { appsDir } = tree({ a: entry(dl('a')) }); + const report = await recheck(opts(appsDir, fakeVt({ [dl('a')]: { empty: true } }).fetch)); + expect(report.rows[0]).toMatchObject({ kind: 'error', reason: 'no engine returned a verdict' }); + expect(report.changed).toBe(0); + }); + + it("takes the URL id from the analysis id when `meta` is missing, and flags an id it can't reproduce", async () => { + const { appsDir } = tree({ a: entry(dl('a')), b: entry(dl('b')) }); + const log = vi.fn(); + const vt = fakeVt({ [dl('a')]: { noMeta: true }, [dl('b')]: { id: 'e'.repeat(64) } }); + const report = await recheck(opts(appsDir, vt.fetch, { log })); + expect(read(appsDir, 'a').security.evidence).toBe(`${GUI}${urlId(dl('a'))}`); + expect(read(appsDir, 'b').security.evidence).toBe(`${GUI}${'e'.repeat(64)}`); + expect(report.rows.find((r: { slug: string }) => r.slug === 'b')).toMatchObject({ + mismatch: true, + }); + expect(log).toHaveBeenCalledWith(expect.stringContaining("b: VirusTotal's URL id differs")); + }); + + it('paces requests at the configured interval', async () => { + const { appsDir } = tree({ a: entry(dl('a')), b: entry(dl('b')) }); + let clock = 0; + const sleep = vi.fn(async (ms: number) => { + clock += ms; + }); + await recheck(opts(appsDir, fakeVt().fetch, { intervalMs: 15_500, now: () => clock, sleep })); + expect(sleep).toHaveBeenCalledTimes(3); // 4 requests, the first one unpaced + expect(sleep.mock.calls.every(([ms]) => ms === 15_500)).toBe(true); + }); + + it('skips files that are not catalogue entries', async () => { + const log = vi.fn(); + const { appsDir } = tree({ broken: '{ nope', partial: '{"name": "x"}' }); + const report = await recheck(opts(appsDir, fakeVt().fetch, { log })); + expect(report.selected).toBe(0); + expect(log).toHaveBeenCalledWith(expect.stringContaining('unparseable broken.json')); + expect(log).toHaveBeenCalledWith(expect.stringContaining('skipping partial.json')); + }); +}); + +describe('carry — accumulating in the open re-check PR', () => { + it('adopts newer scans of the same link, so they are not re-scanned', async () => { + const { appsDir } = tree({ + done: entry(dl('done')), + moved: entry(dl('moved')), + older: entry(dl('older')), + flagged: entry(dl('flagged')), + junk: entry(dl('junk')), + }); + const carried = project({ + 'done.json': entry(dl('done'), { status: 'unverified', checkedAt: '2026-10-22' }), + 'moved.json': entry(dl('moved-elsewhere'), { checkedAt: '2026-10-22' }), + 'older.json': entry(dl('older'), { checkedAt: '2026-05-01' }), + 'flagged.json': entry(dl('flagged'), { status: 'flagged', checkedAt: '2026-10-22' }), + 'junk.json': '{ nope', + }); + const vt = fakeVt(); + const report = await recheck(opts(appsDir, vt.fetch, { carryDir: carried })); + + expect(report.carried).toEqual(['done']); + expect(read(appsDir, 'done').security).toMatchObject({ + status: 'unverified', + checkedAt: '2026-10-22', + }); + // Everything else was still due and got a fresh scan of ITS link. + expect(report.rows.map((r: { slug: string }) => r.slug).sort()).toEqual([ + 'flagged', + 'junk', + 'moved', + 'older', + ]); + expect(read(appsDir, 'moved').security.evidence).toBe(`${GUI}${urlId(dl('moved'))}`); + }); + + it('is a no-op without a carry tree', async () => { + const { appsDir } = tree({ a: entry(dl('a')) }); + const report = await recheck( + opts(appsDir, fakeVt().fetch, { carryDir: join(appsDir, 'none') }), + ); + expect(report.carried).toEqual([]); + }); +}); + +describe('summary — the PR body', () => { + it('lists every row, the review set, carried entries and a quota stop', () => { + const text = summary( + { + rows: [ + { + slug: 'a', + kind: 'scanned', + evidence: `${GUI}aa`, + malicious: 0, + suspicious: 0, + was: 'clean', + status: 'clean', + mismatch: false, + }, + { + slug: 'b', + kind: 'scanned', + evidence: `${GUI}bb`, + malicious: 2, + suspicious: 1, + was: 'clean', + status: 'unverified', + review: true, + mismatch: true, + }, + { slug: 'c', kind: 'skipped', reason: 'budget' }, + ], + review: [{ slug: 'b' }], + carried: ['d'], + spent: 5, + quotaHit: true, + selected: 4, + }, + { today: TODAY }, + ); + expect(text).toContain('- scanned: 2 of 4 due · requests: 5 · **stopped at the daily quota**'); + expect(text).toContain('- needs review (detections): 1 — `b`'); + expect(text).toContain('- carried from the open re-check PR: 1 (d)'); + expect(text).toContain(`| \`a\` | no detections | clean | [scan](${GUI}aa) |`); + expect(text).toContain( + '| `b` | ⚠ 2 malicious, 1 suspicious · id ≠ local hash | clean → **unverified** |', + ); + expect(text).toContain('| `c` | not checked (budget) | — | — |'); + expect(text).toContain('not a safety guarantee'); + }); +}); + +describe('main — the CLI wrapper', () => { + it('writes the report, the review list and the step outputs', async () => { + const { root, appsDir } = tree({ hit: entry(dl('hit')), ok: entry(dl('ok')) }); + vi.stubGlobal('fetch', fakeVt({ [dl('hit')]: { malicious: 1 } }).fetch); + vi.spyOn(console, 'log').mockImplementation(() => {}); + const env = { + VT_API_KEY: 'k', + VT_INTERVAL_MS: '0', + VT_SLUGS: 'ok, hit', + VT_BUDGET: 'lots', + GITHUB_OUTPUT: join(root, 'out.txt'), + VT_SUMMARY: join(root, 'summary.md'), + VT_REVIEW_JSON: join(root, 'review.json'), + }; + expect(await main(env, root)).toBe(0); + expect(readFileSync(env.GITHUB_OUTPUT, 'utf8')).toBe('changed=2\nreview=hit\n'); + expect(readFileSync(env.VT_SUMMARY, 'utf8')).toContain('needs review (detections): 1'); + expect(JSON.parse(readFileSync(env.VT_REVIEW_JSON, 'utf8'))[0]).toMatchObject({ + slug: 'hit', + malicious: 1, + evidence: `${GUI}${urlId(dl('hit'))}`, + }); + expect(read(appsDir, 'ok').security.checkedAt).toBe(new Date().toISOString().slice(0, 10)); + }); + + it('fails the step on a refused key, reporting no changes', async () => { + const { root } = tree({ a: entry(dl('a')) }); + vi.stubGlobal( + 'fetch', + vi.fn(async () => new Response('', { status: 403 })), + ); + vi.spyOn(console, 'error').mockImplementation(() => {}); + const env = { VT_API_KEY: 'k', VT_INTERVAL_MS: '0', GITHUB_OUTPUT: join(root, 'out.txt') }; + expect(await main(env, root)).toBe(1); + expect(readFileSync(env.GITHUB_OUTPUT, 'utf8')).toBe('changed=0\nreview=\n'); + }); + + it('runs as a script: without a key it says so and changes nothing', () => { + const text = entry(dl('a')); + const { root, appsDir } = tree({ a: text }); + const r = run('vt-recheck.mjs', root, { + env: { NODE_V8_COVERAGE: '', VT_API_KEY: '', GITHUB_OUTPUT: join(root, 'out.txt') }, + }); + expect(r.code).toBe(0); + expect(r.out).toContain('VT_API_KEY is not set'); + expect(readFileSync(join(root, 'out.txt'), 'utf8')).toBe('changed=0\nreview=\n'); + expect(readFileSync(join(appsDir, 'a.json'), 'utf8')).toBe(text); + }); +}); diff --git a/src/components/legal/AiDisclosure.astro b/src/components/legal/AiDisclosure.astro index 44a4375..7b9e098 100644 --- a/src/components/legal/AiDisclosure.astro +++ b/src/components/legal/AiDisclosure.astro @@ -51,8 +51,8 @@ const rows = [ { area: { en: 'Security status', vi: 'Trạng thái bảo mật' }, how: { - en: 'Not AI-decided. Each entry is checked by the maintainer against the published vetting checklist, and the scan behind every status is linked from the app page so you can read it yourself. Where a link has changed since its scan, the linked scan is of the earlier link until the next re-check.', - vi: 'Không do AI quyết định. Mỗi mục được người bảo trì kiểm tra theo quy trình đã công bố, và kết quả quét đứng sau mỗi trạng thái đều có liên kết ngay trên trang ứng dụng để bạn tự đọc. Nếu một liên kết đã đổi sau lần quét, kết quả được liên kết là của liên kết cũ cho tới lần kiểm tra lại kế tiếp.', + en: 'Not AI-decided. An entry is marked "no known warnings" only after the maintainer has checked it against the published vetting checklist. From then on, a scheduled job re-scans every entry’s download page on VirusTotal at least every 90 days and moves the date forward. That job is a fixed rule, not a model: any warning sends the entry back to "unverified" and opens an issue for the maintainer, and only the maintainer ever marks an entry clean or removes one. The scan behind every status is linked from the app page so you can read it yourself. Where a link has changed since its scan, the linked scan is of the earlier link until the next re-check.', + vi: 'Không do AI quyết định. Một mục chỉ được ghi "Không có cảnh báo đã biết" sau khi người bảo trì đã kiểm tra nó theo quy trình đã công bố. Từ đó trở đi, một tác vụ định kỳ quét lại trang tải về của mọi mục trên VirusTotal ít nhất 90 ngày một lần và cập nhật ngày kiểm tra. Tác vụ đó là một quy tắc cố định, không phải mô hình AI: chỉ cần một cảnh báo là mục bị đưa về "Chưa kiểm chứng" và một issue được mở cho người bảo trì, và chỉ người bảo trì mới đánh dấu một mục là an toàn hoặc gỡ nó khỏi danh sách. Kết quả quét đứng sau mỗi trạng thái đều có liên kết ngay trên trang ứng dụng để bạn tự đọc. Nếu một liên kết đã đổi sau lần quét, kết quả được liên kết là của liên kết cũ cho tới lần kiểm tra lại kế tiếp.', }, }, ]; @@ -68,8 +68,8 @@ const rows = [

{en - ? 'Claude models developed by Anthropic, used through Claude Code — Anthropic’s command-line coding tool: Claude Opus 5 (model identifier claude-opus-5) for the site and catalogue through v1.0, and Claude Opus 5.5 (claude-opus-5-5) for the v1.1 work of October 2026. Earlier work on the project used Claude models through the same tool. No other AI system contributed to this site.' - : 'Các mô hình Claude do Anthropic phát triển, sử dụng qua Claude Code — công cụ lập trình dòng lệnh của Anthropic: Claude Opus 5 (mã định danh mô hình claude-opus-5) cho trang web và danh mục đến hết v1.0, và Claude Opus 5.5 (claude-opus-5-5) cho phần việc v1.1 vào tháng 10/2026. Các giai đoạn trước của dự án cũng dùng mô hình Claude qua chính công cụ này. Không có hệ thống AI nào khác tham gia vào trang web này.'} + ? 'Claude models developed by Anthropic, used through Claude Code — Anthropic’s command-line coding tool: Claude Opus 5 (model identifier claude-opus-5) for the site and catalogue through v1.0, and Claude Opus 5.5 (claude-opus-5-5) for the v1.1 and v1.2 work of October 2026. Earlier work on the project used Claude models through the same tool. No other AI system contributed to this site.' + : 'Các mô hình Claude do Anthropic phát triển, sử dụng qua Claude Code — công cụ lập trình dòng lệnh của Anthropic: Claude Opus 5 (mã định danh mô hình claude-opus-5) cho trang web và danh mục đến hết v1.0, và Claude Opus 5.5 (claude-opus-5-5) cho phần việc v1.1 và v1.2 vào tháng 10/2026. Các giai đoạn trước của dự án cũng dùng mô hình Claude qua chính công cụ này. Không có hệ thống AI nào khác tham gia vào trang web này.'}

{en ? 'Where it was used' : 'Đã dùng ở đâu'}

diff --git a/src/i18n/en.json b/src/i18n/en.json index f207796..58cb075 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -42,7 +42,7 @@ "detail.related": "More in {category}", "detail.repo": "Repository", "detail.security": "Security", - "detail.securityNote.clean": "On the date shown, this entry went through our published checklist and nothing worrying turned up. It is not an audit or a guarantee — software can change after a check. Download only from the official link, and verify signatures or checksums where the developer offers them.", + "detail.securityNote.clean": "This entry passed our published checklist, and on the date shown a scan of its download page raised no warnings. It is not an audit or a guarantee — software can change after a check. Download only from the official link, and verify signatures or checksums where the developer offers them.", "detail.securityNote.title": "What this status means", "detail.securityNote.unverified": "The checklist has not been completed for this entry, or something it found needs a closer look. It meets every other rule of the list. Take the care you would with any download, and prefer the official link.", "detail.tags": "Tags", diff --git a/src/i18n/vi.json b/src/i18n/vi.json index c18e348..31873de 100644 --- a/src/i18n/vi.json +++ b/src/i18n/vi.json @@ -42,7 +42,7 @@ "detail.related": "Thêm trong {category}", "detail.repo": "Kho mã nguồn", "detail.security": "Bảo mật", - "detail.securityNote.clean": "Vào ngày được ghi, mục này đã qua quy trình kiểm tra công khai của chúng tôi và không phát hiện điều gì đáng lo. Đây không phải kiểm toán hay bảo đảm — phần mềm có thể thay đổi sau lần kiểm tra. Chỉ tải từ liên kết chính thức, và xác minh chữ ký hoặc checksum nếu nhà phát triển cung cấp.", + "detail.securityNote.clean": "Mục này đã qua quy trình kiểm tra công khai của chúng tôi, và vào ngày được ghi, lần quét trang tải về của nó không phát hiện cảnh báo nào. Đây không phải kiểm toán hay bảo đảm — phần mềm có thể thay đổi sau lần kiểm tra. Chỉ tải từ liên kết chính thức, và xác minh chữ ký hoặc checksum nếu nhà phát triển cung cấp.", "detail.securityNote.title": "Trạng thái này nghĩa là gì", "detail.securityNote.unverified": "Quy trình kiểm tra chưa hoàn tất cho mục này, hoặc có điều cần xem kỹ hơn. Mục này đáp ứng mọi quy tắc khác của danh sách. Hãy cẩn trọng như với bất kỳ tệp tải về nào, và ưu tiên liên kết chính thức.", "detail.tags": "Thẻ", diff --git a/src/lib/legal.ts b/src/lib/legal.ts index 0e1105b..6c29e00 100644 --- a/src/lib/legal.ts +++ b/src/lib/legal.ts @@ -38,7 +38,7 @@ export const ACCEPTED_DOCS = [ * One date for all six used to stamp documents that had not changed. */ export const LEGAL_UPDATED: Readonly> = { - aiDisclosure: '2026-10-21', + aiDisclosure: '2026-10-23', disclaimer: '2026-10-21', privacy: '2026-10-21', terms: '2026-10-21',