just-bash 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/bin/chunks/dist-Q3QP7DWN.js +141 -0
- package/dist/bin/just-bash.js +1 -1
- package/dist/bin/shell/chunks/dist-Q3QP7DWN.js +141 -0
- package/dist/bin/shell/shell.js +1 -1
- package/package.json +2 -2
- package/dist/bin/chunks/dist-4NZ74CRE.js +0 -141
- package/dist/bin/shell/chunks/dist-4NZ74CRE.js +0 -141
package/dist/bin/shell/shell.js
CHANGED
|
@@ -796,7 +796,7 @@ sys 0m0.000s
|
|
|
796
796
|
`);let r=0,s=-1,i=!1;try{for(let l=0;l<t.pipelines.length;l++){let u=t.pipelines[l],c=l>0?t.operators[l-1]:null;if(c==="&&"&&r!==0||c==="||"&&r===0)continue;let f=await this.executePipeline(u);n.appendResult(f,qs(f)),r=f.exitCode,s=l,i=u.negated,this.ctx.state.lastExitCode=r,this.ctx.state.env.set("?",String(r))}}catch(l){throw n.prependTo(l),l}let o=s<t.pipelines.length-1,a=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=o||i||a,this.ctx.state.options.errexit&&r!==0&&s===t.pipelines.length-1&&!i&&!this.ctx.state.inCondition&&!a){let l=new Be(r);throw l.prependOutput(n.stdout,n.stderr),l}return n.build(r)}async executePipeline(t){return Af(this.ctx,t,(n,r,s)=>this.executeCommand(n,r,s))}async executeCommand(t,n,r=!1){let s=ju(this.ctx),i;try{i=await this.executeCommandInner(t,n,r)}catch(a){throw await Wi(this.ctx,s).catch(()=>{}),a}let o=await Wi(this.ctx,s);return!o.stdout&&!o.stderr?i:{...i,stdout:o.stdout?Lt(i)+o.stdout:i.stdout,stdoutKind:o.stdout?"bytes":i.stdoutKind,stderr:i.stderr+o.stderr}}async executeCommandInner(t,n,r){switch(this.assertDefenseContext("command"),this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case"SimpleCommand":return this.executeSimpleCommand(t,n,r);case"If":return yf(this.ctx,t);case"For":return gf(this.ctx,t);case"CStyleFor":return wf(this.ctx,t);case"While":return Ef(this.ctx,t,n);case"Until":return bf(this.ctx,t,n);case"Case":return Sf(this.ctx,t);case"Subshell":return this.executeSubshell(t,n,r);case"Group":return this.executeGroup(t,n,r);case"FunctionDef":return kc(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return Dm(t)}}async executeSimpleCommand(t,n,r){let s;try{return await this.executeSimpleCommandInner(t,n,r,i=>{s=i})}catch(i){if(s?.finish(),i instanceof Tt)return L(i.stderr);throw i}}async executeSimpleCommandInner(t,n,r,s){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let D=t,R=0;for(;;){let B=this.expandAlias(D);if(B===D)break;if(R>=this.ctx.limits.maxCallDepth)throw new C(`alias expansion depth limit exceeded (${this.ctx.limits.maxCallDepth})`,"recursion");R++,D=B}this.aliasExpansionStack.clear(),D!==t&&(t=D)}this.ctx.state.expansionStderr="",this.ctx.state.lastSubstitutionExitCode=null;let i=await rf(this.ctx,t);if(i.error)return i.error;let o=i.tempAssignments,a=i.xtraceOutput,l=()=>{for(let[D,R]of o)R===void 0?this.ctx.state.env.delete(D):this.ctx.state.env.set(D,R)};if(!t.name){if(t.redirections.length>0){let R=jn(this.ctx,t.redirections,$c);s(R);let B=await R.prepare(n);if(B.error){if(l(),!B.errorCause)return R.finish(),B.error;try{return Hn(B)}finally{R.finish()}}let k=T("",a,Jr(this.ctx.state,t.redirections)),M=await on(this.ctx,k,t.redirections.length>0,B.outputRoutes);return R.finish(),M}this.ctx.state.lastArg="";let D=(this.ctx.state.expansionStderr||"")+a;return this.ctx.state.expansionStderr="",T("",D,Jr(this.ctx.state,[]))}let u=t.name&&ta(t.name,["local","declare","typeset","export","readonly"]),c=Array.from(o.keys());if(c.length>0&&!u){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let D of c)this.ctx.state.tempExportedVars.add(D)}let f=await ne(this.ctx,t.name),d=[],p=[],h=(D,R)=>{if(d.length>=this.ctx.limits.maxArrayElements)throw new C(`expanded argument element limit exceeded (${this.ctx.limits.maxArrayElements})`,"array_elements");d.push(D),p.push(R)};if(ta(t.name,["local","declare","typeset","export","readonly"])&&(f==="local"||f==="declare"||f==="typeset"||f==="export"||f==="readonly"))for(let D of t.args){let R=await nc(this.ctx,D);if(R)h(R,!0);else{let B=await rc(this.ctx,D);if(B!==null)h(B,!0);else{let k=await wt(this.ctx,D);for(let M of k.values)h(M,k.quoted)}}}else for(let D of t.args){let R=await wt(this.ctx,D);for(let B of R.values)h(B,R.quoted)}let y=t.name.parts.every(D=>D.type==="CommandSubstitution"||D.type==="ParameterExpansion"||D.type==="ArithmeticExpansion");!f&&y&&d.length>0&&(f=d.shift(),p.shift());let b=jn(this.ctx,t.redirections,f==="exec"?xc:mr);s(b);let w=await b.prepare(n);if(w.error)return l(),w.errorCause?Hn(w):(b.finish(),w.error);let E=w.stdinSourceFd,S=w.stdin!==void 0,v=r||w.stdinReplaced;if(w.stdin!==void 0&&(n=w.stdin),!f)return y?(b.finish(),T("","",Jr(this.ctx.state,t.redirections))):(b.finish(),L(`bash: : command not found
|
|
797
797
|
`,127));if(f==="exec"&&(d.length===0||d[0]==="--")){for(let[D,R]of o)R===void 0?this.ctx.state.env.delete(D):this.ctx.state.env.set(D,R);if(this.ctx.state.tempExportedVars)for(let D of o.keys())this.ctx.state.tempExportedVars.delete(D);return b.finish(),J}if(this.ctx.state.extraArgs){let D=this.ctx.state.extraArgs;this.ctx.state.extraArgs=void 0;for(let R of D)h(R,!0)}let A=await tf(this.ctx,f,d);o.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(o)));let $,x=null;try{$=await this.runCommand(f,d,p,n,!1,!1,E,S,v,w.stdinUnavailable)}catch(D){if(D instanceof He||D instanceof Ge)x=D,$=J;else throw D}E>=0&&f!=="read"&&rn(this.ctx,E,$.internalStdinConsumed??0);let I=a+A;if(I&&($={...$,stderr:I+$.stderr}),$=await on(this.ctx,$,t.redirections.length>0,w.outputRoutes,$.internalProducerCommand??f,$.internalProducerOmitsShellPrefix),b.finish(),x)throw x;if(d.length>0){let D=d[d.length-1];if((f==="declare"||f==="local"||f==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(D)){let R=D.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);R&&(D=R[1])}this.ctx.state.lastArg=D}else this.ctx.state.lastArg=f;let P=wc(f)&&f!=="unset"&&f!=="eval";if(!this.ctx.state.options.posix||!P)for(let[D,R]of o)this.ctx.state.fullyUnsetLocals?.has(D)||(R===void 0?this.ctx.state.env.delete(D):this.ctx.state.env.set(D,R));if(this.ctx.state.tempExportedVars)for(let D of o.keys())this.ctx.state.tempExportedVars.delete(D);return o.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&($={...$,stderr:this.ctx.state.expansionStderr+$.stderr},this.ctx.state.expansionStderr=""),$}async runCommand(t,n,r,s,i=!1,o=!1,a=-1,l=!1,u=!1,c=!1){let f={ctx:this.ctx,runCommand:(h,m,y,b,w,E,S,v,A,$)=>this.runCommand(h,m,y,b,w,E,S,v,A,$),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(h,m,y)=>this.executeUserScript(h,m,y)},d=await pf(f,t,n,r,s,i,o,a,l,u,c);return d!==null?d.internalProducerCommand===void 0?{...d,internalProducerCommand:t}:d:{...await hf(f,t,n,s,o,u,c),internalProducerCommand:t}}aliasExpansionStack=new Set;expandAlias(t){return Nl({env:this.ctx.state.env,limits:this.ctx.limits},t,this.aliasExpansionStack)}async findCommandInPath(t){return Ts(this.ctx,t)}async executeSubshell(t,n="",r=!1){return vf(this.ctx,t,n,s=>this.executeStatement(s),r)}async executeGroup(t,n="",r=!1){return $f(this.ctx,t,n,s=>this.executeStatement(s),r)}async executeArithmeticCommand(t){return t.line!==void 0&&(this.ctx.state.currentLine=t.line),Je(this.ctx,t.redirections,"",async()=>{try{let n=await X(this.ctx,t.expression.expression),r=ge(n!==0);return this.ctx.state.expansionStderr&&(r={...r,stderr:this.ctx.state.expansionStderr+r.stderr},this.ctx.state.expansionStderr=""),r}catch(n){return L(`bash: arithmetic expression: ${n.message}
|
|
798
798
|
`)}})}async executeConditionalCommand(t){return t.line!==void 0&&(this.ctx.state.currentLine=t.line),Je(this.ctx,t.redirections,"",async()=>{try{let n=await en(this.ctx,t.expression),r=ge(n);return this.ctx.state.expansionStderr&&(r={...r,stderr:this.ctx.state.expansionStderr+r.stderr},this.ctx.state.expansionStderr=""),r}catch(n){let r=n instanceof oe?1:2;return L(`bash: conditional expression: ${n.message}
|
|
799
|
-
`,r)}})}};function sa(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Im(e){let t=sa(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}var Om=3;function kf(e){let t=e;for(let n=0;n<Om;n++){if(t.includes("\\")||t.includes(";")||/%(?![0-9a-f]{2})/i.test(t))return!0;let r=t.toLowerCase();if(r.includes("%2f")||r.includes("%2e")||r.includes("%5c")||r.includes("%3b"))return!0;let s;try{s=decodeURIComponent(t)}catch{return!0}if(s===t)return!1;t=s}return t.includes("%")}function _m(e,t){return t==="/"||t===""?!0:t.endsWith("/")?e.startsWith(t):e===t||e.startsWith(`${t}/`)}function ia(e,t){let n=sa(e);if(!n)return!1;let r=Im(t);return!r||n.origin!==r.origin||r.pathPrefix!=="/"&&r.pathPrefix!==""&&kf(n.pathname)?!1:_m(n.pathname,r.pathPrefix)}function Pf(e){return typeof e=="string"?e:e.url}function Cf(e,t){return!t||t.length===0?!1:t.some(n=>ia(e,Pf(n)))}function oa(e){let t=Lm(e);if(t==="localhost"||t.endsWith(".localhost"))return!0;let n=Nf(t);if(n)return Bs(n);let r=Fm(t);return r?Mm(r):!1}function Lm(e){let t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Tm(e){if(!e)return null;let t=10,n=e;if(n.startsWith("0x")||n.startsWith("0X")?(t=16,n=n.slice(2)):n.length>1&&n.startsWith("0")&&(t=8),!n||t===16&&!/^[0-9a-fA-F]+$/.test(n)||t===10&&!/^\d+$/.test(n)||t===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,t);return!Number.isFinite(r)||r<0?null:r}function Nf(e){let t=e.split(".");if(t.length===0||t.length>4)return null;let n=t.map(l=>Tm(l));if(n.some(l=>l===null))return null;let r=n;if(t.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(t.length===2){let[l,u]=r;return l>255||u>16777215?null:[l,u>>>16&255,u>>>8&255,u&255]}if(t.length===3){let[l,u,c]=r;return l>255||u>255||c>65535?null:[l,u,c>>>8&255,c&255]}let[s,i,o,a]=r;return s>255||i>255||o>255||a>255?null:[s,i,o,a]}function Fm(e){let t=e,n=null;if(t.includes(".")){let m=t.lastIndexOf(":");if(m<0)return null;let y=t.slice(m+1),b=Nf(y);if(!b)return null;n=b,t=t.slice(0,m)}let r=t.includes("::")?t.split("::").length-1:0;if(r>1)return null;let[s,i]=t.split("::"),o=s?s.split(":").filter(Boolean):[],a=i?i.split(":").filter(Boolean):[],l=m=>/^[0-9a-f]{1,4}$/i.test(m)?Number.parseInt(m,16):null,u=o.map(l),c=a.map(l);if(u.some(m=>m===null)||c.some(m=>m===null))return null;let f=n?2:0,d=u.length+c.length+f,p=0;if(r===1){if(p=8-d,p<0)return null}else if(d!==8)return null;let h=[...u,...new Array(p).fill(0),...c];return n&&(h.push(n[0]<<8|n[1]),h.push(n[2]<<8|n[3])),h.length===8?h:null}function Bs(e){let[t,n]=e;return t===127||t===10||t===172&&n>=16&&n<=31||t===192&&n===168||t===169&&n===254||t===0||t===100&&n>=64&&n<=127||t===198&&(n===18||n===19)||t===192&&n===0&&e[2]===0||t===192&&n===0&&e[2]===2||t===198&&n===51&&e[2]===100||t===203&&n===0&&e[2]===113||t>=240}function Mm(e){if(e.every(s=>s===0)||e.slice(0,7).every(s=>s===0)&&e[7]===1||(e[0]&65472)===65152||(e[0]&65024)===64512)return!0;if(e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535){let s=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Bs(s)}if(e[0]===8193&&e[1]===3512)return!0;if(e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0){let s=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Bs(s)}if(e[0]===100&&e[1]===65435&&e[2]===1)return!0;if(e[0]===8194){let s=[e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255];return Bs(s)}return!1}function Rf(e){let t=[];for(let n of e){if(typeof n!="string"&&(n===null||typeof n!="object"||!("url"in n)||typeof n.url!="string")){t.push('Invalid allow-list entry: must be a string URL or an object with a "url" string property');continue}let r=Pf(n);if(!sa(r)){t.push(`Invalid URL in allow-list: "${r}" - must be a valid URL with scheme and host (e.g., "https://example.com")`);continue}let i=new URL(r);if(i.protocol!=="http:"&&i.protocol!=="https:"){t.push(`Only http and https URLs are allowed in allow-list: "${r}"`);continue}if(!i.hostname){t.push(`Allow-list entry must include a hostname: "${r}"`);continue}if(i.pathname!=="/"&&i.pathname!==""&&kf(i.pathname)){t.push(`Allow-list entry contains ambiguous path separators: "${r}"`);continue}(i.search||i.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: "${r}"`)}return t}var bt=class extends Error{constructor(t,n){let r=n??"URL not in allow-list";super(`Network access denied: ${r}: ${t}`),this.name="NetworkAccessDeniedError"}},Kn=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},un=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Ws=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},vn=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Bm=20,Wm=3e4,Vm=10485760,zm=["GET","HEAD"],$r;typeof __BROWSER__<"u"&&__BROWSER__?$r=null:($r=import("./chunks/dist-
|
|
799
|
+
`,r)}})}};function sa(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function Im(e){let t=sa(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}var Om=3;function kf(e){let t=e;for(let n=0;n<Om;n++){if(t.includes("\\")||t.includes(";")||/%(?![0-9a-f]{2})/i.test(t))return!0;let r=t.toLowerCase();if(r.includes("%2f")||r.includes("%2e")||r.includes("%5c")||r.includes("%3b"))return!0;let s;try{s=decodeURIComponent(t)}catch{return!0}if(s===t)return!1;t=s}return t.includes("%")}function _m(e,t){return t==="/"||t===""?!0:t.endsWith("/")?e.startsWith(t):e===t||e.startsWith(`${t}/`)}function ia(e,t){let n=sa(e);if(!n)return!1;let r=Im(t);return!r||n.origin!==r.origin||r.pathPrefix!=="/"&&r.pathPrefix!==""&&kf(n.pathname)?!1:_m(n.pathname,r.pathPrefix)}function Pf(e){return typeof e=="string"?e:e.url}function Cf(e,t){return!t||t.length===0?!1:t.some(n=>ia(e,Pf(n)))}function oa(e){let t=Lm(e);if(t==="localhost"||t.endsWith(".localhost"))return!0;let n=Nf(t);if(n)return Bs(n);let r=Fm(t);return r?Mm(r):!1}function Lm(e){let t=e.trim().toLowerCase();return t.startsWith("[")&&t.endsWith("]")?t.slice(1,-1):t}function Tm(e){if(!e)return null;let t=10,n=e;if(n.startsWith("0x")||n.startsWith("0X")?(t=16,n=n.slice(2)):n.length>1&&n.startsWith("0")&&(t=8),!n||t===16&&!/^[0-9a-fA-F]+$/.test(n)||t===10&&!/^\d+$/.test(n)||t===8&&!/^[0-7]+$/.test(n))return null;let r=Number.parseInt(n,t);return!Number.isFinite(r)||r<0?null:r}function Nf(e){let t=e.split(".");if(t.length===0||t.length>4)return null;let n=t.map(l=>Tm(l));if(n.some(l=>l===null))return null;let r=n;if(t.length===1){let l=r[0];return l>4294967295?null:[l>>>24&255,l>>>16&255,l>>>8&255,l&255]}if(t.length===2){let[l,u]=r;return l>255||u>16777215?null:[l,u>>>16&255,u>>>8&255,u&255]}if(t.length===3){let[l,u,c]=r;return l>255||u>255||c>65535?null:[l,u,c>>>8&255,c&255]}let[s,i,o,a]=r;return s>255||i>255||o>255||a>255?null:[s,i,o,a]}function Fm(e){let t=e,n=null;if(t.includes(".")){let m=t.lastIndexOf(":");if(m<0)return null;let y=t.slice(m+1),b=Nf(y);if(!b)return null;n=b,t=t.slice(0,m)}let r=t.includes("::")?t.split("::").length-1:0;if(r>1)return null;let[s,i]=t.split("::"),o=s?s.split(":").filter(Boolean):[],a=i?i.split(":").filter(Boolean):[],l=m=>/^[0-9a-f]{1,4}$/i.test(m)?Number.parseInt(m,16):null,u=o.map(l),c=a.map(l);if(u.some(m=>m===null)||c.some(m=>m===null))return null;let f=n?2:0,d=u.length+c.length+f,p=0;if(r===1){if(p=8-d,p<0)return null}else if(d!==8)return null;let h=[...u,...new Array(p).fill(0),...c];return n&&(h.push(n[0]<<8|n[1]),h.push(n[2]<<8|n[3])),h.length===8?h:null}function Bs(e){let[t,n]=e;return t===127||t===10||t===172&&n>=16&&n<=31||t===192&&n===168||t===169&&n===254||t===0||t===100&&n>=64&&n<=127||t===198&&(n===18||n===19)||t===192&&n===0&&e[2]===0||t===192&&n===0&&e[2]===2||t===198&&n===51&&e[2]===100||t===203&&n===0&&e[2]===113||t>=240}function Mm(e){if(e.every(s=>s===0)||e.slice(0,7).every(s=>s===0)&&e[7]===1||(e[0]&65472)===65152||(e[0]&65024)===64512)return!0;if(e[0]===0&&e[1]===0&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===65535){let s=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Bs(s)}if(e[0]===8193&&e[1]===3512)return!0;if(e[0]===100&&e[1]===65435&&e[2]===0&&e[3]===0&&e[4]===0&&e[5]===0){let s=[e[6]>>>8&255,e[6]&255,e[7]>>>8&255,e[7]&255];return Bs(s)}if(e[0]===100&&e[1]===65435&&e[2]===1)return!0;if(e[0]===8194){let s=[e[1]>>>8&255,e[1]&255,e[2]>>>8&255,e[2]&255];return Bs(s)}return!1}function Rf(e){let t=[];for(let n of e){if(typeof n!="string"&&(n===null||typeof n!="object"||!("url"in n)||typeof n.url!="string")){t.push('Invalid allow-list entry: must be a string URL or an object with a "url" string property');continue}let r=Pf(n);if(!sa(r)){t.push(`Invalid URL in allow-list: "${r}" - must be a valid URL with scheme and host (e.g., "https://example.com")`);continue}let i=new URL(r);if(i.protocol!=="http:"&&i.protocol!=="https:"){t.push(`Only http and https URLs are allowed in allow-list: "${r}"`);continue}if(!i.hostname){t.push(`Allow-list entry must include a hostname: "${r}"`);continue}if(i.pathname!=="/"&&i.pathname!==""&&kf(i.pathname)){t.push(`Allow-list entry contains ambiguous path separators: "${r}"`);continue}(i.search||i.hash)&&t.push(`Query strings and fragments are ignored in allow-list entries: "${r}"`)}return t}var bt=class extends Error{constructor(t,n){let r=n??"URL not in allow-list";super(`Network access denied: ${r}: ${t}`),this.name="NetworkAccessDeniedError"}},Kn=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},un=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Ws=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},vn=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var Bm=20,Wm=3e4,Vm=10485760,zm=["GET","HEAD"],$r;typeof __BROWSER__<"u"&&__BROWSER__?$r=null:($r=import("./chunks/dist-Q3QP7DWN.js"),$r.catch(()=>{}));var qm=new Set(["GET","HEAD","OPTIONS"]),Um=new Set([301,302,303,307,308]);function xr(e){return e.reason instanceof Error?e.reason:new DOMException("The operation was aborted","AbortError")}function jm(e){if(e?.aborted)throw xr(e)}function la(e){let t=e.allowedUrlPrefixes??[];if(e._dnsResolve)throw new Error("NetworkConfig._dnsResolve is no longer supported: DNS resolution is performed by guarded-fetch and cannot be overridden");if(e._createConnectionOwner)throw new Error("NetworkConfig._createConnectionOwner is no longer supported: connect-time IP pinning is performed by guarded-fetch and cannot be overridden");let n=e._fetch;if(!e.dangerouslyAllowFullInternetAccess){let S=Rf(t);if(S.length>0)throw new Error(`Invalid network allow-list:
|
|
800
800
|
${S.join(`
|
|
801
801
|
`)}`)}let r=[];for(let S of t)typeof S=="object"&&S.transform&&S.transform.length>0&&r.push(S);function s(S){if(r.length===0)return null;let v=null;for(let A of r)if(ia(S,A.url)&&A.transform){v||(v=new Headers);for(let $ of A.transform)for(let[x,I]of Object.entries($.headers))v.set(x,I)}return v}if(e.maxRedirects!==void 0&&(!Number.isSafeInteger(e.maxRedirects)||e.maxRedirects<0))throw new RangeError("maxRedirects must be a non-negative safe integer");let i=e.maxRedirects??Bm,o=e.timeoutMs??Wm,a=e.maxResponseSize??Vm,l=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??zm,u=e.denyPrivateRanges??(typeof process<"u"&&process.env?.NODE_ENV==="production"),c=[];for(let S of t){let v=typeof S=="string"?S:S.url;try{c.push(new URL(v).hostname)}catch{}}function f(S){try{return new URL(S).hostname||"localhost.invalid"}catch{return"localhost.invalid"}}function d(S){return e.dangerouslyAllowFullInternetAccess?u?{allowedHosts:void 0,skipSsrfCheckForAllowedHosts:void 0}:{allowedHosts:[f(S)],skipSsrfCheckForAllowedHosts:!0}:{allowedHosts:c,skipSsrfCheckForAllowedHosts:!u}}function p(S){try{return oa(new URL(S).hostname)}catch{return!1}}async function h(S,v){let A={method:v.method,headers:v.headers,signal:v.signal,redirect:"manual"};return v.body!==void 0&&(A.body=v.body),await(n??globalThis.fetch)(S,A)}function m(S){if(!e.dangerouslyAllowFullInternetAccess&&!Cf(S,t))throw new bt(S)}function y(S){if(!u)return;let v;try{v=new URL(S)}catch{throw new bt(S,"invalid URL")}if(oa(v.hostname))throw new bt(S,"private/loopback IP address blocked")}function b(S){if(e.dangerouslyAllowFullInternetAccess)return;let v=S.toUpperCase();if(!l.includes(v))throw new Ws(v,l)}function w(S,v,A,$){if(!A.isGuardedFetchError(S))return S;let x=S,{onRedirectHop:I,subReason:P}=$;switch(x.code){case"host_not_allowed":case"protocol_not_allowed":return I?new un(v):new bt(v);case"hostname_unsafe":return I?new un(v):new bt(v,P==="dns_resolution_failed"?"DNS resolution failed for private IP check":"hostname resolves to private/loopback IP address");case"redirect_to_unsafe_host":return new un(v);case"too_many_redirects":return new Kn(i);case"response_too_large":return new vn(a);default:return S}}async function E(S,v={}){let A=v.method?.toUpperCase()??"GET",$=v.followRedirects??!0;if(v.maxRedirects!==void 0&&(!Number.isSafeInteger(v.maxRedirects)||v.maxRedirects<0))throw new RangeError("maxRedirects must be a non-negative safe integer");let x=v.maxRedirects??i,I=Math.min(i,x),P=v.timeoutMs!==void 0?Math.min(v.timeoutMs,o):o,N=new AbortController,D=fa(()=>N.abort(new DOMException("The operation was aborted","AbortError")),P),R=Rr(v.signal,N.signal);try{m(S),y(S),b(A);let B=$r?await $r:null,k=S,M=0,z=[],O=A,_=v.body,V=v.headers,ee=!1;for(;;){jm(R.signal);let K=await Le.runTrustedAsync(async()=>{let Ie=V;if(ee&&Ie){let Dt=Ie instanceof Headers?new Headers(Ie):new Headers(Ie);Dt.delete("authorization"),Dt.delete("cookie"),Ie=Dt}let lt=s(k),Rt=Gm(Ie,lt),ut={method:O,headers:Rt,signal:R.signal,followRedirects:!1,timeoutMs:P,sanitizeHeaders:!1};if(_&&!qm.has(O)&&(ut.body=_),Object.assign(ut,d(k)),!B||p(k)){if(u)throw new bt(k,"DNS pinning unavailable for private IP enforcement");return await h(k,ut)}u?n&&(ut.fetch=n):(ut.fetch=n??globalThis.fetch,ut.dispatcher=null);let ct;ut.onUrlBlocked=Dt=>{ct=Dt.subReason};try{return await B.guardedFetch(k,ut)}catch(Dt){throw w(Dt,k,B,{onRedirectHop:M>0,subReason:ct})}});if(Um.has(K.status)&&$){let Ie=K.headers.get("location");if(!Ie)return await Df(K,k,a,R.signal,z);z.push({status:K.status,statusText:K.statusText,headers:If(K.headers)});let lt=new URL(Ie,k).href;await aa(Hm(K),R.signal);try{m(lt),y(lt)}catch(ct){throw R.signal?.aborted?xr(R.signal):ct instanceof bt?new un(lt):ct}let Rt=K.status;if(((Rt===301||Rt===302)&&O==="POST"||Rt===303&&O!=="GET"&&O!=="HEAD")&&(O="GET",_=void 0,b(O)),new URL(lt).origin!==new URL(k).origin&&(ee=!0),M++,M>I)throw new Kn(I);k=lt;continue}return await Df(K,k,a,R.signal,z)}}finally{da(D),R.cleanup()}}return E}async function aa(e,t){if(!t)return e;if(t.aborted)throw e.catch(()=>{}),xr(t);let n,r=new Promise((s,i)=>{n=()=>i(xr(t)),t.addEventListener("abort",n,{once:!0})});try{return await Promise.race([e,r])}finally{n&&t.removeEventListener("abort",n)}}async function Hm(e){e.body&&!e.body.locked&&await e.body.cancel()}function Gm(e,t){if(!e&&!t)return;if(!t)return e;let n=e instanceof Headers?new Headers(e):new Headers(e);for(let[r,s]of t)n.set(r,s);return n}function If(e){let t=Object.create(null);return e.forEach((n,r)=>{t[r.toLowerCase()]=n}),t}async function Df(e,t,n,r,s){let i=If(e.headers);if(n>0){let l=e.headers.get("content-length");if(l){let u=parseInt(l,10);if(!Number.isNaN(u)&&u>n)throw new vn(n)}}let o;if(n>0&&e.body){let l=e.body.getReader(),u=[],c=0;try{for(;;){let{done:d,value:p}=await aa(l.read(),r);if(d)break;if(p){if(c+=p.byteLength,c>n)throw await l.cancel(),new vn(n);u.push(p)}}}catch(d){throw r?.aborted&&await l.cancel(xr(r)).catch(()=>{}),d}o=new Uint8Array(c);let f=0;for(let d of u)o.set(d,f),f+=d.byteLength}else{let l=await aa(e.arrayBuffer(),r);if(n>0&&l.byteLength>n)throw new vn(n);o=new Uint8Array(l)}let a={status:e.status,statusText:e.statusText,headers:i,body:o,url:t};return s&&s.length>0&&(a.redirectChain=s),a}function ua(e,t){if(e.length>t||W(e)>t)throw new C(`script input size limit exceeded (${t} bytes)`,"string_length")}var Of="/usr/bin:/bin",_f=[["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"]],Vs=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){this.limits=Qs({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}},t.executionLimitProfile);let n=t.fs??new At(t.files,{maxTotalBytes:this.limits.maxFileSystemBytes});this.fs=n,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH",Of],["IFS",`
|
|
802
802
|
`],..._f,["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=la(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth??!0,this.coverageWriter=t.coverage,this.state={env:s,arrays:new Map,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastSubstitutionExitCode:null,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:t.processInfo?.pid??1,virtualPpid:t.processInfo?.ppid??0,virtualUid:t.processInfo?.uid??1e3,virtualGid:t.processInfo?.gid??1e3,bashPid:t.processInfo?.pid??1,nextVirtualPid:(t.processInfo?.pid??1)+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",Lr(this.state.options)),this.state.env.set("BASHOPTS",Tr(this.state.shoptOptions)),La(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&(n instanceof At||n instanceof dn))try{n.mkdirSync(r,{recursive:!0})}catch{}for(let o of Ea(t.commands))this.registerBundledCommand(o);if(t.fetch||t.network)for(let o of ba())this.registerBundledCommand(o);if(t.python)for(let o of Sa())this.registerBundledCommand(o);let i=typeof t.javascript=="object"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let o of Aa())this.registerBundledCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let o of t.customCommands)if(Pa(o)){let a=Ca(o);this.registerCommandInternal(a,!0)}else this.registerCommandInternal(o,!0)}registerCommand(t){this.registerCommandInternal(t,!0)}registerBundledCommand(t){this.registerCommandInternal(t,!1)}registerCommandInternal(t,n,r=n?t.trusted??!0:t.trusted){let s=this.commands.get(t.name),i=n?s?.internalOriginalCommand??(s&&!s.internalIsExtension?s:void 0):void 0,o={name:t.name,trusted:r,internalIsExtension:n,internalOriginalCommand:i,execute:(l,u)=>t.execute(l,u)};this.commands.set(t.name,o);let a=this.fs;if(typeof a.writeFileSync=="function"){let l=`#!/bin/bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-bash",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.2",
|
|
4
4
|
"description": "A simulated bash environment with virtual filesystem",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"diff": "^8.0.4",
|
|
83
83
|
"fast-xml-parser": "^5.10.1",
|
|
84
84
|
"file-type": "^21.3.4",
|
|
85
|
-
"guarded-fetch": "0.
|
|
85
|
+
"guarded-fetch": "0.2.0",
|
|
86
86
|
"ini": "^6.0.0",
|
|
87
87
|
"modern-tar": "^0.7.7",
|
|
88
88
|
"papaparse": "^5.6.0",
|