Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: read the method for a trailing -X in a gh api flag cluster from the next argument
Adam Eivy1bb4ba1b6285
diff --git a/server/lib/commandSecurity.js b/server/lib/commandSecurity.jsindex 74165330f2..530eaea369 100644--- a/server/lib/commandSecurity.js+++ b/server/lib/commandSecurity.js@@ -214,15 +214,19 @@ const GH_FIELD_FLAGS = new Set(['-f', '-F', '--field', '--raw-field', '--input']// value attached (`-XPOST`, `-Fbody=@file`) and clustered after booleans// (`-iXPOST`). Scanning a single-dash cluster: `-X` with anything but GET or// a field shorthand rejects; another value-taking shorthand ends the scan-// (the rest is its value); an unknown letter fails closed.+// (the rest is its value); an unknown letter fails closed. A cluster ending+// in `-X` (`-iX GET`) takes the method from the next argument, as pflag does.const GH_API_VALUE_SHORTHANDS = new Set(['H', 'p', 'q', 't']);const GH_API_BOOLEAN_SHORTHANDS = new Set(['i']);-const ghApiClusterWrites = (arg) => {+const ghApiClusterWrites = (arg, next) => {const cluster = arg.slice(1);for (let i = 0; i < cluster.length; i += 1) {const flag = cluster[i];if (GH_API_BOOLEAN_SHORTHANDS.has(flag)) continue;- if (flag === 'X') return cluster.slice(i + 1).replace(/^=/, '').toUpperCase() !== 'GET';+ if (flag === 'X') {+ const attached = cluster.slice(i + 1).replace(/^=/, '');+ return (attached || next || '').toUpperCase() !== 'GET';+ }return !GH_API_VALUE_SHORTHANDS.has(flag);}return false;@@ -294,7 +298,7 @@ function validateUnattendedGhLike(base, args) {if (GH_FIELD_FLAGS.has(arg) || /^--(?:field|raw-field|input)=/.test(arg)) {return deny(`'${base} api ${arg}' is not allowed on the unattended lane — a field flag makes the request a POST.`);}- if (method === null && /^-[^-]/.test(arg) && arg.length > 2 && ghApiClusterWrites(arg)) {+ if (method === null && /^-[^-]/.test(arg) && arg.length > 2 && ghApiClusterWrites(arg, rest[i + 1])) {return deny(`'${base} api ${arg}' is not allowed on the unattended lane — a method or field shorthand with an attached value can make the request a write.`);}}diff --git a/server/lib/commandSecurity.test.js b/server/lib/commandSecurity.test.jsindex 5672857a1d..630a103690 100644--- a/server/lib/commandSecurity.test.js+++ b/server/lib/commandSecurity.test.js@@ -533,6 +533,7 @@ describe('commandSecurity', () => {['an attached -XPOST is an authenticated write', 'gh api -XPOST /repos/x/y/issues'],['an attached -X=POST is an authenticated write', 'gh api -X=POST /repos/x/y/issues'],['a -XPOST clustered after -i is an authenticated write', 'gh api -iXPOST /repos/x/y/issues'],+ ['a cluster ending in -X takes a write method from the next argument', 'gh api -iX POST /repos/x/y/issues'],['glab api -XDELETE is an authenticated write', 'glab api -XDELETE /projects/1'],['an attached -F field uploads a local file in a POST', 'gh api /repos/x/y/issues -Fbody=@/example/file'],['an attached -f field makes gh api an implicit POST', 'gh api /repos/x/y/issues -ftitle=hi'],@@ -548,6 +549,7 @@ describe('commandSecurity', () => {'gh api /rate_limit','gh api -X GET /rate_limit','gh api -XGET /rate_limit',+ 'gh api -iX GET /rate_limit','gh api -i /rate_limit','gh api /repos/x/y -q.name','glab mr list',