1. What is the primary purpose of input validation?

    • A) To enhance application performance
    • B) To limit user input to required functionality
    • C) To improve user experience
    • D) To format data for reporting
  2. At which levels should input validation be performed?

    • A) Syntactical and Contextual
    • B) Syntactical and Semantic
    • C) Structural and Semantic
    • D) Contextual and Structural
  3. Which of the following is an example of syntactical validation?

    • A) Ensuring a phone number has a specific format
    • B) Checking if a date is valid within a given context
    • C) Verifying if an email address is correctly formatted
    • D) Ensuring a user cannot enter a date in the past
  4. What is semantic validation concerned with?

    • A) The format of the input data
    • B) The correctness of input values within a given context
    • C) The length of the input data
    • D) The presence of certain characters in the input
  5. Why is it important to validate input on both the frontend and backend?

    • A) To enhance the design of the application
    • B) To prevent vulnerabilities from modified requests
    • C) To speed up the data entry process
    • D) To improve the application’s responsiveness
  6. What method should be used to ensure input conforms to specific schemas like JSON or XML?

    • A) Exception handling
    • B) Regular expressions
    • C) Data type specification
    • D) Strict validation checks
  7. What is a common approach for handling file uploads securely?

    • A) Validate only the file extension
    • B) Allow all file types but scan for malware
    • C) Validate the file size and extension, and scan for malicious content
    • D) Rename files with random names but do not validate them
  8. Why is it important to validate email addresses on both the client and server sides?

    • A) To prevent email spoofing
    • B) To ensure emails are correctly formatted and actually exist
    • C) To avoid email server downtime
    • D) To improve email marketing effectiveness
  9. Which approach to handling input validation errors involves generating a security error and redirecting to a generic error page?

    • A) Recovering
    • B) Failing
    • C) Logging
    • D) Sanitizing
  10. What is a key disadvantage of the “failing” approach in input validation?

    • A) It can mask malicious input
    • B) It may disrupt the user experience and lose transactions
    • C) It is less secure than recovering
    • D) It requires more complex coding
  11. How should the file path of an uploaded file be set to ensure security?

    • A) On the client side
    • B) On the server side
    • C) By the user
    • D) Dynamically based on user input
  12. Which tool is used for validating email addresses in PHP?

    • A) Apache Commons Validator
    • B) PHP filter functions
    • C) OWASP Java HTML Sanitizer
    • D) Java Hibernate Validator
  13. What should be done to handle special characters in user input effectively?

    • A) Encode them
    • B) Remove them
    • C) Ignore them
    • D) Allow all special characters
  14. When validating file uploads, what aspect should not be ignored?

    • A) File path
    • B) File content
    • C) File creation date
    • D) File name length
  15. What is the purpose of using regular expressions in input validation?

    • A) To define the range of allowed characters
    • B) To check the entire string rather than just parts of it
    • C) To validate the file type
    • D) To limit the size of the input
  16. Why might blacklisting email addresses be problematic?

    • A) It may be ineffective as new domains can be easily created
    • B) It requires too much server processing power
    • C) It is less secure than whitelisting
    • D) It is not compatible with many email clients
  17. What should be done when a validation error occurs to aid in investigation?

    • A) Display detailed error messages to the user
    • B) Log the error in the application logs
    • C) Ignore the error if it’s not critical
    • D) Redirect the user to a custom error page
  18. Which library is specifically designed for sanitizing HTML content in Java?

    • A) OWASP Java HTML Sanitizer Project
    • B) Java Hibernate Validator
    • C) Apache Commons Validator
    • D) JEP-290
  19. What is one approach to validate file content before accepting uploads?

    • A) Use regex to check the file extension
    • B) Validate the file size and scan for malicious content
    • C) Allow all file types and rely on user trust
    • D) Rename files to prevent security issues
  20. What is the purpose of using UUIDs for file uploads?

    • A) To ensure the file name is unique and not predictable
    • B) To make file names shorter
    • C) To improve file upload speed
    • D) To comply with email address validation rules

Answers:

  1. B) To limit user input to required functionality
  2. B) Syntactical and Semantic
  3. A) Ensuring a phone number has a specific format
  4. B) The correctness of input values within a given context
  5. B) To prevent vulnerabilities from modified requests
  6. D) Strict validation checks
  7. C) Validate the file size and extension, and scan for malicious content
  8. B) To ensure emails are correctly formatted and actually exist
  9. B) Failing
  10. B) It may disrupt the user experience and lose transactions
  11. B) On the server side
  12. B) PHP filter functions
  13. A) Encode them
  14. B) File content
  15. B) To check the entire string rather than just parts of it
  16. A) It may be ineffective as new domains can be easily created
  17. B) Log the error in the application logs
  18. A) OWASP Java HTML Sanitizer Project
  19. B) Validate the file size and scan for malicious content
  20. A) To ensure the file name is unique and not predictable