-
Notifications
You must be signed in to change notification settings - Fork 5
Add database utilities #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Claude Code Review
This PR adds database utility functions but contains multiple serious security vulnerabilities and data safety issues. The code includes SQL injection vulnerabilities, XSS risks, exposed credentials, and unsafe data deletion functions that could compromise the application's security and data integrity.
📁 Files reviewed (2 files, 36 changes)
- 🆕
src/lib/bad-code.ts(+36/-0) - 🆕
testxxx22.png(+0/-0)
Issues Found
- 🚨 Critical: 4
❌ Changes requested - Please fix the critical issues before merging.
Powered by Claude AI
|
|
||
| // CRITICAL: SQL Injection vulnerability - user input directly in query | ||
| export async function getUserByName(name: string) { | ||
| const result = await prisma.$queryRawUnsafe( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 CRITICAL
SQL injection vulnerability: User input is directly interpolated into the SQL query without sanitization. An attacker could inject malicious SQL by providing input like '; DROP TABLE users; --. Use parameterized queries or Prisma's type-safe query methods instead.
| } | ||
|
|
||
| // CRITICAL: XSS vulnerability - rendering unsanitized HTML | ||
| export function renderUserComment(comment: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 CRITICAL
XSS vulnerability: User comment content is directly inserted into HTML without sanitization. Malicious users could inject JavaScript code like <script>alert('XSS')</script>. Sanitize the comment content or use a templating system that escapes HTML by default.
| return `<div class="comment">${comment}</div>`; | ||
| } | ||
|
|
||
| // CRITICAL: Hardcoded credentials exposed in code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 CRITICAL
Exposed credentials: Database password and API secret key are hardcoded in the source code. These will be visible to anyone with access to the repository. Move these to environment variables and never commit secrets to version control.
| } | ||
|
|
||
| // CRITICAL: Deleting all data without confirmation | ||
| export async function clearAllUsers() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨 CRITICAL
Data loss risk: This function deletes all user data without any confirmation mechanism or access controls. This could result in catastrophic data loss if called accidentally or by unauthorized users. Add proper authorization checks and confirmation mechanisms.
|
Test PR with bad code - closing |
Summary
Test plan