• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 23 pages
Exam (elaborations)

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

Document preview thumbnail
Preview 3 out of 23 pages

Practice questions with answers and rationales covering Python secure coding, logging configuration, assertions, exception handling, static analysis with Bandit and pylint, and unit and integration testing aligned with OWASP Top 10 and ISTQB concepts. Each question walks through real security defects, test design choices, and remediation so you can reason through the scenarios and prepare for the performance assessment.

Content preview

2026
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

Document information

Uploaded on
October 20, 2026
Number of pages
23
Written in
2026/2027
Type
Exam (elaborations)
Contains
Questions & answers
$30.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
PremiumExamBank
4.8
(1071)
Sold
522
Followers
78
Items
10577
Last sold
21 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions