just-bash-nx 3.0.1 → 3.0.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/dist/bin/default-init.sh +225 -0
- package/dist/bin/just-bash.js +223 -221
- package/dist/bin/shell/shell.js +2 -2
- package/dist/bundle/browser.js +2 -2
- package/dist/bundle/index.cjs +2 -2
- package/dist/bundle/index.js +2 -2
- package/package.json +33 -32
- package/vendor/cpython-emscripten/python.wasm +0 -0
package/dist/bin/shell/shell.js
CHANGED
|
@@ -693,8 +693,8 @@ ${t}
|
|
|
693
693
|
esac${Ce(e.redirections)}`}function el(e){let t=e.patterns.map(oe).join(" | "),s=ge(e.body);return s?`${t})
|
|
694
694
|
${s}
|
|
695
695
|
${e.terminator}`:`${t})
|
|
696
|
-
${e.terminator}`}function tl(e){return`(${ge(e.body)})${Ce(e.redirections)}`}function sl(e){return`{ ${ge(e.body)}; }${Ce(e.redirections)}`}function nl(e){return`((${H(e.expression.expression)}))${Ce(e.redirections)}`}function rl(e){return`[[ ${Xe(e.expression)} ]]${Ce(e.redirections)}`}function il(e){let t=Ri(e.body);return`${e.name}() ${t}${Ce(e.redirections)}`}function H(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${H(e.left)} ${e.operator} ${H(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${H(e.operand)}`:`${H(e.operand)}${e.operator}`;case"ArithTernary":return`${H(e.condition)} ? ${H(e.consequent)} : ${H(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${H(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${H(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${H(e.target)}[${H(e.subscript)}]`:H(e.target)} ${e.operator} ${H(e.value)}`;case"ArithDynamicElement":return`${H(e.nameExpr)}[${H(e.subscript)}]`;case"ArithGroup":return`(${H(e.expression)})`;case"ArithNested":return`$((${H(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${H(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(H).join("");case"ArithDoubleSubscript":return`${e.array}[${H(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function Xe(e){switch(e.type){case"CondBinary":return`${oe(e.left)} ${e.operator} ${oe(e.right)}`;case"CondUnary":return`${e.operator} ${oe(e.operand)}`;case"CondNot":return`! ${Xe(e.operand)}`;case"CondAnd":return`${Xe(e.left)} && ${Xe(e.right)}`;case"CondOr":return`${Xe(e.left)} || ${Xe(e.right)}`;case"CondGroup":return`( ${Xe(e.expression)} )`;case"CondWord":return oe(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var ps=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new wt(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let n=t.cwd||(this.useDefaultLayout?"/home/user":"/"),r=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["
|
|
697
|
-
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Ai({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Pn(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:r,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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","
|
|
696
|
+
${e.terminator}`}function tl(e){return`(${ge(e.body)})${Ce(e.redirections)}`}function sl(e){return`{ ${ge(e.body)}; }${Ce(e.redirections)}`}function nl(e){return`((${H(e.expression.expression)}))${Ce(e.redirections)}`}function rl(e){return`[[ ${Xe(e.expression)} ]]${Ce(e.redirections)}`}function il(e){let t=Ri(e.body);return`${e.name}() ${t}${Ce(e.redirections)}`}function H(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${H(e.left)} ${e.operator} ${H(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${H(e.operand)}`:`${H(e.operand)}${e.operator}`;case"ArithTernary":return`${H(e.condition)} ? ${H(e.consequent)} : ${H(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${H(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${H(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${H(e.target)}[${H(e.subscript)}]`:H(e.target)} ${e.operator} ${H(e.value)}`;case"ArithDynamicElement":return`${H(e.nameExpr)}[${H(e.subscript)}]`;case"ArithGroup":return`(${H(e.expression)})`;case"ArithNested":return`$((${H(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${H(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(H).join("");case"ArithDoubleSubscript":return`${e.array}[${H(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function Xe(e){switch(e.type){case"CondBinary":return`${oe(e.left)} ${e.operator} ${oe(e.right)}`;case"CondUnary":return`${e.operator} ${oe(e.operand)}`;case"CondNot":return`! ${Xe(e.operand)}`;case"CondAnd":return`${Xe(e.left)} && ${Xe(e.right)}`;case"CondOr":return`${Xe(e.left)} || ${Xe(e.right)}`;case"CondGroup":return`( ${Xe(e.expression)} )`;case"CondWord":return oe(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var ps=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new wt(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let n=t.cwd||(this.useDefaultLayout?"/home/user":"/"),r=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
697
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",n],["OLDPWD",n],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Ai({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Pn(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:r,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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",Ns(this.state.options)),this.state.env.set("BASHOPTS",Os(this.state.shoptOptions)),rr(s,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),n!=="/"&&s instanceof wt)try{s.mkdirSync(n,{recursive:!0})}catch{}for(let a of Yn(t.commands))this.registerCommand(a);if(t.fetch||t.network)for(let a of Qn())this.registerCommand(a);if(t.python)for(let a of Jn())this.registerCommand(a);let i=typeof t.javascript=="object"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let a of er())this.registerCommand(a);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let a of t.customCommands)tr(a)?this.registerCommand(sr(a)):this.registerCommand({...a,trusted:a.trusted??!0})}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let n=`#!/bin/bash
|
|
698
698
|
# Built-in command: ${t.name}
|
|
699
699
|
`;try{s.writeFileSync(`/bin/${t.name}`,n)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,n)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t.stdout=zi(t.stdout),t.stderr=zi(t.stderr),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
700
700
|
`,exitCode:1,env:me(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:me(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let n=s?.cwd??this.state.cwd,r,i=n;if(s?.cwd)if(s.env&&"PWD"in s.env)r=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{r=await this.fs.realpath(n),i=r}catch{r=n}else r=n;let a=s?.replaceEnv?new Map:new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))a.set(f,d);r!==void 0&&a.set("PWD",r);let o={...this.state,env:a,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:ol(s?.stdin,s?.stdinKind),signal:s?.signal,extraArgs:s?.args},l=t;s?.rawScript||(l=Wi(t));let c=this.defenseInDepthConfig?ve.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let d=Ee(l,{maxHeredocSize:this.limits.maxHeredocSize}),h;if(this.transformPlugins.length>0){let y=Object.create(null);for(let v of this.transformPlugins){let b=v.transform({ast:d,metadata:y});d=b.ast,b.metadata&&(y=gs(y,b.metadata))}h=y}let m={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},w=await new _t(m,o).executeScript(d);return h&&(w.metadata=h),this.logResult(w)};return u?await u.run(f):await f()}catch(f){if(f instanceof B)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof be)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:me(this.state.env,s?.env)});if(f instanceof Ue)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:me(this.state.env,s?.env)});if(f instanceof Tt)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:me(this.state.env,s?.env)});if(f instanceof Y)return this.logResult({stdout:f.stdout,stderr:Te(f.stderr),exitCode:Y.EXIT_CODE,env:me(this.state.env,s?.env)});if(f instanceof Je)return this.logResult({stdout:"",stderr:`bash: security violation: ${Te(f.message)}
|
package/dist/bundle/browser.js
CHANGED
|
@@ -1488,8 +1488,8 @@ ${t}
|
|
|
1488
1488
|
esac${Pn(e.redirections)}`}function Wv(e){let t=e.patterns.map(Wt).join(" | "),n=bn(e.body);return n?`${t})
|
|
1489
1489
|
${n}
|
|
1490
1490
|
${e.terminator}`:`${t})
|
|
1491
|
-
${e.terminator}`}function zv(e){return`(${bn(e.body)})${Pn(e.redirections)}`}function Hv(e){return`{ ${bn(e.body)}; }${Pn(e.redirections)}`}function jv(e){return`((${qe(e.expression.expression)}))${Pn(e.redirections)}`}function Gv(e){return`[[ ${Yr(e.expression)} ]]${Pn(e.redirections)}`}function Vv(e){let t=D7(e.body);return`${e.name}() ${t}${Pn(e.redirections)}`}function qe(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${qe(e.left)} ${e.operator} ${qe(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${qe(e.operand)}`:`${qe(e.operand)}${e.operator}`;case"ArithTernary":return`${qe(e.condition)} ? ${qe(e.consequent)} : ${qe(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${qe(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${qe(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${qe(e.target)}[${qe(e.subscript)}]`:qe(e.target)} ${e.operator} ${qe(e.value)}`;case"ArithDynamicElement":return`${qe(e.nameExpr)}[${qe(e.subscript)}]`;case"ArithGroup":return`(${qe(e.expression)})`;case"ArithNested":return`$((${qe(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${qe(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(qe).join("");case"ArithDoubleSubscript":return`${e.array}[${qe(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function Yr(e){switch(e.type){case"CondBinary":return`${Wt(e.left)} ${e.operator} ${Wt(e.right)}`;case"CondUnary":return`${e.operator} ${Wt(e.operand)}`;case"CondNot":return`! ${Yr(e.operand)}`;case"CondAnd":return`${Yr(e.left)} && ${Yr(e.right)}`;case"CondOr":return`${Yr(e.left)} || ${Yr(e.right)}`;case"CondGroup":return`( ${Yr(e.expression)} )`;case"CondWord":return Wt(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Rf=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let n=t.fs??new rr(t.files);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","/usr/bin:/bin"],["
|
|
1492
|
-
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=E7({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Of(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,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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","
|
|
1491
|
+
${e.terminator}`}function zv(e){return`(${bn(e.body)})${Pn(e.redirections)}`}function Hv(e){return`{ ${bn(e.body)}; }${Pn(e.redirections)}`}function jv(e){return`((${qe(e.expression.expression)}))${Pn(e.redirections)}`}function Gv(e){return`[[ ${Yr(e.expression)} ]]${Pn(e.redirections)}`}function Vv(e){let t=D7(e.body);return`${e.name}() ${t}${Pn(e.redirections)}`}function qe(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${qe(e.left)} ${e.operator} ${qe(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${qe(e.operand)}`:`${qe(e.operand)}${e.operator}`;case"ArithTernary":return`${qe(e.condition)} ? ${qe(e.consequent)} : ${qe(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${qe(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${qe(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${qe(e.target)}[${qe(e.subscript)}]`:qe(e.target)} ${e.operator} ${qe(e.value)}`;case"ArithDynamicElement":return`${qe(e.nameExpr)}[${qe(e.subscript)}]`;case"ArithGroup":return`(${qe(e.expression)})`;case"ArithNested":return`$((${qe(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${qe(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(qe).join("");case"ArithDoubleSubscript":return`${e.array}[${qe(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function Yr(e){switch(e.type){case"CondBinary":return`${Wt(e.left)} ${e.operator} ${Wt(e.right)}`;case"CondUnary":return`${e.operator} ${Wt(e.operand)}`;case"CondNot":return`! ${Yr(e.operand)}`;case"CondAnd":return`${Yr(e.left)} && ${Yr(e.right)}`;case"CondOr":return`${Yr(e.left)} || ${Yr(e.right)}`;case"CondGroup":return`( ${Yr(e.expression)} )`;case"CondWord":return Wt(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Rf=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let n=t.fs??new rr(t.files);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","/usr/bin:/bin"],["IFS",`
|
|
1492
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=E7({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Of(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,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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",zc(this.state.options)),this.state.env.set("BASHOPTS",Hc(this.state.shoptOptions)),F2(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&n instanceof rr)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let o of k2(t.commands))this.registerCommand(o);if(t.fetch||t.network)for(let o of N2())this.registerCommand(o);if(t.python)for(let o of I2())this.registerCommand(o);let i=typeof t.javascript=="object"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let o of $2())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let o of t.customCommands)T2(o)?this.registerCommand(O2(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(t){this.commands.set(t.name,t);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
|
|
1493
1493
|
# Built-in command: ${t.name}
|
|
1494
1494
|
`;try{n.writeFileSync(`/bin/${t.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t.stdout=U7(t.stdout),t.stderr=U7(t.stderr),t}async exec(t,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
1495
1495
|
`,exitCode:1,env:pn(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:pn(this.state.env,n?.env)};this.logger?.info("exec",{command:t});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=n?.replaceEnv?new Map:new Map(this.state.env);if(n?.env)for(let[f,p]of Object.entries(n.env))o.set(f,p);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Zv(n?.stdin,n?.stdinKind),signal:n?.signal,extraArgs:n?.args},l=t;n?.rawScript||(l=M7(t));let c=this.defenseInDepthConfig?Et.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let p=Nn(l,{maxHeredocSize:this.limits.maxHeredocSize}),h;if(this.transformPlugins.length>0){let w=Object.create(null);for(let b of this.transformPlugins){let x=b.transform({ast:p,metadata:w});p=x.ast,x.metadata&&(w=Dr(w,x.metadata))}h=w}let d={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},y=await new Di(d,a).executeScript(p);return h&&(y.metadata=h),this.logResult(y)};return u?await u.run(f):await f()}catch(f){if(f instanceof we)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:pn(this.state.env,n?.env)});if(f instanceof nn)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:pn(this.state.env,n?.env)});if(f instanceof Le)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:pn(this.state.env,n?.env)});if(f instanceof is)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:pn(this.state.env,n?.env)});if(f instanceof X)return this.logResult({stdout:f.stdout,stderr:He(f.stderr),exitCode:X.EXIT_CODE,env:pn(this.state.env,n?.env)});if(f instanceof de)return this.logResult({stdout:"",stderr:`bash: security violation: ${He(f.message)}
|
package/dist/bundle/index.cjs
CHANGED
|
@@ -2102,8 +2102,8 @@ ${e}
|
|
|
2102
2102
|
esac${es(t.redirections)}`}function RG(t){let e=t.patterns.map(fn).join(" | "),n=_r(t.body);return n?`${e})
|
|
2103
2103
|
${n}
|
|
2104
2104
|
${t.terminator}`:`${e})
|
|
2105
|
-
${t.terminator}`}function $G(t){return`(${_r(t.body)})${es(t.redirections)}`}function FG(t){return`{ ${_r(t.body)}; }${es(t.redirections)}`}function _G(t){return`((${At(t.expression.expression)}))${es(t.redirections)}`}function DG(t){return`[[ ${uo(t.expression)} ]]${es(t.redirections)}`}function LG(t){let e=fT(t.body);return`${t.name}() ${e}${es(t.redirections)}`}function At(t){switch(t.type){case"ArithNumber":return String(t.value);case"ArithVariable":return t.hasDollarPrefix?`$${t.name}`:t.name;case"ArithSpecialVar":return`$${t.name}`;case"ArithBinary":return`${At(t.left)} ${t.operator} ${At(t.right)}`;case"ArithUnary":return t.prefix?`${t.operator}${At(t.operand)}`:`${At(t.operand)}${t.operator}`;case"ArithTernary":return`${At(t.condition)} ? ${At(t.consequent)} : ${At(t.alternate)}`;case"ArithAssignment":return`${t.subscript?`${t.variable}[${At(t.subscript)}]`:t.stringKey!==void 0?`${t.variable}[${t.stringKey}]`:t.variable} ${t.operator} ${At(t.value)}`;case"ArithDynamicAssignment":return`${t.subscript?`${At(t.target)}[${At(t.subscript)}]`:At(t.target)} ${t.operator} ${At(t.value)}`;case"ArithDynamicElement":return`${At(t.nameExpr)}[${At(t.subscript)}]`;case"ArithGroup":return`(${At(t.expression)})`;case"ArithNested":return`$((${At(t.expression)}))`;case"ArithCommandSubst":return`$(${t.command})`;case"ArithBracedExpansion":return`\${${t.content}}`;case"ArithArrayElement":return t.stringKey!==void 0?`${t.array}[${t.stringKey}]`:t.index?`${t.array}[${At(t.index)}]`:t.array;case"ArithDynamicBase":return`\${${t.baseExpr}}#${t.value}`;case"ArithDynamicNumber":return`\${${t.prefix}}${t.suffix}`;case"ArithConcat":return t.parts.map(At).join("");case"ArithDoubleSubscript":return`${t.array}[${At(t.index)}]`;case"ArithNumberSubscript":return`${t.number}[${t.errorToken}]`;case"ArithSyntaxError":return t.errorToken;case"ArithSingleQuote":return`'${t.content}'`;default:{let e=t;throw new Error(`Unsupported arithmetic expression type: ${e.type}`)}}}function uo(t){switch(t.type){case"CondBinary":return`${fn(t.left)} ${t.operator} ${fn(t.right)}`;case"CondUnary":return`${t.operator} ${fn(t.operand)}`;case"CondNot":return`! ${uo(t.operand)}`;case"CondAnd":return`${uo(t.left)} && ${uo(t.right)}`;case"CondOr":return`${uo(t.left)} || ${uo(t.right)}`;case"CondGroup":return`( ${uo(t.expression)} )`;case"CondWord":return fn(t.word);default:{let e=t;throw new Error(`Unsupported conditional expression type: ${e.type}`)}}}var Oa=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){let n=e.fs??new bs(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["
|
|
2106
|
-
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(e.env??{})]);if(this.limits=eT({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=Xw(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.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","
|
|
2105
|
+
${t.terminator}`}function $G(t){return`(${_r(t.body)})${es(t.redirections)}`}function FG(t){return`{ ${_r(t.body)}; }${es(t.redirections)}`}function _G(t){return`((${At(t.expression.expression)}))${es(t.redirections)}`}function DG(t){return`[[ ${uo(t.expression)} ]]${es(t.redirections)}`}function LG(t){let e=fT(t.body);return`${t.name}() ${e}${es(t.redirections)}`}function At(t){switch(t.type){case"ArithNumber":return String(t.value);case"ArithVariable":return t.hasDollarPrefix?`$${t.name}`:t.name;case"ArithSpecialVar":return`$${t.name}`;case"ArithBinary":return`${At(t.left)} ${t.operator} ${At(t.right)}`;case"ArithUnary":return t.prefix?`${t.operator}${At(t.operand)}`:`${At(t.operand)}${t.operator}`;case"ArithTernary":return`${At(t.condition)} ? ${At(t.consequent)} : ${At(t.alternate)}`;case"ArithAssignment":return`${t.subscript?`${t.variable}[${At(t.subscript)}]`:t.stringKey!==void 0?`${t.variable}[${t.stringKey}]`:t.variable} ${t.operator} ${At(t.value)}`;case"ArithDynamicAssignment":return`${t.subscript?`${At(t.target)}[${At(t.subscript)}]`:At(t.target)} ${t.operator} ${At(t.value)}`;case"ArithDynamicElement":return`${At(t.nameExpr)}[${At(t.subscript)}]`;case"ArithGroup":return`(${At(t.expression)})`;case"ArithNested":return`$((${At(t.expression)}))`;case"ArithCommandSubst":return`$(${t.command})`;case"ArithBracedExpansion":return`\${${t.content}}`;case"ArithArrayElement":return t.stringKey!==void 0?`${t.array}[${t.stringKey}]`:t.index?`${t.array}[${At(t.index)}]`:t.array;case"ArithDynamicBase":return`\${${t.baseExpr}}#${t.value}`;case"ArithDynamicNumber":return`\${${t.prefix}}${t.suffix}`;case"ArithConcat":return t.parts.map(At).join("");case"ArithDoubleSubscript":return`${t.array}[${At(t.index)}]`;case"ArithNumberSubscript":return`${t.number}[${t.errorToken}]`;case"ArithSyntaxError":return t.errorToken;case"ArithSingleQuote":return`'${t.content}'`;default:{let e=t;throw new Error(`Unsupported arithmetic expression type: ${e.type}`)}}}function uo(t){switch(t.type){case"CondBinary":return`${fn(t.left)} ${t.operator} ${fn(t.right)}`;case"CondUnary":return`${t.operator} ${fn(t.operand)}`;case"CondNot":return`! ${uo(t.operand)}`;case"CondAnd":return`${uo(t.left)} && ${uo(t.right)}`;case"CondOr":return`${uo(t.left)} || ${uo(t.right)}`;case"CondGroup":return`( ${uo(t.expression)} )`;case"CondWord":return fn(t.word);default:{let e=t;throw new Error(`Unsupported conditional expression type: ${e.type}`)}}}var Oa=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(e={}){let n=e.fs??new bs(e.files);this.fs=n,this.useDefaultLayout=!e.cwd&&!e.files;let r=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
2106
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(e.env??{})]);if(this.limits=eT({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.fetch?this.secureFetch=e.fetch:e.network&&(this.secureFetch=Xw(e.network)),this.sleepFn=e.sleep,this.traceFn=e.trace,this.logger=e.logger,this.defenseInDepthConfig=e.defenseInDepth??!0,this.coverageWriter=e.coverage,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,virtualPid:e.processInfo?.pid??1,virtualPpid:e.processInfo?.ppid??0,virtualUid:e.processInfo?.uid??1e3,virtualGid:e.processInfo?.gid??1e3,bashPid:e.processInfo?.pid??1,nextVirtualPid:(e.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(e.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",f6(this.state.options)),this.state.env.set("BASHOPTS",h6(this.state.shoptOptions)),mv(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&n instanceof bs)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let o of sv(e.commands))this.registerCommand(o);if(e.fetch||e.network)for(let o of iv())this.registerCommand(o);if(e.python)for(let o of av())this.registerCommand(o);let i=typeof e.javascript=="object"?e.javascript:Object.create(null);if(e.javascript||i.invokeTool){for(let o of cv())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(e.customCommands)for(let o of e.customCommands)uv(o)?this.registerCommand(hv(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(e){this.commands.set(e.name,e);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
|
|
2107
2107
|
# Built-in command: ${e.name}
|
|
2108
2108
|
`;try{n.writeFileSync(`/bin/${e.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${e.name}`,r)}catch{}}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e.stdout=gT(e.stdout),e.stderr=gT(e.stderr),e}async exec(e,n){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
2109
2109
|
`,exitCode:1,env:Sr(this.state.env,n?.env)};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:Sr(this.state.env,n?.env)};this.logger?.info("exec",{command:e});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=n?.replaceEnv?new Map:new Map(this.state.env);if(n?.env)for(let[f,h]of Object.entries(n.env))o.set(f,h);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:BG(n?.stdin,n?.stdinKind),signal:n?.signal,extraArgs:n?.args},l=e;n?.rawScript||(l=mT(e));let c=this.defenseInDepthConfig?tt.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let h=Bn(l,{maxHeredocSize:this.limits.maxHeredocSize}),p;if(this.transformPlugins.length>0){let w=Object.create(null);for(let b of this.transformPlugins){let E=b.transform({ast:h,metadata:w});h=E.ast,E.metadata&&(w=Is(w,E.metadata))}p=w}let d={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},y=await new fc(d,a).executeScript(h);return p&&(y.metadata=p),this.logResult(y)};return u?await u.run(f):await f()}catch(f){if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Sr(this.state.env,n?.env)});if(f instanceof ar)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Sr(this.state.env,n?.env)});if(f instanceof lt)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Sr(this.state.env,n?.env)});if(f instanceof Eo)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:Sr(this.state.env,n?.env)});if(f instanceof se)return this.logResult({stdout:f.stdout,stderr:Fe(f.stderr),exitCode:se.EXIT_CODE,env:Sr(this.state.env,n?.env)});if(f instanceof Se)return this.logResult({stdout:"",stderr:`bash: security violation: ${Fe(f.message)}
|
package/dist/bundle/index.js
CHANGED
|
@@ -692,8 +692,8 @@ ${t}
|
|
|
692
692
|
esac${Ne(e.redirections)}`}function wl(e){let t=e.patterns.map(ie).join(" | "),s=$e(e.body);return s?`${t})
|
|
693
693
|
${s}
|
|
694
694
|
${e.terminator}`:`${t})
|
|
695
|
-
${e.terminator}`}function vl(e){return`(${$e(e.body)})${Ne(e.redirections)}`}function bl(e){return`{ ${$e(e.body)}; }${Ne(e.redirections)}`}function El(e){return`((${Z(e.expression.expression)}))${Ne(e.redirections)}`}function $l(e){return`[[ ${it(e.expression)} ]]${Ne(e.redirections)}`}function Sl(e){let t=Gi(e.body);return`${e.name}() ${t}${Ne(e.redirections)}`}function Z(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${Z(e.left)} ${e.operator} ${Z(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${Z(e.operand)}`:`${Z(e.operand)}${e.operator}`;case"ArithTernary":return`${Z(e.condition)} ? ${Z(e.consequent)} : ${Z(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${Z(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${Z(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${Z(e.target)}[${Z(e.subscript)}]`:Z(e.target)} ${e.operator} ${Z(e.value)}`;case"ArithDynamicElement":return`${Z(e.nameExpr)}[${Z(e.subscript)}]`;case"ArithGroup":return`(${Z(e.expression)})`;case"ArithNested":return`$((${Z(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${Z(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(Z).join("");case"ArithDoubleSubscript":return`${e.array}[${Z(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function it(e){switch(e.type){case"CondBinary":return`${ie(e.left)} ${e.operator} ${ie(e.right)}`;case"CondUnary":return`${e.operator} ${ie(e.operand)}`;case"CondNot":return`! ${it(e.operand)}`;case"CondAnd":return`${it(e.left)} && ${it(e.right)}`;case"CondOr":return`${it(e.left)} || ${it(e.right)}`;case"CondGroup":return`( ${it(e.expression)} )`;case"CondWord":return ie(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Ft=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new ze(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["
|
|
696
|
-
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Mi({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Ur(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:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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","
|
|
695
|
+
${e.terminator}`}function vl(e){return`(${$e(e.body)})${Ne(e.redirections)}`}function bl(e){return`{ ${$e(e.body)}; }${Ne(e.redirections)}`}function El(e){return`((${Z(e.expression.expression)}))${Ne(e.redirections)}`}function $l(e){return`[[ ${it(e.expression)} ]]${Ne(e.redirections)}`}function Sl(e){let t=Gi(e.body);return`${e.name}() ${t}${Ne(e.redirections)}`}function Z(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${Z(e.left)} ${e.operator} ${Z(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${Z(e.operand)}`:`${Z(e.operand)}${e.operator}`;case"ArithTernary":return`${Z(e.condition)} ? ${Z(e.consequent)} : ${Z(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${Z(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${Z(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${Z(e.target)}[${Z(e.subscript)}]`:Z(e.target)} ${e.operator} ${Z(e.value)}`;case"ArithDynamicElement":return`${Z(e.nameExpr)}[${Z(e.subscript)}]`;case"ArithGroup":return`(${Z(e.expression)})`;case"ArithNested":return`$((${Z(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${Z(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(Z).join("");case"ArithDoubleSubscript":return`${e.array}[${Z(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function it(e){switch(e.type){case"CondBinary":return`${ie(e.left)} ${e.operator} ${ie(e.right)}`;case"CondUnary":return`${e.operator} ${ie(e.operand)}`;case"CondNot":return`! ${it(e.operand)}`;case"CondAnd":return`${it(e.left)} && ${it(e.right)}`;case"CondOr":return`${it(e.left)} || ${it(e.right)}`;case"CondGroup":return`( ${it(e.expression)} )`;case"CondWord":return ie(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var Ft=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;jsBootstrapCode;invokeToolFn;transformPlugins=[];state;constructor(t={}){let s=t.fs??new ze(t.files);this.fs=s,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),n=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
696
|
+
`],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=Mi({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.fetch?this.secureFetch=t.fetch:t.network&&(this.secureFetch=Ur(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:n,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,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",Zs(this.state.options)),this.state.env.set("BASHOPTS",qs(this.state.shoptOptions)),vn(s,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&s instanceof ze)try{s.mkdirSync(r,{recursive:!0})}catch{}for(let o of hn(t.commands))this.registerCommand(o);if(t.fetch||t.network)for(let o of pn())this.registerCommand(o);if(t.python)for(let o of mn())this.registerCommand(o);let i=typeof t.javascript=="object"?t.javascript:Object.create(null);if(t.javascript||i.invokeTool){for(let o of yn())this.registerCommand(o);i.bootstrap&&(this.jsBootstrapCode=i.bootstrap),i.invokeTool&&(this.invokeToolFn=i.invokeTool)}if(t.customCommands)for(let o of t.customCommands)gn(o)?this.registerCommand(wn(o)):this.registerCommand({...o,trusted:o.trusted??!0})}registerCommand(t){this.commands.set(t.name,t);let s=this.fs;if(typeof s.writeFileSync=="function"){let r=`#!/bin/bash
|
|
697
697
|
# Built-in command: ${t.name}
|
|
698
698
|
`;try{s.writeFileSync(`/bin/${t.name}`,r)}catch{}try{s.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t.stdout=Ji(t.stdout),t.stderr=Ji(t.stderr),t}async exec(t,s){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
|
|
699
699
|
`,exitCode:1,env:ve(this.state.env,s?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:ve(this.state.env,s?.env)};this.logger?.info("exec",{command:t});let r=s?.cwd??this.state.cwd,n,i=r;if(s?.cwd)if(s.env&&"PWD"in s.env)n=s.env.PWD;else if(s?.env&&!("PWD"in s.env))try{n=await this.fs.realpath(r),i=n}catch{n=r}else n=r;let o=s?.replaceEnv?new Map:new Map(this.state.env);if(s?.env)for(let[f,d]of Object.entries(s.env))o.set(f,d);n!==void 0&&o.set("PWD",n);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:Al(s?.stdin,s?.stdinKind),signal:s?.signal,extraArgs:s?.args},l=t;s?.rawScript||(l=Qi(t));let c=this.defenseInDepthConfig?me.getInstance(this.defenseInDepthConfig):null,u=c?.activate();try{let f=async()=>{let d=fe(l,{maxHeredocSize:this.limits.maxHeredocSize}),h;if(this.transformPlugins.length>0){let y=Object.create(null);for(let v of this.transformPlugins){let b=v.transform({ast:d,metadata:y});d=b.ast,b.metadata&&(y=Ct(y,b.metadata))}h=y}let m={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter,requireDefenseContext:c?.isEnabled()===!0,jsBootstrapCode:this.jsBootstrapCode,invokeTool:this.invokeToolFn},w=await new It(m,a).executeScript(d);return h&&(w.metadata=h),this.logResult(w)};return u?await u.run(f):await f()}catch(f){if(f instanceof j)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:ve(this.state.env,s?.env)});if(f instanceof Je)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:ve(this.state.env,s?.env)});if(f instanceof Ht)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:124,env:ve(this.state.env,s?.env)});if(f instanceof J)return this.logResult({stdout:f.stdout,stderr:Le(f.stderr),exitCode:J.EXIT_CODE,env:ve(this.state.env,s?.env)});if(f instanceof Ve)return this.logResult({stdout:"",stderr:`bash: security violation: ${Le(f.message)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-bash-nx",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "A simulated bash environment with virtual filesystem",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -56,6 +56,37 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
61
|
+
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
62
|
+
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
63
|
+
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
64
|
+
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
65
|
+
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
|
|
66
|
+
"build:cli": "mkdir -p dist/cli dist/bin && cp src/cli/default-init.sh dist/cli/default-init.sh && cp src/cli/default-init.sh dist/bin/default-init.sh && esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
67
|
+
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
68
|
+
"prepublishOnly": "pnpm test:dist",
|
|
69
|
+
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
70
|
+
"typecheck": "tsc --noEmit",
|
|
71
|
+
"lint": "pnpm lint:banned",
|
|
72
|
+
"check:worker-sync": "node scripts/check-worker-sync.js",
|
|
73
|
+
"lint:banned": "node scripts/check-banned-patterns.js",
|
|
74
|
+
"lint:fix": "pnpm --workspace-root lint:fix",
|
|
75
|
+
"knip": "knip",
|
|
76
|
+
"test": "vitest",
|
|
77
|
+
"test:run": "vitest run --exclude src/security/fuzzing/ --exclude src/commands/python3/ --exclude src/commands/sqlite3/ --exclude src/commands/js-exec/ --exclude src/agent-examples/python-scripting.test.ts",
|
|
78
|
+
"test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
|
|
79
|
+
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
80
|
+
"test:wasm": "vitest run --config vitest.wasm.config.ts",
|
|
81
|
+
"test:comparison": "vitest run --config vitest.comparison.config.ts",
|
|
82
|
+
"test:comparison:record": "RECORD_FIXTURES=1 vitest run --config vitest.comparison.config.ts",
|
|
83
|
+
"test:coverage": "vitest run --coverage",
|
|
84
|
+
"test:coverage:unit": "vitest run --config vitest.unit.config.ts --coverage",
|
|
85
|
+
"test:fuzz": "vitest run src/security/fuzzing/",
|
|
86
|
+
"test:fuzz:long": "FUZZ_RUNS=10000 vitest run src/security/fuzzing/",
|
|
87
|
+
"shell": "npx tsx src/cli/shell.ts",
|
|
88
|
+
"dev:exec": "npx tsx src/cli/exec.ts"
|
|
89
|
+
},
|
|
59
90
|
"keywords": [],
|
|
60
91
|
"author": "Malte and Claude",
|
|
61
92
|
"license": "Apache-2.0",
|
|
@@ -93,35 +124,5 @@
|
|
|
93
124
|
"optionalDependencies": {
|
|
94
125
|
"@mongodb-js/zstd": "^7.0.0",
|
|
95
126
|
"node-liblzma": "^2.0.3"
|
|
96
|
-
},
|
|
97
|
-
"scripts": {
|
|
98
|
-
"build": "rm -rf dist && tsc && pnpm build:lib && pnpm build:lib:cjs && pnpm build:browser && pnpm build:cli && pnpm build:shell && pnpm build:worker && pnpm build:clean && cp dist/index.d.ts dist/index.d.cts && sed '1,/^-->/d' AGENTS.npm.md > dist/AGENTS.md",
|
|
99
|
-
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
|
|
100
|
-
"build:worker": "esbuild src/commands/python3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/python3/worker.js --external:../../../vendor/cpython-emscripten/* && cp src/commands/python3/worker.js dist/commands/python3/worker.js && mkdir -p dist/bin/chunks && cp src/commands/python3/worker.js dist/bin/chunks/worker.js && mkdir -p dist/bundle/chunks && cp src/commands/python3/worker.js dist/bundle/chunks/worker.js && esbuild src/commands/js-exec/js-exec-worker.ts --bundle --platform=node --format=esm --outfile=src/commands/js-exec/js-exec-worker.js --external:quickjs-emscripten && cp src/commands/js-exec/js-exec-worker.js dist/commands/js-exec/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bin/chunks/js-exec-worker.js && cp src/commands/js-exec/js-exec-worker.js dist/bundle/chunks/js-exec-worker.js && esbuild src/commands/sqlite3/worker.ts --bundle --platform=node --format=esm --outfile=src/commands/sqlite3/worker.js --external:sql.js && mkdir -p dist/commands/sqlite3 && cp src/commands/sqlite3/worker.js dist/commands/sqlite3/worker.js && cp src/commands/sqlite3/worker.js dist/bin/chunks/sqlite3-worker.js && cp src/commands/sqlite3/worker.js dist/bundle/chunks/sqlite3-worker.js",
|
|
101
|
-
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
102
|
-
"build:lib:cjs": "esbuild dist/index.js --bundle --platform=node --format=cjs --minify --outfile=dist/bundle/index.cjs --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
103
|
-
"build:browser": "esbuild dist/browser.js --bundle --platform=browser --format=esm --minify --outfile=dist/bundle/browser.js --external:diff --external:minimatch --external:sprintf-js --external:turndown --external:node:zlib --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip --define:__BROWSER__=true --alias:node:dns=./src/shims/browser-unsupported.js",
|
|
104
|
-
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
105
|
-
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node' --external:sql.js --external:quickjs-emscripten --external:@mongodb-js/zstd --external:node-liblzma --external:seek-bzip",
|
|
106
|
-
"validate": "pnpm lint && pnpm knip && pnpm typecheck && pnpm build && pnpm check:worker-sync && pnpm test:run && pnpm test:wasm && pnpm test:dist",
|
|
107
|
-
"typecheck": "tsc --noEmit",
|
|
108
|
-
"lint": "pnpm lint:banned",
|
|
109
|
-
"check:worker-sync": "node scripts/check-worker-sync.js",
|
|
110
|
-
"lint:banned": "node scripts/check-banned-patterns.js",
|
|
111
|
-
"lint:fix": "pnpm --workspace-root lint:fix",
|
|
112
|
-
"knip": "knip",
|
|
113
|
-
"test": "vitest",
|
|
114
|
-
"test:run": "vitest run --exclude src/security/fuzzing/ --exclude src/commands/python3/ --exclude src/commands/sqlite3/ --exclude src/commands/js-exec/ --exclude src/agent-examples/python-scripting.test.ts",
|
|
115
|
-
"test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
|
|
116
|
-
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
117
|
-
"test:wasm": "vitest run --config vitest.wasm.config.ts",
|
|
118
|
-
"test:comparison": "vitest run --config vitest.comparison.config.ts",
|
|
119
|
-
"test:comparison:record": "RECORD_FIXTURES=1 vitest run --config vitest.comparison.config.ts",
|
|
120
|
-
"test:coverage": "vitest run --coverage",
|
|
121
|
-
"test:coverage:unit": "vitest run --config vitest.unit.config.ts --coverage",
|
|
122
|
-
"test:fuzz": "vitest run src/security/fuzzing/",
|
|
123
|
-
"test:fuzz:long": "FUZZ_RUNS=10000 vitest run src/security/fuzzing/",
|
|
124
|
-
"shell": "npx tsx src/cli/shell.ts",
|
|
125
|
-
"dev:exec": "npx tsx src/cli/exec.ts"
|
|
126
127
|
}
|
|
127
|
-
}
|
|
128
|
+
}
|
|
File without changes
|