sinapse-ai 7.7.5 → 7.7.6
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/.claude/CLAUDE.md +1 -0
- package/.claude/rules/security-data-protection.md +184 -0
- package/.codex/delegation-matrix.json +364 -475
- package/.codex/handoff-packet.schema.json +13 -93
- package/.codex/scripts/resolve-codex-delegation-parity.js +205 -0
- package/.codex/scripts/resolve-codex-delegation.js +92 -121
- package/.codex/tasks/route-sinapse-request.md +2 -2
- package/.sinapse-ai/constitution.md +67 -1
- package/.sinapse-ai/core/doctor/checks/constitution-consistency.js +1 -0
- package/.sinapse-ai/core/health-check/checks/project/constitution-consistency.js +1 -0
- package/.sinapse-ai/data/entity-registry.yaml +757 -764
- package/.sinapse-ai/data/registry-update-log.jsonl +3 -0
- package/.sinapse-ai/infrastructure/scripts/validate-codex-delegation.js +5 -3
- package/.sinapse-ai/install-manifest.yaml +12 -12
- package/.sinapse-ai/product/templates/ide-rules/claude-rules.md +1 -0
- package/docs/codex-delegation-parity.md +115 -0
- package/docs/codex-parity-program.md +7 -0
- package/package.json +1 -1
package/.claude/CLAUDE.md
CHANGED
|
@@ -24,6 +24,7 @@ O SINAPSE possui uma **Constitution formal** com princípios inegociáveis e gat
|
|
|
24
24
|
| VII | Ecosystem Metrics Accuracy | NON-NEGOTIABLE |
|
|
25
25
|
| VIII | Mandatory Delegation | NON-NEGOTIABLE |
|
|
26
26
|
| IX | Safe Collaboration | NON-NEGOTIABLE |
|
|
27
|
+
| X | Security & Data Protection | NON-NEGOTIABLE |
|
|
27
28
|
|
|
28
29
|
**Gates automáticos bloqueiam violações.** Consulte a Constitution para detalhes completos.
|
|
29
30
|
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# Security & Data Protection (NON-NEGOTIABLE)
|
|
2
|
+
|
|
3
|
+
> **Constitution Article X — NON-NEGOTIABLE**
|
|
4
|
+
> Applies to ALL agents, ALL projects handling user data.
|
|
5
|
+
> Source: SINAPSE Cyber Squad + CRIABR Security Guide #0023
|
|
6
|
+
|
|
7
|
+
## Rule
|
|
8
|
+
|
|
9
|
+
Every project that handles user data MUST follow these security practices from the first commit. No shortcuts, no "we'll add security later."
|
|
10
|
+
|
|
11
|
+
## Database Security
|
|
12
|
+
|
|
13
|
+
### RLS (Row Level Security) — MANDATORY
|
|
14
|
+
```sql
|
|
15
|
+
-- EVERY table with user data must have RLS enabled
|
|
16
|
+
ALTER TABLE {table_name} ENABLE ROW LEVEL SECURITY;
|
|
17
|
+
|
|
18
|
+
-- Policy: users only see their own data
|
|
19
|
+
CREATE POLICY "users_own_data"
|
|
20
|
+
ON {table_name}
|
|
21
|
+
FOR ALL
|
|
22
|
+
USING (auth.uid() = user_id);
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### service_role — NEVER in frontend
|
|
26
|
+
| Key | Where | What |
|
|
27
|
+
|-----|-------|------|
|
|
28
|
+
| `anon` | Frontend/client | Respects RLS policies |
|
|
29
|
+
| `service_role` | Server ONLY | Bypasses RLS — full access |
|
|
30
|
+
|
|
31
|
+
### SQL Injection — ALWAYS parameterize
|
|
32
|
+
```javascript
|
|
33
|
+
// FORBIDDEN: string interpolation
|
|
34
|
+
db.query(`SELECT * FROM users WHERE name = '${input}'`);
|
|
35
|
+
|
|
36
|
+
// REQUIRED: parameterized queries
|
|
37
|
+
db.query('SELECT * FROM users WHERE name = $1', [input]);
|
|
38
|
+
|
|
39
|
+
// Supabase: already parameterized
|
|
40
|
+
supabase.from('users').select('*').eq('name', input);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Least Privilege
|
|
44
|
+
- Each service uses a dedicated role with minimal permissions
|
|
45
|
+
- Read-only services get SELECT only
|
|
46
|
+
- Never connect with postgres superuser from application code
|
|
47
|
+
|
|
48
|
+
## API Security
|
|
49
|
+
|
|
50
|
+
### Rate Limiting — MANDATORY
|
|
51
|
+
```javascript
|
|
52
|
+
// Every public API must have rate limiting
|
|
53
|
+
const limiter = rateLimit({
|
|
54
|
+
windowMs: 15 * 60 * 1000, // 15 minutes
|
|
55
|
+
max: 100, // 100 requests per window
|
|
56
|
+
standardHeaders: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Stricter for auth endpoints
|
|
60
|
+
const authLimiter = rateLimit({
|
|
61
|
+
windowMs: 15 * 60 * 1000,
|
|
62
|
+
max: 5, // Only 5 login attempts per window
|
|
63
|
+
});
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Input Validation — MANDATORY
|
|
67
|
+
```javascript
|
|
68
|
+
// Use Zod or equivalent for ALL inputs
|
|
69
|
+
const schema = z.object({
|
|
70
|
+
email: z.string().email(),
|
|
71
|
+
name: z.string().min(2).max(100),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const result = schema.safeParse(input);
|
|
75
|
+
if (!result.success) return res.status(400).json(result.error);
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### CORS — RESTRICT origins
|
|
79
|
+
```javascript
|
|
80
|
+
// FORBIDDEN in production
|
|
81
|
+
app.use(cors({ origin: '*' }));
|
|
82
|
+
|
|
83
|
+
// REQUIRED: explicit origins
|
|
84
|
+
app.use(cors({
|
|
85
|
+
origin: ['https://myapp.com', 'https://api.myapp.com'],
|
|
86
|
+
credentials: true,
|
|
87
|
+
}));
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Security Headers — helmet
|
|
91
|
+
```javascript
|
|
92
|
+
app.use(helmet()); // Sets X-Frame-Options, CSP, HSTS, etc.
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Secrets Management
|
|
96
|
+
|
|
97
|
+
### .env rules
|
|
98
|
+
- `.env` files MUST be in `.gitignore` — NEVER committed
|
|
99
|
+
- `.env.example` MUST exist with placeholder values
|
|
100
|
+
- `NEXT_PUBLIC_*` variables are PUBLIC — never put secrets in them
|
|
101
|
+
- Rotate keys immediately on any suspected leak
|
|
102
|
+
|
|
103
|
+
### Platform secrets
|
|
104
|
+
| Platform | Where to store |
|
|
105
|
+
|----------|---------------|
|
|
106
|
+
| Vercel | Environment Variables in dashboard |
|
|
107
|
+
| Supabase | Vault or Edge Function secrets |
|
|
108
|
+
| AWS | Secrets Manager or Parameter Store |
|
|
109
|
+
| GitHub | Repository Secrets (Settings > Secrets) |
|
|
110
|
+
|
|
111
|
+
## LGPD Compliance
|
|
112
|
+
|
|
113
|
+
### Required for ALL projects with Brazilian user data
|
|
114
|
+
- Consent collection before processing personal data (Art. 7)
|
|
115
|
+
- User rights: access, correct, delete their data (Art. 18)
|
|
116
|
+
- DPO/Encarregado designation (Art. 37)
|
|
117
|
+
- Technical security measures (Art. 46)
|
|
118
|
+
- Breach notification to ANPD + data subjects (Art. 48)
|
|
119
|
+
- Data retention period defined and documented
|
|
120
|
+
- Audit logging for all personal data access
|
|
121
|
+
|
|
122
|
+
## Security Checklist (verify before EVERY deploy)
|
|
123
|
+
|
|
124
|
+
### Database
|
|
125
|
+
- [ ] RLS enabled on ALL tables with user data
|
|
126
|
+
- [ ] service_role NOT exposed in frontend code
|
|
127
|
+
- [ ] All queries parameterized (no string interpolation)
|
|
128
|
+
- [ ] Sensitive data encrypted at rest (pgcrypto or equivalent)
|
|
129
|
+
- [ ] Database roles follow least privilege principle
|
|
130
|
+
|
|
131
|
+
### APIs
|
|
132
|
+
- [ ] Rate limiting on all public endpoints
|
|
133
|
+
- [ ] Auth endpoints have stricter rate limits
|
|
134
|
+
- [ ] Input validation with schema (Zod/Joi)
|
|
135
|
+
- [ ] CORS restricted to known origins
|
|
136
|
+
- [ ] Security headers active (helmet)
|
|
137
|
+
|
|
138
|
+
### Secrets
|
|
139
|
+
- [ ] .env in .gitignore
|
|
140
|
+
- [ ] .env.example exists with placeholders
|
|
141
|
+
- [ ] No NEXT_PUBLIC_ with secrets
|
|
142
|
+
- [ ] No hardcoded keys in source code
|
|
143
|
+
- [ ] git-secrets or truffleHog scan ran
|
|
144
|
+
|
|
145
|
+
### GitHub
|
|
146
|
+
- [ ] Repository is private (for production code)
|
|
147
|
+
- [ ] Branch protection active on main
|
|
148
|
+
- [ ] GitHub Secret Scanning enabled
|
|
149
|
+
- [ ] Dependabot configured
|
|
150
|
+
- [ ] CODEOWNERS protects critical files
|
|
151
|
+
- [ ] CI/CD uses GitHub Secrets (not hardcoded)
|
|
152
|
+
|
|
153
|
+
### LGPD
|
|
154
|
+
- [ ] Consent form with explicit opt-in
|
|
155
|
+
- [ ] Data deletion endpoint/mechanism exists
|
|
156
|
+
- [ ] DPO/Encarregado designated
|
|
157
|
+
- [ ] Privacy policy published and accessible
|
|
158
|
+
- [ ] Breach notification procedure documented
|
|
159
|
+
- [ ] Data retention periods defined
|
|
160
|
+
|
|
161
|
+
## Delegation
|
|
162
|
+
|
|
163
|
+
Security work MUST be delegated to the appropriate specialist:
|
|
164
|
+
|
|
165
|
+
| Request | Delegate To |
|
|
166
|
+
|---------|-------------|
|
|
167
|
+
| Threat modeling | @cyber-orqx → Shield |
|
|
168
|
+
| Penetration testing | @cyber-orqx → Breach |
|
|
169
|
+
| Incident response | @cyber-orqx → Rapid |
|
|
170
|
+
| LGPD/compliance | @cyber-orqx → Govern |
|
|
171
|
+
| Cloud security | @cyber-orqx → Nimbus |
|
|
172
|
+
| Database security/RLS | @data-engineer (Dara) |
|
|
173
|
+
| Application security | @developer (Dex) |
|
|
174
|
+
|
|
175
|
+
## Anti-Patterns (FORBIDDEN)
|
|
176
|
+
|
|
177
|
+
- Using superuser credentials in application code
|
|
178
|
+
- Disabling RLS "temporarily" (it never gets re-enabled)
|
|
179
|
+
- Hardcoding API keys "just for testing"
|
|
180
|
+
- Using `origin: '*'` in CORS
|
|
181
|
+
- Skipping input validation on "internal" APIs
|
|
182
|
+
- Storing passwords in plain text
|
|
183
|
+
- Logging personal data (PII) without masking
|
|
184
|
+
- "We'll add security later" — security is from day one
|