-
Notifications
You must be signed in to change notification settings - Fork 29
Add MySQL support to MCP Database Server #5
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
Updated package.json and package-lock.json to include MySQL dependencies. Enhanced README with MySQL usage instructions and configuration details. Modified index.ts to handle MySQL connection parameters and logging. Added MysqlAdapter for database interactions.
⏳ I'm reviewing this pull request for security vulnerabilities and code quality issues. I'll provide an update when I'm done |
*/ | ||
async init(): Promise<void> { | ||
try { | ||
console.error(`[INFO] Connecting to MySQL: ${this.host}, Database: ${this.database}`); |
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.
Warning
Description: Log Injection occurs when untrusted user input is directly written to log files without proper sanitization. This can allow attackers to manipulate log entries, potentially leading to security issues like log forging or cross-site scripting. To prevent this, always sanitize user input before logging by removing or encoding newline characters, using string encoding functions, and leveraging built-in sanitization features of logging libraries when available. Learn more - https://cwe.mitre.org/data/definitions/117.html
Severity: High
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.
The fix involves using a sanitizeLog function (from an imported sanitize-log package) to sanitize user input before logging, preventing potential log injection vulnerabilities.
console.error(`[INFO] Connecting to MySQL: ${this.host}, Database: ${this.database}`); | |
// Import the sanitize-log package for log sanitization | |
async init(): Promise<void> { | |
try { | |
console.error(`[INFO] Connecting to MySQL: ${sanitizeLog(this.host)}, Database: ${sanitizeLog(this.database)}`); | |
this.connection = await mysql.createConnection(this.config); | |
console.error(`[INFO] MySQL connection established successfully`); | |
} catch (err) { | |
console.error(`[ERROR] MySQL connection error: ${sanitizeLog((err as Error).message)}`); | |
throw new Error(`Failed to connect to MySQL: ${sanitizeLog((err as Error).message)}`); | |
} | |
} |
✅ I finished the code review, and left comments with the issues I found. I will now generate code fix suggestions. |
Added validation for the MySQL connection port to ensure it is a number, with error handling for invalid values. Included a debug log statement to output the port being used for the connection.
Bumped version to 1.1.0 in index.ts and package.json. Updated README and connection reference documentation to include MySQL port option and usage examples. Added release notes for new features and improvements related to MySQL support.
Updated package.json and package-lock.json to include MySQL dependencies. Enhanced README with MySQL usage instructions and configuration details. Modified index.ts to handle MySQL connection parameters and logging. Added MysqlAdapter for database interactions.