From the course: Secure Coding in Java

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Challenge: Refactor Java code susceptible to injection attacks

Challenge: Refactor Java code susceptible to injection attacks

From the course: Secure Coding in Java

Challenge: Refactor Java code susceptible to injection attacks

(upbeat music) - [Instructor] Now we're ready for the first code challenge for this course. You're going to be working on some code that is unfortunately injectable via SQL injection. So let's go over a bit more detail for our challenge exercise. First of all, I've written some code for you that is broken, and you can find that in the codespace's environment. Now, if you look at the code, it's pretty simple. There are a couple of classes and a test class. Open that test class and run it in your IDE. You'll see two tests exist, but only one will pass. This is actually a good strategy that we will talk about more when I show my solution. You will note that that failure is caused by an injection failure. Your challenge, therefore, is to fix that injection defect. When you think you have it fixed, utilize the test to run it until you truly have fixed the error, hopefully on the first time, but it may take you a couple. I will return with my solution to this challenge.

Contents