Skip to content
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

Crud app v2 #15

Closed
wants to merge 52 commits into from
Closed

Crud app v2 #15

wants to merge 52 commits into from

Conversation

Amits64
Copy link
Owner

@Amits64 Amits64 commented Aug 22, 2024

No description provided.

app.get('/table/:dbName/:tableName', async (req, res) => {
const { dbName, tableName } = req.params;
try {
const [rows] = await mysqlConnection.query(`SELECT * FROM ${dbName}.${tableName}`);

Check failure

Code scanning / SonarCloud

Database queries should not be vulnerable to injection attacks High

Change this code to not construct SQL queries directly from user-controlled data. See more on SonarCloud
const placeholders = values.map(() => '?').join(', ');

try {
const [result] = await mysqlConnection.query(`INSERT INTO ${dbName}.${tableName} (${columns}) VALUES (${placeholders})`, values);

Check failure

Code scanning / SonarCloud

Database queries should not be vulnerable to injection attacks High

Change this code to not construct SQL queries directly from user-controlled data. See more on SonarCloud
const values = [...Object.values(data), id];

try {
const [result] = await mysqlConnection.query(`UPDATE ${dbName}.${tableName} SET ${updates} WHERE id = ?`, values);

Check failure

Code scanning / SonarCloud

Database queries should not be vulnerable to injection attacks High

Change this code to not construct SQL queries directly from user-controlled data. See more on SonarCloud
const { dbName, tableName, id } = req.params;

try {
const [result] = await mysqlConnection.query(`DELETE FROM ${dbName}.${tableName} WHERE id = ?`, [id]);

Check failure

Code scanning / SonarCloud

Database queries should not be vulnerable to injection attacks High

Change this code to not construct SQL queries directly from user-controlled data. See more on SonarCloud
@Amits64 Amits64 closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant