Скилл Quality

Security Baseline

Канонический набор правил S1–S9, на который ссылается CLAUDE.md § Security Mandate. Загружай для plan/qa/compliance/do, затрагивающих shipped-артефакты.

Обзор

Security Baseline — канонический набор правил S1–S9 для shipped-артефактов Datarim (skills, agents, commands, templates, scripts, docs). Загружается агентами reviewer, security, compliance во время /dr-plan, /dr-qa, /dr-compliance и /dr-do при работе с production code-paths. Источник: corporate security audit, 2026-04-28 (6 findings: 2× HIGH command injection, 4× MEDIUM SSH/credentials/supply-chain).

Threat Model

Datarim поставляет skills, templates, agents и commands, которые AI-агенты копируют в runtime и исполняют — часто с elevated privileges (root SSH, OAuth-токены с write-scope, package installation). Уязвимая строка в shipped-скрипте реплицируется в production-runbook каждого consumer-а. Документированный curl | bash в skill превращается в канонический install-паттерн всей экосистемы. Каждый shipped-артефакт — это production-код под атакой.

Кластеры правил (быстрая справка)

ClusterScopeRequired CI gate
S1Shell-скрипты + embedded shell-блокиshellcheck (committed .sh)
S2Python + python-fenced блокиbandit -ll -ii
S3Credentials, секреты, tenant identifiersgitleaks, trufflehog
S4Supply chainactionlint, zizmor, osv-scanner, signed releases
S5Markdown documentation as coderegex anti-pattern grep (markdown-policy)
S6Repo hygiene (LICENSE, SECURITY.md, …)manifest presence checks
S7CI verification gate (эта матрица)meta — каждый required job блокирует merge
S8Standards mapping (S1–S7 → ASVS / SOC 2 / …)(нет автогейта — informative)
S9Drift, evolution, incident responsebats regression tests + suppression registry sync

S1 — Shell-скрипты

  • Strict mode в начале каждого скрипта: set -euo pipefail + quoted IFS=$'\n\t'.
  • Quote каждое parameter expansion ("$1", "$@"). Unquoted = дефект.
  • Валидация positional arguments через явный regex перед использованием.
  • Quoted heredoc terminators (<<'EOF'), если heredoc несёт переменные, которые должны достигнуть consumer-а буквально.
  • No eval на user-controlled или filesystem-derived input.
  • No curl | bash install-рецепты; только hash-pinned tarballs / package-manager.
  • No ssh -o StrictHostKeyChecking=no; bootstrap host-keys через ssh-keyscan -H.
  • shellcheck -S warning clean; suppression обязан inline указывать reason + finding-ID + reviewer.

S2 — Python

  • No shell=True с user-controlled input; subprocess с argv-списками.
  • Atomic mode-0o600 credential writes через O_EXCL.
  • No eval / pickle.loads / yaml.load на untrusted input.
  • requests verify=True (default; никогда не False ради «удобства»).
  • SHA-256 или сильнее (без MD5 / SHA-1 за пределами legacy).
  • bandit -ll -ii clean.

S3 — Credentials & Secrets

  • Никаких хардкоженных секретов, API-ключей, tenant-ID в коде или docs.
  • Generic env-var paths (${PROJECT_CREDS_DIR}) — никаких host-specific путей.
  • Секреты только через env / Vault / prompt — никогда в .env, закоммиченном в git.
  • .gitignore coverage: *.pem, *.key, *.token, **/Credentials/**.
  • Rotation-политика на случайный commit: ротация в 24ч, scrub history, force-push, уведомление clones.

S4 — Supply Chain

  • No curl | bash; только hash-pinned installs.
  • GitHub Actions pinned to commit SHA + explicit permissions: блок.
  • SBOM (CycloneDX) поставляется на каждый release.
  • Signed releases (Sigstore cosign keyless, GitHub OIDC).
  • SLSA L2 build provenance через actions/attest-build-provenance.
  • Dependabot / Renovate на каждом repo.
  • Consumer-side verify: см. skill release-verify.

S5 — Markdown как код

  • Placeholders, не реальные ID в shipped-рецептах.
  • Никогда не предписывать unsafe-паттерны как primary recipe.
  • Counter-example fence syntax для unsafe-паттернов: <!-- security:counter-example --><!-- /security:counter-example -->.
  • Embedded fenced blocks (```bash, ```python) наследуют соответствующие S1 / S2 правила.

S6 — Repo Hygiene

Каждый Datarim-published repo ОБЯЗАН содержать: LICENSE, SECURITY.md, CODE_OF_CONDUCT.md, CONTRIBUTING.md, CODEOWNERS, dependabot.yml, branch protection rules, tag protection rules.

S7 — CI Verification Gate

Required jobs (каждый PR / push в main): shellcheck, bandit, semgrep, gitleaks, trufflehog, actionlint, zizmor, osv-scanner, regression bats. Каждый блокирует merge на non-zero finding.

S8 — Standards Mapping

S1–S7 маппятся в OWASP ASVS v5, SOC 2 CC controls, ISO 27001 Annex A, CIS Controls v8. Полная таблица в docs/standards-mapping.md; informative — нет автогейта, используется в аудитах.

S9 — Drift & Evolution

  • No relaxation без architect approval.
  • Новый finding → rule update + regression test в tests/security/ в течение 7 дней.
  • Suppression registry: tests/security/baseline.json — каждая запись # shellcheck disable, # nosec, # nosemgrep ОБЯЗАНА указывать reason + finding-ID + reviewer.

Когда используется

Загружается агентами reviewer, security, compliance во время /dr-plan, /dr-qa, /dr-compliance, /dr-do. Цитируется из CLAUDE.md § Security Mandate. Companion: skill security (операционные рецепты — git history scrub, Tailscale+VPN coexistence, recon-vs-compromise heuristics) и skill release-verify (S4 consumer-side entry point).