007
無料Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.
日本語の概要は準備中です。原文の説明を表示しています。
Implement security best practices for TwinMind integrations. Use when securing API keys, configuring privacy settings, or implementing data protection for meeting recordings. Trigger with phrases like "twinmind security", "secure twinmind", "twinmind privacy", "protect twinmind data", "twinmind api key security".
インストールする前に、エージェントに与えられる指示の中身を確認できます。
Essential security practices for TwinMind integrations, focusing on API security, data privacy, and compliance.
// NEVER do this - hardcoded secrets
const TWINMIND_API_KEY = "tm_sk_abc123"; // BAD!
// DO this - use environment variables
const apiKey = process.env.TWINMIND_API_KEY;
if (!apiKey) {
throw new Error('TWINMIND_API_KEY environment variable required');
}
// Even better - use a secrets manager
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
async function getApiKey(): Promise<string> {
const client = new SecretManagerServiceClient();
const [version] = await client.accessSecretVersion({
name: 'projects/my-project/secrets/twinmind-api-key/versions/latest',
});
return version.payload?.data?.toString() || '';
}
# .env file (gitignored)
TWINMIND_API_KEY=tm_sk_your_secret_key
TWINMIND_WEBHOOK_SECRET=whsec_your_webhook_secret
TWINMIND_ENCRYPTION_KEY=your_32_byte_encryption_key
# .env.example (committed to repo - no real values)
TWINMIND_API_KEY=tm_sk_xxx
TWINMIND_WEBHOOK_SECRET=whsec_xxx
TWINMIND_ENCRYPTION_KEY=xxx
# .gitignore
.env
.env.local
.env.*.local
*.pem
*.key
secrets/
// src/twinmind/webhooks/verify.ts
import crypto from 'crypto';
export function verifyWebhookSignature(
payload: string | Buffer,
signature: string,
secret: string
): boolean {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
const providedSignature = signature.replace('sha256=', '');
// Use timing-safe comparison to prevent timing attacks
return crypto.timingSafeEqual(
Buffer.from(expectedSignature),
Buffer.from(providedSignature)
);
}
// Express middleware
export function webhookMiddleware(req: Request, res: Response, next: NextFunction) {
const signature = req.headers['x-twinmind-signature'] as string;
const secret = process.env.TWINMIND_WEBHOOK_SECRET!;
if (!signature) {
return res.status(401).json({ error: 'Missing signature' });
}
const rawBody = (req as any).rawBody || JSON.stringify(req.body);
if (!verifyWebhookSignature(rawBody, signature, secret)) {
return res.status(401).json({ error: 'Invalid signature' });
}
next();
}
// src/twinmind/encryption.ts
import crypto from 'crypto';
const ALGORITHM = 'aes-256-gcm';
const IV_LENGTH = 16;
const TAG_LENGTH = 16;
export function encrypt(text: string, key: string): string {
const iv = crypto.randomBytes(IV_LENGTH);
const cipher = crypto.createCipheriv(
ALGORITHM,
Buffer.from(key, 'hex'),
iv
);
let encrypted = cipher.update(text, 'utf8', 'hex');
encrypted += cipher.final('hex');
const tag = cipher.getAuthTag();
// Return iv:tag:encrypted
return `${iv.toString('hex')}:${tag.toString('hex')}:${encrypted}`;
}
export function decrypt(encryptedData: string, key: string): string {
const [ivHex, tagHex, encrypted] = encryptedData.split(':');
const iv = Buffer.from(ivHex, 'hex');
const tag = Buffer.from(tagHex, 'hex');
const decipher = crypto.createDecipheriv(
ALGORITHM,
Buffer.from(key, 'hex'),
iv
);
decipher.setAuthTag(tag);
let decrypted = decipher.update(encrypted, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}
// Usage for storing transcripts
export function storeTranscript(transcript: string): string {
const key = process.env.TWINMIND_ENCRYPTION_KEY!;
return encrypt(transcript, key);
}
export function retrieveTranscript(encryptedTranscript: string): string {
const key = process.env.TWINMIND_ENCRYPTION_KEY!;
return decrypt(encryptedTranscript, key);
}
// src/twinmind/auth/permissions.ts
export enum Permission {
READ_TRANSCRIPTS = 'transcripts:read',
WRITE_TRANSCRIPTS = 'transcripts:write',
DELETE_TRANSCRIPTS = 'transcripts:delete',
MANAGE_SETTINGS = 'settings:manage',
VIEW_ANALYTICS = 'analytics:view',
ADMIN = 'admin:*',
}
export interface User {
id: string;
email: string;
permissions: Permission[];
organizationId: string;
}
export function hasPermission(user: User, permission: Permission): boolean {
if (user.permissions.includes(Permission.ADMIN)) {
return true;
}
return user.permissions.includes(permission);
}
export function requirePermission(permission: Permission) {
return (req: Request, res: Response, next: NextFunction) => {
const user = req.user as User;
if (!user) {
return res.status(401).json({ error: 'Unauthorized' });
}
if (!hasPermission(user, permission)) {
return res.status(403).json({ error: 'Insufficient permissions' });
}
next();
};
}
// Usage in routes
app.get(
'/api/transcripts',
requirePermission(Permission.READ_TRANSCRIPTS),
getTranscripts
);
app.delete(
'/api/transcripts/:id',
requirePermission(Permission.DELETE_TRANSCRIPTS),
deleteTranscript
);
// src/twinmind/privacy.ts
export interface PrivacyConfig {
// Audio handling
storeAudio: boolean;
audioRetentionDays: number;
// Transcript handling
storeTranscripts: boolean;
transcriptRetentionDays: number;
encryptTranscripts: boolean;
// Processing
processLocally: boolean; // Use on-device processing when possible
// Sharing
allowSharing: boolean;
requireConsent: boolean;
// PII handling
redactPII: boolean;
piiPatterns: string[];
}
const defaultPrivacyConfig: PrivacyConfig = {
storeAudio: false, // TwinMind default - never store audio
audioRetentionDays: 0,
storeTranscripts: true,
transcriptRetentionDays: 90,
encryptTranscripts: true,
processLocally: true,
allowSharing: false,
requireConsent: true,
redactPII: true,
piiPatterns: [
'\\b\\d{3}-\\d{2}-\\d{4}\\b', // SSN
'\\b\\d{16}\\b', // Credit card
'\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b', // Email
],
};
export function redactPII(text: string, patterns: string[]): string {
let redacted = text;
for (const pattern of patterns) {
const regex = new RegExp(pattern, 'gi');
redacted = redacted.replace(regex, '[REDACTED]');
}
return redacted;
}
// src/twinmind/audit.ts
export interface AuditEvent {
timestamp: Date;
userId: string;
action: string;
resource: string;
resourceId?: string;
details?: Record<string, any>;
ipAddress?: string;
userAgent?: string;
}
export class AuditLogger {
private events: AuditEvent[] = [];
log(event: Omit<AuditEvent, 'timestamp'>): void {
const fullEvent: AuditEvent = {
...event,
timestamp: new Date(),
};
this.events.push(fullEvent);
this.persist(fullEvent);
// Log to console in development
if (process.env.NODE_ENV === 'development') {
console.log('[AUDIT]', JSON.stringify(fullEvent));
}
}
private async persist(event: AuditEvent): Promise<void> {
// Send to logging service (e.g., CloudWatch, Datadog)
// await logService.write(event);
}
async query(filters: Partial<AuditEvent>): Promise<AuditEvent[]> {
return this.events.filter(event => {
return Object.entries(filters).every(([key, value]) =>
event[key as keyof AuditEvent] === value
);
});
}
}
export const auditLogger = new AuditLogger();
// Usage
auditLogger.log({
userId: 'user_123',
action: 'TRANSCRIPT_ACCESSED',
resource: 'transcript',
resourceId: 'tr_abc123',
details: { method: 'GET', endpoint: '/api/transcripts/tr_abc123' },
});
## Pre-Deployment Security Checklist
### API Security
- [ ] API keys stored in environment variables or secrets manager
- [ ] No hardcoded credentials in source code
- [ ] API key rotation process documented
- [ ] Rate limiting implemented
### Data Protection
- [ ] Transcripts encrypted at rest
- [ ] PII redaction enabled
- [ ] Data retention policies configured
- [ ] Backup encryption verified
### Authentication
- [ ] Webhook signatures verified
- [ ] JWT tokens validated properly
- [ ] Session timeout configured
- [ ] MFA enabled for admin accounts
### Access Control
- [ ] RBAC implemented
- [ ] Least privilege principle applied
- [ ] Regular permission audits scheduled
### Monitoring
- [ ] Audit logging enabled
- [ ] Failed auth attempts monitored
- [ ] Anomaly detection configured
- [ ] Incident response plan documented
| Scenario | Risk | Mitigation |
|---|---|---|
| API key exposed | Full account access | Rotate key immediately, audit logs |
| Webhook unverified | Spoofed events | Always verify signatures |
| PII leaked | Compliance violation | Enable redaction, encrypt data |
| Unauthorized access | Data breach | Implement RBAC, audit logging |
TwinMind provides built-in privacy protection:
For production deployment, see twinmind-prod-checklist.
まだレビューはありません。使ってみた感想をお寄せください。
概要と使いどころ
Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.
日本語の概要は準備中です。原文の説明を表示しています。
Guides the creation of agile user stories and Gherkin feature files. Use when the user wants to create a user story, write acceptance criteria, define Gherkin scenarios, or author BDD feature files. This should trigger for requests such as Create a user story; Write a user story; I need to write a user story. Part of cursor-rules-java project
日本語の概要は準備中です。原文の説明を表示しています。
Facilitates conversational discovery to create Architectural Decision Records (ADRs) for non-functional requirements using the ISO/IEC 25010:2023 quality model. Use when the user wants to document quality attributes, NFR decisions, security/performance/scalability architecture, or design systems with measurable quality criteria. This should trigger for requests such as Create ADR for Non-functional requirements; Document Non-functional requirements; Capture Non-functional requirements; Generate Non-functional requirements in an ADR. Part of cursor-rules-java project
日本語の概要は準備中です。原文の説明を表示しています。
Run a health check on an existing project: dependency audit, security scan, test runner detection, CI/CD evaluation, and missing configuration analysis. Maps the three execution gates (pre/in/post) from /10x-bootstrapper to an assessment framework for existing codebases. Reads optional context/foundation/stack-assessment.md from /10x-stack-assess to focus checks on identified gaps. Writes context/foundation/health-check.md with findings, prioritized fixes, and an agent-readiness verdict. Use when the user has an existing project and wants to verify its health before working with an agent. Trigger phrases: "health check", "check my project", "audit my project", "is my project healthy", "sprawdź projekt", "audyt projektu", "health-check", "project health". Use AFTER /10x-stack-assess (brownfield chain), BEFORE agent onboarding (m1-l4).
日本語の概要は準備中です。原文の説明を表示しています。
You MUST use this when building projects end-to-end. Orchestrates all 12 team roles — automatically switches between CTO, architect, PM, engineers, SRE, security, DBA, QA, and EM based on the current phase of work. Starts with brainstorming before any implementation.
日本語の概要は準備中です。原文の説明を表示しています。
Use when you need to add or configure Maven plugins in your pom.xml — including quality tools (enforcer, surefire, failsafe, jacoco, pitest, spotbugs, pmd), security scanning (OWASP), code formatting (Spotless), version management, container image build (Jib), build information tracking, and benchmarking (JMH) — through a consultative, modular step-by-step approach that only adds what you actually need. This should trigger for requests such as Add Maven plugins in pom.xml; Improve Maven plugins in pom.xml. Part of cursor-rules-java project
日本語の概要は準備中です。原文の説明を表示しています。