cerber-core 1.1.6 → 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.
- package/CHANGELOG.md +111 -0
- package/README.md +157 -1
- package/bin/cerber +14 -1
- package/dev/templates/BACKEND_SCHEMA.ts.tpl +87 -50
- package/dev/templates/cerber-guardian.mjs.tpl +254 -148
- package/dev/templates/cerber.yml.tpl +96 -53
- package/dev/templates/pre-commit.tpl +4 -4
- package/dist/cli/contract-parser.d.ts.map +1 -1
- package/dist/cli/contract-parser.js +47 -20
- package/dist/cli/contract-parser.js.map +1 -1
- package/dist/cli/doctor.d.ts +16 -0
- package/dist/cli/doctor.d.ts.map +1 -0
- package/dist/cli/doctor.js +140 -0
- package/dist/cli/doctor.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +93 -8
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/override-validator.d.ts +27 -0
- package/dist/cli/override-validator.d.ts.map +1 -0
- package/dist/cli/override-validator.js +100 -0
- package/dist/cli/override-validator.js.map +1 -0
- package/dist/cli/template-generator.d.ts.map +1 -1
- package/dist/cli/template-generator.js +71 -16
- package/dist/cli/template-generator.js.map +1 -1
- package/dist/cli/types.d.ts +7 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +117 -117
- package/solo/templates/BACKEND_SCHEMA.ts.tpl +87 -50
- package/solo/templates/cerber-guardian.mjs.tpl +254 -148
- package/solo/templates/cerber.yml.tpl +96 -53
- package/solo/templates/pre-commit.tpl +4 -4
- package/team/templates/BACKEND_SCHEMA.ts.tpl +87 -50
- package/team/templates/CODEOWNERS.tpl +18 -6
- package/team/templates/cerber-guardian.mjs.tpl +254 -148
- package/team/templates/cerber.yml.tpl +96 -53
- 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
|
@@ -52,6 +52,18 @@ npx cerber init
|
|
|
52
52
|
|
|
53
53
|
**Working with Cerber:** Read `CERBER.md` first. It tells you what's allowed and what's protected.
|
|
54
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
|
+
|
|
55
67
|
---
|
|
56
68
|
|
|
57
69
|
## 📊 Real Production Metrics
|
|
@@ -511,6 +523,9 @@ cat .cerber/FOCUS_CONTEXT.md
|
|
|
511
523
|
All features available through unified CLI:
|
|
512
524
|
|
|
513
525
|
```bash
|
|
526
|
+
# Doctor - Setup validation (new in v1.1.7)
|
|
527
|
+
npx cerber doctor # Validate CERBER.md, schema, hooks, CI
|
|
528
|
+
|
|
514
529
|
# Guardian - Pre-commit validation
|
|
515
530
|
cerber guardian --schema ./SCHEMA.ts
|
|
516
531
|
|
|
@@ -537,6 +552,54 @@ cerber-focus
|
|
|
537
552
|
|
|
538
553
|
---
|
|
539
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
|
+
|
|
540
603
|
## ⚠️ Important: Schema Files Are NOT Source of Truth
|
|
541
604
|
|
|
542
605
|
Before diving into examples below, understand this:
|
|
@@ -1589,12 +1652,103 @@ Include:
|
|
|
1589
1652
|
|
|
1590
1653
|
**Response time:** 24-48 hours acknowledgment, 7-14 days for fix.
|
|
1591
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
|
+
|
|
1592
1744
|
### Security Features
|
|
1593
1745
|
|
|
1594
1746
|
✅ **No External Calls:** Guardian and Cerber run locally, no data sent externally
|
|
1595
1747
|
✅ **Open Source:** Full transparency - audit the code yourself
|
|
1596
1748
|
✅ **No Telemetry:** No tracking, no analytics, no data collection
|
|
1597
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)
|
|
1598
1752
|
|
|
1599
1753
|
### Best Practices
|
|
1600
1754
|
|
|
@@ -1603,8 +1757,10 @@ Include:
|
|
|
1603
1757
|
- Update regularly: `npm update cerber-core`
|
|
1604
1758
|
- Enable Dependabot for automated security updates
|
|
1605
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)
|
|
1606
1762
|
|
|
1607
|
-
**Full security policy:** [SECURITY.md](SECURITY.md)
|
|
1763
|
+
**Full security policy:** [SECURITY.md](SECURITY.md) (includes supply-chain security, vulnerability reporting, supported versions)
|
|
1608
1764
|
|
|
1609
1765
|
---
|
|
1610
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
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
+
*/
|