pi-ext
bugabingas pi extensions
owned by bugabinga
Harden benchmark command guard against trailing shell chains
0c0a9c02e8d920737e60d068600bb5a0c88a566e
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Result: {"status":"keep","wall_time":500,"tests_passed":46,"failures":0,"expectations":102}
Changed files (2)
extensions/tune/__tests__/unit.test.ts
Modified 89 89 it(
"rejects chained commands", ()
=> {
90 90 expect(
isBenchmarkCommand(
"evil.py; node benchmark.mjs")).
toBe(
false);
91 + expect(
isBenchmarkCommand(
"node benchmark.mjs && echo pwned")).
toBe(
false);
extensions/tune/index.ts
Modified 493 493 cmd
= cmd.
replace(
/^(?:env|time|nice|nohup)(?:\s+-\S+(?:\s+\d+)?)*\s+/,
"");
494 494 }
while (cmd
!== prev);
496 - return /^(?:node)\s+(?:.*\/)?benchmark\.mjs(?:\s|$)/.
test(cmd);
496 + return /^(?:node)\s+(?:.*\/)?benchmark\.mjs\s*$/.
test(cmd);