Critical bug fixes and recall improvements (#68)

This commit is contained in:
Eli Peter 2026-05-11 12:42:39 -04:00 committed by GitHub
parent 7d0e7320e2
commit 55247b7fcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
352 changed files with 60069 additions and 900 deletions

View file

@ -0,0 +1,22 @@
// Phase 13 path-traversal sanitized (Java). Canonicalises the path
// via `base.resolve(name).normalize()` and validates containment with
// `startsWith(base)`; the canonical value is returned as a string,
// never reaching a FILE_IO sink. Demonstrates the new `Path.normalize`
// Sanitizer(FILE_IO) recogniser registered in `src/labels/java.rs`.
package handlers;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.servlet.http.HttpServletRequest;
public class PathTraversalSafe {
public String safeHandle(HttpServletRequest req) throws Exception {
String name = req.getParameter("name");
Path base = Paths.get("/var/data");
Path candidate = base.resolve(name).normalize();
if (!candidate.startsWith(base)) {
throw new SecurityException("escape");
}
return candidate.toString();
}
}