# 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.

Source: https://ha-barkley.github.io/security/controls/ci/

From HASC, the Home Assistant Security Controls for integrations, cards and apps. A community catalog, not an official Home Assistant or Open Home Foundation project.

Each control has an ID, cited as HASC-CI-4, and a level from 1 to 3. "Level marker" means anyone can check the control from outside the project, and levels are graded on those controls only.

> **From the 2026 sweep.** 909 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](https://ha-barkley.github.io/marketplace/2026/security-basics/) has more on this.

## Controls

### CI-1: Turn on CodeQL default setup

*Level 1 (or a security workflow) · Level marker*

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.

### CI-2: Turn on Dependabot alerts and security updates

*Level 1 · Level marker*

**Turn 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.

### CI-3: Turn on secret scanning and push protection

*Level 1*

Settings → Advanced Security. Push protection stops a push that contains a known token format before it reaches GitHub.

### CI-4: Add a security workflow

*Level 1 (or CodeQL) · Level marker*

**Add 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](https://ha-barkley.github.io/security/controls/dependencies/) covers pinning.

### CI-5: Validate against Home Assistant's own rules

*Level 1 · Applies to integrations and cards*

**Validate 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.

### CI-6: Optional: catch problems before you commit

*Level 1 · optional*

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.

### CI-7: Give workflows read-only tokens

*Level 1*

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.

### CI-8: Keep untrusted text out of `run:` lines

*Level 1*

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 }}"
```

### CI-9: Never run a pull request's code in a `pull_request_target` workflow

*Level 1*

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.

### CI-10: Pin actions to a full commit SHA

*Level 2*

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.

### CI-11: Don't leave the token behind after checkout

*Level 2*

`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
```

### CI-12: Use a GitHub App token instead of a personal access token

*Level 2*

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.

### CI-13: Check your workflows with zizmor

*Level 2*

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.
