Skip to content

Instantly share code, notes, and snippets.

View rizkytegar's full-sized avatar
🙂
Busy

Rizky Tegar Pratama rizkytegar

🙂
Busy
View GitHub Profile
@rizkytegar
rizkytegar / TestController.ts
Last active August 19, 2023 02:55
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');
}

contoh kode Express.js yang rentan terhadap serangan SQL injection pada bagian SELECT dan contoh kode yang aman:

Contoh Kode Rentan SQL Injection:

// Route yang rentan terhadap SQL injection
app.get('/users', (req, res) => {
  const username = req.query.username;
  const sql = `SELECT * FROM users WHERE username = '${username}'`;

Return

const nama = 'iky';

const cetakNama = (nama) => `hi, nama saya ${nama}`;
console.log(cetakNama(nama));

const cetakNama2 = (nama) => {
 return (
sudo apt install --reinstall php8.2 libapache2-mod-php8.2
sudo a2enconf php8.0-fpm
sudo service apache2 restart

sudo a2enconf php8.2-fpm