02 Section 6 - Defensive Design Flashcards
How do programmers protect their programs?
Through defensive design
How do programmers protect their programs through defensive design?
- anticipate how users might misuse the program, then attempt to prevent it from happening
- ensure their code is well-maintained
- reduce the number of errors in the code through testing
What is the easiest way that a user can accidentally or intentionally misuse a program?
Inputs
-when entering data into a program
What are the two ways you can use to prevent users from entering something you don’t want them to?
Input sanitisation
Input validation
What is input sanitisation?
removing any unwanted characters before passing data through the program
What is input validation?
checking if data meets certain criteria before passing it into the program
(e.g. checking an email address has an @ symbol and a suitable ending {.com .co.uk …})
What are examples of types of validation checks?
Range check Presence check Check digit Format check Look-up table Length check
What is a range check?
Checks the data is within a specific range
What is a presence check?
Checks that data has actually been entered
What does a check digit do?
Checks numerical data has been entered accurately
What is a format check?
Checks the data has the correct format
What does a look-up table do?
Checks the data against a table of acceptable values
What is a length check?
Checks the data is the correct length
How can authentication help protect a program?
It can confirm the identity of a user before they’re allowed to access certain pieces of data or feature of the program. (commonly done by using usernames and passwords)
What are ways to increase the security of a password-based authentication system?
- force users to have strong passwords and get them to change them regularly
- limit the number of failed authentication attempts before access to account is lost
- ask for a random selection of characters from the password on each authentication