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 β "?".
Difficulty: advanced
Back to lesson: Checkpoint: The Request Firewall