BarkleyGitHub
Controls · CI
Markdown file

Checks in CI

GitHub runs most of these for free on public repositories. Some are a switch in Settings; the rest are a short workflow file.

From the 2026 sweep909 of 6,753 apps (13.5%) run a security scanner, and 1,602 (23.7%) use Dependabot or Renovate to keep libraries current. 824 apps (12%) use a library version with a newer release out. The Marketplace report has more on this.

Controls

  1. CI-1Level 1 (or a security workflow)Level markerTurn on CodeQL default setup. Settings → Advanced Security → Code scanning → CodeQL analysis → Set up → Default. It picks up Python, JavaScript and TypeScript, and runs on every pull request. Check that GitHub Actions is in its list of languages too, because that's the language that scans your workflow files, and default setup doesn't always include it. If it's missing, choose View CodeQL configuration, then Edit, select GitHub Actions under Languages, and choose Save changes.

  2. CI-2Level 1Level markerTurn on Dependabot alerts and security updates in the same Settings page, then add version updates for your package files and your workflow actions.

    .github/dependabot.yml
    version: 2
    updates:
      - package-ecosystem: "pip"
        directory: "/"
        schedule:
          interval: "weekly"
        cooldown:
          default-days: 7
      - package-ecosystem: "npm"        # cards: package.json and its lockfile
        directory: "/"
        schedule:
          interval: "weekly"
        cooldown:
          default-days: 7
      - package-ecosystem: "github-actions"
        directory: "/"
        schedule:
          interval: "weekly"
        cooldown:
          default-days: 7

    Dependabot doesn't read an integration's manifest.json. The workflow below checks those requirements with pip-audit instead.

    cooldown makes Dependabot wait until a release is 7 days old before proposing it. It only delays version updates; security updates still arrive straight away.

  3. CI-3Level 1Turn on secret scanning and push protection. Settings → Advanced Security. Push protection stops a push that contains a known token format before it reaches GitHub.

  4. CI-4Level 1 (or CodeQL)Level markerAdd a security workflow that runs on pull requests and on main. This one is for an integration; for a card, swap pip-audit for npm audit --omit=dev.

    .github/workflows/security.yaml
    name: Security
    on:
      pull_request:
      push:
        branches: [main]
    permissions:
      contents: read
    jobs:
      dependency-review:
        if: github.event_name == 'pull_request'
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7
          - uses: actions/dependency-review-action@v5
            with:
              fail-on-severity: moderate
      pip-audit:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7
          - uses: actions/setup-python@v7
            with:
              python-version: "3.13"
          - run: pip install pip-audit==2.10.1
          - name: Check the integration's requirements
            run: |
              jq -r '.requirements // [] | .[]' custom_components/your_domain/manifest.json > requirements.txt
              if [ -s requirements.txt ]; then pip-audit -r requirements.txt; fi
      ruff-security:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7
          - uses: astral-sh/ruff-action@v4.1.0
            with:
              args: check --select S

    ruff-action has no v4 tag, only exact versions such as v4.1.0, so it's pinned to one here.

    pip-audit sometimes reports a vulnerability that has no fixed version yet, so there's nothing to upgrade to and the job keeps failing. Check whether it affects how your integration uses the library. If it doesn't, skip that one finding with --ignore-vuln ID and a comment saying why. An unpinned requirement resolves to its newest version on every run, so the result can change without a commit. Dependencies covers pinning.

  5. CI-5Level 1Validate against Home Assistant's own rules with hassfest and the Marketplace's validation action.

    .github/workflows/validate.yaml
    name: Validate
    on:
      pull_request:
      push:
        branches: [main]
    permissions:
      contents: read
    jobs:
      hassfest:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v7
          - uses: home-assistant/actions/hassfest@master
      marketplace:
        runs-on: ubuntu-latest
        steps:
          - uses: hacs/action@main
            with:
              category: integration

    For a card, leave out the hassfest job, which only checks integrations, and set category: plugin, the Marketplace's name for dashboard cards.

  6. CI-6Level 1 · optionalOptional: catch problems before you commit. pre-commit hooks run on your machine, so they're a convenience and can be skipped. Keep the CI checks too.

    .pre-commit-config.yaml
    repos:
      - repo: https://github.com/astral-sh/ruff-pre-commit
        rev: v0.17.6         # use the newest release
        hooks:
          - id: ruff-check
            args: [--extend-select, S]
      - repo: https://github.com/gitleaks/gitleaks
        rev: v8.30.1
        hooks:
          - id: gitleaks

Keep the workflows and their tokens safe

Every workflow run gets a token that can act on your repository, and every action and script in the run can use it. These steps keep that token weak and keep strangers' text from running as code.

  1. CI-7Level 1Give workflows read-only tokens. Set permissions: contents: read at the top of every workflow and widen it only in the job that needs more. Then make read-only the default under Settings → Actions → General → Workflow permissions, and untick Allow GitHub Actions to create and approve pull requests. Repositories created since 2023 start read-only, but older ones may still give every workflow write access.

  2. CI-8Level 1Keep untrusted text out of run: lines. An issue title, a pull request title or a branch name is chosen by whoever opens it. Written straight into a run: line with ${{ }}, it runs as a shell command with your token. Pass it through env: instead, so the shell treats it as text.

    Do pass it as a variable
    - name: Log the new issue
      env:
        TITLE: ${{ github.event.issue.title }}
      run: echo "New issue: $TITLE"
    Don't write it into the command
    - name: Log the new issue
      run: echo "New issue: ${{ github.event.issue.title }}"
  3. CI-9Level 1Never run a pull request's code in a pull_request_target workflow. That trigger runs with your secrets and a token that can write, so checking out the pull request's code hands both to whoever opened it. Use pull_request for anything that builds or tests contributed code. actions/checkout v7 refuses this by default.

  4. CI-10Level 2Pin actions to a full commit SHA. A tag like @v7 can be moved to different code by whoever controls the action, and your next run uses it with your token. The examples here use version tags and branch names so they're easier to read. Dependabot keeps pinned SHAs current when an action publishes new releases.

    Some Home Assistant actions are updated on a branch instead. hacs/action hasn't tagged a release since 2022, and hassfest only started tagging in November 2026. Pin these to a commit SHA from their default branch, not to the old release, and check them for new commits every month or so.

  5. CI-11Level 2Don't leave the token behind after checkout. actions/checkout saves the token so later git commands work, which also hands it to every later step. Turn that off unless a later step pushes.

    .github/workflows/security.yaml (part)
    - uses: actions/checkout@v7
      with:
        persist-credentials: false
  6. CI-12Level 2Use a GitHub App token instead of a personal access token. When the built-in token can't do something, such as triggering another workflow, create a GitHub App with only the permissions it needs and install it on the repositories that need it. actions/create-github-app-token turns it into a token that expires after an hour. The app's private key is still a stored secret, but each token reaches only what you picked, and nothing is tied to your own account.

  7. CI-13Level 2Check your workflows with zizmor. It finds the problems above, such as untrusted text in run: lines, broad tokens, unpinned actions and credentials left behind. Run uvx zizmor .github/workflows/ before you push, or add it to your security workflow.

Check it worked

Open a pull request that pins an old library with a known vulnerability in manifest.json. pip-audit should fail. For a card, add it to package.json instead, and dependency review and npm audit should both fail. CodeQL's check should run on the pull request.

Barkley lists the security scanners, update bots and pre-commit hooks it finds in a repository.

Open the full page