CHALLENGE ${esc(p.challenge)} · ${tx(p.kind)}
${go(`project/${p.id}`,tx(p.name))}
${tx(p.intro)}
diff --git a/AGENTS.md b/AGENTS.md index 2029433..9360f2e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,10 +9,13 @@ Read `README.md` and `docs/codebase-index.md` before editing. This is a static, - Edit projects in `content/projects/*.json` and shared settings in `content/settings.json`. Follow `docs/content-editing.md`. - Generate `content.js` with `npm run content`, `npm test` or `npm run build`. Commit generated changes alongside their source; never hand-edit the module. - Keep Dutch and English text complete, project IDs stable, and repository links pinned to a reviewed revision. +- Projects default to the school repository in settings. For another repository, use the validated `repository` object and pass the project to `source(path, directory, project)` in every renderer. Supported hosts are `github.com` and `codealvin.xyz`; pins must be full lowercase commit SHAs. +- Set bilingual `setting` explicitly for projects outside school year 2. Use `challenge: "—"` for personal projects; the scaffold still defaults to school repository paths and does not supply a context override. +- Record repository selections, reviewed pins and exclusions in `docs/repository-review.md`. Keep unmapped source links separate from claims of exam evidence, and preserve recorded user exclusions when refreshing the selection. - Preserve explicit evidence gaps. Do not invent personal contributions, assessment results, test outcomes or deployment claims. Only change the source review date after actually reviewing the sources. - UI copy and shared contribution/reflection placeholders also live in `app.js`; metadata lives in `index.html`. JSON is not a complete CMS. - Keep the static publication boundary: five public assets, no public editor or write API. If assets change, update the build, preview allowlist, Docker inputs and Nginx allowlist together. -- Do not commit `.env`, `dist/`, logs, dependencies or private material. The build does not clean `dist/`, so inspect it before publishing. +- Do not commit `.env`, `dist/`, logs, dependencies or private material. The build validates and stages exactly five public assets before replacing `dist/`; never add private files to publication output. ## Checks and documentation diff --git a/README.md b/README.md index 0c3155e..7fd54d4 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ npm test npm run build ``` -The build regenerates tracked `content.js` from JSON and copies `index.html`, `styles.css`, `app.js`, `content.js` and `favicon.svg` into ignored `dist/`. It does not clean old files from `dist/`; keep that directory limited to these five assets before publishing. A general static host can serve them at a domain root or subdirectory; the included Nginx configuration serves only the domain root. Hash-based routes need no server fallback. Dutch is the default; `?lang=en#evidence` opens English evidence navigation. Language switching preserves the current page. +The build regenerates tracked `content.js` from JSON and copies `index.html`, `styles.css`, `app.js`, `content.js` and `favicon.svg` into ignored `dist/`. It validates content and stages these five assets before replacing `dist/`, removing stale files. Redirected build directories are rejected. A general static host can serve them at a domain root or subdirectory; the included Nginx configuration serves only the domain root. Hash-based routes need no server fallback. Dutch is the default; `?lang=en#evidence` opens English evidence navigation. Language switching preserves the current page. ## Maintain content @@ -44,24 +44,24 @@ An evidence item looks like this: } ``` -Use `"directory": true` for a folder. Paths are relative to the school repository. Keep project `id` values stable to preserve links. Use exactly three `nodes` for the system diagram. Project numbers and challenge numbers are strings. +Use `"directory": true` for a folder. Paths are relative to the school repository by default; a project can specify its own pinned GitHub or Gitea repository. Keep project `id` values stable to preserve links. Use exactly three `nodes` for the system diagram. Project numbers and challenge numbers are strings. See [the content reference](docs/content-editing.md) for every field, validation limits and how project tags differ from evidence mappings. Run `npm run dev` and refresh the browser to preview saved edits. Invalid content will prevent the preview content module from loading; run `npm run content` for a descriptive validation error. Run `npm run build` to validate and prepare publication. `content.js` is generated; do not edit it directly. `npm run content` regenerates it without building. -Only deploy `dist/`. Everything in the generated content is public, so keep credentials and private documents out of these files. Repository links remain pinned to the `revision` in `content/settings.json`; update it after reviewing a newer snapshot. +Only deploy `dist/`. Everything in the generated content is public, so keep credentials and private documents out of these files. Repository links default to the `revision` in `content/settings.json`. Projects outside the school archive supply a `repository` object with their own URL, forge and reviewed commit. See the [repository review](docs/repository-review.md) for the 10 November 2026 selection. ## Finish the exam content -The interface is functional; the exam dossier is not yet complete. Summaries are based on the supplied school repository, not invented personal experience. Artifact paths were checked against the repository tree. DOCX contents were not reviewed and the source projects' test scripts were not executed. +The interface is functional; the exam dossier is not yet complete. The selection contains nine school and personal projects, based on public GitHub and Gitea sources, not invented personal experience. Artifact paths were checked against the repository tree. DOCX contents were not reviewed and the source projects' test scripts were not executed. Before submission, add your personal contribution and reflection for every case study, confirm solo/team context, include actual test results, and substantiate improvement claims. Add evidence for B1-K2-W1, W2 and W3 (collaboration, presentation and evaluation). The current mappings are suggestions, not assessment decisions. Ask the examiner which artifacts and authenticity statements VISTA requires. General subjects, electives and institution-specific requirements are outside this vocational index. The source is SBB's 2024 qualification for Software Developer, code 25998: https://kwalificatie-mijn.s-bb.nl/Details/DownloadDocument/1963420 -English process names are informal translations. The recorded source review date is 9 November 2026; this documentation refresh does not constitute a new source or qualification review. +English process names are informal translations. The qualification review date remains 9 November 2026. The separate repository review on 10 November 2026 selected six additional projects and checked pinned source paths; it did not reassess the qualification. Direct contact details, a CV, screenshots, assessed outcomes and personal reflections were not supplied, so the site does not invent them. Add these as real material becomes available. Project diagrams illustrate structure; they are not screenshots of running applications. diff --git a/app.js b/app.js index 672b66b..5fa5864 100644 --- a/app.js +++ b/app.js @@ -8,12 +8,12 @@ const ext = (url, label, cls = '') => ` `${esc(text)}`; const route = () => location.hash.slice(1) || 'home'; document.querySelector('.skip').addEventListener('click', event => { event.preventDefault(); main.focus(); main.scrollIntoView(); }); -const go = (id, label, cls = '') => `${label}`; +const go = (id, label, cls = '') => `${label}`; function header() { const current = route(); document.querySelector('#header').innerHTML = `
Alvin Zilverstand · VISTA college, Heerlen
CHALLENGE ${esc(p.challenge)} · ${tx(p.kind)}
${tx(p.intro)}
${p.challenge === '—' ? tx(['PERSOONLIJK PROJECT','PERSONAL PROJECT']) : `CHALLENGE ${esc(p.challenge)}`} · ${tx(p.kind)}
${tx(p.intro)}
${tx(['Nog geen projecten toegevoegd.','No projects added yet.'])}
`; } function work() { - return `01 / ${tx(['PROJECTARCHIEF','PROJECT ARCHIVE'])}
${tx(['Schoolprojecten, bekeken vanuit het probleem, de uitvoering en het beschikbare bewijs. De broncode blijft één klik verder.','School projects, through their problems, implementation, and available evidence. The source code is always one click away.'])}
01 / ${tx(['PROJECTARCHIEF','PROJECT ARCHIVE'])}
${tx(['Schoolprojecten en persoonlijke experimenten, bekeken vanuit het probleem, de uitvoering en de beschikbare bronnen. De broncode blijft één klik verder.','School projects and personal experiments, through their problems, implementation, and available sources. The source code is always one click away.'])}
PROJECT ${esc(p.number)} / CHALLENGE ${esc(p.challenge)}
${tx(p.intro)}
0${i+1}
${tx(body)}
04
${tx(['Dit zijn gevonden bronnen, geen goedgekeurde examenbewijzen. Documentinhoud en testresultaten moeten nog worden gecontroleerd.','These are located sources, not approved exam evidence. Document contents and test results still need review.'])}
05 / ${tx(['PERSOONLIJKE REFLECTIE','PERSONAL REFLECTION'])}
${tx(['Nog aan te vullen door Alvin: welke onderdelen heb ik zelf gemaakt, met wie werkte ik samen, welke feedback kreeg ik en wat zou ik anders doen?','To be completed by Alvin: which parts did I build myself, who did I work with, what feedback did I receive, and what would I do differently?'])}
PROJECT ${esc(p.number)} / ${p.challenge === '—' ? tx(['PERSOONLIJK PROJECT','PERSONAL PROJECT']) : `CHALLENGE ${esc(p.challenge)}`}
${tx(p.intro)}
0${i+1}
${tx(body)}
04
${tx(['Dit zijn gevonden bronnen, geen goedgekeurde examenbewijzen. Documentinhoud en testresultaten moeten nog worden gecontroleerd.','These are located sources, not approved exam evidence. Document contents and test results still need review.'])}
05 / ${tx(['PERSOONLIJKE REFLECTIE','PERSONAL REFLECTION'])}
${tx(['Nog aan te vullen door Alvin: welke onderdelen heb ik zelf gemaakt, met wie werkte ik samen, welke feedback kreeg ik en wat zou ik anders doen?','To be completed by Alvin: which parts did I build myself, who did I work with, what feedback did I receive, and what would I do differently?'])}
02 / ${tx(['EXAMENPORTFOLIO','EXAM PORTFOLIO'])}
${tx(['Bronnen per werkproces. Een navigeerbare voorbereiding op mijn examen, met zichtbaar onderscheid tussen gevonden materiaal en wat nog ontbreekt.','Sources by work process. A navigable preparation for my exam, making the distinction between located material and missing evidence visible.'])}
${tx(['In opbouw. Koppelingen zijn voorlopig; aanwezigheid van code of een document bewijst nog geen beheersing. Persoonlijke bijdrage, resultaten en beoordeling moeten worden toegevoegd. Stem de definitieve bewijslast af met de examinator.','In progress. Mappings are provisional; code or a document alone does not demonstrate competence. Personal contributions, results, and assessment need to be added. Agree the final evidence requirements with the examiner.'])}
SBB / 25998 / 2024
${tx(['Deze index volgt de acht beroepsspecifieke werkprocessen uit het gekoppelde dossier. Generieke vakken, keuzedelen en VISTA-examenafspraken vallen buiten deze index. Engelse labels zijn eigen vertalingen.','This index follows the eight vocational work processes in the linked qualification. General subjects, electives, and VISTA exam arrangements are outside this index. English labels are informal translations.'])}
${ext(profile.qualification,tx(['Lees het officiële kwalificatiedossier','Read the official qualification document']),'text-link')}02 / ${tx(['EXAMENPORTFOLIO','EXAM PORTFOLIO'])}
${tx(['Bronnen per werkproces. Een navigeerbare voorbereiding op mijn examen, met zichtbaar onderscheid tussen gevonden materiaal en wat nog ontbreekt.','Sources by work process. A navigable preparation for my exam, making the distinction between located material and missing evidence visible.'])}
${tx(['In opbouw. Koppelingen zijn voorlopig; aanwezigheid van code of een document bewijst nog geen beheersing. Persoonlijke bijdrage, resultaten en beoordeling moeten worden toegevoegd. Stem de definitieve bewijslast af met de examinator.','In progress. Mappings are provisional; code or a document alone does not demonstrate competence. Personal contributions, results, and assessment need to be added. Agree the final evidence requirements with the examiner.'])}
SBB / 25998 / 2024
${tx(['Deze index volgt de acht beroepsspecifieke werkprocessen uit het gekoppelde dossier. Generieke vakken, keuzedelen en VISTA-examenafspraken vallen buiten deze index. Engelse labels zijn eigen vertalingen.','This index follows the eight vocational work processes in the linked qualification. General subjects, electives, and VISTA exam arrangements are outside this index. English labels are informal translations.'])}
${ext(profile.qualification,tx(['Lees het officiële kwalificatiedossier','Read the official qualification document']),'text-link')}${tx(p.description)}
${found.length?`${tx(['Te controleren: inhoud, eigen bijdrage en geschiktheid voor het examen.','To verify: contents, personal contribution, and suitability for the exam.'])}
`:`${tx(p.description)}
${found.length?`${tx(['Te controleren: inhoud, eigen bijdrage en geschiktheid voor het examen.','To verify: contents, personal contribution, and suitability for the exam.'])}
`:`03 / ${tx(['OVER MIJ','ABOUT ME'])}
${tx(['Software Developer in opleiding. Derdejaars bij VISTA college in Heerlen.','Software Developer in training. Third-year student at VISTA college in Heerlen.'])}
${tx(['Mijn schoolwerk loopt uiteen van websites en PHP-applicaties tot een magazijnsysteem en narrowcasting. Dit portfolio brengt de projecten en de bijbehorende bronnen bij elkaar.','My schoolwork ranges from websites and PHP applications to a warehouse system and narrowcasting. This portfolio brings those projects and their sources together.'])}
${tx(['Ik bouw dit portfolio voor mijn eindexamen. Daarna wil ik het verder gebruiken om mijn werk aan toekomstige werkgevers te laten zien.','I’m building this portfolio for my final exam. After that, I want to keep using it to show my work to future employers.'])}
${tx(['VERDER KIJKEN','TAKE A CLOSER LOOK'])}
${tx(['Een rechtstreeks contactadres en cv worden later toegevoegd.','A direct contact address and CV will be added later.'])}
03 / ${tx(['OVER MIJ','ABOUT ME'])}
${tx(['Software Developer in opleiding. Derdejaars bij VISTA college in Heerlen.','Software Developer in training. Third-year student at VISTA college in Heerlen.'])}
${tx(['Mijn projecten lopen uiteen van websites en PHP-applicaties tot narrowcasting, een muziekgame, desktopsoftware en beheerscripts. Dit portfolio brengt de projecten en de bijbehorende bronnen bij elkaar.','My projects range from websites and PHP applications to narrowcasting, a music game, desktop software, and administration scripts. This portfolio brings those projects and their sources together.'])}
${tx(['Ik bouw dit portfolio voor mijn eindexamen. Daarna wil ik het verder gebruiken om mijn werk aan toekomstige werkgevers te laten zien.','I’m building this portfolio for my final exam. After that, I want to keep using it to show my work to future employers.'])}
${tx(['VERDER KIJKEN','TAKE A CLOSER LOOK'])}
${tx(['Een rechtstreeks contactadres en cv worden later toegevoegd.','A direct contact address and CV will be added later.'])}
`, `#ab
The compiler reads JSON files directly inside `content/projects/`, sorts by `number` using numeric-aware comparison, validates project fields and emits exports. The first project is featured and the homepage count is derived from the array; an empty portfolio is supported. The preview generates content in memory on request. Content, test and build commands regenerate the tracked module on disk.
-Project IDs are stable route identifiers. Evidence paths are relative to `profile.school` at the pinned `revision`. Text pairs are `[Dutch, English]`. The existing design uses exactly three diagram nodes. Personal contribution and reflection copy is still shared placeholder text in `app.js`.
+Project IDs are stable route identifiers. Evidence paths default to `profile.school` at the pinned `revision`. An optional project `repository` overrides the base, commit and forge; `source(path, directory, project)` constructs GitHub or Gitea URLs. An optional bilingual `setting` describes school year or personal-project context. Text pairs are `[Dutch, English]`. The existing design uses exactly three diagram nodes. Personal contribution and reflection copy is still shared placeholder text in `app.js`.
`tests/content.test.mjs` checks translations, mappings, pinned URL construction and the currently missing collaboration evidence. `tests/editor.test.mjs` checks compilation, empty collections, invalid inputs and homepage rendering with the featured project or all projects removed. Its DOM stub does not test real layout or browser interactions.
@@ -43,4 +44,4 @@ The print button opens all currently rendered process details and invokes browse
## Exposure boundary
-Editing happens in local JSON files. The preview server has no write endpoint and binds to `127.0.0.1`; it serves only `/` and the five public assets. Production ships five static files, with no editor, login, database or application backend. Docker uses an Nginx server process on port 8080 and adds `/healthz`. All content included in a build is public: only put publishable material in these files. Publish `dist/`, not the repository root. The build overwrites its five files but does not remove stale files from that directory.
+Editing happens in local JSON files. The preview server has no write endpoint and binds to `127.0.0.1`; it serves only `/` and the five public assets. Production ships five static files, with no editor, login, database or application backend. Docker uses an Nginx server process on port 8080 and adds `/healthz`. All content included in a build is public: only put publishable material in these files. Publish `dist/`, not the repository root. The build validates content and stages five assets before replacing `dist/`, removing stale files; it rejects redirected output/staging directories.
diff --git a/docs/content-editing.md b/docs/content-editing.md
index a3ab433..c72629b 100644
--- a/docs/content-editing.md
+++ b/docs/content-editing.md
@@ -17,35 +17,43 @@ Delete a project's JSON file to remove it. Remove entries from its `evidence` ar
| --- | --- |
| `id` | Unique lowercase slug, for example `my-project`; used by `#project/my-project` |
| `number` | Nonempty string; numeric-aware string sorting determines display order and the homepage feature. Use distinct numeric values such as `01`, `02` |
-| `challenge` | Nonempty string, including combined labels such as `14 + 15` |
+| `challenge` | Nonempty string, including combined labels such as `14 + 15`; use `—` for personal projects |
| `kind`, `title`, `name`, `intro`, `context`, `implementation`, `decisions` | Two nonempty strings in `[Dutch, English]` order. `title` is required by validation but not currently rendered |
| `stack` | Nonempty array of nonempty strings; technology badges |
| `nodes` | Exactly three nonempty strings; shared diagram labels in both languages |
-| `path` | Repository-relative project directory path, without a leading slash or `.` / `..` segments |
+| `path` | Repository-relative project directory path, without a leading slash or `.` / `..` segments. An empty string links to the root only when `repository` is supplied |
+| `repository` | Optional object: `url` (HTTPS repository URL on github.com or codealvin.xyz), `revision` (40-character lowercase commit SHA), `forge` (`github` or `gitea`, matching the host). Applies to project and evidence links |
+| `setting` | Optional `[Dutch, English]` context, such as personal project or school year. Defaults to school project, year 2 |
| `codes` | Array of known process codes; dossier tags linking to the evidence index. May be empty |
| `evidence` | Array of evidence objects; may be empty |
-Evidence objects require `label` (`[Dutch, English]`), `path` (repository-relative), `type` (nonempty display label such as `JS` or `DOCX`) and `codes` (array of known process codes). Optional `directory` is a boolean: `true` creates a repository `tree` link; omitted or `false` creates a `blob` link.
+Evidence objects require `label` (`[Dutch, English]`), `path` (nonempty and repository-relative), `type` (nonempty display label such as `JS` or `DOCX`) and `codes` (array of known process codes). Optional `directory` is a boolean: on GitHub, `true` creates a `tree` link and omitted or `false` creates a `blob` link. Gitea uses `src/commit` for both files and directories. Evidence paths always use their project's repository; individual evidence items cannot override it.
+
+The scaffold supplies `challenge: "—"`, `path: "projects"` and no `repository` or `setting`. Before publishing a personal project, set its repository and bilingual context explicitly; otherwise its links still target the school archive and its dossier context defaults to school year 2. Use a repository URL without a trailing slash, query or fragment, and copy the full reviewed commit SHA rather than a branch name.
Evidence counts come only from each evidence item's `codes`, not the project's `codes`. An item can map to several processes, so summed process counts can exceed the number of evidence items. Empty mappings are allowed and do not appear in process counts.
## Shared settings and copy
-`content/settings.json` supplies `profile`, `revision` and `processes`. Keep these top-level keys stable: they become ES module exports.
+`content/settings.json` supplies `profile`, `revision` and `processes`. Only these top-level keys are accepted. The compiler explicitly exports profile, revision, processes, projects and the source helper; arbitrary settings cannot become JavaScript exports.
- `profile.github` and `profile.gitea` supply external profile links; `profile.school` supplies the repository base for source links.
- `profile.qualification` supplies the qualification document link. `profile.name` and `profile.reviewed` are stored but are not currently rendered; visible identity and biography remain in `app.js`.
-- `revision` pins every generated source link. Review project and evidence paths against a new revision before updating it. Change `profile.reviewed` only after that review.
+- `revision` pins default school-archive source links; a project `repository.revision` overrides it. Review project and evidence paths against a new revision before updating it. Change `profile.reviewed` only after that review.
- Each process has a unique `code`, bilingual `title` and bilingual `description`. The current tests expect eight processes.
Shared contribution and reflection placeholders are in `app.js`. Per-project reflections require a deliberate schema and renderer change; adding arbitrary JSON fields alone will not display them. `index.html` also contains static title, description, language fallback and a school repository link.
## Validation limits
-The compiler validates project fields and checks mapping codes against settings. It is not a complete settings schema validator, external-link checker or assessment tool. Review settings structure, URLs, unique process codes and content accuracy manually. Text is rendered as escaped text, not Markdown or HTML.
+The compiler validates the exact settings and profile structure, nonempty name, valid ISO review date, safe HTTPS links without credentials, GitHub/Gitea profile hosts, the GitHub school repository, full lowercase commit pins, unique process codes (B-K-W, positive integers), and complete Dutch/English titles and descriptions. Project mappings must reference known codes. Optional project repositories require supported hosts, matching forge types and full commit pins. Validation does not check remote availability or assess evidence; review content accuracy manually. Text is rendered as escaped text, not Markdown or HTML.
The current tests deliberately assert that B1-K2-W1, W2 and W3 have no evidence yet. When genuine collaboration evidence is added, update that test to reflect the supported evidence and remaining gaps. Do not remove the safeguard simply to make unsupported mappings pass.
An invalid file causes preview `/content.js` to return HTTP 500 with a generic message. Run `npm run content` to see the underlying validation or JSON error. The scaffold command writes its new JSON file before compiling; if compilation fails, inspect the created file and fix the reported issue before retrying.
All generated content is public. The build includes settings and project fields even if the interface does not display them.
+
+## Reviewing repositories
+
+Keep a dated record in [repository-review.md](repository-review.md). Review representative source files and verify all linked paths at the exact commit before adding a project. Account ownership alone does not establish authorship of every file. Avoid duplicating mirrors and do not present upstream forks as original work. New sources may use empty `codes` arrays until an exam mapping is supported; these links remain visible in the project dossier without changing process counts. The current six additions follow this policy.
diff --git a/docs/docker-hosting.md b/docs/docker-hosting.md
index 0c7066e..788a562 100644
--- a/docs/docker-hosting.md
+++ b/docs/docker-hosting.md
@@ -13,7 +13,7 @@ docker compose ps
curl -f http://192.168.1.50:8080/healthz
```
-Docker validates content, runs tests and builds inside a Node build stage. Only static assets enter the Nginx runtime image. No Node installation, database or persistent volume is required on the guest. Configure the guest and Docker to start on boot; the service uses `restart: unless-stopped`.
+Docker validates content, runs tests and builds inside a Node build stage. The build replaces its publication directory with exactly five validated static assets; only those assets enter the Nginx runtime image. The Docker context and Nginx public-file allowlists remain unchanged. No Node installation, database or persistent volume is required on the guest. Configure the guest and Docker to start on boot; the service uses `restart: unless-stopped`.
## Network access
@@ -80,4 +80,4 @@ The container runs as the Nginx user with a read-only filesystem, dropped Linux
The health check expects `/healthz` to return `ok`. The restart policy handles process exits; an unhealthy status alone does not restart the container. Compose settings follow the [Docker service reference](https://docs.docker.com/reference/compose-file/services/).
-On 10 November 2026, all six local tests, the static build and `docker compose config --quiet` passed. The Docker engine was unavailable, so image build, runtime health, proxy access and Proxmox deployment remain unverified. Configuration validation alone does not prove that the container can start.
+During the initial documentation pass on 10 November 2026, the then-current six tests, static build and `docker compose config --quiet` passed. The suite has since expanded; see [verification](verification.md) for subsequent results. The Docker engine was unavailable during that initial pass, so image build, runtime health, proxy access and Proxmox deployment remain unverified. Configuration validation alone does not prove that the container can start.
diff --git a/docs/repository-review.md b/docs/repository-review.md
new file mode 100644
index 0000000..b49c1a3
--- /dev/null
+++ b/docs/repository-review.md
@@ -0,0 +1,42 @@
+# Repository review — 10 November 2026
+
+Public account inventories were read from the GitHub and Gitea APIs for Alvin-Zilverstand. Each returned 24 public repositories (page size 100; no further page required). The GitHub connector returned an empty list, so public API access was used. This review covers public repositories only, not private or organization repositories. Repository ownership is not proof that every line was personally written by Alvin.
+
+## Selected additions
+
+Six additional projects remain selected alongside the existing three school dossiers. Femcode and Tralalero were removed at Alvin’s request after the initial review. During that initial eleven-dossier review, readmes and representative source files were inspected and all 39 project/artifact targets were checked at their pinned commits. The current nine dossiers retain 33 targets: nine project links and twenty-four source/evidence links. The source programs were not run. The twelve retained additional source items have empty exam mappings; the existing twelve mapped items and collaboration gaps remain unchanged.
+
+| Project | Account source | Reviewed revision | Linked artifacts |
+| --- | --- | --- | --- |
+| Music Guessr | [gitea](https://codealvin.xyz/Alvin-Zilverstand/music_guessr) | `b306f860443a6cd3e18835ed83a59ea113414399` | `rust_app/README.md`, `rust_app/src/lib.rs` |
+| ClipForge | [github](https://github.com/Alvin-Zilverstand/clipforge-game-clipper) | `32e258dee7179a58fc2d693a7d0e33a228be37b2` | `README.md`, `docs/architecture.md` |
+| Car Tuning CRM | [gitea](https://codealvin.xyz/Alvin-Zilverstand/challenge-11) | `66d2f197dcaab5a8d16504010a2fe5075500add3` | `README.md`, `server.js` |
+| Pokédex | [gitea](https://codealvin.xyz/Alvin-Zilverstand/pokedex) | `43d4ca6798796c600b9044f8545f1c38c422c466` | `v1/pokedex/get_pokemons.php`, `v1/pokedex/details.html` |
+| School canteen | [gitea](https://codealvin.xyz/Alvin-Zilverstand/Schoolkantine) | `01f98ea7d0d489b62728c7ca4abee1d86e0228d3` | `website/script.js`, `website/place_order.php` |
+| Proxmox LXC toolbox | [gitea](https://codealvin.xyz/Alvin-Zilverstand/scripts) | `cb237cf5b0910c77917a8cad3c45b15a6c05a454` | `lxc-toolbox-README.md`, `lxc-toolbox.sh` |
+
+Additional inspected implementation files include ClipForge's src/lib.rs and package.json, the CRM's client/src/App.js, and Music Guessr's rust_app/src/lib.rs. Schoolkantine's script.js and place_order.php, Pokédex's get_pokemons.php, Femcode's main.py, Tralalero's main.rs and the LXC toolbox script support the implementation summaries. Source review was selective, not a full code or security audit. ClipForge's architecture document still describes pending native work while its README describes newer functionality; runtime and installer claims were not independently validated.
+
+Gitea snapshots are selected for five retained additions; ClipForge is linked to GitHub. Overlapping account repositories are represented once. The original warehouse, narrowcasting and refactoring IDs and school snapshot remain unchanged. The school revision is d420c317abcbd117e0e1dd641674ab3283ab34ba; its linked paths were rechecked, but its DOCX contents and source test scripts were not reviewed or run. The qualification review date in settings is unchanged.
+
+## Inventory decisions
+
+Femcode and Tralalero_lang were reviewed but excluded from the visible portfolio at Alvin’s request. The initial 39-target check remains a historical review record; the current nine dossiers contain 33 targets.
+
+| Repositories | Decision |
+| --- | --- |
+| school; Challenge_14_Magazijn_App_plannen; Challenge_15_Magazijn_App_Maken; narrow_casting_system | Existing dossiers already cover these projects; avoid duplicate cards |
+| music_guessr; clipforge-game-clipper; challenge-11; pokedex; Schoolkantine; scripts | Added with reviewed source links |
+| bob16; nginx-proxy-manager; novatorem; return-youtube-dislike; Twitter-X-Media-Batch-Downloader | GitHub marks these as forks; no independently reviewed contribution selected. Gitea mirror flags alone do not establish original authorship |
+| Alvin-Zilverstand | Profile README and generated profile graphics, not a separate application |
+| adblock | Gitea has no default branch; no project dossier selected |
+| compiled | Tree contains binaries without accompanying source context |
+| Challenge_16 | Sprite assets and README; not presented as a finished game |
+| carsite | Earlier static website with bundled framework/builder assets; left as archive material pending clearer contribution context |
+| Spik-en-span | Ticket-oriented HTML/PHP project; archive README's cleaning-service label does not accurately describe the inspected files. Left out of this selected set pending a fuller source review |
+| ict-algemeen-opdrachten | Exercise collection, retained in account archive rather than one application dossier |
+| sloppatron | Mixed experiments and minimal root documentation; not selected for a separate case study |
+| RTA-test | Small HTML demonstration, not selected for a separate case study |
+| install-docker; customised-pve-helper-script | Small administration scripts; the broader scripts/LXC toolbox provides the selected administration case study |
+
+The site is a curated selection, not an assertion that all other repositories lack value. Personal contributions, collaborators, reflections, executed test results and assessed outcomes still need Alvin's own evidence.
diff --git a/docs/verification.md b/docs/verification.md
index 6367d2b..0a9128d 100644
--- a/docs/verification.md
+++ b/docs/verification.md
@@ -1,6 +1,59 @@
# Verification
-## Current checks — 10 November 2026
+## Latest checks — security verification, 10 November 2026
+
+The initial working tree was clean. The checked-in baseline already contained staged replacement of build output, guarded preview URL parsing, strict settings validation, explicit module exports, process-code escaping and four security regression tests. This pass reviewed and verified those protections, made invalid review dates report the intended validation error, added direct bilingual rendering-injection and export-surface assertions, and corrected outdated publication/settings documentation. No project content, source-review dates, Docker/Nginx allowlists or rendering code changed. Generated `content.js` was regenerated by commands and remains byte-identical.
+
+- Node v24.5.0; `npm test`: all 14 tests passed.
+- `npm run build`: passed. Regression tests confirm exactly five byte-identical public assets, removal of a nested synthetic stale file, rejection of redirected output, repository-relative operation from another working directory, and preservation of existing output when content validation fails.
+- Preview regression: malformed URL returns 400, subsequent valid request returns 200; source/private paths return 404 and all five public assets return 200. Loopback binding remains unchanged.
+- Settings regressions cover structure, unsafe URLs, unexpected export keys, duplicate/injected codes, incomplete translations and invalid dates. Renderer regression deliberately bypasses validation and verifies escaped process codes in option attributes, option labels, summaries and dossier links in both languages.
+- `node --check`: passed for scripts/content.mjs, scripts/build.mjs, scripts/serve.mjs, tests/editor.test.mjs, tests/security.test.mjs, app.js and generated content.js.
+- `docker compose config --quiet`: passed. Docker engine unavailable: Docker Desktop Linux engine named pipe missing; image build and runtime tests could not run.
+- Browser: home, work, all nine project routes, about and evidence checked in Dutch and English at 320px without document-width overflow. Evidence filter selected B1-K1-W4, rendered one open process and focused main; switching to Dutch preserved the filter. Keyboard activation of the skip link focused main and preserved the filter. No browser console errors recorded. Temporary viewport override reset afterward.
+- Port 4173 was unavailable (EACCES); browser checks used an automatically assigned loopback port instead.
+- `git diff --check`: passed. Historical results below are retained.
+
+Limits: print/PDF was not rendered again; no rendering or print implementation changed in this pass. Container runtime, reverse proxy and deployment remain unverified. No external evidence review, commit, push or deployment was performed.
+
+## Latest checks — documentation follow-up, 10 November 2026
+
+Checked the documentation against the current compiler, renderers, tests and generated content. Confirmed nine projects, twenty-four source/evidence items and twelve mapped items. Updated contributor rules for repository overrides and context, clarified forge-specific evidence URLs and scaffold defaults, and separated historical eleven-project checks from the current nine-project selection.
+
+- Repeated `npm test`: all eight tests passed.
+- Repeated `npm run build`: passed.
+- Local Markdown targets and `git diff --check`: passed.
+- Browser, external repositories and Docker were not rechecked in this documentation-only follow-up. Earlier results below retain their original scope.
+
+## Earlier checks — selection adjustment, 10 November 2026
+
+Removed Femcode and Tralalero at Alvin’s request, renumbered the LXC toolbox to 09 and updated bilingual biography copy and current project counts. Nine projects and twenty-four source/evidence items remain.
+
+- Repeated `npm test`: all eight tests passed.
+- Repeated `npm run build`, `node --check app.js`, `node --check content.js` and `git diff --check`: passed.
+- Browser work archive checked in Dutch and English: nine project cards, neither removed project visible.
+- Broader navigation, mobile and evidence checks below belong to the earlier expansion pass and were not repeated for this removal.
+- No push or deployment performed.
+
+## Earlier checks — repository expansion, 10 November 2026
+
+Added eight reviewed projects, bilingual context labels and per-project pinned GitHub/Gitea source links. See [repository-review.md](repository-review.md) for scope, revisions, selection decisions and limitations.
+
+- Node v24.5.0.
+- `npm test`: all eight tests passed, including forge-specific links and repository validation.
+- `npm run build`: passed; generated content and exactly five public assets.
+- `node --check`: app.js, content.js, scripts/content.mjs and both test files passed.
+- All 39 project and artifact paths verified through repository APIs at the selected commit IDs.
+- Real browser: 15 routes (home, work, eleven projects, evidence, about) in Dutch and English at the default viewport and 320px; no document-width overflow or undefined output.
+- Language switching preserved the selected project and focused the language control. Navigation focused main; keyboard activation of the skip link preserved the evidence route and focused main.
+- Filtering B1-K1-W4 displayed the three existing testing sources. No browser console errors observed. Music Guessr inspected visually at default and mobile widths.
+- `git diff --check`: passed after correcting mixed line-ending whitespace in edited lines.
+- Build output inspected for the five allowed assets and byte equality with source.
+
+Preview uses http://127.0.0.1:5178 because port 4173 returned EACCES. Print/PDF rendering was not repeated; print CSS and the set of mapped exam evidence are unchanged. Source applications, installers, live Proxmox scripts and their test suites were not executed. DOCX contents, personal authorship and assessment outcomes remain unverified. Docker configuration was unchanged, so Docker checks were not repeated. No commit, push or deployment was performed.
+
+
+## Earlier documentation checks — 10 November 2026
Documentation baseline reviewed against all tracked source, configuration, tests, JSON content, generated content and saved PNG references. No application behavior was changed in this pass.
@@ -22,7 +75,7 @@ The saved desktop and mobile PNGs were inspected as historical references, not r
## Historical record — 9 November 2026
-The following is the previous verification record, retained for context. Its two-test count predates the current six-test suite; these browser and external-source results were not repeated on 10 November.
+The following is the previous verification record, retained for context. Its two-test count predates the current six-test suite; these results describe that earlier pass. See the latest checks above for the subsequently repeated browser and source-path checks.
- `node --check app.js` passed.
- `npm test`: both content integrity checks passed.
diff --git a/scripts/build.mjs b/scripts/build.mjs
index 7154171..883198b 100644
--- a/scripts/build.mjs
+++ b/scripts/build.mjs
@@ -1,9 +1,30 @@
-import { mkdir, copyFile } from 'node:fs/promises';
-import { writeFile } from 'node:fs/promises';
+import { mkdir, copyFile, writeFile, realpath, lstat, rm, rename } from 'node:fs/promises';
+import { fileURLToPath } from 'node:url';
+import { resolve, dirname } from 'node:path';
import { compileContent } from './content.mjs';
-await writeFile(new URL('../content.js', import.meta.url), await compileContent());
-await mkdir('dist', { recursive: true });
-for (const file of ['index.html', 'styles.css', 'app.js', 'content.js', 'favicon.svg']) {
- await copyFile(file, `dist/${file}`);
+const root = await realpath(fileURLToPath(new URL('../', import.meta.url)));
+const output = resolve(root, 'dist');
+const staging = resolve(root, '.dist-staging');
+// Never recursively remove a redirected directory or a path outside this repository.
+async function verifyTarget(target) {
+ if (dirname(target) !== root || !['dist', '.dist-staging'].some(name => target === resolve(root, name))) throw new Error('Unsafe build target');
+ const stat = await lstat(target).catch(error => { if (error.code !== 'ENOENT') throw error; });
+ if (stat && (stat.isSymbolicLink() || !stat.isDirectory() || await realpath(target) !== target)) throw new Error('Build target must be a real repository directory');
+}
+const content = await compileContent();
+await verifyTarget(output);
+await verifyTarget(staging);
+// Exclusive creation prevents concurrent builds from sharing staging output.
+await mkdir(staging);
+try {
+ for (const file of ['index.html', 'styles.css', 'app.js', 'favicon.svg']) await copyFile(resolve(root, file), resolve(staging, file));
+ await writeFile(resolve(staging, 'content.js'), content);
+ await writeFile(resolve(root, 'content.js'), content);
+ await verifyTarget(output);
+ await rm(output, { recursive: true, force: true });
+ await rename(staging, output);
+} finally {
+ await verifyTarget(staging);
+ await rm(staging, { recursive: true, force: true });
}
console.log('Built static site in dist/');
diff --git a/scripts/content.mjs b/scripts/content.mjs
index 0e0f7c5..4fd507e 100644
--- a/scripts/content.mjs
+++ b/scripts/content.mjs
@@ -4,6 +4,36 @@ import { pathToFileURL } from 'node:url';
const root = new URL('../', import.meta.url);
const readJSON = async path => JSON.parse(await readFile(new URL(path, root), 'utf8'));
const pairs = ['kind', 'title', 'name', 'intro', 'context', 'implementation', 'decisions'];
+const require = (ok, message) => { if (!ok) throw new Error(message); };
+const pair = value => Array.isArray(value) && value.length === 2 && value.every(v => typeof v === 'string' && v.trim());
+const keys = (value, expected) => value !== null && typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === expected.length && expected.every(k => Object.hasOwn(value, k));
+const safeHTTPS = value => {
+ if (typeof value !== 'string' || /[\s\\<>"']/.test(value)) return false;
+ try {
+ const url = new URL(value);
+ return value.startsWith('https://') && url.protocol === 'https:' && !!url.hostname && !url.username && !url.password;
+ } catch { return false; }
+};
+export function validateSettings(settings) {
+ require(keys(settings, ['profile', 'revision', 'processes']), 'settings: expected only profile, revision and processes');
+ const p = settings.profile;
+ require(keys(p, ['name', 'github', 'gitea', 'school', 'qualification', 'reviewed']), 'profile: invalid structure');
+ require(typeof p.name === 'string' && p.name.trim(), 'profile.name: required text');
+ require(typeof p.reviewed === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(p.reviewed) && Number.isFinite(Date.parse(p.reviewed)) && new Date(p.reviewed).toISOString().slice(0, 10) === p.reviewed, 'profile.reviewed: expected a valid ISO date');
+ for (const key of ['github', 'gitea', 'school', 'qualification']) require(safeHTTPS(p[key]), `profile.${key}: expected a safe HTTPS URL`);
+ require(/^https:\/\/github\.com\/[A-Za-z0-9_-]+$/.test(p.github), 'profile.github: expected a GitHub profile');
+ require(/^https:\/\/codealvin\.xyz\/[A-Za-z0-9_-]+$/.test(p.gitea), 'profile.gitea: expected a Gitea profile');
+ require(/^https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_.-]+$/.test(p.school) && !['.', '..'].includes(p.school.split('/').pop()), 'profile.school: expected a GitHub repository');
+ require(typeof settings.revision === 'string' && /^[a-f0-9]{40}$/.test(settings.revision), 'revision: expected a full lowercase commit SHA');
+ require(Array.isArray(settings.processes), 'processes: expected an array');
+ const codes = new Set();
+ for (const process of settings.processes) {
+ require(keys(process, ['code', 'title', 'description']), 'process: invalid structure');
+ require(typeof process.code === 'string' && /^B[1-9]\d*-K[1-9]\d*-W[1-9]\d*$/.test(process.code) && !codes.has(process.code), 'process.code: invalid or duplicate code');
+ codes.add(process.code);
+ require(pair(process.title) && pair(process.description), 'process: provide Dutch and English title and description');
+ }
+}
export function validateProjects(projects, processes) {
const ids = new Set();
const codes = new Set(processes.map(p => p.code));
@@ -18,7 +48,12 @@ export function validateProjects(projects, processes) {
for (const key of ['number', 'challenge']) require(typeof p[key] === 'string' && p[key].trim(), `${p.id}.${key}: required text`);
for (const key of ['stack', 'nodes']) require(Array.isArray(p[key]) && p[key].length > 0 && p[key].every(v => typeof v === 'string' && v.trim()), `${p.id}.${key}: provide text entries`);
require(p.nodes.length === 3, `${p.id}.nodes: provide three diagram labels`);
- require(path(p.path), `${p.id}.path: provide a repository-relative path`);
+ if (p.repository !== undefined) {
+ const r = p.repository;
+ require(r && /^https:\/\/(github\.com|codealvin\.xyz)\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(r.url) && /^[a-f0-9]{40}$/.test(r.revision) && ['github', 'gitea'].includes(r.forge) && (r.forge === 'github') === r.url.startsWith('https://github.com/'), `${p.id}.repository: provide a supported repository and pinned commit`);
+ }
+ require(path(p.path) || (p.repository && p.path === ''), `${p.id}.path: provide a repository-relative path`);
+ require(p.setting === undefined || pair(p.setting), `${p.id}.setting: provide Dutch and English text`);
require(mapping(p.codes), `${p.id}.codes: unknown process code`);
require(Array.isArray(p.evidence), `${p.id}.evidence: expected an array`);
for (const e of p.evidence) {
@@ -28,13 +63,18 @@ export function validateProjects(projects, processes) {
}
export async function compileContent() {
const settings = await readJSON('content/settings.json');
+ validateSettings(settings);
const files = (await readdir(new URL('content/projects/', root))).filter(f => f.endsWith('.json')).sort();
const projects = await Promise.all(files.map(f => readJSON(`content/projects/${f}`)));
projects.sort((a, b) => a.number.localeCompare(b.number, undefined, { numeric: true }));
validateProjects(projects, settings.processes);
return '// Generated from content/ by npm run content. Edit the JSON source files.\n' +
- Object.entries({ ...settings, projects }).map(([key, value]) => `export const ${key} = ${JSON.stringify(value, null, 2)};`).join('\n') +
- '\nexport const source = (path, directory = false) => `${profile.school}/${directory ? "tree" : "blob"}/${revision}/${path.split("/").map(encodeURIComponent).join("/")}`;\n';
+ Object.entries({ profile: settings.profile, revision: settings.revision, processes: settings.processes, projects }).map(([key, value]) => `export const ${key} = ${JSON.stringify(value, null, 2)};`).join('\n') +
+ '\nexport const source = (path, directory = false, project = {}) => {\n' +
+ ' const repo = project.repository || { url: profile.school, revision, forge: "github" };\n' +
+ ' const view = repo.forge === "gitea" ? "src/commit" : (directory ? "tree" : "blob");\n' +
+ ' return `${repo.url}/${view}/${repo.revision}${path ? "/" + path.split("/").map(encodeURIComponent).join("/") : ""}`;\n' +
+ '};\n';
}
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
const [command, id] = process.argv.slice(2);
diff --git a/scripts/serve.mjs b/scripts/serve.mjs
index 06e7161..130af69 100644
--- a/scripts/serve.mjs
+++ b/scripts/serve.mjs
@@ -4,12 +4,16 @@ import { compileContent } from './content.mjs';
const port = Number(process.env.PORT || 4173);
const files = new Map([['/', 'index.html'], ['/index.html', 'index.html'], ['/styles.css', 'styles.css'], ['/app.js', 'app.js'], ['/content.js', 'content.js'], ['/favicon.svg', 'favicon.svg']]);
const mime = { html: 'text/html', css: 'text/css', js: 'text/javascript', svg: 'image/svg+xml' };
-createServer(async (req, res) => {
- const file = files.get(new URL(req.url, 'http://localhost').pathname);
+const server = createServer(async (req, res) => {
+ let pathname;
+ try { pathname = new URL(req.url, 'http://localhost').pathname; }
+ catch { res.writeHead(400); return res.end('Bad request'); }
+ const file = files.get(pathname);
if (!file) { res.writeHead(404); return res.end('Not found'); }
try {
const body = file === 'content.js' ? await compileContent() : await readFile(new URL(`../${file}`, import.meta.url));
res.writeHead(200, { 'Content-Type': `${mime[file.split('.').pop()]}; charset=utf-8`, 'Cache-Control': 'no-cache', 'X-Content-Type-Options': 'nosniff' });
res.end(body);
} catch { res.writeHead(500); res.end('Unable to read file'); }
-}).listen(port, '127.0.0.1', () => console.log(`Local: http://127.0.0.1:${port}`));
+}).listen(port, '127.0.0.1', () => console.log(`Local: http://127.0.0.1:${server.address().port}`));
+
diff --git a/tests/content.test.mjs b/tests/content.test.mjs
index 0ad06fc..7733c21 100644
--- a/tests/content.test.mjs
+++ b/tests/content.test.mjs
@@ -14,10 +14,11 @@ test('Evidence mappings use real process IDs and complete translations', () => {
for (const e of p.evidence) {
assert.ok(e.codes.every(c => ids.has(c)), e.path);
assert.ok(e.label.length === 2 && e.label.every(Boolean));
- const url = new URL(source(e.path, e.directory));
- assert.equal(url.hostname, 'github.com');
- assert.ok(url.pathname.includes(revision));
- assert.equal(decodeURIComponent(url.pathname.split(`${revision}/`)[1]), e.path);
+ const url = new URL(source(e.path, e.directory, p));
+ const pin = p.repository?.revision || revision;
+ assert.equal(url.hostname, p.repository ? new URL(p.repository.url).hostname : 'github.com');
+ assert.ok(url.pathname.includes(pin));
+ assert.equal(decodeURIComponent(url.pathname.split(`${pin}/`)[1]), e.path);
}
}
});
@@ -26,3 +27,13 @@ test('Collaboration gaps remain explicit rather than claiming unsupported eviden
assert.ok(!projects.some(p => p.evidence.some(e => e.codes.includes(code))));
}
});
+
+test('Repository links distinguish GitHub and Gitea and encode paths', () => {
+ const revision = 'a'.repeat(40);
+ const github = { repository: { url: 'https://github.com/example/repo', revision, forge: 'github' } };
+ const gitea = { repository: { url: 'https://codealvin.xyz/example/repo', revision, forge: 'gitea' } };
+ assert.equal(source('a b/test.md', false, github), github.repository.url + '/blob/' + revision + '/a%20b/test.md');
+ assert.equal(source('', true, github), github.repository.url + '/tree/' + revision);
+ assert.equal(source('src', true, gitea), gitea.repository.url + '/src/commit/' + revision + '/src');
+ assert.equal(source('a b.md', false, gitea), gitea.repository.url + '/src/commit/' + revision + '/a%20b.md');
+});
diff --git a/tests/editor.test.mjs b/tests/editor.test.mjs
index b6f0a23..e22c1a2 100644
--- a/tests/editor.test.mjs
+++ b/tests/editor.test.mjs
@@ -9,6 +9,7 @@ import { runInNewContext } from 'node:vm';
test('content compiler preserves source data', async () => {
const result = await import(`data:text/javascript;base64,${Buffer.from(await compileContent()).toString('base64')}`);
assert.deepEqual(result.projects, projects);
+ assert.deepEqual(Object.keys(result).sort(), ['processes', 'profile', 'projects', 'revision', 'source']);
});
test('deleting all projects or evidence is supported', () => {
assert.doesNotThrow(() => validateProjects([], processes));
@@ -41,3 +42,41 @@ test('homepage renders after removing the featured project or all projects', asy
else assert.ok(html.includes('No projects added yet.'));
}
});
+
+test('Repository overrides require safe supported URLs and full commit pins', () => {
+ for (const repository of [null, {}, { url: 'javascript:alert(1)', revision: 'a'.repeat(40), forge: 'gitea' }, { url: 'https://github.com/example/repo', revision: 'main', forge: 'github' }, { url: 'https://codealvin.xyz/example/repo', revision: 'a'.repeat(40), forge: 'github' }]) {
+ assert.throws(() => validateProjects([{ ...projects[0], repository }], processes));
+ }
+ assert.throws(() => validateProjects([{ ...projects[0], setting: ['Only one language'] }], processes));
+});
+
+test('process injection is escaped in option values, labels, summaries and dossier links', async () => {
+ const code = (await readFile(new URL('../app.js', import.meta.url), 'utf8')).replace(/^import .*;\r?\n/, '');
+ const payload = '\">
&\'';
+ const escaped = '"><img src=x onerror=alert(1)>&'';
+ for (const language of ['nl', 'en']) {
+ for (const hash of ['#evidence', `#project/${projects[0].id}`]) {
+ const elements = new Map();
+ const document = {
+ documentElement: {},
+ querySelector(selector) {
+ if (!elements.has(selector)) elements.set(selector, { innerHTML: '', addEventListener() {} });
+ return elements.get(selector);
+ },
+ querySelectorAll() { return []; },
+ };
+ runInNewContext(code, { profile, source, projects: [{ ...projects[0], codes: [payload] }], processes: [{ ...processes[0], code: payload }], document, URLSearchParams, location: { search: `?lang=${language}`, hash }, window: { addEventListener() {} } });
+ const html = elements.get('main').innerHTML;
+ assert.ok(!html.includes(payload));
+ assert.ok(!html.includes('
${escaped} ·`));
+ assert.ok(html.includes(`process-code">${escaped}`));
+ } else {
+ assert.ok(html.includes(`href="#evidence/${escaped}"`));
+ assert.ok(html.includes(`>${escaped}`));
+ }
+ }
+ }
+});
diff --git a/tests/security.test.mjs b/tests/security.test.mjs
new file mode 100644
index 0000000..4e1bd6b
--- /dev/null
+++ b/tests/security.test.mjs
@@ -0,0 +1,79 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { mkdtemp, cp, mkdir, writeFile, readFile, readdir, rm, symlink } from 'node:fs/promises';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { spawn, execFileSync } from 'node:child_process';
+import { request } from 'node:http';
+import { once } from 'node:events';
+import { validateSettings } from '../scripts/content.mjs';
+const root = new URL('../', import.meta.url);
+const settings = JSON.parse(await readFile(new URL('content/settings.json', root)));
+const assets = ['app.js', 'content.js', 'favicon.svg', 'index.html', 'styles.css'];
+async function fixture(t) {
+ const dir = await mkdtemp(join(tmpdir(), 'portfolio-security-'));
+ t.after(() => rm(dir, { recursive: true, force: true }));
+ for (const name of ['scripts', 'content', ...assets]) await cp(new URL(name, root), join(dir, name), { recursive: true });
+ return dir;
+}
+test('build replaces stale output from any cwd and preserves output on invalid content', async t => {
+ const dir = await fixture(t);
+ await mkdir(join(dir, 'dist/private'), { recursive: true });
+ await writeFile(join(dir, 'dist/private/secret.txt'), 'synthetic');
+ const build = () => execFileSync(process.execPath, [join(dir, 'scripts/build.mjs')], { cwd: tmpdir(), stdio: 'pipe' });
+ build();
+ assert.deepEqual((await readdir(join(dir, 'dist'))).sort(), assets);
+ for (const file of assets) assert.deepEqual(await readFile(join(dir, 'dist', file)), await readFile(join(dir, file)));
+ await writeFile(join(dir, 'content/settings.json'), '{}');
+ assert.throws(build);
+ assert.deepEqual((await readdir(join(dir, 'dist'))).sort(), assets);
+});
+test('build refuses a redirected publication directory', async t => {
+ const dir = await fixture(t);
+ const outside = join(dir, 'protected');
+ await mkdir(outside);
+ await writeFile(join(outside, 'keep'), 'keep');
+ await symlink(outside, join(dir, 'dist'), process.platform === 'win32' ? 'junction' : 'dir');
+ assert.throws(() => execFileSync(process.execPath, [join(dir, 'scripts/build.mjs')], { stdio: 'pipe' }));
+ assert.equal(await readFile(join(outside, 'keep'), 'utf8'), 'keep');
+});
+test('settings reject invalid structures, URLs, exports, duplicate codes and injection', () => {
+ assert.doesNotThrow(() => validateSettings(settings));
+ const mutations = [
+ s => { s.extra = 'unexpected'; }, s => { s['x = 1; alert(1); //'] = 1; },
+ s => { s.profile = null; }, s => { delete s.profile.name; },
+ s => { s.revision = 'main'; }, s => { s.revision = 'A'.repeat(40); },
+ s => { s.processes = {}; }, s => { s.processes.push(s.processes[0]); },
+ s => { s.processes[0].code = '\">
'; },
+ s => { s.processes[0].title = ['Dutch', '']; }, s => { s.processes[0].description = ['one']; },
+ s => { s.profile.reviewed = '2026-02-30'; },
+ s => { s.profile.reviewed = '2026-99-99'; },
+ ...['javascript:alert(1)', 'http://example.com', 'https://user:pass@example.com', 'https://example.com/\" onmouseover=\"alert(1)', 'https://example.com\\evil', 'https://'].map(url => s => { s.profile.qualification = url; }),
+ s => { s.profile.school = 'https://github.com/user/repo?evil'; },
+ s => { s.profile.github = 'https://github.com.evil.test/user'; },
+ ];
+ for (const mutate of mutations) { const value = structuredClone(settings); mutate(value); assert.throws(() => validateSettings(value)); }
+});
+test('preview survives malformed URLs and denies private/source paths', async t => {
+ const child = spawn(process.execPath, ['scripts/serve.mjs'], { cwd: root, env: { ...process.env, PORT: '0' }, stdio: ['ignore', 'pipe', 'pipe'] });
+ t.after(async () => { child.kill(); if (child.exitCode === null) await once(child, 'exit'); });
+ const address = await new Promise((resolve, reject) => {
+ child.stdout.once('data', data => resolve(String(data).match(/:(\d+)/)[1]));
+ child.once('error', reject); child.once('exit', code => reject(new Error(`Preview exited: ${code}`)));
+ });
+ const get = path => new Promise((resolve, reject) => {
+ const req = request({ hostname: '127.0.0.1', port: address, path }, res => { res.resume(); res.on('end', () => resolve(res.statusCode)); });
+ req.on('error', reject); req.end();
+ });
+ assert.equal(await get('http://[invalid'), 400);
+ assert.equal(await get('/'), 200);
+ for (const path of ['/content/settings.json', '/scripts/content.mjs', '/.env', '/docs/verification.md', '/package.json', '/%2e%2e/.env', '/dist/index.html']) assert.equal(await get(path), 404, path);
+ for (const file of assets) assert.equal(await get(`/${file}`), 200);
+});
+
+
+test('invalid review dates produce a descriptive validation error', () => {
+ const value = structuredClone(settings);
+ value.profile.reviewed = '2026-99-99';
+ assert.throws(() => validateSettings(value), /profile.reviewed: expected a valid ISO date/);
+});