myconvergio 2.1.0

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 (85) hide show
  1. package/.claude/agents/business_operations/andrea-customer-success-manager.md +175 -0
  2. package/.claude/agents/business_operations/anna-executive-assistant.md +268 -0
  3. package/.claude/agents/business_operations/dave-change-management-specialist.md +200 -0
  4. package/.claude/agents/business_operations/davide-project-manager.md +203 -0
  5. package/.claude/agents/business_operations/enrico-business-process-engineer.md +180 -0
  6. package/.claude/agents/business_operations/fabio-sales-business-development.md +175 -0
  7. package/.claude/agents/business_operations/luke-program-manager.md +105 -0
  8. package/.claude/agents/business_operations/marcello-pm.md +130 -0
  9. package/.claude/agents/business_operations/oliver-pm.md +134 -0
  10. package/.claude/agents/business_operations/sofia-marketing-strategist.md +175 -0
  11. package/.claude/agents/business_operations/steve-executive-communication-strategist.md +111 -0
  12. package/.claude/agents/compliance_legal/dr-enzo-healthcare-compliance-manager.md +198 -0
  13. package/.claude/agents/compliance_legal/elena-legal-compliance-expert.md +169 -0
  14. package/.claude/agents/compliance_legal/guardian-ai-security-validator.md +207 -0
  15. package/.claude/agents/compliance_legal/luca-security-expert.md +229 -0
  16. package/.claude/agents/compliance_legal/sophia-govaffairs.md +132 -0
  17. package/.claude/agents/core_utility/CONSTITUTION.md +365 -0
  18. package/.claude/agents/core_utility/CommonValuesAndPrinciples.md +296 -0
  19. package/.claude/agents/core_utility/MICROSOFT_VALUES.md +121 -0
  20. package/.claude/agents/core_utility/SECURITY_FRAMEWORK_TEMPLATE.md +137 -0
  21. package/.claude/agents/core_utility/diana-performance-dashboard.md +238 -0
  22. package/.claude/agents/core_utility/marcus-context-memory-keeper.md +218 -0
  23. package/.claude/agents/core_utility/po-prompt-optimizer.md +194 -0
  24. package/.claude/agents/core_utility/socrates-first-principles-reasoning.md +260 -0
  25. package/.claude/agents/core_utility/strategic-planner.md +292 -0
  26. package/.claude/agents/core_utility/taskmaster-strategic-task-decomposition-master.md +152 -0
  27. package/.claude/agents/core_utility/thor-quality-assurance-guardian.md +223 -0
  28. package/.claude/agents/core_utility/wanda-workflow-orchestrator.md +247 -0
  29. package/.claude/agents/core_utility/xavier-coordination-patterns.md +251 -0
  30. package/.claude/agents/design_ux/jony-creative-director.md +172 -0
  31. package/.claude/agents/design_ux/sara-ux-ui-designer.md +166 -0
  32. package/.claude/agents/design_ux/stefano-design-thinking-facilitator.md +180 -0
  33. package/.claude/agents/leadership_strategy/ali-chief-of-staff.md +594 -0
  34. package/.claude/agents/leadership_strategy/amy-cfo.md +179 -0
  35. package/.claude/agents/leadership_strategy/antonio-strategy-expert.md +217 -0
  36. package/.claude/agents/leadership_strategy/dan-engineering-gm.md +260 -0
  37. package/.claude/agents/leadership_strategy/domik-mckinsey-strategic-decision-maker.md +324 -0
  38. package/.claude/agents/leadership_strategy/matteo-strategic-business-architect.md +177 -0
  39. package/.claude/agents/leadership_strategy/satya-board-of-directors.md +222 -0
  40. package/.claude/agents/release_management/app-release-manager.md +2352 -0
  41. package/.claude/agents/release_management/feature-release-manager.md +235 -0
  42. package/.claude/agents/specialized_experts/angela-da.md +140 -0
  43. package/.claude/agents/specialized_experts/ava-analytics-insights-virtuoso.md +203 -0
  44. package/.claude/agents/specialized_experts/behice-cultural-coach.md +202 -0
  45. package/.claude/agents/specialized_experts/coach-team-coach.md +180 -0
  46. package/.claude/agents/specialized_experts/ethan-da.md +139 -0
  47. package/.claude/agents/specialized_experts/evan-ic6da.md +140 -0
  48. package/.claude/agents/specialized_experts/fiona-market-analyst.md +148 -0
  49. package/.claude/agents/specialized_experts/giulia-hr-talent-acquisition.md +175 -0
  50. package/.claude/agents/specialized_experts/jenny-inclusive-accessibility-champion.md +200 -0
  51. package/.claude/agents/specialized_experts/michael-vc.md +130 -0
  52. package/.claude/agents/specialized_experts/riccardo-storyteller.md +158 -0
  53. package/.claude/agents/specialized_experts/sam-startupper.md +253 -0
  54. package/.claude/agents/specialized_experts/wiz-investor-venture-capital.md +182 -0
  55. package/.claude/agents/technical_development/baccio-tech-architect.md +210 -0
  56. package/.claude/agents/technical_development/dario-debugger.md +250 -0
  57. package/.claude/agents/technical_development/marco-devops-engineer.md +200 -0
  58. package/.claude/agents/technical_development/omri-data-scientist.md +194 -0
  59. package/.claude/agents/technical_development/otto-performance-optimizer.md +262 -0
  60. package/.claude/agents/technical_development/paolo-best-practices-enforcer.md +303 -0
  61. package/.claude/agents/technical_development/rex-code-reviewer.md +231 -0
  62. package/.claude/rules/api-development.md +358 -0
  63. package/.claude/rules/code-style.md +129 -0
  64. package/.claude/rules/documentation-standards.md +359 -0
  65. package/.claude/rules/ethical-guidelines.md +383 -0
  66. package/.claude/rules/security-requirements.md +182 -0
  67. package/.claude/rules/testing-standards.md +266 -0
  68. package/.claude/skills/architecture/SKILL.md +228 -0
  69. package/.claude/skills/code-review/SKILL.md +140 -0
  70. package/.claude/skills/debugging/SKILL.md +192 -0
  71. package/.claude/skills/performance/SKILL.md +277 -0
  72. package/.claude/skills/project-management/SKILL.md +382 -0
  73. package/.claude/skills/release-management/SKILL.md +342 -0
  74. package/.claude/skills/security-audit/SKILL.md +276 -0
  75. package/.claude/skills/strategic-analysis/SKILL.md +338 -0
  76. package/LICENSE +60 -0
  77. package/README.md +379 -0
  78. package/VERSION +29 -0
  79. package/bin/myconvergio.js +304 -0
  80. package/package.json +43 -0
  81. package/scripts/bump-agent-version.sh +220 -0
  82. package/scripts/postinstall.js +172 -0
  83. package/scripts/sync-from-convergiocli.sh +169 -0
  84. package/scripts/test-deployment.sh +188 -0
  85. package/scripts/version-manager.sh +213 -0
