mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-10-23 03:47:00 +09:00
test(security): distinguish direct argv from shell splitting
This commit is contained in:
1 parent
2950997f3e
commit
abf6da6beb
1 file changed
+13
-2
@@ -15,7 +15,9 @@
|
||||
* 2. The temp-file content is verbatim (not shell-expanded).
|
||||
* 3. A body >256KB triggers a rejection BEFORE gh is invoked (Phase 2 target;
|
||||
* Phase 1 documents the expected red→green without failing the build).
|
||||
* 4. An empty body skips the temp-file path entirely (no-op, helper exits 0).
|
||||
* 4. A benign whitespace-bearing non-body argument reaches `gh` as one exact
|
||||
* argv item, which fails on the historical shell-joined implementation.
|
||||
* 5. An empty body skips the temp-file path entirely (no-op, helper exits 0).
|
||||
*
|
||||
* Runs against every shipped copy:
|
||||
* 1. .claude/helpers/github-safe.js (dogfood)
|
||||
@@ -74,6 +76,11 @@ const cases = [
|
||||
expectBodyVerbatim: 'a; b; c',
|
||||
expectBodyFileFlagInArgv: true,
|
||||
},
|
||||
{
|
||||
name: 'non-body argv preserves whitespace without shell splitting',
|
||||
args: ['repo', 'view', 'owner/repo with space'],
|
||||
expectArgv: ['repo', 'view', 'owner/repo with space'],
|
||||
},
|
||||
{
|
||||
// Phase 2: github-safe.js now enforces the 256KB cap (GITHUB_SAFE_VERSION=1.0.0).
|
||||
// A body exceeding the limit must be rejected (exit 1) BEFORE gh is invoked.
|
||||
@@ -126,7 +133,7 @@ function runOne(helperPath, c) {
|
||||
}
|
||||
}
|
||||
|
||||
if (c.expectBodyFileFlagInArgv || c.expectBodyVerbatim) {
|
||||
if (c.expectBodyFileFlagInArgv || c.expectBodyVerbatim || c.expectArgv) {
|
||||
// Read the argv captured by the fake gh script.
|
||||
let argv = [];
|
||||
if (existsSync(captureFile)) {
|
||||
@@ -139,6 +146,10 @@ function runOne(helperPath, c) {
|
||||
fails.push('fake gh was not invoked (capture file missing) — helper may have crashed before calling gh');
|
||||
}
|
||||
|
||||
if (c.expectArgv && JSON.stringify(argv) !== JSON.stringify(c.expectArgv)) {
|
||||
fails.push(`argv mismatch: expected ${JSON.stringify(c.expectArgv)}, got ${JSON.stringify(argv)}`);
|
||||
}
|
||||
|
||||
if (c.expectBodyFileFlagInArgv) {
|
||||
const hasBodyFile = argv.includes('--body-file');
|
||||
const hasBodyInline = argv.includes('--body');
|
||||
|
||||
Reference in new issue
Block a user