cerber-core 1.1.5 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +111 -0
  2. package/README.md +206 -36
  3. package/bin/cerber +14 -1
  4. package/dev/templates/BACKEND_SCHEMA.ts.tpl +87 -50
  5. package/dev/templates/cerber-guardian.mjs.tpl +254 -148
  6. package/dev/templates/cerber.yml.tpl +96 -53
  7. package/dev/templates/pre-commit.tpl +4 -4
  8. package/dist/cli/contract-parser.d.ts.map +1 -1
  9. package/dist/cli/contract-parser.js +47 -20
  10. package/dist/cli/contract-parser.js.map +1 -1
  11. package/dist/cli/doctor.d.ts +16 -0
  12. package/dist/cli/doctor.d.ts.map +1 -0
  13. package/dist/cli/doctor.js +140 -0
  14. package/dist/cli/doctor.js.map +1 -0
  15. package/dist/cli/init.d.ts.map +1 -1
  16. package/dist/cli/init.js +93 -8
  17. package/dist/cli/init.js.map +1 -1
  18. package/dist/cli/override-validator.d.ts +27 -0
  19. package/dist/cli/override-validator.d.ts.map +1 -0
  20. package/dist/cli/override-validator.js +100 -0
  21. package/dist/cli/override-validator.js.map +1 -0
  22. package/dist/cli/template-generator.d.ts.map +1 -1
  23. package/dist/cli/template-generator.js +71 -16
  24. package/dist/cli/template-generator.js.map +1 -1
  25. package/dist/cli/types.d.ts +7 -0
  26. package/dist/cli/types.d.ts.map +1 -1
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +3 -3
  30. package/dist/index.js.map +1 -1
  31. package/package.json +10 -2
  32. package/solo/templates/BACKEND_SCHEMA.ts.tpl +87 -50
  33. package/solo/templates/cerber-guardian.mjs.tpl +254 -148
  34. package/solo/templates/cerber.yml.tpl +96 -53
  35. package/solo/templates/pre-commit.tpl +4 -4
  36. package/team/templates/BACKEND_SCHEMA.ts.tpl +87 -50
  37. package/team/templates/CODEOWNERS.tpl +18 -6
  38. package/team/templates/cerber-guardian.mjs.tpl +254 -148
  39. package/team/templates/cerber.yml.tpl +96 -53
  40. package/team/templates/pre-commit.tpl +4 -4
