security

Rules for protecting secrets and private machine data in a Home Assistant Git integration. Home Assistant is software for controlling smart-home devices.

In plain words
What is it for?
Use them when changing Git synchronisation, staging files, or checking that sensitive Home Assistant data stays out of a repository.
Why use it?
They prevent secret files, SSH keys, logs, databases, and runtime files from being read or committed to Git.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ckrl/ha-gitops/security
Clone the repo
git clone --depth 1 https://github.com/ckrl/ha-gitops

Made for: Cursor.

Per session 1,166 This file is loaded in full into every session.
When invoked 1,166 The same file — it is already loaded in full.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01166 $0.01166
Opus 5 $0.00583 $0.00583
Sonnet 5 $0.00233 $0.00233
Haiku 4.5 $0.00117 $0.00117

Measured yesterday against content hash 71a0e887e509, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

security scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootlowPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

- Файлы: `id_ed25519` (приватный, **chmod 600**), `id_ed25519.pub` (публичный), `known_hosts`.

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

.cursor/rules/security.mdc · 79 lines

How it starts

The opening of the file, as written. The whole thing — 79 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Security Rules (CRITICAL)

Несоблюдение этих правил = баг безопасности. См. docs/architecture.md §10.

secrets.yaml — двойная защита, всегда

  1. .gitignore — записи secrets.yaml, secrets_backup.yaml, *.secrets.yaml создаются и поддерживаются GitManager автоматически. Не позволять пользователю переопределить.
  2. Panic guard в коде_get_yaml_files() явно фильтрует secrets.yaml и *.secrets.yaml ДО любого git add.
  3. Pre-push проверка — перед git push запускать git diff --cached --name-only; если в staged есть secrets*.yamlgit reset HEAD <file>, abort, ERROR-лог, persistent_notification.

Никогда:

  • НЕ добавлять флаг/опцию для включения secrets.yaml в синхронизацию.
  • НЕ читать содержимое secrets.yaml в коде интеграции.
  • НЕ выводить путь secrets.yaml пользователю в advisory-режиме как "можно добавить".

Runtime-state HA — никогда

Всегда исключены из git (через .gitignore, генерируемый из const.py):

  • .storage/
  • .cloud/
  • core_* (любые файлы, начинающиеся с core_)
  • home-assistant_v2.db, home-assistant_v2.db-shm, home-assistant_v2.db-wal
  • home-assistant.log, home-assistant.log.1
  • __pycache__/, *.pyc, *.tmp, *.bak

Эти паттерны управляются интеграцией. Если пользователь удалил/изменил блок # ha-gitops: в .gitignore — пересоздать при следующей операции, WARNING в лог.

SSH-ключи

  • Каталог: /config/.ha_gitops/ (через hass.config.path(".ha_gitops")).
  • Файлы: id_ed25519 (приватный, chmod 600), id_ed25519.pub (публичный), known_hosts.
  • Генерация — только ED25519 (ssh-keygen -t ed25519 -N "" -f <path> через executor) либо чистый Python (cryptography.hazmat) в Release. RSA/DSA/ECDSA — нет.
  • chmod 600 устанавливается программно сразу после создания/записи.
  • Каталог .ha_gitops/ обязательно в .gitignore. Двойная проверка: при initialize и перед каждым push.
  • Приватный ключ:
    • НЕ читать его содержимое в коде интеграции (передавать только путь через GIT_SSH_COMMAND);
    • НЕ возвращать через service-вызов или атрибут сенсора;
    • НЕ логировать ни на каком уровне.

Read the full file on GitHub · 79 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 79 lines · 1,166 tokens per session scan A 71a0e887e509

Subscribe to this mod's changes

security is a cursor rule published in the GitHub repository ckrl/ha-gitops (4 stars, last pushed 3mo ago), licensed MIT. It adds 1,166 tokens to every session, about $0.0058 per session on Opus 5. A static security scan graded it A with 1 finding (asks for root). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.