Skip to content
<Notes of dev/>

Set up Dependabot, CodeQL, and the install delay

13 min read

Armored defenders on a city rampart fire energy rifles at incoming bug-droids and dripping virus creatures, while engineers in hardhats build a glowing futuristic city behind them.

Four free guardrails: Dependabot, CodeQL, a SECURITY.md file, and a package install delay, plus an auto-merge workflow for the boring updates.

TL;DR

Four guardrails (Dependabot, CodeQL, a SECURITY markdown file, and a package install delay) turn a repo from “we hope nothing breaks” into one that catches problems before they ship. They are free on public repos (CodeQL on private repos needs GitHub Code Security) and take under an hour to configure. npm and Bun still ship with the install delay off, so set it yourself.

Most repos enable Dependabot, then forget it. Most never enable CodeQL. The SECURITY.md file points to an inbox nobody monitors.

One setting, a minimum release age, would have kept the July 2025 eslint-config-prettier compromise out of fresh installs, because the poisoned versions were reported the same day they were published. pnpm and Yarn now turn it on by default. npm and Bun still leave it off.

Supply-chain attack — an attack that compromises a package you depend on, so the malicious code arrives through your normal install instead of through your own code.

AI-generated code can introduce a CVE before anyone notices, and the guardrails below flag it in a pull request.

CVE — Common Vulnerabilities and Exposures, the public ID given to a known security flaw.

Dependabot, CodeQL, and SECURITY.md

Dependabot watches your dependencies. It opens version-update pull requests (PRs) on a schedule you pick (weekly works best, because daily becomes noise). It opens security PRs as soon as a CVE is published for something in your lockfile. And it shows vulnerability alerts in the GitHub Security tab.

CodeQL scans your code. It is GitHub's static analysis engine. It compiles your repo into a queryable database, then runs queries looking for taint flows, injection patterns, and hardcoded secrets, on push, on pull request, and weekly. Findings land in the same Security tab.

Taint flow — the path untrusted input (a form field, a URL parameter) takes through your code until it reaches something dangerous, such as a database query.

Dependabot is the doorman checking IDs and CodeQL is the camera watching inside. You want both.

Set up Dependabot

Dependabot needs a config file that says what to update and a repo setting that turns on security alerts. Create .github/dependabot.yml first:

yaml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    target-branch: "develop"
    schedule:
      interval: "weekly"
      day: "monday"
    open-pull-requests-limit: 10
    cooldown:
      default-days: 3
      semver-major-days: 14
    groups:
      prod-deps:
        dependency-type: "production"
      dev-deps:
        dependency-type: "development"

  - package-ecosystem: "github-actions"
    directory: "/"
    target-branch: "develop"
    schedule:
      interval: "weekly"
      day: "monday"
    open-pull-requests-limit: 5

The grouping block is the difference between five PRs a week and forty. Without groups, Dependabot opens one PR per bump. With it, production deps land in one PR and dev deps in another.