package/CHANGELOG.md CHANGED
@@ -5,6 +5,117 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.7] - 2026-01-04
9
+
10
+ ### Added
11
+
12
+ #### 🩺 `npx cerber doctor` - Setup Validation Command
13
+ - New diagnostic command validates Cerber installation
14
+ - Checks: `CERBER.md`, schema file (strict mode), hooks, workflow
15
+ - Returns stable exit codes: 0=OK, 2=missing contract, 3=missing schema, 4=missing hooks/workflow
16
+ - Shows override state: DISABLED/ACTIVE/EXPIRED/INVALID
17
+ - Prints actionable "Next Steps" for each failure scenario
18
+ - MVP implementation (ASCII-only output for stability)
19
+
20
+ #### 🛡️ `CERBER_GUARDRAILS` - Protected Assets Declaration
21
+ - Added to `CERBER.md` template
22
+ - Documents protected files: contract, schema, workflow, guardian, hooks, CODEOWNERS
23
+ - Change policy: never delete/disable, never rename job IDs
24
+ - Allowed changes: schema rules (must match contract), CI config with PR justification
25
+ - Emergency override placeholder for TTL mechanism
26
+
27
+ #### 🔐 Self-Protection Mechanisms
28
+
29
+ **cerber-integrity Workflow Job:**
30
+ - New first job (runs before `cerber-ci`)
31
+ - Validates protected files exist
32
+ - In strict mode: checks schema file presence
33
+ - Verifies `cerber-ci` job ID intact (prevents sabotage)
34
+ - **Cannot be skipped or disabled** (fail-safe)
35
+
36
+ **CODEOWNERS Protection (Team Mode):**
37
+ - Now includes all Cerber files: contract, schema, workflow, guardian, hooks
38
+ - Self-protection: `/.github/CODEOWNERS` requires owner approval
39
+ - Prevents unauthorized changes to enforcement infrastructure
40
+
41
+ #### 🚨 Emergency Override (TTL-based, Controlled)
42
+
43
+ **`CERBER_OVERRIDE` Contract Section:**
44
+ - Time-to-live based safety fuse (NOT a power switch)
45
+ - Required fields when enabled: `reason`, `expires` (ISO 8601), `approvedBy`
46
+ - If expired → treated as disabled
47
+ - If invalid (missing fields) → treated as disabled
48
+
49
+ **What Override DOES:**
50
+ - ✅ Pre-commit: Allows commit WITH WARNING (prints full metadata)
51
+ - ✅ Post-deploy: May skip health gate (if flaky/blocking hotfix)
52
+
53
+ **What Override NEVER DOES (Hard Limits):**
54
+ - ❌ NEVER disables `cerber-integrity` job
55
+ - ❌ NEVER disables entire CI pipeline
56
+ - ❌ NEVER disables `cerber-ci` validation
57
+ - ❌ NEVER bypasses CODEOWNERS (team mode)
58
+
59
+ **Implementation:**
60
+ - Guardian checks override at startup
61
+ - Doctor shows override state
62
+ - Override metadata printed for audit trail
63
+ - Applied to all modes: solo, dev, team
64
+
65
+ #### 🔒 Guided Schema Templates (Security Baseline)
66
+ - Added commented security patterns to `BACKEND_SCHEMA.mjs` template
67
+ - Categories: hardcoded secrets, dev artifacts, critical TODOs
68
+ - Examples: `password=`, `API_KEY=`, `JWT_SECRET=`, `console.log`, `debugger`
69
+ - Clear instruction: "Uncomment patterns that match rules in your CERBER.md"
70
+ - Enforces "never invent rules" principle (translation only)
71
+
72
+ #### 📦 Supply-Chain Security Policy
73
+ - Updated `SECURITY.md` with comprehensive supply-chain guidance
74
+ - npm 2FA required for all maintainers
75
+ - CI-only publishing strongly recommended
76
+ - No risky lifecycle scripts (`postinstall`, `preinstall`)
77
+ - Dependencies updated only via reviewed PRs
78
+ - Installation safety guarantees documented
79
+ - Package verification steps provided
80
+ - Compromise response procedures added
81
+
82
+ #### 🛡️ Generator Path Safety
83
+ - Resolves repository root via `git rev-parse --show-toplevel`
84
+ - Writes ONLY inside repository root (fail-closed if root unknown)
85
+ - Blocks `..` path traversal attempts
86
+ - Whitelists allowed outputs (contract, schema, workflow, guardian, hooks, CODEOWNERS)
87
+ - Validates every file path before write operation
88
+ - Path traversal protection prevents security issues with malicious contracts
89
+
90
+ ### Changed
91
+
92
+ #### 📝 Hardened "For AI Agents" Section (README)
93
+
94
+ **New MUST Rules:**
95
+ 1. **Schema Generation = Translation Only**
96
+ - Agent can ONLY translate explicit rules from `CERBER.md`
97
+ - If rule not in `CERBER.md` → ask user / fail / leave empty
98
+ - Never invent, guess, or auto-generate architecture rules
99
+
100
+ 2. **NO-HEREDOC for TS/JS Files**
101
+ - Never create TypeScript/JavaScript files using bash `cat <<EOF`
102
+ - Reason: Causes `${}` template literal corruption and UTF-8 encoding issues
103
+ - Use editor tools, `fs.writeFile`, or proper file generation utilities
104
+
105
+ ### Fixed
106
+ - Added final newline to `CODEOWNERS.tpl` (prevented last line truncation)
107
+
108
+ ### Security
109
+ - **Supply-chain hardening**: No postinstall scripts, 2FA required, CI-only publish
110
+ - **Path safety**: Generator validates all file writes (repo-root + whitelist)
111
+ - **Self-protection**: cerber-integrity job prevents sabotage/deletion
112
+ - **Emergency override**: Controlled bypass with TTL and audit trail (never disables integrity)
113
+
114
+ ### Breaking Changes
115
+ None. All changes are backward compatible with existing Cerber installations.
116
+
117
+ ---
118
+
8
119
  ## [1.1.4] - 2026-01-04
