Study Guide Exam and Correct Answers
2026 Updated.
Primary defense against log injection attacks - Answer sanitize outbound log messages
Result of exploiting a cross-site scripting vulnerability - Answer attacker can execute malicious
scripts in a user's browser
function prone to code injection attacks - Answer eval()
Package for internal use by Python for regression testing - Answer test
Vulnerability encountered when an attacker takes over multiple users' accounts - Answer
Broken Object Level Authorization (BOLA) vulnerability
Method used for a SQL injection attack - Answer exploit query parameters
Security vulnerability shown by lack of HSTS headers - Answer lack of HTTP Strict Transport
Security (HSTS) headers
Response code for requesting an invalid URL - Answer 404 Not Found
Method that returns information about the server's response - Answer response.content
Cross-origin resource sharing (CORS) allows users to do what - Answer override the same-
origin policy for specific resources
Protocol that caches a token after it has been acquired - Answer MSAL (Microsoft
Authentication Library)
Result of running code with authorizeAdmin(['user']) - Answer assertion error with the
message "No admin found."
Write a function that logs division by zero errors and outputs the results. The function should
log errors to the console and print the quotient for valid divisions.
, import logging
import sys
def divideByZeroError(dividend, divisor):
logging.basicConfig(stream=sys.stdout, format='%(levelname)s:%(message)s')
try:
quotient = dividend / divisor
print(quotient)
except Exception as e:
# logging error here, use str(e) as part of the output
if __name__ == '__main__':
dividend = int(input())
divisor = int(input())
divideByZeroError(dividend, divisor) - Answer logging.error('The exception that occurred is: ' +
str(e))
Use the unittest library to create unit tests that check for None values in the multiply_numbers
function. Use assertIsNone to verify if an input is None and return the not-null value.
import unittest
def multiply_numbers(x, y):
# add your code here
return x * y
# add your code here
class TestForNone(unittest.TestCase):
def test_when_a_is_null(self):
try:
self.assertIsNone(multiply_numbers(5, None))
except AssertionError as msg:
print(msg)
if __name__ == '__main__':
unittest.main() - Answer if x is None:
print("x is a null value")
return y
elif y is None: