Docsity

WGU D385 TASK 1 COMPLETE PRACTICE GUIDE SOFTWARE SECURITY & TESTING STATIC ANALYSIS, PYTH,, Exams of Software Engineering

Toggle sidebar
bg1
Page 1
WGU D385 TASK 1 COMPLETE PRACTICE GUIDE
SOFTWARE SECURITY & TESTING STATIC ANALYSIS,
PYTH, Exams of Computer Security - Questions and Answers
Already Graded A+ Premium Exam Tested And Verified
GRADED A+
ABSTRACT
This exam assesses mastery of software security fundamentals, threat modeling, static
analysis tooling, secure coding in Python, vulnerability identification and remediation,
software testing principles, code review, and risk assessment documentation aligned
with WGU D385 Task 1 performance assessment. It emphasizes practical application
of OWASP Top 10, CWE/SANS Top 25, and NIST SSDF within Python-centric static
analysis workflows.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12

Partial preview of the text

Download WGU D385 TASK 1 COMPLETE PRACTICE GUIDE SOFTWARE SECURITY & TESTING STATIC ANALYSIS, PYTH, and more Exams Software Engineering in PDF only on Docsity!

WGU D385 TASK 1 COMPLETE PRACTICE GUIDE

SOFTWARE SECURITY & TESTING STATIC ANALYSIS,

PYTH, Exams of Computer Security - Questions and Answers

Already Graded A+ Premium Exam Tested And Verified

GRADED A+

ABSTRACT

This exam assesses mastery of software security fundamentals, threat modeling, static

analysis tooling, secure coding in Python, vulnerability identification and remediation,

software testing principles, code review, and risk assessment documentation aligned

with WGU D385 Task 1 performance assessment. It emphasizes practical application

of OWASP Top 10, CWE/SANS Top 25, and NIST SSDF within Python-centric static

analysis workflows.

1. Which Python construct most directly enables SQL injection when used with

user input?

A. Parameterized queries with placeholders B. String concatenation to build SQL C. ORM query builders with bound parameters D. Stored procedures with input validation

Answer: B. String concatenation to build SQL

String concatenation embeds untrusted input directly into SQL, enabling injection (CWE-89). Parameterized queries, ORM bound parameters, and stored procedures with validation prevent injection by separating code from data.

2. A static analysis tool reports a high-severity finding in a Python module.

What is the most appropriate first step?

A. Immediately refactor the code to remove the finding B. Suppress the finding to reduce noise C. Triage the finding to confirm exploitability and context D. Escalate to management without review

Answer: C. Triage the finding to confirm exploitability and context

Triage confirms whether the finding is a true positive and assesses exploitability in context, preventing wasted effort on false positives. Immediate refactoring or suppression without validation can be premature or risky, and escalation without review lacks technical basis.

3. Which threat modeling approach best integrates with a Python microservice

using OWASP Top 10?

A. STRIDE per element with trust boundaries B. VAST scaled to enterprise architecture C. PASTA focused on business impact D. OCTAVE for organizational risk

Answer: A. STRIDE per element with trust boundaries

STRIDE applied per element with trust boundaries systematically identifies threats like spoofing and tampering in microservice interactions, aligning with OWASP Top 10 categories. VAST, PASTA, and OCTAVE are broader or organization-level and less directly mapped to code-level OWASP risks.

7. Which NIST SSDF practice directly addresses static analysis integration in

CI/CD?

A. PW.7 (Review and/or Analyze Human-Readable Code) B. PS.1 (Protect All Forms of Code) C. RV.1 (Identify and Confirm Vulnerabilities) D. PO.5 (Implement and Maintain Secure Environments)

Answer: A. PW.7 (Review and/or Analyze Human-Readable Code)

PW.7 explicitly covers code review and static analysis to identify vulnerabilities. PS.1 protects code integrity, RV.1 focuses on vulnerability response, and PO. addresses environment security.

8. Which OWASP ASVS chapter is most relevant to verifying secure session

management in a Python web app?

A. V2 Authentication B. V3 Session Management C. V5 Validation, Sanitization, Encoding D. V8 Data Protection

Answer: B. V3 Session Management

ASVS V3 Session Management specifies requirements for session tokens, timeouts, and binding. Authentication (V2), validation (V5), and data protection (V8) address different security domains.

9. Which risk assessment metric best prioritizes a static analysis finding of

SQL injection in a public-facing login?

