nerdexam
CompTIA

SY0-301 · Question #51

Which of the following is the below pseudo-code an example of? IF VARIABLE (CONTAINS NUMBERS = TRUE) THEN EXIT

The correct answer is B. Input validation. The pseudocode inspects a variable for numeric content before allowing execution to continue, which is a textbook example of input validation.

Threats, vulnerabilities, and mitigations

Question

Which of the following is the below pseudo-code an example of? IF VARIABLE (CONTAINS NUMBERS = TRUE) THEN EXIT

Options

  • ABuffer overflow prevention
  • BInput validation
  • CCSRF prevention
  • DCross-site scripting prevention

How the community answered

(27 responses)
  • A
    7% (2)
  • B
    85% (23)
  • C
    4% (1)
  • D
    4% (1)

Why each option

The pseudocode inspects a variable for numeric content before allowing execution to continue, which is a textbook example of input validation.

ABuffer overflow prevention

Buffer overflow prevention focuses on enforcing memory boundary limits on input length, not on checking the data type or content of a variable.

BInput validationCorrect

Input validation is the practice of checking data against expected formats, types, or ranges before processing it. The pseudocode explicitly tests whether a variable contains numbers and exits if that condition is met, preventing undesired input from propagating through the system - a direct implementation of an input validation gate.

CCSRF prevention

CSRF prevention uses techniques such as synchronizer tokens or SameSite cookies to stop unauthorized cross-site requests, which has no relation to variable content inspection.

DCross-site scripting prevention

XSS prevention involves encoding or sanitizing output rendered in a browser to block injected scripts, not checking whether a variable contains numeric characters.

Concept tested: Input validation to reject unwanted data types

Source: https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html

Topics

#input validation#secure coding#application security#injection prevention

Community Discussion

No community discussion yet for this question.

Full SY0-301 Practice