Skip to content

Commit 957ebf7

Browse files
committed
Document native Phobos paths and stabilise wrapper tests
1 parent edb0af4 commit 957ebf7

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

docs/Overview.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ Phobos provides an alternative security mechanism based on **external container
234234

235235
`JavaPhobosTestCase` transforms the abstract permission model into concrete shell-script and configuration-file content that an external sandbox runtime can enforce.
236236

237+
### Native configuration: bracket-leading filesystem entries
238+
239+
The bundled Phobos parser reserves any line whose first meaningful character is `[` for a section header. A relative filesystem entry beginning with `[` therefore needs an explicit `./` prefix when it is written by hand in a `Base*.cfg` file or in a file passed through `--config`: write `./[draft` rather than `[draft`. Both spellings name the same relative location once the wrapper canonicalises the path, so the prefix records the intended meaning rather than changing it.
240+
241+
The rule covers every relative filesystem entry whose first character is `[`, in each of the `readonly`, `read`, `write`, `hide` and `tmpfs` sections. Absolute paths, and entries whose brackets appear later such as `relative/[draft` or `/tmp/a[b]c`, need no change. Phobos policies generated by Ares apply this serialisation automatically, so only hand-written configurations are concerned.
242+
237243
**Key design patterns:** Builder (`JavaPhobosTestCase.Builder`), Strategy (extractors), Template Method.
238244

239245
---

src/test/java/de/tum/cit/ase/ares/api/phobos/PhobosShellContractTest.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,13 +488,29 @@ private Path wrapperShellRoot(String baseConfiguration) throws IOException {
488488
Path shellRoot = Files.createDirectory(temporaryDirectory.resolve("wrapper"));
489489
for (String script : new String[] { "phobos.sh", "phobos-common.sh", "phobos-timeout.sh", "phobos-network.sh",
490490
"phobos-filesystem.sh" }) {
491-
Files.copy(TEMPLATES.resolve(script), shellRoot.resolve(script));
491+
makeExecutable(Files.copy(TEMPLATES.resolve(script), shellRoot.resolve(script)));
492492
}
493493
Files.writeString(shellRoot.resolve("Base.cfg"), baseConfiguration);
494494
Files.createFile(shellRoot.resolve("TailPhobos.cfg"));
495495
return shellRoot;
496496
}
497497

498+
/**
499+
* Reproduces the precondition the Phobos image establishes with
500+
* {@code chmod +x} over its script directory. The layers hand over to one
501+
* another with {@code exec}, so a copy that is only readable stops part-way
502+
* through the chain with "Permission denied". The bundled resources are not
503+
* tracked as executable and a copy inherits that, which is why the fixture
504+
* grants the bit on the copy rather than on the resource it came from. A
505+
* fixture that cannot establish it is a setup failure, never a skipped test.
506+
*/
507+
private static void makeExecutable(Path script) {
508+
script.toFile().setExecutable(true);
509+
if (!Files.isExecutable(script)) {
510+
throw new IllegalStateException("The wrapper fixture needs an executable copy of " + script);
511+
}
512+
}
513+
498514
private Path markerOf(Path shellRoot) {
499515
return shellRoot.resolve("protected-command-ran");
500516
}

0 commit comments

Comments
 (0)