Database secret handling fix#17
Conversation
|
PR Review: Database Secret Handling FixSummaryThis PR improves database secret handling by migrating from manually managed secrets to AWS RDS-managed master user passwords stored in Secrets Manager. This is a good security improvement that follows AWS best practices. ✅ Strengths
🔍 Issues & Concerns1. Critical: Error Handling Gap in Secret RetrievalLocation: The code doesn't differentiate between network failures and missing secrets: const dbSecretStr = await vault.getSecret(dbSecretArn);
if (!dbSecretStr) {
console.error('Failed to retrieve secret from Secrets Manager');
return;
}Issue: According to Recommendation: Add proper error handling: try {
const dbSecretStr = await vault.getSecret(dbSecretArn);
if (!dbSecretStr) {
console.error(`Secret not found in Secrets Manager: ${dbSecretArn}`);
return;
}
// ... rest of the code
} catch (error) {
console.error('Failed to retrieve secret from Secrets Manager:', error);
return;
}2. Inconsistency with server-doj ImplementationLocation: The RDS-managed secrets format: When using {
"engine": "postgres",
"host": "...",
"port": 5432,
"dbname": "postgres",
"username": "postgres",
"password": "..."
}Issue: The sandbox code expects only Recommendation: Update const dbSecret = JSON.parse(dbSecretStr);
if (!dbSecret.username || !dbSecret.password || !dbSecret.host || !dbSecret.port || !dbSecret.dbname) {
console.error('Secret from Secrets Manager is missing required fields');
return;
}
return {
dbUri: `postgresql://${dbSecret.username}:${dbSecret.password}@${dbSecret.host}:${dbSecret.port}/${dbSecret.dbname}`,
};Then update the infrastructure code to only pass the secret ARN, not the individual connection parameters. 3. Commented-Out CI StepsLocation: Performance budget checks for Spotlight and Design packages have been commented out. Question: Is this intentional for this PR, or should it be in a separate commit? The PR title doesn't mention this change, suggesting it might be unrelated. Recommendation:
🧪 Testing ConcernsNo test coverage: There are no tests for Recommendation: Add unit tests covering:
🔒 Security Assessment✅ Good practices:
📝 Minor Suggestions
interface RDSManagedSecret {
engine: string;
host: string;
port: number;
dbname: string;
username: string;
password: string;
}📋 SummaryThis is a solid improvement to secret management, but needs attention to:
The infrastructure changes look good - using RDS-managed passwords is definitely the right approach! |
No description provided.