Skip to content

Latest commit

 

History

History
32 lines (27 loc) · 1.34 KB

invalid_login_bug_fixing_№11.md

File metadata and controls

32 lines (27 loc) · 1.34 KB

Description

Invalid Login - Bug Fixing #11

Oh NO! Timmy has moved divisions... but now he's in the field of security. Timmy, being the top coder he is, has allowed some bad code through. You must help Timmy and filter out any injected code!

Task

Your task is simple, search the password string for any injected code (Injected code is any thing that would be used to exploit flaws in the current code, so basically anything that contains || or //) if you find any you must return "Wrong username or password!" because no one likes someone trying to cheat their way in!

Preloaded

You will be given a preloaded class called Database with a method login this takes two parameters username and password. This is a generic login function which will check the database for the user it will return either 'Successfully Logged in!' if it passes the test or 'Wrong username or password!' if either the password is wrong or username does not exist.

Usage

database = Database.new;
database.login('Timmy', 'password')

My Solution

def validate(username, password)
  return 'Wrong username or password!' if password.include?('||') && password.include?('//')
  database = Database.new;
  database.login(username, password)
end