mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-09 19:45:13 +02:00
[pitboss] phase 05: M5 — JS/TS, Go, Java, PHP harness emitters
This commit is contained in:
parent
84638e7d57
commit
345b44d3cc
103 changed files with 5637 additions and 34 deletions
27
tests/dynamic_fixtures/java/fileio_negative.java
Normal file
27
tests/dynamic_fixtures/java/fileio_negative.java
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// File I/O — negative fixture.
|
||||
// Safe: normalizes path and checks it stays within the base directory.
|
||||
// Entry: Entry.readFile(String) Cap: FILE_IO
|
||||
// Expected verdict: NotConfirmed
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class Entry {
|
||||
private static final String BASE_DIR = "/var/data";
|
||||
|
||||
public static void readFile(String userPath) throws Exception {
|
||||
Path base = Paths.get(BASE_DIR).toRealPath();
|
||||
Path resolved = base.resolve(userPath).normalize();
|
||||
if (!resolved.startsWith(base)) {
|
||||
System.out.println("Access denied");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
byte[] data = Files.readAllBytes(resolved);
|
||||
int len = Math.min(data.length, 100);
|
||||
System.out.write(data, 0, len);
|
||||
} catch (IOException e) {
|
||||
System.out.println("File not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue