BM: Baca dalam Bahasa Melayu
World 8: Shields: Security
CodeQL basics
You will learn: how CodeQL finds risky code before attackers do.
The problem
Your login page works. The tests pass. But one line lets a trickster read every user’s data. Could you find it in 500 files?
Watch
CodeQL: GitHub's code detective. It turns code into data and asks questions to find risky code. is a code detective from GitHub. It turns your code into data. Then it asks questions, like “can typed text reach the database?”
Try it
Be the detective. Tap the line that glues typed text into a database question.
Tap the line that glues typed text into the query.
0 of 1 found
Hint
Look for a + sign that sticks the name onto the question.Watch
CodeQL runs as code scanning: Automatic checks, like CodeQL, that look for security problems in your code.. Turn it on. Then GitHub Actions checks your code on pushes and pull requests. Problems show up as alerts on the exact line.
Try it
Three guards, three jobs. Who catches what?
Drag a card into a box. Or tap the card, then tap the box.
Predict
CodeQL flags a line in your pull request. What now?
Pick one answer.
Check
Put the code scanning loop in order, first at the top.
First step at the top. Put these in order. Use the arrows, or drag.
- Open a pull request
- Turn on code scanning
- You read the alert and fix the line
- CodeQL checks the new code
You did it!
You can now let CodeQL hunt for risky code.
Go deeper (optional)
The bug in the detective card is called SQL injection. CodeQL knows many languages, like JavaScript, Python, Java, Go, C# and Ruby. Default setup picks settings for you. Advanced setup adds a workflow file that you can change.
Bahasa Melayu
Laman log masuk anda berfungsi. Ujian pun lulus. Tapi satu baris benarkan penipu baca data setiap pengguna. Bolehkah anda jumpa baris itu dalam 500 fail?
CodeQL ialah detektif kod dari GitHub. Ia jadikan kod anda sebagai data. Kemudian ia tanya soalan. Contohnya: “bolehkah teks yang ditaip sampai ke pangkalan data?”
Jadi detektif. Ketik baris yang lekatkan teks ditaip terus ke soalan pangkalan data.
CodeQL berjalan sebagai code scanning (imbasan kod). Hidupkan, dan GitHub Actions semak kod anda setiap push dan pull request. Masalah muncul sebagai amaran pada baris yang tepat.
Tiga pengawal, tiga tugas. Siapa tangkap apa?
CodeQL tanda satu baris dalam pull request anda. Apa sekarang?
Susun kitaran code scanning, yang pertama di atas.
Kini anda boleh biar CodeQL memburu kod berisiko.
You finished this before. Practice is always welcome!
Official docs: About code scanning with CodeQL · About code scanning
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?