Files
pulse/.semgrep/pulse.js
T
jaredandClaude Opus 5.5 bf7e91cc57
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 26s
CI / Security (npm audit) (push) Successful in 18s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m13s
CI / Integration (api) (push) Successful in 2m24s
CI / Lint (eslint) (pull_request) Successful in 42s
CI / Test (jest) (pull_request) Successful in 23s
CI / Security (npm audit) (pull_request) Successful in 8s
CI / UI (playwright) (push) Successful in 2m30s
CI / Integration (api) (pull_request) Successful in 1m54s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 1m37s
CI / UI screenshots (before/after) (pull_request) Successful in 6s
CI / Lint (eslint) (push) Successful in 18s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped
CI / UI (playwright) (pull_request) Successful in 1m59s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI: Pulse's own semgrep rules, with tests
.semgrep/pulse.yml, run in the Scan job next to the registry packs:
- pulse-no-vm: no require('vm'), eval or new Function outside tests (the
  workflow-condition bug from #62 can't come back).
- pulse-no-shell-in-server: server.js and lib/ may not use exec/execSync
  or spawn with a shell; running commands is the worker's job.
- pulse-innerhtml-unescaped: member values (w.name, r.host) inserted into
  innerHTML in public/assets must go through esc()/Pulse.esc(); method
  names, comparisons, Set.has() and the fmt formatters are not values.

The rules' test cases (.semgrep/pulse.js) run first with semgrep --test,
so a rule that stops matching fails CI. Pulse has no findings today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 23:02:00 -05:00

33 lines
1.3 KiB
JavaScript

/* Test cases for .semgrep/pulse.yml (semgrep --test .semgrep). Not loaded by Pulse. */
/* eslint-disable */
function render(el, w, rows, keep) {
// ruleid: pulse-innerhtml-unescaped
el.innerHTML = '<b>' + w.name + '</b>';
// ruleid: pulse-innerhtml-unescaped
el.innerHTML = rows.map(r => '<td>' + r.host + '</td>').join('');
// ruleid: pulse-innerhtml-unescaped
el.innerHTML += `<i>${w.note}</i>`;
// ok: pulse-innerhtml-unescaped
el.innerHTML = '<b>' + esc(w.name) + '</b>';
// ok: pulse-innerhtml-unescaped
el.innerHTML = '<b>' + Pulse.esc(w.name) + '</b>';
// ok: pulse-innerhtml-unescaped
el.innerHTML = '<a href="/x?id=' + encodeURIComponent(w.id) + '">x</a>';
// ok: pulse-innerhtml-unescaped
el.innerHTML = '<span class="' + Pulse.fmt.status(w.status) + '">' + (w.status === 'online' ? 'on' : 'off') + '</span>';
// ok: pulse-innerhtml-unescaped
el.innerHTML = rows.map(r => (keep.has(r.id) ? 'x' : '') + esc(r.name)).join('');
}
function server() {
// ruleid: pulse-no-shell-in-server
require('child_process').execSync('ls ' + dir);
// ok: pulse-no-shell-in-server
require('child_process').execFileSync('git', ['rev-parse', 'HEAD']);
// ruleid: pulse-no-vm
const vm = require('vm');
// ruleid: pulse-no-vm
return eval(input);
}