Multiple choice technology security

Identify code below is what type of validation. String input = request.getParameter ("input"); String characterPattern = "/ [^A-z]/"; If (! input. matches (characterPattern)) { out.println (“Invalid Input”); }

  1. White list validation

  2. Blacklist validation

  3. Mix validation

  4. No validation

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

This is whitelist validation because it explicitly defines allowed characters (A-Z, a-z) using the pattern [^A-z] and rejects anything that doesn't match. Whitelist validation is more secure because it only permits known good characters, rejecting everything else as the code does with 'Invalid Input'.

AI explanation

This is whitelist (allow-list) validation: the regex [^A-z] is used to check the input against a defined set of acceptable characters (here, roughly the alphabetic range) and reject anything falling outside that permitted set. Whitelist validation works by explicitly defining what IS allowed and rejecting everything else, which is exactly the pattern shown. Blacklist validation would instead define specific bad characters/patterns to reject while allowing everything else — the opposite approach. 'Mix' and 'No validation' don't apply since there clearly is a single-pattern check being enforced before accepting the input.