Skip to content

Instantly share code, notes, and snippets.

@rizkytegar
Last active August 19, 2023 02:55
Show Gist options
  • Save rizkytegar/75998e62286219b646f719b144fa5c12 to your computer and use it in GitHub Desktop.
Save rizkytegar/75998e62286219b646f719b144fa5c12 to your computer and use it in GitHub Desktop.
TestController.ts
// Route yang rentan terhadap SQL injection
app.get('/users', (req, res) => {
const username = req.query.username;
const sql = `SELECT * FROM users WHERE username = '${username}'`;
db.query(sql, (err, results) => {
if (err) {
console.error('Error executing query:', err);
return res.status(500).send('Error executing query');
}
res.json(results);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment