Bird
0
0

A developer wrote this code to enforce the 'Fail-Safe Defaults' pattern:

medium📝 Analysis Q14 of 15
Cybersecurity - Security Architecture and Design
A developer wrote this code to enforce the 'Fail-Safe Defaults' pattern:
def check_access(user):
    if user == 'admin':
        return True
    elif user == 'guest':
        return False
    # Missing return for other users

What is the main problem with this code?
AIt uses incorrect syntax for the function.
BIt grants access to all users by default.
CIt does not deny access by default for unknown users.
DIt returns True for guests.
Step-by-Step Solution
Solution:
  1. Step 1: Understand 'Fail-Safe Defaults'

    This pattern means access should be denied unless explicitly allowed.
  2. Step 2: Check the function's return paths

    The function returns True for 'admin', False for 'guest', but returns nothing (None) for others, which may be treated as allowed or cause errors.
  3. Final Answer:

    It does not deny access by default for unknown users. -> Option C
  4. Quick Check:

    Fail-Safe Defaults = deny unless allowed [OK]
Quick Trick: Always deny access if user unknown [OK]
Common Mistakes:
MISTAKES
  • Assuming missing return means deny
  • Thinking syntax is wrong
  • Confusing guest access rights

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Cybersecurity Quizzes