utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | da97708d0aaf8f500d87bc0ded79bbb08a79324110be9879b1bb1a6ae7cf3b8b |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-12 12:40 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-12 12:40 +02:00 |
| Parents | c8095cfbfb2b |
3 files changed
modified deploy-sandbox.sh +12 −1
| @@ -46,7 +46,11 @@ | ||
| 46 | 46 | DOCS=(sandbox.html exthost-iframe.html) |
| 47 | 47 | STAGE=$(mktemp -d) |
| 48 | 48 | trap 'rm -rf "$STAGE"' EXIT |
| 49 | -for f in "${DOCS[@]}"; do cp "sandbox/x2/v1/$f" "$STAGE/$f"; done | |
| 49 | +# mktemp -d crea la carpeta con 700 y rsync -a copia ese modo a x2/v1/ del | |
| 50 | +# servidor: nginx (otro usuario) no podría ni entrar y los dos documentos | |
| 51 | +# darían 404 con «Permission denied» en el log de errores | |
| 52 | +chmod 755 "$STAGE" | |
| 53 | +for f in "${DOCS[@]}"; do cp "sandbox/x2/v1/$f" "$STAGE/$f"; chmod 644 "$STAGE/$f"; done | |
| 50 | 54 | ssh -i "$KEY" "$HOST" "mkdir -p '$DEST/x2/v1'" |
| 51 | 55 | rsync -a --delete -e "ssh -i $KEY" "$STAGE/" "$HOST:$DEST/x2/v1/" |
| 52 | 56 | |
| @@ -58,4 +62,11 @@ | ||
| 58 | 62 | diff <(printf '%s\n' "$EXPECTED") <(printf '%s\n' "$REMOTE") >&2 || true |
| 59 | 63 | exit 1 |
| 60 | 64 | fi |
| 65 | +# y que el servidor web los pueda leer: la carpeta 755 y los documentos 644 | |
| 66 | +MODES=$(ssh -i "$KEY" "$HOST" "cd '$DEST/x2/v1' && stat -c '%a %n' . ${DOCS[*]}") | |
| 67 | +if [ "$MODES" != "$(printf '755 .\n644 sandbox.html\n644 exthost-iframe.html')" ]; then | |
| 68 | + echo "✗ permisos en el servidor (se esperaba 755 la carpeta y 644 los documentos):" >&2 | |
| 69 | + printf '%s\n' "$MODES" >&2 | |
| 70 | + exit 1 | |
| 71 | +fi | |
| 61 | 72 | echo "recinto en el servidor y verificado; mira sus cabeceras con: X2_SANDBOX=$ORIGIN node tests/x2_headers.mjs" |
modified sandbox/x2/nginx.conf.example +10 −4
| @@ -16,12 +16,15 @@ | ||
| 16 | 16 | # the manifest names. |
| 17 | 17 | |
| 18 | 18 | server { |
| 19 | - listen 443 ssl http2; | |
| 19 | + listen 443 ssl; # http2 is per socket: set it where the other vhosts on :443 do | |
| 20 | 20 | server_name x2.utopiaia.com; |
| 21 | 21 | ssl_certificate /etc/letsencrypt/live/x2.utopiaia.com/fullchain.pem; |
| 22 | 22 | ssl_certificate_key /etc/letsencrypt/live/x2.utopiaia.com/privkey.pem; |
| 23 | 23 | root /var/www/x2.utopiaia.com; |
| 24 | - access_log off; # the sandbox keeps no log of who loaded it | |
| 24 | + # its own log, with the address truncated (log_format elffuss_anon of the | |
| 25 | + # server's conf.d/elffuss-zones.conf): no record of who loaded it | |
| 26 | + access_log /var/log/nginx/x2.utopiaia.com.access.log elffuss_anon; | |
| 27 | + error_log /var/log/nginx/x2.utopiaia.com.error.log; | |
| 25 | 28 | autoindex off; |
| 26 | 29 | server_tokens off; |
| 27 | 30 | |
| @@ -46,8 +49,11 @@ | ||
| 46 | 49 | server { |
| 47 | 50 | listen 80; |
| 48 | 51 | server_name x2.utopiaia.com; |
| 49 | - access_log off; | |
| 50 | - return 301 https://$host$request_uri; | |
| 52 | + access_log /var/log/nginx/x2.utopiaia.com.access.log elffuss_anon; | |
| 53 | + # in a location, not at server level: a server-level return runs before | |
| 54 | + # certbot's nginx authenticator gets to answer the HTTP-01 challenge, and the | |
| 55 | + # certificate would stop renewing | |
| 56 | + location / { return 301 https://$host$request_uri; } | |
| 51 | 57 | } |
| 52 | 58 | |
| 53 | 59 | # In the server block of Code (code.elffuss.com), for the verified vendor |
modified tests/x2_deploy.mjs +10 −1
| @@ -63,6 +63,11 @@ | ||
| 63 | 63 | const cmd = process.argv.at(-1).replaceAll('/var/www/', SERVER); |
| 64 | 64 | const dir = (/cd '([^']+)'/.exec(cmd) || /mkdir -p '([^']+)'/.exec(cmd) || [])[1]; |
| 65 | 65 | if (/^mkdir -p/.test(cmd)) { fs.mkdirSync(dir, { recursive: true }); process.exit(0); } |
| 66 | + // stat -c '%a %n' NAMES: the octal mode of each, as GNU stat prints it | |
| 67 | + if (/stat -c '%a %n'/.test(cmd)) { | |
| 68 | + for (const n of cmd.split("stat -c '%a %n' ")[1].trim().split(/\s+/)) console.log((fs.statSync(path.join(dir, n)).mode & 0o777).toString(8) + ' ' + n); | |
| 69 | + process.exit(0); | |
| 70 | + } | |
| 66 | 71 | if (/sha256sum/.test(cmd)) { |
| 67 | 72 | if (!fs.existsSync(dir)) process.exit(1); |
| 68 | 73 | const globs = /find \./.test(cmd) ? null : ((/sha256sum ([^"|;&]+)/.exec(cmd) || [])[1] || '').trim().split(/\s+/); |
| @@ -85,7 +90,9 @@ | ||
| 85 | 90 | const src = a.at(-2), dst = a.at(-1).replace(/^[^:]*:/, '').replaceAll('/var/www/', SERVER); |
| 86 | 91 | fs.mkdirSync(dst, { recursive: true }); |
| 87 | 92 | const files = names || fs.readdirSync(src).filter(f => fs.statSync(path.join(src, f)).isFile()); |
| 88 | - for (const f of files) { const to = path.join(dst, f); if (a.includes('--ignore-existing') && fs.existsSync(to)) continue; fs.copyFileSync(path.join(src, f), to); } | |
| 93 | + for (const f of files) { const to = path.join(dst, f); if (a.includes('--ignore-existing') && fs.existsSync(to)) continue; fs.copyFileSync(path.join(src, f), to); fs.chmodSync(to, fs.statSync(path.join(src, f)).mode & 0o777); } | |
| 94 | + // rsync -a SRC/ DEST/ gives DEST the mode of SRC (a mktemp -d folder is 700) | |
| 95 | + if (a.includes('-a') && !names) fs.chmodSync(dst, fs.statSync(src).mode & 0o777); | |
| 89 | 96 | if (a.includes('--delete') && !names) for (const f of fs.readdirSync(dst)) if (!files.includes(f)) fs.rmSync(path.join(dst, f), { recursive: true }); |
| 90 | 97 | } |
| 91 | 98 | for (const [name, fn] of [['ssh', fakeSsh], ['rsync', fakeRsync]]) exe(name, `#!/usr/bin/env node\n(${fn.toString()})(${JSON.stringify(log)}, ${JSON.stringify(server + '/')});\n`); |
| @@ -152,6 +159,8 @@ | ||
| 152 | 159 | && r.calls.some(c => c.startsWith('rsync ') && c.endsWith(':/var/www/x2.utopiaia.com/x2/v1/')) |
| 153 | 160 | && fs.existsSync(sbxProd) && JSON.stringify(fs.readdirSync(sbxProd).sort()) === JSON.stringify(['exthost-iframe.html', 'sandbox.html']) |
| 154 | 161 | && /X2_SANDBOX=https:\/\/x2\.utopiaia\.com node tests\/x2_headers\.mjs/.test(r.out), r.out.slice(-300)); |
| 162 | +const modes = fs.existsSync(sbxProd) ? [sbxProd, ...['sandbox.html', 'exthost-iframe.html'].map(f => path.join(sbxProd, f))].map(p => (fs.statSync(p).mode & 0o777).toString(8)).join(' ') : 'missing'; | |
| 163 | +ok('D6 the web server can read what it uploaded: folder 755, documents 644 (rsync -a of a mktemp folder left 700 and both 404)', modes === '755 644 644', modes); | |
| 155 | 164 | |
| 156 | 165 | // D7 |
| 157 | 166 | const live = (env = {}) => spawnSync('node', [path.join(repo, 'vendor/vscode-ext2/check-output.mjs'), '--live', path.join(repo, 'web')], { encoding: 'utf8', env: { ...process.env, ...env } }).status; |