9
120
 
10
121
  ### Fixed
package/README.md CHANGED
@@ -25,13 +25,47 @@ It's a contract that everything else must obey.
25
25
 
26
26
  ```bash
27
27
  npm install cerber-core --save-dev
28
- npx cerber-guardian --help
28
+ npx cerber init
29
+ # Follow prompts to generate CERBER.md contract + guardian hooks
29
30
  ```
30
31
 
31
32
  ⭐ **Like what you see?** [Star the repo](https://github.com/Agaslez/cerber-core) and share with your team!
32
33
 
33
34
  ---
34
35
 
36
+ ## 🤖 For AI Agents (Copilot, Cursor, Windsurf, Claude, etc.)
37
+
38
+ **Cerber's one rule:** `CERBER.md` is the single source of truth.
39
+
40
+ - If `CERBER.md` is missing → generate template and **STOP**. User must fill the contract.
41
+ - If `CERBER.md` exists → execute contract exactly as specified.
42
+ - **Never guess architecture.** Never invent rules. Never auto-design.
43
+
44
+ **Schema modes:**
45
+ - `schema.mode: template_only` → Generate minimal starter with "NOT SOURCE OF TRUTH" header
46
+ - `schema.mode: strict` → Require existing schema file, never generate
47
+
48
+ **Three enforcement points:**
49
+ 1. **Pre-commit** (Guardian) - Blocks violating commits
50
+ 2. **CI** (GitHub Actions) - Validates on push
51
+ 3. **Post-deploy** - Health gate checks production
52
+
53
+ **Working with Cerber:** Read `CERBER.md` first. It tells you what's allowed and what's protected.
54
+
55
+ ### MUST (Non-Negotiable Rules for AI Agents)
56
+
57
+ **Rule 1: Schema Generation = Translation Only**
58
+ - Agent can **only translate** explicit rules from `CERBER.md` into `BACKEND_SCHEMA.*` format
59
+ - If a rule is **not in CERBER.md** → ask user / fail / leave empty
60
+ - **Never invent**, guess, or auto-generate architecture rules
61
+
62
+ **Rule 2: NO-HEREDOC for TS/JS Files**
63
+ - **Never** create TypeScript/JavaScript files using bash `cat <<EOF` or heredoc syntax
64
+ - Reason: Causes `${}` template literal corruption and UTF-8 encoding issues
65
+ - Use editor tools, `fs.writeFile`, or proper file generation utilities instead
66
+
67
+ ---
68
+
35
69
  ## 📊 Real Production Metrics
36
70
 
37
71
  > From Eliksir SaaS Backend (2026-01-02 session)
@@ -228,7 +262,7 @@ In `CERBER.md` contract, you control schema generation:
228
262
  ```yaml
229
263
  schema:
230
264
  enabled: true
231
- file: BACKEND_SCHEMA.ts
265
+ file: BACKEND_SCHEMA.mjs
232
266
  mode: strict # or template_only
233
267
  ```
234
268
 
@@ -236,7 +270,7 @@ schema:
236
270
  - ✅ Cerber NEVER creates schema file
237
271
  - ✅ You create schema based on YOUR architecture
238
272
  - ✅ Full control, no helpers, no assumptions
239
- - ✅ `npx cerber init` shows: "You must create BACKEND_SCHEMA.ts"
273
+ - ✅ `npx cerber init` shows: "You must create BACKEND_SCHEMA.mjs"
240
274
 
241
275
  **For beginners → `mode: template_only`**
242
276
  - ✅ Cerber creates minimal template if file missing
@@ -307,11 +341,11 @@ mode: dev # solo | dev | team
307
341
 
308
342
  guardian:
309
343
  enabled: true
310
- schemaFile: BACKEND_SCHEMA.ts
344
+ schemaFile: BACKEND_SCHEMA.mjs
311
345
 
312
346
  schema:
313
347
  enabled: true
314
- file: BACKEND_SCHEMA.ts
348
+ file: BACKEND_SCHEMA.mjs
315
349
  mode: template_only # strict (mature teams) | template_only (beginners)
316
350
  # strict = You create schema, Cerber never generates
317
351
  # template_only = Cerber creates minimal helper if missing
@@ -370,18 +404,13 @@ npm install cerber-core --save-dev
370
404
  #### 🎨 **Frontend Developer (React/Vue/Angular)**
371
405
 
372
406
  ```bash
373
- # 1. Copy frontend schema example (then customize!)
374
- cp node_modules/cerber-core/examples/frontend-schema.ts ./FRONTEND_SCHEMA.ts
375
-
376
- # 2. Copy validation script
377
- mkdir -p scripts
378
- cp node_modules/cerber-core/guardian/templates/validate-schema.mjs scripts/
407
+ # 1. Initialize Cerber (generates CERBER.md + templates)
408
+ npx cerber init --mode=solo
379
409
 
380
- # 3. Install pre-commit hook
381
- npx husky-init
382
- npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
410
+ # 2. Customize your schema for frontend
411
+ # Edit BACKEND_SCHEMA.mjs (rename to FRONTEND_SCHEMA.mjs if you prefer)
383
412
 
384
- # 4. Test it!
413
+ # 3. Test it!
385
414
  git commit -m "test"
386
415
  # Guardian will validate automatically (<1s)
387
416
  ```
@@ -392,26 +421,21 @@ git commit -m "test"
392
421
  - ✅ Required imports (`react`, `react-dom`)
393
422
  - ✅ Required files (`tsconfig.json`, `vite.config.ts`)
394
423
 
395
- **Then customize:** Edit FRONTEND_SCHEMA.ts to match YOUR folder structure, YOUR rules, YOUR tech stack.
424
+ **Then customize:** Edit BACKEND_SCHEMA.mjs (rename to FRONTEND_SCHEMA.mjs if you prefer) to match YOUR folder structure, YOUR rules, YOUR tech stack.
396
425
 
397
426
  #### ⚙️ **Backend Developer (Node.js/Express/NestJS)**
398
427
 
399
428
  ```bash
400
- # 1. Copy backend schema example (then customize!)
401
- cp node_modules/cerber-core/examples/backend-schema.ts ./BACKEND_SCHEMA.ts
429
+ # 1. Initialize Cerber (generates CERBER.md + guardian + health templates)
430
+ npx cerber init --mode=dev
402
431
 
403
- # 2. Copy validation script
404
- mkdir -p scripts
405
- cp node_modules/cerber-core/guardian/templates/validate-schema.mjs scripts/
432
+ # 2. Customize BACKEND_SCHEMA.mjs
433
+ # Edit to match YOUR routes, YOUR layers, YOUR security rules
406
434
 
407
- # 3. Install pre-commit hook
408
- npx husky-init
409
- npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
410
-
411
- # 4. Add health endpoint
435
+ # 3. Add health endpoint (see example below)
412
436
  ```
413
437
 
414
- **Then customize:** Edit BACKEND_SCHEMA.ts to match YOUR routes, YOUR layers, YOUR security rules.
438
+ **Then customize:** Edit BACKEND_SCHEMA.mjs to match YOUR routes, YOUR layers, YOUR security rules.
415
439
 
416
440
  ```javascript
417
441
  // server.js (ESM)
@@ -499,6 +523,9 @@ cat .cerber/FOCUS_CONTEXT.md
499
523
  All features available through unified CLI:
500
524
 
501
525
  ```bash
526
+ # Doctor - Setup validation (new in v1.1.7)
527
+ npx cerber doctor # Validate CERBER.md, schema, hooks, CI
528
+
502
529
  # Guardian - Pre-commit validation
503
530
  cerber guardian --schema ./SCHEMA.ts
504
531
 
@@ -525,11 +552,59 @@ cerber-focus
525
552
 
526
553
  ---
527
554
 
555
+ ## 🩺 npx cerber doctor (New in v1.1.7)
556
+
557
+ Validate your Cerber setup before commits or deploys:
558
+
559
+ ```bash
560
+ npx cerber doctor
561
+ ```
562
+
563
+ **Exit codes:**
564
+ - `0` ✅ All checks pass
565
+ - `2` ❌ Missing CERBER.md
566
+ - `3` ❌ Missing schema (strict mode only)
567
+ - `4` ❌ Missing pre-commit hook or CI workflow
568
+
569
+ **What it checks:**
570
+ - CERBER.md present + valid YAML
571
+ - Schema file exists (if `schema.mode: strict`)
572
+ - `.husky/pre-commit` hook installed (if `guardian.enabled: true`)
573
+ - GitHub Actions workflow present (if `ci.provider: github`)
574
+ - Emergency override state (DISABLED | ACTIVE | EXPIRED | INVALID)
575
+
576
+ **Example output:**
577
+
578
+ ```
579
+ 🩺 Cerber Doctor - Setup Validation
580
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
581
+
582
+ ✓ CERBER.md: Found and valid
583
+ ✓ Schema: BACKEND_SCHEMA.mjs exists
584
+ ✓ Pre-commit hook: Installed (.husky/pre-commit)
585
+ ✓ CI workflow: Found (.github/workflows/cerber.yml)
586
+ Override: DISABLED
587
+
588
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
589
+ ✅ All checks passed (exit 0)
590
+ ```
591
+
592
+ **Use in CI:**
593
+
594
+ ```yaml
595
+ - name: Validate Cerber setup
596
+ run: npx cerber doctor
597
+ ```
598
+
599
+ If doctor fails → build fails → prevents incomplete Cerber deployments.
600
+
601
+ ---
602
+
528
603
  ## ⚠️ Important: Schema Files Are NOT Source of Truth
529
604
 
530
605
  Before diving into examples below, understand this:
531
606
 
532
- **📋 Schema files (BACKEND_SCHEMA.ts, FRONTEND_SCHEMA.ts):**
607
+ **📋 Schema files (BACKEND_SCHEMA.mjs, FRONTEND_SCHEMA.mjs):**
533
608
  - Are **examples** and **optional templates**
534
609
  - Mirror YOUR architecture decisions from CERBER.md
535
610
  - Are user-owned and user-created (in strict mode)
@@ -548,8 +623,8 @@ Before diving into examples below, understand this:
548
623
 
549
624
  **1. Create architecture schema:**
550
625
 
551
- ```typescript
552
- // BACKEND_SCHEMA.ts
626
+ ```javascript
627
+ // BACKEND_SCHEMA.mjs
553
628
  export const BACKEND_SCHEMA = {
554
629
  version: '1.0.0',
555
630
  rules: [
@@ -573,7 +648,9 @@ export const BACKEND_SCHEMA = {
573
648
  **2. Add pre-commit hook:**
574
649
 
575
650
  ```bash
576
- npx husky add .husky/pre-commit "node scripts/validate-schema.mjs"
651
+ # Pre-commit hook is automatically installed by npx cerber init
652
+ # Or manually:
653
+ npx husky add .husky/pre-commit "npm run cerber:guardian"
577
654
  ```
578
655
 
579
656
  **3. Done!** Guardian now blocks commits that violate architecture rules.
@@ -707,8 +784,8 @@ curl https://your-api.com/api/health
707
784
 
708
785
  ### Example 1: Enforce Express Router in routes
709
786
 
710
- ```typescript
711
- // BACKEND_SCHEMA.ts
787
+ ```javascript
788
+ // BACKEND_SCHEMA.mjs
712
789
  {
713
790
  name: 'Route files must import Router',
714
791
  pattern: /routes\/.*\.ts$/,
@@ -840,8 +917,8 @@ export const cloudinaryCheck = async () => {
840
917
 
841
918
  ### Guardian Configuration
842
919
 
843
- ```typescript
844
- // BACKEND_SCHEMA.ts
920
+ ```javascript
921
+ // BACKEND_SCHEMA.mjs
845
922
  export const BACKEND_SCHEMA = {
846
923
  version: '1.0.0',
847
924
 
@@ -1575,12 +1652,103 @@ Include:
1575
1652
 
1576
1653
  **Response time:** 24-48 hours acknowledgment, 7-14 days for fix.
1577
1654
 
1655
+ ---
1656
+
1657
+ ## 🚨 Emergency Override (New in v1.1.7)
1658
+
1659
+ For **critical production hotfixes only** (P0 incidents), Cerber provides a **controlled safety fuse** with strict time limits.
1660
+
1661
+ ### What Override DOES ✅
1662
+
1663
+ - Allows pre-commit to pass **WITH WARNING** (audit trail logged)
1664
+ - Can skip `postDeploy` gate if configured
1665
+ - Requires: reason, expiry timestamp (TTL), approver name
1666
+ - Automatically expires (guardian validates TTL)
1667
+
1668
+ ### What Override NEVER DOES ❌
1669
+
1670
+ Override is a **safety fuse**, NOT a power switch. It **NEVER** disables:
1671
+
1672
+ - ❌ `cerber-integrity` job (self-protection always runs)
1673
+ - ❌ Entire CI pipeline (build, test, lint must pass)
1674
+ - ❌ `cerber-ci` workflow job (contract validation always runs)
1675
+ - ❌ CODEOWNERS enforcement (team mode protection)
1676
+
1677
+ ### Example: P0 Hotfix
1678
+
1679
+ ```yaml
1680
+ ## CERBER_OVERRIDE
1681
+ enabled: true
1682
+ reason: "P0 - Payment API down, emergency rollback required"
1683
+ expires: "2026-01-04T18:00:00Z" # 6-hour TTL
1684
+ approvedBy: "CTO Stefan"
1685
+ ```
1686
+
1687
+ **Guardian behavior:**
1688
+
1689
+ ```bash
1690
+ git commit -m "fix: rollback payment API to v1.2.3"
1691
+
1692
+ ⚠️ CERBER EMERGENCY OVERRIDE ACTIVE
1693
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1694
+ Reason: P0 - Payment API down, emergency rollback required
1695
+ Expires: 2026-01-04T18:00:00Z (5h 23m remaining)
1696
+ Approved: CTO Stefan
1697
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1698
+ Guardian checks: BYPASSED WITH WARNING
1699
+ Self-protection: STILL ACTIVE (cerber-integrity runs)
1700
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
1701
+
1702
+ [main 3a7f2e9] fix: rollback payment API to v1.2.3
1703
+ ```
1704
+
1705
+ **CI behavior:**
1706
+
1707
+ - ✅ `cerber-integrity` job **runs** (validates CERBER.md, override metadata)
1708
+ - ✅ Build, test, lint jobs **run**
1709
+ - ✅ `cerber-ci` job **runs** (contract validation)
1710
+ - ⚠️ Override warning shown in CI logs (audit trail)
1711
+
1712
+ **After expiry:**
1713
+
1714
+ ```bash
1715
+ git commit -m "feat: add new feature"
1716
+
1717
+ ❌ CERBER EMERGENCY OVERRIDE EXPIRED
1718
+ Override expired at: 2026-01-04T18:00:00Z
1719
+ Proceeding with normal validation...
1720
+
1721
+ ❌ Schema validation failed: Missing type annotation for handlePayment()
1722
+ ```
1723
+
1724
+ ### Verification
1725
+
1726
+ ```bash
1727
+ npx cerber doctor
1728
+ # Shows: Override: ACTIVE (expires 2026-01-04T18:00:00Z)
1729
+ # Or: Override: EXPIRED (expired 2h ago)
1730
+ # Or: Override: DISABLED
1731
+ ```
1732
+
1733
+ ### Rules
1734
+
1735
+ 1. **All fields required:** enabled, reason, expires, approvedBy (missing = invalid = disabled)
1736
+ 2. **TTL enforced:** Guardian checks expiry timestamp (expired = proceeds with normal validation)
1737
+ 3. **Audit trail:** All commits with active override logged with full metadata
1738
+ 4. **No carte blanche:** Hard limits enforced (integrity, CI, CODEOWNERS never bypassed)
1739
+
1740
+ **Use sparingly.** Override is for emergencies, not convenience.
1741
+
1742
+ ---
1743
+
1578
1744
  ### Security Features
1579
1745
 
1580
1746
  ✅ **No External Calls:** Guardian and Cerber run locally, no data sent externally
1581
1747
  ✅ **Open Source:** Full transparency - audit the code yourself
1582
1748
  ✅ **No Telemetry:** No tracking, no analytics, no data collection
1583
1749
  ✅ **MIT Licensed:** Safe for commercial use
1750
+ ✅ **Supply-Chain Hardened:** 2FA, CI-only publishing, no risky lifecycle scripts (v1.1.7)
1751
+ ✅ **Path Safety:** Generator writes only to repo root, whitelist-validated paths (v1.1.7)
1584
1752
 
1585
1753
  ### Best Practices
1586
1754
 
@@ -1589,8 +1757,10 @@ Include:
1589
1757
  - Update regularly: `npm update cerber-core`
1590
1758
  - Enable Dependabot for automated security updates
1591
1759
  - Run `npm audit` regularly
1760
+ - Review CERBER.md changes in PRs (protected by CODEOWNERS in team mode)
1761
+ - Use emergency override sparingly (P0 incidents only)
1592
1762
 
1593
- **Full security policy:** [SECURITY.md](SECURITY.md)
1763
+ **Full security policy:** [SECURITY.md](SECURITY.md) (includes supply-chain security, vulnerability reporting, supported versions)
1594
1764
 
1595
1765
  ---
1596
1766
 
package/bin/cerber CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
 
3
3
  /**
4
4
  * Cerber Core - Unified CLI
@@ -118,4 +118,17 @@ program
118
118
  execSync('node solo/scripts/cerber-dashboard.js', { stdio: 'inherit' });
119
119
  });
120
120
 
121
+
122
+ program
123
+ .command('doctor')
124
+ .description('Validate Cerber setup (checks for missing files)')
125
+ .action(async () => {
126
+ const { runDoctor, printDoctorReport } = await import('../dist/cli/doctor.js');
127
+ const result = await runDoctor(process.cwd());
128
+ printDoctorReport(result);
129
+ process.exit(result.exitCode);
130
+ });
131
+
132
+ program.parse();
133
+
121
134
  program.parse();
@@ -1,50 +1,87 @@
1
- /**
2
- * ⚠️ CERBER TEMPLATE (NOT SOURCE OF TRUTH)
3
- *
4
- * This file is a starting point. Edit it to match YOUR architecture.
5
- * The source of truth is CERBER.md.
6
- *
7
- * Generated by: npx cerber init
8
- * Project: {{PROJECT_NAME}}
9
- *
10
- * See: https://github.com/Agaslez/cerber-core#guardian-configuration
11
- */
12
-
13
- export const BACKEND_SCHEMA = {
14
- version: "1.0.0",
15
-
16
- // Your architecture rules (customize)
17
- rules: [],
18
-
19
- // Patterns that should never appear in your code
20
- forbiddenPatterns: [
21
- // Uncomment and customize based on your tech stack:
22
- // {
23
- // pattern: "password\\s*=\\s*['\"][^'\"]+['\"]",
24
- // flags: "i",
25
- // name: "Hardcoded passwords",
26
- // severity: "error"
27
- // },
28
- // {
29
- // pattern: "api[_-]?key\\s*=\\s*['\"][^'\"]+['\"]",
30
- // flags: "i",
31
- // name: "Hardcoded API keys",
32
- // severity: "error"
33
- // }
34
- ]
35
- };
36
-
37
- export default BACKEND_SCHEMA;
38
-
39
- /**
40
- * 💡 Next Steps:
41
- *
42
- * 1. Define your project structure in CERBER.md (single source of truth)
43
- * 2. Add forbiddenPatterns for your tech stack
44
- * 3. Add requiredImports rules for your architecture layers
45
- * 4. Test with: npx cerber-guardian
46
- *
47
- * Full examples:
48
- * - node_modules/cerber-core/examples/backend-schema.ts
49
- * - node_modules/cerber-core/examples/frontend-schema.ts
50
- */
1
+ /**
2
+ * ⚠️ CERBER TEMPLATE (NOT SOURCE OF TRUTH)
3
+ *
4
+ * This file is a starting point. Edit it to match YOUR architecture.
5
+ * The source of truth is CERBER.md.
6
+ *
7
+ * Generated by: npx cerber init
8
+ * Project: {{PROJECT_NAME}}
9
+ *
10
+ * See: https://github.com/Agaslez/cerber-core#guardian-configuration
11
+ */
12
+
13
+ export const BACKEND_SCHEMA = {
14
+ version: "1.0.0",
15
+
16
+ // Your architecture rules (customize)
17
+ rules: [],
18
+
19
+ // Patterns that should never appear in your code
20
+ forbiddenPatterns: [
21
+ // ──────────────────────────────────────────────────────────────────────
22
+ // 🔐 SECURITY BASELINE (Uncomment and adapt to your CERBER.md contract)
23
+ // ──────────────────────────────────────────────────────────────────────
24
+
25
+ // Hardcoded secrets (common examples - adapt to your stack):
26
+ // {
27
+ // pattern: "password\\s*=\\s*['\"][^'\"]+['\"]" ,
28
+ // flags: "i",
29
+ // name: "Hardcoded passwords (e.g., password='admin123')",
30
+ // severity: "error"
31
+ // },
32
+ // {
33
+ // pattern: "api[_-]?key\\s*=\\s*['\"][^'\"]+['\"]" ,
34
+ // flags: "i",
35
+ // name: "Hardcoded API keys (e.g., API_KEY='xyz')",
36
+ // severity: "error"
37
+ // },
38
+ // {
39
+ // pattern: "JWT_SECRET\\s*=\\s*['\"][^'\"]+['\"]" ,
40
+ // flags: "i",
41
+ // name: "Hardcoded JWT secrets",
42
+ // severity: "error"
43
+ // },
44
+
45
+ // Development artifacts (should not reach production):
46
+ // {
47
+ // pattern: "console\\.log\\(",
48
+ // flags: "g",
49
+ // name: "console.log (use proper logging)",
50
+ // severity: "warning"
51
+ // },
52
+ // {
53
+ // pattern: "debugger;",
54
+ // flags: "g",
55
+ // name: "debugger statement",
56
+ // severity: "warning"
57
+ // },
58
+
59
+ // TODOs that should be resolved before commit:
60
+ // {
61
+ // pattern: "TODO_REMOVE|FIXME_REMOVE",
62
+ // flags: "i",
63
+ // name: "Unresolved critical TODOs",
64
+ // severity: "error"
65
+ // },
66
+
67
+ // ──────────────────────────────────────────────────────────────────────
68
+ // ⚠️ IMPORTANT: Uncomment patterns that match rules in your CERBER.md
69
+ // Never invent rules. Only translate what's documented in your contract.
70
+ // ──────────────────────────────────────────────────────────────────────
71
+ ]
72
+ };
73
+
74
+ export default BACKEND_SCHEMA;
75
+
76
+ /**
77
+ * 💡 Next Steps:
78
+ *
79
+ * 1. Define your project structure in CERBER.md (single source of truth)
80
+ * 2. Add forbiddenPatterns for your tech stack
81
+ * 3. Add requiredImports rules for your architecture layers
82
+ * 4. Test with: npx cerber-guardian
83
+ *
84
+ * Full examples:
85
+ * - node_modules/cerber-core/examples/backend-schema.ts
86
+ * - node_modules/cerber-core/examples/frontend-schema.ts
87
+ */