@@ -0,0 +1,383 @@
1
+ # Ethical Guidelines
2
+
3
+ > This rule is enforced by the MyConvergio agent ecosystem.
4
+
5
+ ## Overview
6
+ Technology has profound impact on individuals and society. All development in the MyConvergio ecosystem must adhere to ethical principles that prioritize user welfare, privacy, accessibility, and fairness. These guidelines complement our [CONSTITUTION.md](../CONSTITUTION.md) and ensure responsible, inclusive technology development.
7
+
8
+ ## Requirements
9
+
10
+ ### User Privacy Protection
11
+ - Collect only necessary data (data minimization principle)
12
+ - Obtain explicit consent before collecting personal information
13
+ - Provide clear, understandable privacy policies
14
+ - Implement privacy by design and by default
15
+ - Allow users to access, modify, and delete their data
16
+ - Encrypt sensitive data in transit and at rest
17
+ - Comply with GDPR, CCPA, and relevant privacy regulations
18
+ - Regular privacy impact assessments
19
+
20
+ ### Accessibility (WCAG 2.1 AA Compliance)
21
+ - All user interfaces must be keyboard navigable
22
+ - Provide text alternatives for non-text content
23
+ - Ensure sufficient color contrast (4.5:1 for normal text)
24
+ - Support screen readers and assistive technologies
25
+ - Provide captions for audio/video content
26
+ - Allow text resizing up to 200% without loss of functionality
27
+ - Design for diverse abilities (motor, visual, auditory, cognitive)
28
+ - Test with actual users with disabilities
29
+
30
+ ### Inclusive Language
31
+ - Use gender-neutral language in code and documentation
32
+ - Avoid terms with historical negative connotations (blacklist/whitelist → blocklist/allowlist)
33
+ - Use person-first language when discussing disabilities
34
+ - Avoid cultural assumptions in examples and defaults
35
+ - Support internationalization and localization
36
+ - Be mindful of cultural sensitivities in imagery and content
37
+ - Use clear, simple language (avoid jargon when possible)
38
+
39
+ ### Non-Discriminatory Algorithms
40
+ - Audit algorithms for bias across protected characteristics
41
+ - Ensure training data represents diverse populations
42
+ - Test for disparate impact on different demographic groups
43
+ - Document limitations and potential biases in AI/ML systems
44
+ - Provide explanations for automated decisions affecting users
45
+ - Enable human review for high-stakes decisions
46
+ - Monitor deployed systems for emerging biases
47
+
48
+ ### Transparency in AI Decisions
49
+ - Clearly disclose when users interact with AI systems
50
+ - Provide explanations for AI-driven recommendations
51
+ - Allow users to opt out of automated decision-making when possible
52
+ - Document AI model capabilities and limitations
53
+ - Make training data sources transparent (when appropriate)
54
+ - Provide confidence scores for AI predictions
55
+ - Enable user feedback on AI decisions
56
+
57
+ ### Data Minimization
58
+ - Collect only data necessary for stated purposes
59
+ - Delete data when no longer needed
60
+ - Avoid "just in case" data collection
61
+ - Aggregate or anonymize data when possible
62
+ - Provide users with data portability
63
+ - Regular data audits to remove unnecessary information
64
+ - Clear data retention policies
65
+
66
+ ### Consent and Control
67
+ - Obtain informed consent for data collection
68
+ - Use clear, plain language in consent requests
69
+ - Granular consent options (not all-or-nothing)
70
+ - Easy-to-use privacy controls and preferences
71
+ - Respect "Do Not Track" and similar signals
72
+ - Allow consent withdrawal at any time
73
+ - No dark patterns or manipulative design
74
+
75
+ ### Security as User Protection
76
+ - Security measures protect users, not just systems
77
+ - Prompt notification of data breaches
78
+ - Secure defaults (opt-in for sharing, not opt-out)
79
+ - Regular security audits and penetration testing
80
+ - Vulnerability disclosure program
81
+ - User education about security features
82
+
83
+ ### Environmental Responsibility
84
+ - Optimize code for energy efficiency
85
+ - Consider carbon footprint of infrastructure choices
86
+ - Use renewable energy for hosting when possible
87
+ - Implement efficient caching and data transfer strategies
88
+ - Monitor and reduce resource consumption
89
+
90
+ ### Honesty and Integrity
91
+ - Never mislead users about product capabilities
92
+ - Clearly communicate limitations and risks
93
+ - Acknowledge and fix mistakes promptly
94
+ - No deceptive design patterns
95
+ - Transparent about business model and incentives
96
+ - Honest marketing and feature claims
97
+
98
+ ## Examples
99
+
100
+ ### Good Examples
101
+
102
+ #### Privacy by Design
103
+ ```typescript
104
+ // Good: Minimal data collection with explicit consent
105
+ interface UserRegistration {
106
+ email: string; // Required for account
107
+ name: string; // Required for personalization
108
+ // Optional fields require separate consent
109
+ marketingConsent?: boolean;
110
+ analyticsConsent?: boolean;
111
+ }
112
+
113
+ const registerUser = async (data: UserRegistration) => {
114
+ // Only collect consented data
115
+ const userData = {
116
+ email: data.email,
117
+ name: data.name,
118
+ preferences: {
119
+ marketing: data.marketingConsent ?? false,
120
+ analytics: data.analyticsConsent ?? false
121
+ },
122
+ createdAt: new Date()
123
+ };
124
+
125
+ // No tracking without consent
126
+ if (userData.preferences.analytics) {
127
+ trackEvent('user_registered');
128
+ }
129
+
130
+ return await createUser(userData);
131
+ };
132
+ ```
133
+
134
+ #### Accessible UI Components
135
+ ```typescript
136
+ // Good: Accessible button with ARIA labels
137
+ const AccessibleButton: React.FC<{
138
+ onClick: () => void;
139
+ icon: React.ReactNode;
140
+ label: string;
141
+ }> = ({ onClick, icon, label }) => {
142
+ return (
143
+ <button
144
+ onClick={onClick}
145
+ aria-label={label}
146
+ className="btn"
147
+ // Ensure focus is visible
148
+ style={{ outline: '2px solid transparent' }}
149
+ onFocus={(e) => e.target.style.outline = '2px solid blue'}
150
+ onBlur={(e) => e.target.style.outline = '2px solid transparent'}
151
+ >
152
+ {icon}
153
+ <span className="sr-only">{label}</span>
154
+ </button>
155
+ );
156
+ };
157
+
158
+ // Good: Sufficient color contrast
159
+ const styles = {
160
+ text: {
161
+ color: '#1a1a1a', // Dark text
162
+ backgroundColor: '#ffffff' // White background
163
+ // Contrast ratio: 18.5:1 (exceeds WCAG AAA)
164
+ },
165
+ link: {
166
+ color: '#0066cc', // Blue link
167
+ textDecoration: 'underline' // Not relying on color alone
168
+ // Contrast ratio: 8.6:1 (exceeds WCAG AA)
169
+ }
170
+ };
171
+ ```
172
+
173
+ #### Inclusive Language
174
+ ```python
175
+ # Good: Inclusive terminology
176
+ ALLOWED_DOMAINS = ['example.com', 'trusted.com'] # Instead of "whitelist"
177
+ BLOCKED_DOMAINS = ['spam.com', 'malicious.com'] # Instead of "blacklist"
178
+
179
+ # Good: Gender-neutral language
180
+ def notify_users(users: list[User]) -> None:
181
+ """Send notifications to users."""
182
+ for user in users:
183
+ send_email(user.email, f"Hello {user.name}") # Not "Hi guys"
184
+
185
+ # Good: Person-first language
186
+ class AccessibilityFeature:
187
+ """Features for users with visual impairments."""
188
+ # Not "features for blind users" or "for the disabled"
189
+ ```
190
+
191
+ #### Bias Detection in ML
192
+ ```python
193
+ # Good: Audit model for bias across demographics
194
+ def audit_model_fairness(
195
+ model: Model,
196
+ test_data: pd.DataFrame,
197
+ protected_attributes: list[str]
198
+ ) -> FairnessReport:
199
+ """Audit ML model for bias across protected characteristics.
200
+
201
+ Args:
202
+ model: Trained ML model to audit
203
+ test_data: Test dataset with demographic attributes
204
+ protected_attributes: Attributes to check for bias (race, gender, age)
205
+
206
+ Returns:
207
+ FairnessReport with metrics across demographic groups
208
+ """
209
+ report = FairnessReport()
210
+
211
+ for attr in protected_attributes:
212
+ for group_value in test_data[attr].unique():
213
+ group_data = test_data[test_data[attr] == group_value]
214
+ predictions = model.predict(group_data)
215
+
216
+ # Calculate metrics for this demographic group
217
+ accuracy = calculate_accuracy(predictions, group_data['label'])
218
+ false_positive_rate = calculate_fpr(predictions, group_data['label'])
219
+
220
+ report.add_group_metrics(attr, group_value, {
221
+ 'accuracy': accuracy,
222
+ 'false_positive_rate': false_positive_rate,
223
+ 'sample_size': len(group_data)
224
+ })
225
+
226
+ # Flag disparate impact
227
+ if report.has_disparate_impact(threshold=0.8):
228
+ logger.warning(f"Model shows disparate impact: {report.summary()}")
229
+
230
+ return report
231
+ ```
232
+
233
+ #### Transparent AI Disclosure
234
+ ```typescript
235
+ // Good: Clear AI disclosure with explanation
236
+ const AIRecommendation: React.FC<{ recommendation: Product }> = ({
237
+ recommendation
238
+ }) => {
239
+ return (
240
+ <div className="ai-recommendation">
241
+ <div className="ai-badge" role="status" aria-label="AI-generated recommendation">
242
+ <RobotIcon /> AI Recommendation
243
+ </div>
244
+ <ProductCard product={recommendation} />
245
+ <details>
246
+ <summary>Why are we recommending this?</summary>
247
+ <p>
248
+ This recommendation is based on:
249
+ <ul>
250
+ <li>Your recent browsing history</li>
251
+ <li>Similar users' preferences</li>
252
+ <li>Product popularity in your region</li>
253
+ </ul>
254
+ <a href="/privacy/ai-recommendations">
255
+ Learn more about our recommendation system
256
+ </a>
257
+ </p>
258
+ </details>
259
+ <button onClick={handleOptOut}>
260
+ Don't show AI recommendations
261
+ </button>
262
+ </div>
263
+ );
264
+ };
265
+ ```
266
+
267
+ ### Bad Examples
268
+
269
+ #### Privacy Violations
270
+ ```typescript
271
+ // Bad: Excessive data collection without consent
272
+ interface UserRegistration {
273
+ email: string;
274
+ name: string;
275
+ phoneNumber: string; // Why do we need this?
276
+ dateOfBirth: string; // Why do we need this?
277
+ location: GeoLocation; // Collected without consent!
278
+ deviceFingerprint: string; // Tracking without disclosure!
279
+ }
280
+
281
+ // Bad: Sharing data without consent
282
+ const registerUser = async (data: UserRegistration) => {
283
+ await createUser(data);
284
+
285
+ // Sharing with third parties without consent!
286
+ await sendToAnalytics(data);
287
+ await sendToMarketingPartner(data);
288
+ await trackUserBehavior(data);
289
+ };
290
+ ```
291
+
292
+ #### Inaccessible Design
293
+ ```typescript
294
+ // Bad: Not keyboard accessible, poor contrast
295
+ const InaccessibleButton = ({ onClick, icon }) => {
296
+ return (
297
+ <div
298
+ onClick={onClick} // Not keyboard accessible!
299
+ style={{
300
+ color: '#999', // Poor contrast
301
+ backgroundColor: '#aaa' // Contrast ratio: 1.7:1 (fails WCAG)
302
+ }}
303
+ >
304
+ {icon}
305
+ {/* No text label for screen readers! */}
306
+ </div>
307
+ );
308
+ };
309
+ ```
310
+
311
+ #### Biased Algorithm
312
+ ```python
313
+ # Bad: No bias checking, discriminatory features
314
+ def predict_loan_approval(applicant: dict) -> bool:
315
+ """Predict if loan should be approved."""
316
+ # Using protected characteristics directly!
317
+ if applicant['zip_code'] in LOW_INCOME_ZIPS: # Proxy for race
318
+ return False
319
+ if applicant['gender'] == 'female': # Direct discrimination
320
+ return False
321
+ if applicant['age'] > 65: # Age discrimination
322
+ return False
323
+ return True
324
+ # No fairness audit, no explanation provided
325
+ ```
326
+
327
+ #### Dark Patterns
328
+ ```typescript
329
+ // Bad: Deceptive design patterns
330
+ const NewsletterSignup = () => {
331
+ return (
332
+ <div>
333
+ <h2>Complete Your Registration</h2>
334
+ {/* Deceptive: Makes it seem required */}
335
+ <label>
336
+ <input type="checkbox" checked={true} />
337
+ <small style={{ color: '#999' }}>
338
+ I agree to receive marketing emails, share data with partners,
339
+ and allow tracking across websites
340
+ </small>
341
+ {/* Bad: Pre-checked, tiny text, bundled consent */}
342
+ </label>
343
+
344
+ {/* Deceptive: Prominent "agree" vs hidden "decline" */}
345
+ <button className="big-green-button">
346
+ AGREE AND CONTINUE
347
+ </button>
348
+ <a href="/decline" style={{ fontSize: '10px', color: '#999' }}>
349
+ No thanks
350
+ </a>
351
+ </div>
352
+ );
353
+ };
354
+ ```
355
+
356
+ #### Non-Inclusive Language
357
+ ```python
358
+ # Bad: Non-inclusive terminology
359
+ WHITELIST = ['allowed.com'] # Use "allowlist"
360
+ BLACKLIST = ['blocked.com'] # Use "blocklist"
361
+
362
+ def notify_users(users):
363
+ """Send notifications to users."""
364
+ for user in users:
365
+ # Bad: Gender assumption
366
+ send_email(user.email, f"Hey guys, ...")
367
+
368
+ # Bad: Insensitive terminology
369
+ MASTER_SERVER = 'main.example.com' # Use "primary" or "main"
370
+ SLAVE_SERVERS = ['replica1', 'replica2'] # Use "replica" or "secondary"
371
+ ```
372
+
373
+ ## References
374
+ - [MyConvergio CONSTITUTION.md](../CONSTITUTION.md)
375
+ - [WCAG 2.1 Guidelines](https://www.w3.org/WAI/WCAG21/quickref/)
376
+ - [GDPR Compliance](https://gdpr.eu/)
377
+ - [Inclusive Design Principles](https://inclusivedesignprinciples.org/)
378
+ - [AI Ethics Guidelines by IEEE](https://standards.ieee.org/industry-connections/ec/autonomous-systems/)
379
+ - [Algorithmic Fairness](https://fairmlbook.org/)
380
+ - [Inclusive Naming Initiative](https://inclusivenaming.org/)
381
+ - [Dark Patterns Hall of Shame](https://www.darkpatterns.org/)
382
+ - [Privacy by Design Principles](https://www.ipc.on.ca/wp-content/uploads/resources/7foundationalprinciples.pdf)
383
+ - [UN Sustainable Development Goals](https://sdgs.un.org/)
@@ -0,0 +1,182 @@
1
+ # Security Requirements
2
+
3
+ > This rule is enforced by the MyConvergio agent ecosystem.
4
+
5
+ ## Overview
6
+ Security is a first-class concern in the MyConvergio ecosystem. All code must adhere to industry-standard security practices, with awareness of OWASP Top 10 vulnerabilities and implementation of defense-in-depth strategies.
7
+
8
+ ## Requirements
9
+
10
+ ### Input Validation
11
+ - Validate all user input on both client and server side
12
+ - Use allowlists (whitelist) over denylists (blacklist) when possible
13
+ - Sanitize input before processing or storage
14
+ - Implement length limits on all text inputs
15
+ - Validate data types, formats, and ranges
16
+ - Reject unexpected or malformed input
17
+
18
+ ### SQL Security
19
+ - Always use parameterized queries or prepared statements
20
+ - Never concatenate user input into SQL strings
21
+ - Use ORM frameworks with built-in protection (SQLAlchemy, Prisma)
22
+ - Apply principle of least privilege for database accounts
23
+ - Implement connection pooling with proper timeout settings
24
+
25
+ ### Cross-Site Scripting (XSS) Prevention
26
+ - Escape all user-generated content before rendering in HTML
27
+ - Use Content Security Policy (CSP) headers
28
+ - Sanitize HTML input using established libraries (DOMPurify)
29
+ - Never use `dangerouslySetInnerHTML` without sanitization
30
+ - Set appropriate `X-Content-Type-Options` headers
31
+
32
+ ### Secrets Management
33
+ - Never commit secrets, API keys, or credentials to version control
34
+ - Use environment variables for all sensitive configuration
35
+ - Use secret management services (HashiCorp Vault, AWS Secrets Manager)
36
+ - Rotate secrets regularly
37
+ - Use `.env` files locally, never commit them (`.gitignore`)
38
+ - Use different secrets for different environments
39
+
40
+ ### Authentication & Authorization
41
+ - Implement proper authentication for all protected resources
42
+ - Use industry-standard protocols (OAuth 2.0, OpenID Connect)
43
+ - Implement role-based access control (RBAC)
44
+ - Verify authorization on every request (server-side)
45
+ - Use secure session management
46
+ - Implement account lockout after failed login attempts
47
+ - Require strong passwords (minimum length, complexity)
48
+
49
+ ### HTTPS & Transport Security
50
+ - Use HTTPS for all external communication
51
+ - Implement HSTS (HTTP Strict Transport Security)
52
+ - Use secure cookies (`Secure`, `HttpOnly`, `SameSite` flags)
53
+ - Validate SSL/TLS certificates
54
+ - Use TLS 1.2 or higher
55
+
56
+ ### Dependencies & Supply Chain
57
+ - Keep all dependencies up to date
58
+ - Use dependency scanning tools (Snyk, npm audit, safety)
59
+ - Review security advisories regularly
60
+ - Pin dependency versions in production
61
+ - Verify package integrity using checksums
62
+
63
+ ### Error Handling & Logging
64
+ - Never expose stack traces or internal details to users
65
+ - Log security events (failed logins, access violations)
66
+ - Sanitize logs to prevent log injection
67
+ - Implement rate limiting to prevent abuse
68
+ - Monitor for suspicious patterns
69
+
70
+ ## Examples
71
+
72
+ ### Good Examples
73
+
74
+ #### SQL Parameterization (Python)
75
+ ```python
76
+ # Good: Parameterized query
77
+ def get_user_by_email(email: str) -> Optional[User]:
78
+ query = "SELECT * FROM users WHERE email = ?"
79
+ result = db.execute(query, (email,))
80
+ return result.fetchone()
81
+
82
+ # Good: ORM usage
83
+ def get_user_by_email(email: str) -> Optional[User]:
84
+ return db.query(User).filter(User.email == email).first()
85
+ ```
86
+
87
+ #### Input Validation (TypeScript)
88
+ ```typescript
89
+ // Good: Comprehensive validation
90
+ const validateEmail = (email: string): boolean => {
91
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
92
+ return email.length <= 255 && emailRegex.test(email);
93
+ };
94
+
95
+ const createUser = async (email: string, name: string) => {
96
+ if (!validateEmail(email)) {
97
+ throw new ValidationError('Invalid email format');
98
+ }
99
+ if (name.length < 2 || name.length > 100) {
100
+ throw new ValidationError('Name must be 2-100 characters');
101
+ }
102
+ // Proceed with sanitized input
103
+ };
104
+ ```
105
+
106
+ #### Secrets Management
107
+ ```typescript
108
+ // Good: Environment variables
109
+ const apiKey = process.env.STRIPE_API_KEY;
110
+ if (!apiKey) {
111
+ throw new Error('STRIPE_API_KEY not configured');
112
+ }
113
+
114
+ // Good: .env file (not committed)
115
+ // .env
116
+ STRIPE_API_KEY=sk_live_xxxxxxxxxxxxx
117
+ DATABASE_URL=postgresql://user:pass@host:5432/db
118
+ ```
119
+
120
+ #### XSS Prevention (React)
121
+ ```typescript
122
+ // Good: Sanitized HTML
123
+ import DOMPurify from 'dompurify';
124
+
125
+ const SafeHtmlDisplay = ({ htmlContent }: { htmlContent: string }) => {
126
+ const sanitized = DOMPurify.sanitize(htmlContent);
127
+ return <div dangerouslySetInnerHTML={{ __html: sanitized }} />;
128
+ };
129
+
130
+ // Good: Escaped by default
131
+ const UserComment = ({ comment }: { comment: string }) => {
132
+ return <p>{comment}</p>; // React escapes by default
133
+ };
134
+ ```
135
+
136
+ ### Bad Examples
137
+
138
+ #### SQL Injection Vulnerability
139
+ ```python
140
+ # Bad: String concatenation - SQL injection risk!
141
+ def get_user_by_email(email: str):
142
+ query = f"SELECT * FROM users WHERE email = '{email}'"
143
+ return db.execute(query)
144
+ # Attacker can use: email = "'; DROP TABLE users; --"
145
+ ```
146
+
147
+ #### Hardcoded Secrets
148
+ ```typescript
149
+ // Bad: Secret in code!
150
+ const API_KEY = 'NEVER_HARDCODE_SECRETS_USE_ENV_VARS';
151
+ fetch('https://api.stripe.com/v1/charges', {
152
+ headers: { 'Authorization': `Bearer ${API_KEY}` }
153
+ });
154
+ ```
155
+
156
+ #### No Input Validation
157
+ ```typescript
158
+ // Bad: No validation
159
+ const createUser = async (email: string, age: number) => {
160
+ await db.users.create({ email, age });
161
+ // What if email is malicious HTML? What if age is -1000?
162
+ };
163
+ ```
164
+
165
+ #### XSS Vulnerability
166
+ ```typescript
167
+ // Bad: Unescaped user content
168
+ const UserProfile = ({ bio }: { bio: string }) => {
169
+ return <div dangerouslySetInnerHTML={{ __html: bio }} />;
170
+ // Attacker can inject: <script>steal_cookies()</script>
171
+ };
172
+ ```
173
+
174
+ ## References
175
+ - [OWASP Top 10](https://owasp.org/www-project-top-ten/)
176
+ - [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/)
177
+ - [CWE Top 25 Most Dangerous Software Weaknesses](https://cwe.mitre.org/top25/)
178
+ - [NIST Cybersecurity Framework](https://www.nist.gov/cyberframework)
179
+ - [MyConvergio Security Framework](../frameworks/security-framework.md)
180
+ - [SQLAlchemy Security Considerations](https://docs.sqlalchemy.org/en/20/faq/security.html)
181
+ - [OWASP SQL Injection Prevention](https://cheatsheetseries.owasp.org/cheatsheets/SQL_Injection_Prevention_Cheat_Sheet.html)
182
+ - [Content Security Policy (CSP)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP)