Harden workflows and dev scripts against code-scanning findings
- auto-release: pass step outputs to run scripts through env, not ${{ }} interpolation
- perf-comment: download the PR's perf artifact to RUNNER_TEMP, outside the workspace
- dev server: log errors to the terminal instead of sending stack traces in the response
- i18n-add/i18n-check: escape every regex metacharacter when building patterns from labels
This commit is contained in:
parent
1a6c63e920
commit
e7729d0a1e
5 changed files with 21 additions and 8 deletions
|
|
@ -53,8 +53,10 @@ const server = http.createServer((req, res) => {
|
|||
res.writeHead(200, { 'content-type': TYPES[path.extname(file)] || 'application/octet-stream', 'cache-control': 'no-store' });
|
||||
fs.createReadStream(file).pipe(res);
|
||||
} catch (e) {
|
||||
// The stack goes to the terminal running the server, never into the response.
|
||||
console.error(e);
|
||||
res.writeHead(500, { 'content-type': 'text/plain; charset=utf-8' });
|
||||
res.end(String(e && e.stack || e));
|
||||
res.end('Could not build the page: see the terminal running npm run dev.');
|
||||
}
|
||||
});
|
||||
const relay = createRelay({ server });
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ if (args[0] === '--rename') {
|
|||
for (const f of listFiles(src)) {
|
||||
if (f === 'i18n/en.js') continue;
|
||||
const p = path.join(src, f), t = fs.readFileSync(p, 'utf8');
|
||||
const u = t.replace(new RegExp(String.raw`(['"\x60])${from.replace(/\./g, '\\.')}\1`, 'g'), (m, q) => { n++; return q + to + q; });
|
||||
const u = t.replace(new RegExp(String.raw`(['"\x60])${from.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\1`, 'g'), (m, q) => { n++; return q + to + q; });
|
||||
if (u !== t) fs.writeFileSync(p, u);
|
||||
}
|
||||
console.log(`renamed ${from} → ${to} in every dictionary and ${n} place(s) in src/`);
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ function registration(lang, html) {
|
|||
const sw = fs.readFileSync(path.join(SITE, 'sw.js'), 'utf8');
|
||||
const out = [];
|
||||
const m = html.match(/SOT_LANGS=\{([^}]*)\}/);
|
||||
if (!m || !new RegExp(String.raw`(^|[,{\s])${lang}\s*:`).test(m[1])) out.push('not in the language list (SOT_LANGS in src/index.html)');
|
||||
if (!m || !new RegExp(String.raw`(^|[,{\s])${lang.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\s*:`).test(m[1])) out.push('not in the language list (SOT_LANGS in src/index.html)');
|
||||
if (!sw.includes(`/i18n/${lang}.js`)) out.push('not cached for offline play (CORE in site/sw.js)');
|
||||
if (!D.tidy(lang)) out.push('not sorted one entry per line: run npm run i18n:fix');
|
||||
return out;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue