A+ VERIFIED
WGU D385 TASK 1 PERFORMANCE ASSESSMENT GUIDE SOFTWARE
SECURITY & TESTING PYTHON LOGGING ASSERTIONS STATIC
CODE ANALYSIS & TESTING PRACTICE EXAM QUESTIONS AND
CORRECT ANSWERS PLUS RATIONALES INSTANT DOWNLOAD 108
Questions
Clinical | Rationale-Driven - Pass Guaranteed - A+ Graded
108 1 108
QUESTIONS SECTIONS RATIONALES
WHAT THIS COVERS
01 Software Security and Testing (Python)
02 Python logging configuration
03 Assertion
04 Exception handling
05 Static code analysis with tools such as Bandit
06 Unit/integration testing practices aligned with OWASP Top 10 (2021/2025)
ABOUT THIS ASSESSMENT
This performance assessment exam evaluates secure coding, Python logging configuration, assertion and exception handling, static
code analysis with tools such as Bandit and pylint, and unit/integration testing practices aligned with OWASP Top 10 (2021/2025)
and ISTQB foundational concepts. Questions require multi-step reasoning about real-world security defects, test design, and
remediation.
,EXAMINATION QUESTIONS
SECTION 1 - Software Security and Testing (Python) (Questions 1 to 108)
1. Which logging configuration most effectively prevents log injection in a security-sensitive Python service?
A. Using logging.basicConfig with default Formatter and writing raw user input directly.
B. Setting a custom Formatter that sanitizes newline and control characters in messages.
C. Increasing log level to CRITICAL to reduce volume of untrusted input logged.
D. Redirecting logs to sys.stderr without any formatting to avoid parsing issues.
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: Log injection occurs when untrusted input containing newlines or control characters forges log entries; a custom Formatter
that escapes or strips these characters neutralizes the attack. BasicConfig with raw input, raising levels, or redirecting streams does not
sanitize content and therefore fails to prevent injection.
2. Which logging configuration prevents sensitive data leakage in production while preserving debuggability?
A. Set root logger to DEBUG and filter at the handler level using a regex for passwords.
B. Use a custom Formatter that redacts fields and set level to INFO with structured JSON output.
C. Disable all logging in production and rely on print statements for error tracking.
D. Log all request data at WARNING level to ensure visibility without debug overhead.
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: A custom Formatter with redaction and INFO-level structured logs balances security and debuggability. Option A risks
leakage if filters fail; C loses observability; D still logs sensitive data at a high level.
3. What is the primary purpose of using a custom exception hierarchy in a Python application?
A. To improve performance by reducing exception handling overhead.
B. To allow callers to catch specific error types and handle them appropriately.
C. To automatically log all exceptions to a file.
D. To enforce type checking at runtime.
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: A custom hierarchy enables granular exception handling by callers, improving error management. A is false (performance
is not the goal); C requires explicit logging; D is unrelated to type checking.
4. A CI pipeline runs `pylint --errors-only` and passes, yet a SQL injection ships. What is the flaw?
A. Pylint analyzes style and some errors, not taint-based security flows; Bandit or Semgrep is needed.
B. Pylint must be run with `--disable=all` to enable security checks.
C. The pipeline should use flake8 instead because it detects injection.
D. SQL injection cannot be detected by any static analyzer.
Answer: A [Concept: Software Security and Testing (Python)]
Rationale: Pylint focuses on code quality and limited error patterns, not data-flow taint analysis for injection. Security-focused tools
like Bandit or Semgrep perform taint tracking; flake8 is style-oriented, and injection is statically detectable with the right tool.
5. A developer uses assert to validate user authorization in a Flask route. Why is this insecure?
A. Flask disables assert statements automatically.
B. Python's -O flag removes asserts, bypassing the authorization check.
C. Assertions cannot evaluate boolean expressions.
D. Assert raises HTTP 403 by default.
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: Under optimization (-O), Python strips assert statements, so authorization checks silently disappear, creating a bypass.
Flask does not disable asserts (A), asserts evaluate booleans fine (C), and assert raises AssertionError, not HTTP 403 (D).
Page 2 | WGU D385 TASK 1 PERFORMANCE ASSESSMENT GUIDE SOFTWARE SECURITY & TESTING PYTHON LOGGING ASSERTIONS
, 6. Which pytest feature best supports parameterized security tests across many malicious payloads with minimal
duplication?
A. Using pytest.mark.parametrize with a list of payload tuples.
B. Writing a separate test function for each payload string.
C. Using pytest.skip for payloads that are hard to encode.
D. Relying on unittest.TestCase subclasses exclusively.
Answer: A [Concept: Software Security and Testing (Python)]
Rationale: pytest.mark.parametrize generates distinct test cases from a payload list, giving clear per-payload reporting without
duplicating test logic. Separate functions duplicate code, skip hides coverage, and unittest subclasses do not provide pytest's concise
parameterization.
7. Which unittest feature best isolates a test from external dependencies like a database?
A. setUpClass to initialize a real database connection once.
B. unittest.mock.patch to replace the database call with a mock.
C. tearDown to close the database connection after each test.
D. skipIf decorator to skip tests when the database is unavailable.
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: unittest.mock.patch replaces the real database call with a mock object, allowing the test to run in isolation without external
dependencies. setUpClass and tearDown still require a real database, and skipIf merely skips tests rather than isolating them.
8. Bandit flags 'B602: subprocess with shell=True'. What is the most secure remediation?
A. Replace shell=True with a list of arguments and shell=False, validating each argument.
B. Escape all spaces in the command string before passing it to subprocess.
C. Wrap the command in shlex.quote and keep shell=True for compatibility.
D. Suppress the finding with '# nosec' because shell=True is required for pipelines.
Answer: A [Concept: Software Security and Testing (Python)]
Rationale: Passing an argument list with shell=False avoids shell interpretation and command injection. Escaping spaces (B) or using
shlex.quote with shell=True (C) still invokes a shell and remains risky. Suppressing with # nosec (D) hides a real vulnerability.
9. Which OWASP Top 10 2021 category is most directly mitigated by parameterized queries in Python?
A. A01: Broken Access Control
B. A03: Injection
C. A05: Security Misconfiguration
D. A07: Identification and Authentication Failures
Answer: B [Concept: Software Security and Testing (Python)]
Rationale: Parameterized queries prevent SQL injection, which falls under A03: Injection. The other categories are addressed by
different controls (access checks, config hardening, authentication mechanisms).
10. Which exception-handling pattern best supports secure failure while preserving diagnostic context in a service?
A. except Exception: pass to keep the service responsive.
B. except Exception as e: raise RuntimeError(str(e)) from None
C. except Exception as e: logger.error(e); return None
D. except Exception as e: logger.exception('op failed'); raise
Answer: D [Concept: Software Security and Testing (Python)]
Rationale: logger.exception records the traceback at ERROR and bare raise preserves the original exception chain for callers,
supporting both forensics and fail-closed behavior. Swallowing exceptions, discarding the chain with from None, or returning None on
error hides failures and violates defensive-programming guidance.
Page 3 | WGU D385 TASK 1 PERFORMANCE ASSESSMENT GUIDE SOFTWARE SECURITY & TESTING PYTHON LOGGING ASSERTIONS