A. CVSS base score alone B. CWE severity rating C. Contextual risk (exploitability, data sensitivity) D. Lines of code affected

Answer: C. Contextual risk (exploitability, data sensitivity)

Contextual risk combines exploitability, exposure, and data sensitivity to prioritize remediation effectively. CVSS base score lacks environmental context, CWE severity is generic, and lines of code do not indicate risk.

10. Which Python static analysis tool is best suited for detecting taint-style data

flow vulnerabilities?

A. Pylint B. Bandit C. Flake D. Mypy

Answer: B. Bandit

Bandit is designed to find security issues including data flow from sources to sinks (e.g., SQL injection). Pylint and Flake8 focus on style and errors, while Mypy checks type annotations.

11. Which Python construct most directly enables SQL injection when used

with untrusted input in a query?

A. Parameterized query with placeholders B. f-string interpolation of user input into SQL C. ORM query builder with bound parameters D. Stored procedure call with typed arguments

Answer: B. f-string interpolation of user input into SQL

f-string interpolation embeds user input directly into SQL text, allowing injection (CWE-89). Parameterized queries, ORM binding, and typed stored procedures separate code from data and prevent injection.

12. A SAST tool flags a data flow from request.args to os.system. Which

remediation best preserves functionality?

A. Suppress the finding with a # nosec comment B. Replace os.system with subprocess.run using a list and shell=False C. Encode the input with base64 before concatenation D. Move the call into a try/except block

Answer: B. Replace os.system with subprocess.run using a list and

shell=False

Using subprocess with an argument list and shell=False prevents shell interpretation, mitigating OS command injection (CWE-78) while preserving the command's function. Suppression hides risk, base64 is reversible, and try/except does not remove the vulnerability.

16. Under NIST SSDF (SP 800-218), which practice corresponds to PW.4.1?

A. Reuse well-secured software components B. Define security requirements C. Implement secure design principles D. Perform static analysis

Answer: A. Reuse well-secured software components

PW.4.1 in NIST SSDF is 'Reuse Existing, Well-Secured Software When Feasible.' Defining requirements is PW.1, secure design is PW.2, and static analysis is PW.7.

17. Which CWE category is most associated with Python's eval() on untrusted

input?

A. CWE-79 Cross-site Scripting B. CWE-95 Code Injection C. CWE-22 Path Traversal D. CWE-352 CSRF

Answer: B. CWE-95 Code Injection

eval() executes arbitrary code, directly mapping to CWE-95 (Improper Neutralization of Directives in Dynamically Evaluated Code). XSS, path traversal, and CSRF involve different mechanisms.

18. In a CI pipeline, which configuration most effectively prevents a SAST

finding from being ignored without review?

A. Allow developers to dismiss findings locally B. Require a documented risk acceptance with approver identity C. Disable the rule globally after first occurrence D. Run SAST only on release branches

Answer: B. Require a documented risk acceptance with approver identity

Enforcing documented risk acceptance with approver identity ensures accountability and traceability, aligning with SSDF and audit requirements. Local dismissal, global rule disabling, and infrequent scans undermine the control.

19. Which Python library is designed to provide constant-time comparison for

secrets to mitigate timing attacks?

A. hashlib B. hmac.compare_digest C. secrets.token_hex D. base64.b64encode

Answer: B. hmac.compare_digest

hmac.compare_digest performs constant-time comparison, preventing timing side channels (CWE-208). hashlib, secrets.token_hex, and base64.b64encode do not provide constant-time comparison.

20. When writing a security defect report from a static analysis finding, which

element is most critical for remediation?

A. The exact line number only B. A proof-of-concept exploit C. The data flow trace from source to sink D. The developer's commit history

Answer: C. The data flow trace from source to sink

A data flow trace identifies how untrusted input reaches a dangerous sink, enabling precise remediation. Line number alone lacks context, a PoC may not be feasible, and commit history is not directly actionable for fixing the defect.

21. Which Python construct most directly enables CWE-78 OS command

injection when combined with unsanitized input?

A. subprocess.run with shell=True and string concatenation B. os.path.join with user-supplied path segments C. pickle.loads on untrusted byte streams D. eval on a sanitized arithmetic expression

Answer: A. subprocess.run with shell=True and string concatenation

