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-код под атакой.
Кластеры правил (быстрая справка)
| Cluster | Scope | Required CI gate |
|---|---|---|
| S1 | Shell-скрипты + embedded shell-блоки | shellcheck (committed .sh) |
| S2 | Python + python-fenced блоки | bandit -ll -ii |
| S3 | Credentials, секреты, tenant identifiers | gitleaks, trufflehog |
| S4 | Supply chain | actionlint, zizmor, osv-scanner, signed releases |
| S5 | Markdown documentation as code | regex anti-pattern grep (markdown-policy) |
| S6 | Repo hygiene (LICENSE, SECURITY.md, …) | manifest presence checks |
| S7 | CI verification gate (эта матрица) | meta — каждый required job блокирует merge |
| S8 | Standards mapping (S1–S7 → ASVS / SOC 2 / …) | (нет автогейта — informative) |
| S9 | Drift, evolution, incident response | bats regression tests + suppression registry sync |
S1 — Shell-скрипты
- Strict mode в начале каждого скрипта:
set -euo pipefail+ quotedIFS=$'\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 | bashinstall-рецепты; только hash-pinned tarballs / package-manager. - No
ssh -o StrictHostKeyChecking=no; bootstrap host-keys черезssh-keyscan -H. shellcheck -S warningclean; 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 -iiclean.
S3 — Credentials & Secrets
- Никаких хардкоженных секретов, API-ключей, tenant-ID в коде или docs.
- Generic env-var paths (
${PROJECT_CREDS_DIR}) — никаких host-specific путей. - Секреты только через env / Vault / prompt — никогда в
.env, закоммиченном в git. .gitignorecoverage:*.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).