Checkpoint: the request firewall
Challenge on lesson: Checkpoint: The Request Firewall
Inside Solution, implement public static class Firewall:
1. Constructor Firewall(Path root, Set<String> allowedHosts); expose
public final Path root and public final Set<String> allowedHosts.
2. boolean canRead(String userPath) — canonical containment against root.
3. boolean canCall(String url) — host extraction + allowlist.
4. boolean authenticate(byte[] salt, String password, byte[] stored) — salted
recompute + constant-time verify.
5. static String review(java.util.Map<String, String> findings) — given findings
like {"sql":"parameterized", "secret":"env", "depends":"audited"}, return
"pass" iff every value is one of the accepted controls:
sql∈{parameterized}, secret∈{env}, depends∈{audited}; otherwise return the FIRST
key whose control is unacceptable. Unknown keys count as unacceptable.
6. static String threatOf(String control) — map each control to the STRIDE
letter it primarily addresses: "canonicalization"→"T", "allowlist"→"I",
"parameterized"→"T", "least-privilege"→"E", "rate-limit"→"D"; unknown → "?".
Back to lesson: Checkpoint: The Request Firewall