diff --git a/.dockerignore b/.dockerignore
deleted file mode 100644
index ab01fe4..0000000
--- a/.dockerignore
+++ /dev/null
@@ -1,22 +0,0 @@
-node_modules
-npm-debug.log*
-.git
-.github
-.gitignore
-.env
-
-# Output di compilazione di installazioni precedenti: non servono a runtime.
-backend/compiled
-backend/static
-esempi/*.pdf
-esempi/*.html
-latex-source/*.html
-
-# Non serve a runtime (frontend/ e docs/ invece sì: li serve server.js)
-deploy
-api
-vercel.json
-CHANGELOG.md
-CONTRIBUTING.md
-.vscode
-.idea
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 75b1184..545e2f4 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -7,14 +7,12 @@ on:
branches: [main, master]
jobs:
- server:
- name: Server Node + smoke test
+ sito:
+ name: Sito di presentazione
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
-
- - name: Setup Node
- uses: actions/setup-node@v4
+ - uses: actions/setup-node@v4
with:
node-version: "22"
@@ -26,178 +24,128 @@ jobs:
node server.js &
echo $! > server.pid
for i in $(seq 1 30); do
- if curl -sf -o /dev/null http://localhost:3000/; then
- echo "server pronto dopo ${i}s"
- exit 0
- fi
+ curl -sf -o /dev/null http://localhost:3000/ && exit 0
sleep 1
done
- echo "il server non ha risposto entro 30s"
- exit 1
+ echo "il server non ha risposto entro 30s"; exit 1
- - name: La documentazione e' la pagina d'ingresso
+ - name: La documentazione è servita
run: |
curl -sf http://localhost:3000/ | grep -q 'id="navLinks"'
curl -sf -o /dev/null http://localhost:3000/style.css
curl -sf -o /dev/null http://localhost:3000/script.js
echo "Docs OK"
- - name: Il compilatore e' servito su /app
- run: |
- curl -sf http://localhost:3000/app/ | grep -q 'id="dropzone"'
- curl -sf -o /dev/null http://localhost:3000/app/app.js
- curl -sf -o /dev/null http://localhost:3000/app/app.css
- curl -sf -o /dev/null http://localhost:3000/app/manifest.json
- curl -sf -o /dev/null http://localhost:3000/app/sw.js
- echo "Frontend OK"
-
- - name: Il vecchio indirizzo /docs reindirizza
+ - name: Il sito non contiene più il compilatore
run: |
- code=$(curl -s -o /dev/null -w '%{http_code}' http://localhost:3000/docs/)
- test "$code" = "301" || { echo "atteso 301, ricevuto $code"; exit 1; }
- echo "Redirect OK"
+ # niente form di upload né endpoint di compilazione
+ if curl -sf http://localhost:3000/ | grep -q 'id="dropzone"'; then
+ echo "il sito espone ancora il compilatore"; exit 1
+ fi
+ code=$(curl -s -o /dev/null -w '%{http_code}' -X POST http://localhost:3000/compile)
+ test "$code" = "404" || { echo "/compile risponde ancora: $code"; exit 1; }
+ echo "Nessun compilatore sul web OK"
- - name: Gli endpoint di download rispondono
+ - name: Il sito non rimanda a risorse esterne inattese
run: |
- curl -sf http://localhost:3000/api/template/quiz.tex | grep -q 'documentclass'
- curl -sf -o /dev/null http://localhost:3000/api/download/file/quizstruct.sty
- curl -sf -o /dev/null http://localhost:3000/api/download/package.zip
- echo "Download OK"
-
- - name: Compilazione di un singolo .tex
- run: |
- curl -sf -X POST http://localhost:3000/compile \
- -F "files=@latex-source/quiz.tex" -o out.json
node -e "
const fs = require('fs');
- const d = require('./out.json');
- if (!d.success) { console.error(d.log); process.exit(1); }
- if (!d.pdf || !d.html) { console.error('output mancanti', d); process.exit(1); }
- // gli output arrivano nella risposta, non da un URL sul server
- fs.writeFileSync('out.pdf', Buffer.from(d.pdf.base64, 'base64'));
- fs.writeFileSync('out.html', Buffer.from(d.html.base64, 'base64'));
- console.log('Compile OK');
+ const html = fs.readFileSync('docs/index.html', 'utf-8');
+ const host = [...html.matchAll(/https?:\/\/([a-zA-Z0-9.-]+)/g)].map(m => m[1]);
+ const ammessi = new Set(['github.com', 'www.w3.org']);
+ const estranei = [...new Set(host)].filter(h => !ammessi.has(h));
+ if (estranei.length) { console.error('domini inattesi:', estranei); process.exit(1); }
+ console.log('Nessun dominio esterno inatteso');
"
- head -c 4 out.pdf | grep -q '%PDF'
- grep -qi ' evil.tex <<'TEX'
- \documentclass{article}
- \usepackage{enumitem}
- \usepackage{quizstruct}
- \begin{document}
- \begin{quiz}{T}
- \domanda[1]{D?}
- \begin{opzioni}
- \rispostacorretta{ok}
- \end{opzioni}
- \end{quiz}
- \end{document}
- TEX
- curl -sf -X POST http://localhost:3000/compile -F "files=@evil.tex" -o evil.json
- node -e "
- const d = require('./evil.json');
- const html = Buffer.from(d.html.base64, 'base64').toString();
- if (/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-