CWE-78 occurs when untrusted input reaches a shell interpreter; subprocess.run(shell=True) with concatenated input allows metacharacter injection. os.path.join affects path traversal (CWE-22), pickle.loads enables deserialization RCE (CWE-502), and eval on sanitized arithmetic is still risky but not OS command injection.

25. Which Bandit finding should be triaged as highest risk in a Flask API

handling authentication?

A. B101 assert_used in test modules B. B105 hardcoded_password_string in config.py C. B404 subprocess import in a CLI utility D. B311 random for non-security jitter

Answer: B. B105 hardcoded_password_string in config.py

A hardcoded credential in configuration is a direct secret exposure (CWE-798) affecting authentication. Assert usage, a subprocess import alone, and non-security randomness are lower-impact or false-positive-prone.

26. Per NIST SSDF PW.7, which artifact most directly evidences secure code

review for a Python release?

A. A signed SBOM listing dependencies B. Documented review records with defect dispositions C. A passing unit test coverage threshold D. An approved change advisory board ticket

Answer: B. Documented review records with defect dispositions

PW.7 requires code review with defined criteria and disposition of findings; review records with defect dispositions are the direct evidence. SBOMs, coverage thresholds, and CAB tickets support other practices but not review evidence.

27. Which Python pattern most effectively prevents CWE-22 path traversal in

a file download endpoint?

A. os.path.normpath then open the joined path B. Resolve realpath and verify it starts with the base directory C. Strip '../' substrings from the user filename once D. URL-encode the filename before joining

Answer: B. Resolve realpath and verify it starts with the base directory

Canonicalizing with realpath and confirming containment under the base directory defeats encoded and nested traversal. normpath alone can still escape, single-pass substring stripping is bypassable, and URL-encoding does not constrain the filesystem path.

28. A SAST baseline shows 400 findings; which triage approach best aligns

with risk-based remediation?

A. Fix findings alphabetically by file name B. Prioritize by exploitability, data sensitivity, and reachability C. Suppress all low-severity rules globally D. Remediate only findings in new pull requests

Answer: B. Prioritize by exploitability, data sensitivity, and reachability

Risk-based triage ranks by exploitability, asset sensitivity, and whether the vulnerable path is reachable, focusing effort on real exposure. Alphabetical order, blanket suppression, and new-code-only scoping ignore existing high-risk defects.

29. Which test-design technique best isolates a Python function that reads

environment secrets during unit testing?

A. Mark the test as integration and skip in CI B. Monkeypatch os.environ and inject a fake secret C. Increase retries to mask environment variance D. Read the real secret from a developer .env file

Answer: B. Monkeypatch os.environ and inject a fake secret

Monkeypatching os.environ with a controlled fake secret gives deterministic, isolated unit tests without real credentials. Skipping, retries, and real secrets introduce nondeterminism or secret exposure.

30. During code review, which Python change most warrants blocking under

CWE-502 deserialization risk?

A. Replacing json.loads with yaml.safe_load B. Replacing json.loads with pickle.loads on request data C. Adding type hints to a dataclass D. Switching requests to httpx with timeouts

Answer: B. Replacing json.loads with pickle.loads on request data

pickle.loads on untrusted request data enables arbitrary code execution (CWE-502) and must be blocked. safe_load is safer YAML, type hints are inert, and httpx with timeouts improves robustness without deserialization risk.

34. In a threat model using STRIDE, which threat category is most relevant to

a Python API that trusts client-supplied JWT claims without signature

verification?

A. Denial of Service B. Information Disclosure C. Spoofing D. Repudiation

Answer: C. Spoofing

Accepting unverified JWT claims allows an attacker to impersonate another user, which is Spoofing in STRIDE. DoS, Information Disclosure, and Repudiation do not directly describe identity forgery.

35. Which NIST SSDF practice most directly addresses integrating static

analysis into the CI/CD pipeline?

A. PO.1 Define security requirements B. PS.2 Provide a mechanism for verifying software release integrity C. PW.7 Review and/or analyze human-readable code to identify vulnerabilities D. RV.1 Identify and confirm vulnerabilities on an ongoing basis

Answer: C. PW.7 Review and/or analyze human-readable code to identify

vulnerabilities

PW.7 explicitly covers code review and analysis (including SAST) to find vulnerabilities. PO.1 is requirements, PS.2 is release integrity, and RV.1 is ongoing vulnerability identification, not pipeline integration of static analysis.

36. A SAST report shows a high-severity finding in a code path never

reachable in production. What is the most defensible triage action?