The cooldown block holds back new releases. With the values above, Dependabot waits 3 days before it opens a PR for a new minor or patch release and 14 days for a new major (the cooldown options are in GitHub's reference). It applies to version updates only, so security PRs still arrive immediately.

The npm ecosystem also covers pnpm and Yarn. Keep the github-actions block, since workflow files pin third-party actions too.

Then commit, push, and open Settings → Advanced Security. Turn on:

  • Dependency graph — off by default on private repos, and required for everything else
  • Dependabot alerts — surfaces CVEs in the Security tab
  • Dependabot security updates — opens patch PRs when alerts fire
  • Grouped security updates — bundles alerts for one package manager into one PR
  • Dependabot version updates — confirms the dependabot.yml you committed

Set up CodeQL

CodeQL has two setups: default is a checkbox, and advanced is a workflow file. Start with default.

In the repo, go to Settings → Advanced Security, find CodeQL analysis, and click Set up → Default. GitHub detects languages for you (CodeQL supports JavaScript/TypeScript, Python, Java/Kotlin, C/C++, C#, Go, Ruby, Rust, Swift, and GitHub Actions workflows).

The default query suite is fine (security-extended catches more but adds noise), and the standard triggers are push to main, pull requests against main, and a weekly schedule. GitHub pauses that weekly scan after six months without repo activity.

The first scan finishes within ten minutes, and findings show up under Security → Code scanning. Copilot Autofix comes with it. It is free on public repos (private repos need GitHub Code Security), needs no Copilot subscription, and proposes one fix per alert for you to review.

Switch to advanced when you want to ignore generated files or scan a non-main branch. Create .github/workflows/codeql.yml:

yaml
name: CodeQL

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]
  schedule:
    - cron: '0 6 * * 1'

jobs:
  analyze:
    runs-on: ubuntu-latest
    permissions:
      security-events: write
      contents: read

    steps:
      - uses: actions/checkout@v7

      - uses: github/codeql-action/init@v4
        with:
          languages: javascript-typescript
          config-file: ./.github/codeql/codeql-config.yml

      - uses: github/codeql-action/analyze@v4

The config-file reference is covered in the last section.

Add a SECURITY.md

SECURITY.md is the file someone reads when they think they found a vulnerability in your code. It tells the reporter how to reach you and how soon to expect a reply.

Place it at the repo root, .github/, or docs/. GitHub looks in all three, and root is the most visible. Without it, a stranger files a public issue titled "SQL injection in your API," which discloses the flaw before you can patch it.

A minimal template (promote the headings when you copy it):

markdown
### Security policy

#### Reporting a vulnerability

Use GitHub's private vulnerability reporting:
https://github.com/<owner>/<repo>/security/advisories/new
Or email security@<your-domain>, with the affected version, steps to reproduce, and the impact.

#### What to expect

Acknowledgement within 72 hours, a status update within 7 days, and a disclosure timeline agreed before any public write-up.

Go advanced when you have a real disclosure pipeline (a bug bounty, a CVE Numbering Authority assignment, or a security team). Then add scope, safe-harbor language, supported versions, and PGP (Pretty Good Privacy) keys.

Add an install delay

Most npm supply-chain attacks are caught within hours. A compromised maintainer account publishes a malicious version. pnpm's release notes say such versions are usually removed from the registry within an hour. An install that refused anything younger than a day would have skipped it.

Every major JavaScript package manager now has this. pnpm shipped minimumReleaseAge first, in v10.16 (September 2025). Yarn followed with npmMinimalAgeGate in 4.10 (September 2025), Bun added minimumReleaseAge in 1.3 (October 2025), and npm added min-release-age in 11.10 (February 2026). The idea is the same, but the names, units, and defaults differ.

pnpm uses pnpm-workspace.yaml, with the value in minutes:

yaml
minimumReleaseAge: 1440
minimumReleaseAgeExclude:
  - '@yourorg/*'

Since pnpm 11 this is on by default at 1440 minutes (24 hours). Before 11 it was off. pnpm 11 also stopped reading settings like this one from .npmrc, which now holds only auth and registry settings. The exclude list takes name patterns and exact versions, such as webpack@5.102.1.

minimumReleaseAgeStrict makes resolution fail when no version in your range is old enough (otherwise pnpm installs the too-new version anyway). It defaults to on only when you set minimumReleaseAge yourself.

npm uses .npmrc at the project root, with the value in days:

ini
min-release-age=1
min-release-age-exclude[]=@yourorg/*

min-release-age needs npm CLI 11.10 or newer, and it is off by default. The exclude list arrived later, in 11.17, and takes package names or glob patterns (see the config reference). On 11.10 to 11.16 every package gets the same delay.

Yarn uses .yarnrc.yml. A bare number means minutes, and a duration string such as "3d" works too:

yaml
npmMinimalAgeGate: "3d"
npmPreapprovedPackages:
  - "@yourorg/*"

This needs Yarn 4.10 or newer. Since 4.15 the delay is on by default at one day. npmPreapprovedPackages takes package names and globs.

Bun uses bunfig.toml, with the value in seconds:

toml
[install]
minimumReleaseAge = 86400
minimumReleaseAgeExcludes = ["@yourorg/core"]

This needs Bun 1.3 or newer, and it is off by default. Seconds is the easiest unit to typo: 86400 is 24 hours and 604800 is a week.

uv (Python) calls it exclude-newer. It takes a timestamp or a duration such as "1 week", and it compares against each file's upload time. Setting a package to false exempts it:

toml
[tool.uv]
exclude-newer = "1 week"
exclude-newer-package = { my-internal-lib = false }

Then pick how long to wait. 24 hours suits most teams: it catches attacks rolled back the same day and rarely blocks a legitimate update. 3 days suits regulated environments, and matches Dependabot's default cooldown. 7 days fits slow-moving libraries, but security patches also wait a week.

When a hotfix can't wait, add the package to your tool's exclude list from the configs above (pnpm 11's pnpm audit --fix does this for you). npm also accepts min-release-age=0 for one install. Document every exception you add.

Example: eslint-config-prettier on a Friday

On July 18, 2025, four versions of eslint-config-prettier (8.10.1, 9.1.1, 10.1.6 and 10.1.7) were published with a Windows payload after the maintainer was phished. A repo with a 24-hour delay that ran a fresh install that Friday resolved the previous release. A repo without one pulled the poisoned version.

Limits and pairing with cooldown

A delay would not have stopped xz-utils. The backdoor in 5.6.0 (February 2024) was found on March 29, more than a month later, and spread through Linux distributions, not npm. A delay only buys time when someone else is looking, so it covers attacks caught within your delay window.

Dependabot's cooldown decides when a PR opens. The install delay blocks any install, including a teammate's manual pnpm add. Set the cooldown no shorter than the install delay.

They conflict on security updates. Cooldown does not apply to them, but your install delay does, so a security PR for a version younger than your delay can fail the install in continuous integration (CI). Add that version to the exclude list.

Auto-merge Dependabot PRs

Five Dependabot PRs a week become five hundred over two years. Auto-merge patch and minor bumps after CI passes, and require human review for majors. Drop this into .github/workflows/dependabot-auto-merge.yml:

yaml
name: Dependabot auto-merge

on: pull_request_target

permissions:
  contents: write
  pull-requests: write

jobs:
  auto-merge:
    if: github.event.pull_request.user.login == 'dependabot[bot]' && github.base_ref == 'develop'
    runs-on: ubuntu-latest
    steps:
      - id: meta
        uses: dependabot/fetch-metadata@v3

      - if: contains(fromJSON('["version-update:semver-patch","version-update:semver-minor"]'), steps.meta.outputs.update-type)
        run: gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{ github.event.pull_request.html_url }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dependabot targets develop (the target-branch line), not main, so the release flow stays human-reviewed. Auto-merge only starts once branch protection's required checks pass. And fetch-metadata exposes update-type, so you can branch on patch, minor, or major.

This workflow runs on pull_request_target so the token can write, which is why it must never check out or run the PR's code (the action's README explains the trade-off).

When to keep a human in the loop

Review major bumps by hand, since semantic versioning (semver) says majors can break. Do the same for anything touching auth, crypto, payments, or your build toolchain (Webpack, Vite, TypeScript, your test runner), and for production with no staging environment. For the first month, keep a required review on these PRs and check that CI catches what you expect, then drop the review.

When default CodeQL isn't enough

Default CodeQL catches SQL injection, cross-site scripting (XSS) sinks, prototype pollution, command injection, and obvious hardcoded credentials. Three signs it's time to extend:

  • Half the findings are in generated code, fixtures, or vendored files
  • A framework or in-house wrapper isn't recognized as a sink (a place where tainted data does harm)
  • Your own sanitization helpers are unknown to CodeQL

Switch to advanced setup, then create .github/codeql/codeql-config.yml:

yaml
name: "Custom CodeQL config"

queries:
  - uses: security-and-quality

paths-ignore:
  - "**/*.test.ts"
  - "src/generated/**"

query-filters:
  - exclude:
      problem.severity:
        - recommendation

The config has four levers: query packs, paths, paths-ignore, and query-filters. Each suite includes the one below it: security-and-quality contains security-extended, which contains default. Paths and paths-ignore scope where CodeQL looks, and query-filters silence noisy queries.

Most teams need only a broader suite and path exclusions. Few teams need custom .ql files. Linting follows the same scope-and-ignore logic, covered in the ESLint setup for Next.js 16.


With these files in place, you hear about a compromised release from a Dependabot alert, and your installs skip it for a day, before it reaches your error tracker. If you add only one of them this week, make it the install delay.