A. Immediately remediate as critical B. Mark as false positive and suppress permanently C. Document as a risk-accepted finding with justification and review date D. Escalate to penetration testing team

Answer: C. Document as a risk-accepted finding with justification and review

date

Unreachable code lowers exploitability, so documenting risk acceptance with justification and periodic review aligns with risk-based triage. Immediate critical remediation ignores context, permanent suppression lacks governance, and escalation is unnecessary without exploitability evidence.

37. Which Python pattern most effectively prevents SQL injection when using

a database driver?

A. String concatenation with escaped quotes B. Parameterized queries with bound parameters C. Using an ORM with raw SQL string formatting D. Input sanitization via regular expressions

Answer: B. Parameterized queries with bound parameters

Parameterized queries separate code from data, eliminating SQL injection (CWE-89). Concatenation and raw SQL formatting remain vulnerable; regex sanitization is error-prone and not a primary defense.

38. When configuring a SAST tool, which setting most reduces false positives

without sacrificing coverage of tainted data flows?

A. Disabling interprocedural analysis B. Enabling taint tracking with sanitizer definitions C. Lowering the severity threshold to informational D. Excluding third-party libraries from scanning

Answer: B. Enabling taint tracking with sanitizer definitions

Taint tracking with properly defined sanitizers focuses on exploitable flows and reduces noise. Disabling interprocedural analysis reduces coverage, lowering thresholds increases noise, and excluding libraries may miss vulnerabilities.

42. A Bandit report flags B608 on a query built with f-strings. Which

remediation aligns with OWASP ASVS v5.0?

A. Escape single quotes with replace("'", "''") B. Use parameterized queries with bound parameters C. Enable WAF rule blocking SQL keywords D. Hash the input with SHA-256 before concatenation

Answer: B. Use parameterized queries with bound parameters

ASVS requires parameterized queries to prevent SQL injection (CWE-89); manual escaping is error-prone. WAF and hashing do not fix the root cause.

43. Which testing technique best isolates a defect in a function with multiple

conditional branches?

A. Statement coverage only B. Boundary value analysis on each condition C. MC/DC (modified condition/decision coverage) D. Random fuzzing without oracles

Answer: C. MC/DC (modified condition/decision coverage)

MC/DC requires each condition to independently affect the decision outcome, providing strong isolation of branch defects. Statement coverage and random fuzzing lack this rigor; BVA targets boundaries, not condition independence.

44. During code review, a developer uses eval() on JSON input. Which CWE

and SSDF practice apply?

A. CWE-502; SSDF PW.5 secure coding B. CWE-79; SSDF PS.1 protect code C. CWE-89; SSDF PW.7 review code D. CWE-798; SSDF PW.4 reuse secure components

Answer: A. CWE-502; SSDF PW.5 secure coding

eval() on untrusted data enables arbitrary code execution, mapped to CWE- (deserialization of untrusted data); SSDF PW.5 covers secure coding. CWE-79 is XSS, CWE-89 SQLi, CWE-798 hardcoded credentials.

45. Which risk rating approach best prioritizes a CWE-798 finding in a public

repo?

A. CVSS base score only B. Qualitative low/medium/high without context C. CVSS environmental score with exploitability and data sensitivity D. Line count of affected code

Answer: C. CVSS environmental score with exploitability and data sensitivity

Environmental metrics adjust for deployment context, exploitability, and data sensitivity, improving prioritization. Base score alone ignores context; qualitative labels and line counts are insufficient.

46. Which SAST configuration minimizes false positives for a Django project

using ORM?

A. Enable all rules including SQL string checks B. Suppress CWE-89 rules for ORM-managed queries C. Disable taint analysis entirely D. Run only on test files

Answer: B. Suppress CWE-89 rules for ORM-managed queries

Django ORM parameterizes queries, so suppressing raw SQL injection rules reduces false positives while retaining taint analysis for raw SQL. Disabling taint analysis or scanning only tests misses real issues.

47. Which Python pattern prevents path traversal (CWE-22) when serving

user files?

A. os.path.join(base, user_path) without normalization B. Resolve realpath and verify it starts with base directory C. Strip '../' once from input D. URL-encode the filename

Answer: B. Resolve realpath and verify it starts with base directory

Canonicalizing with realpath and checking the prefix ensures the resolved path stays within the base directory. Simple stripping or encoding can be bypassed; os.path.join alone does not prevent traversal.